From 5725cb7635e93a0c09d6af97881c75f907edd225 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 5 Feb 2019 08:12:50 -0800 Subject: linenoise: bugfix: caret notation in insert-at-end. * linenoise.c (edit_insert): In the optimized insertion case at the end of the buffer in multi-line mode, we must render control characters in the same manner as in the slow refresh case: namely, with the caret notatiion: ^@, ^A, ... --- linenoise/linenoise.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'linenoise') diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index f409c98f..a83964e5 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1569,7 +1569,16 @@ static int edit_insert(lino_t *l, wchar_t c) { * make the display length different from the buffer length. * multi-line-mode: we are just adding to the end. */ - wchar_t str[2] = { c }; + wchar_t str[3] = L"^"; + + if (c == 0xdc00 || c < ' ') { + str[1] = '@' + (c & 0xff); + } else if (c == 127) { + str[1] = '?'; + } else { + str[0] = c; + } + if (!lino_os.puts_fn(l->tty_ofs, str)) return -1; if (l->mlmode) -- cgit v1.2.3