diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-14 07:57:38 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-14 07:57:38 -0800 |
commit | d6aed482403280000627ea8c7103aef22d76936d (patch) | |
tree | d92af1cefdc2d00bbadbec29699a1d9cead1b1aa /linenoise | |
parent | 2ab6f0183ba2fb014cc028aeb8afb6a2aba7c059 (diff) | |
download | txr-d6aed482403280000627ea8c7103aef22d76936d.tar.gz txr-d6aed482403280000627ea8c7103aef22d76936d.tar.bz2 txr-d6aed482403280000627ea8c7103aef22d76936d.zip |
linenoise: fix multi-line mode regression.
When Enter is input in multi-line mode, a ^M appears instead
of advancing to the next line. When the display is refreshed,
the ^M's are properly treated as line breaks.
* linenoise.c (edit_insert): Let's restructure the conditional
ladder here into a switch and handle ENTER by issuing CR-LF.
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index a83964e5..9869737d 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1571,12 +1571,23 @@ static int edit_insert(lino_t *l, wchar_t c) { */ wchar_t str[3] = L"^"; - if (c == 0xdc00 || c < ' ') { - str[1] = '@' + (c & 0xff); - } else if (c == 127) { + switch (c) { + case ENTER: + str[0] = '\r'; + str[1] = '\n'; + break; + case 127: str[1] = '?'; - } else { - str[0] = c; + break; + default: + if (c >= ' ') { + str[0] = c; + break; + } + /* fallthrough */ + case 0xdc00: + str[1] = '@' + (c & 0xff); + break; } if (!lino_os.puts_fn(l->tty_ofs, str)) |