From: Thomas Roessler Date: Wed, 3 Jan 2001 10:44:23 +0000 (+0000) Subject: Extend the editor so it supports unprintable characters. X-Git-Tag: mutt-1-3-14-rel~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=317e754d2ebfd3a77abe263917b3fc86240e3508;p=mutt Extend the editor so it supports unprintable characters. --- diff --git a/enter.c b/enter.c index 13e2fc3e..ccf0bd69 100644 --- a/enter.c +++ b/enter.c @@ -33,11 +33,16 @@ enum M_REDRAW_LINE /* redraw entire line */ }; -/* FIXME: these functions should deal with unprintable characters */ - static int my_wcwidth (wchar_t wc) { - return wcwidth (wc); + int n = wcwidth (wc); + if (n > 0) + return n; + if (!(wc & ~0x7f)) + return 2; + if (!(wc & ~0xffff)) + return 6; + return 10; } static int my_wcswidth (const wchar_t *s, size_t n) @@ -50,7 +55,14 @@ static int my_wcswidth (const wchar_t *s, size_t n) static int my_addwch (wchar_t wc) { - return mutt_addwch (wc); + int n = wcwidth (wc); + if (n > 0) + return mutt_addwch (wc); + if (!(wc & ~0x7f)) + return printw ("^%c", ((int)wc + 0x40) & 0x7f); + if (!(wc & ~0xffff)) + return printw ("\\u%04x", (int)wc); + return printw ("\\u%08x", (int)wc); } static size_t width_ceiling (const wchar_t *s, size_t n, int w1)