summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-05 08:12:50 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-05 08:12:50 -0800
commit5725cb7635e93a0c09d6af97881c75f907edd225 (patch)
treebb3f6717b653e65b5566a1b2c7c0d7c2ff5405e7 /linenoise
parent5df2f8a4c30866e140b609733b79eb3832b5bd37 (diff)
downloadtxr-5725cb7635e93a0c09d6af97881c75f907edd225.tar.gz
txr-5725cb7635e93a0c09d6af97881c75f907edd225.tar.bz2
txr-5725cb7635e93a0c09d6af97881c75f907edd225.zip
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, ...
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c11
1 files changed, 10 insertions, 1 deletions
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)