top: adapt utf8 logic to support extra wide characters
Back when top was refactored to support UTF-8 encoding
it was acknowledged that languages like zh_CN were not
supported. That was because a single 'character' might
require more than a single 'column' when it's printed.
Well I've now figured out how to accommodate languages
like that. My adaptation is represented in this patch.
[ and just in case someone wishes to avoid the extra ]
[ runtime costs, a #define OFF_XTRAWIDE is included. ]
Along the way, I've cleaned up some miscellaneous code
supporting the 'Inspect' feature so that the rightmost
screen column was always used rather than being blank.
[ interestingly, my xterm & urxvt terminal emulators ]
[ are able to split extra wide characters then print ]
[ 1/2 of such graphics in the last column. the gnome ]
[ terminal emulator does not duplicate such behavior ]
[ but prints 1 extra character in same width window. ]
Reference(s):
. Sep, 2017 - original utf8 support
commit 9773c56add
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
//#define OFF_SCROLLBK /* disable tty emulators scrollback buffer */
|
||||
//#define OFF_STDERROR /* disable our stderr buffering (redirect) */
|
||||
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
|
||||
//#define OFF_XTRAWIDE /* disable our extra wide multi-byte logic */
|
||||
//#define PRETENDNOCAP /* use a terminal without essential caps */
|
||||
//#define QUICK_GRAPHS /* use fast algorithm, accept +2% distort */
|
||||
//#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */
|
||||
@@ -553,6 +554,7 @@ typedef struct WIN_t {
|
||||
//atic void sig_resize (int dont_care_sig);
|
||||
/*------ Special UTF-8 Multi-Byte support ------------------------------*/
|
||||
/*atic char UTF8_tab[] = { ... } */
|
||||
//atic inline int utf8_cols (const unsigned char *p, int n);
|
||||
//atic int utf8_delta (const char *str);
|
||||
//atic int utf8_embody (const char *str, int width);
|
||||
//atic const char *utf8_justify (const char *str, int width, int justr);
|
||||
|
Reference in New Issue
Block a user