summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-20 18:56:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-20 18:56:07 -0700
commit0eed0b1cbcf301c594020fb4bbe9a39c3f94a8a6 (patch)
tree55f7214542c03a77e8ad683663b2169a9eb27a2a /linenoise
parent18f016a0e577982d9d78ec7133b3b53ff218da93 (diff)
downloadtxr-0eed0b1cbcf301c594020fb4bbe9a39c3f94a8a6.tar.gz
txr-0eed0b1cbcf301c594020fb4bbe9a39c3f94a8a6.tar.bz2
txr-0eed0b1cbcf301c594020fb4bbe9a39c3f94a8a6.zip
linenoise: move to end in mlmode on Ctrl-C, Ctrl-Z.
If we don't move the cursor to the end, then the shell prompt (Ctrl-Z) or next REPL prompt (Ctrl-C) comes in the middle of the previous input. * linenoise/linenoise.c (edit): in multi-line mode, move to end of input on Ctrl-C. On Ctrl-Z suspend, do the same, but save and restore the position.
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 0464bf9d..f62a97d8 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -1557,6 +1557,11 @@ static int edit(lino_t *l, const char *prompt)
record_undo(l);
return (int)l->len;
case CTL('C'):
+ if (l->mlmode) {
+ edit_move_end(l);
+ if (l->need_refresh)
+ refresh_line(l);
+ }
record_undo(l);
l->error = lino_intr;
return -1;
@@ -1727,10 +1732,18 @@ static int edit(lino_t *l, const char *prompt)
l->need_refresh = 1;
break;
case CTL('Z'):
- disable_raw_mode(l);
- raise(SIGTSTP);
- enable_raw_mode(l);
- l->need_refresh = 1;
+ {
+ size_t dpos = l->dpos;
+ if (l->mlmode)
+ edit_move_end(l);
+ if (l->need_refresh)
+ refresh_line(l);
+ disable_raw_mode(l);
+ raise(SIGTSTP);
+ enable_raw_mode(l);
+ l->dpos = dpos;
+ l->need_refresh = 1;
+ }
break;
case CTL('O'):
restore_undo(l);