From d0c25e3cb12f6905a68952b0eeb9c17f6edcee48 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 22 Sep 2015 06:04:04 -0700 Subject: linenoise: selection endpoint toggle with Ctrl-^. * linenoise/linenoise.c (edit): Implemented. * txr.1: Documented. --- linenoise/linenoise.c | 9 +++++++++ txr.1 | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 782fdfde..7dd29aa5 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1870,6 +1870,15 @@ static int edit(lino_t *l, const char *prompt) l->dsel = l->dend = l->dpos; l->need_refresh = 1; break; + case CTL('^'): + if (l->selmode) + { + size_t tmp = l->dsel; + l->dsel = l->dend; + l->dend = l->dpos = tmp; + l->need_refresh = 1; + } + break; case CTL('Y'): yank_sel(l); clear_sel(l); diff --git a/txr.1 b/txr.1 index 76fda8f6..273dd533 100644 --- a/txr.1 +++ b/txr.1 @@ -33909,6 +33909,14 @@ the mode. Tab completion, history navigation, history search and editing in an external editor all cancel visual selection mode. +.NP* Selection Endpoint Toggle + +In visual selection, the starting point of the selection remains fixed, while +the ending point tracks the movement of the cursor. The Ctrl-^ command will +exchange the two points. The effect is that the cursor jumps to the opposite +end of the selection. That end is now the ending point which tracks the cursor +movement. + .NP* Visual Copy The Ctrl-Y command ("yank") copies the selected text into a clipboard buffer. -- cgit v1.2.3