From 2d234f9d416cab25fb7d3d334bcfe1ef7ffa461f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 1 Oct 2015 07:04:53 -0700 Subject: linenoise: Ctrl-A/E overloaded in multi-line mode. * linenoise/linenoise.c (edit_move_sol): If the cursor is already at the beginning of a line, then move it to the start of the buffer. (edit_move_eol): If the cursor is at the end of the line, then move it to the end of the buffer. This also fixes a bug: previously, if the cursor was at the end of the line already, it moved to the end of the following line. * txr.1: Documented. --- linenoise/linenoise.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'linenoise') diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 01e48ed9..de12bdb4 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1339,6 +1339,8 @@ static void edit_move_sol(lino_t *l) { if (l->dpos != dpos) { l->dpos = dpos; l->need_refresh = 1; + } else { + edit_move_home(l); } } } @@ -1357,12 +1359,13 @@ static void edit_move_eol(lino_t *l) { } else { size_t dpos = l->dpos; - dpos += strspn(l->data + dpos, "\r"); dpos += strcspn(l->data + dpos, "\r"); if (l->dpos != dpos) { l->dpos = dpos; l->need_refresh = 1; + } else { + edit_move_end(l); } } } -- cgit v1.2.3