aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Federico Ferri <federico.ferri@cern.ch>2016-03-20 02:08:23 +0100
committerGravatar Kurtis Rader <krader@skepticism.us>2016-03-20 19:22:04 -0700
commit168a156e5896fcaaf82a1b36587cde948f1765be (patch)
tree5cace4212475745aad732479bdcefe826c18897c /src
parent879ee61a30aa495456649e2b53714664264ff1bb (diff)
implement swap-selection-start-stop function
The swap-selection-start-stop function goes to the other end of the highlighted text, the equivalent of `o' for vim visual mode. Add binding to the swap-selection-start-stop function, `o' when in visual mode. Document swap-selection-start-stop, begin-selection, end-selection, kill-selection.
Diffstat (limited to 'src')
-rw-r--r--src/input.cpp2
-rw-r--r--src/input_common.h1
-rw-r--r--src/reader.cpp11
3 files changed, 14 insertions, 0 deletions
diff --git a/src/input.cpp b/src/input.cpp
index c3e26815..b4277724 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -132,6 +132,7 @@ static const wchar_t * const name_arr[] =
L"suppress-autosuggestion",
L"accept-autosuggestion",
L"begin-selection",
+ L"swap-selection-start-stop",
L"end-selection",
L"kill-selection",
L"forward-jump",
@@ -242,6 +243,7 @@ static const wchar_t code_arr[] =
R_SUPPRESS_AUTOSUGGESTION,
R_ACCEPT_AUTOSUGGESTION,
R_BEGIN_SELECTION,
+ R_SWAP_SELECTION_START_STOP,
R_END_SELECTION,
R_KILL_SELECTION,
R_FORWARD_JUMP,
diff --git a/src/input_common.h b/src/input_common.h
index e605d18b..8f4cdd52 100644
--- a/src/input_common.h
+++ b/src/input_common.h
@@ -68,6 +68,7 @@ enum
R_SUPPRESS_AUTOSUGGESTION,
R_ACCEPT_AUTOSUGGESTION,
R_BEGIN_SELECTION,
+ R_SWAP_SELECTION_START_STOP,
R_END_SELECTION,
R_KILL_SELECTION,
R_FORWARD_JUMP,
diff --git a/src/reader.cpp b/src/reader.cpp
index a7e8ec7e..50c8c93d 100644
--- a/src/reader.cpp
+++ b/src/reader.cpp
@@ -4026,6 +4026,17 @@ const wchar_t *reader_readline(int nchars)
break;
}
+ case R_SWAP_SELECTION_START_STOP:
+ {
+ if (!data->sel_active) break;
+ size_t tmp = data->sel_begin_pos;
+ data->sel_begin_pos = data->command_line.position;
+ data->sel_start_pos = data->command_line.position;
+ editable_line_t *el = data->active_edit_line();
+ update_buff_pos(el, tmp);
+ break;
+ }
+
case R_END_SELECTION:
{
data->sel_active = false;