Commit 317e754d authored by Thomas Roessler's avatar Thomas Roessler

Extend the editor so it supports unprintable characters.

parent 552556cf
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment