diff options
author | Federico Ferri <federico.ferri@cern.ch> | 2016-03-20 02:08:23 +0100 |
---|---|---|
committer | Kurtis Rader <krader@skepticism.us> | 2016-03-20 19:22:04 -0700 |
commit | 168a156e5896fcaaf82a1b36587cde948f1765be (patch) | |
tree | 5cace4212475745aad732479bdcefe826c18897c | |
parent | 879ee61a30aa495456649e2b53714664264ff1bb (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.
-rw-r--r-- | doc_src/bind.txt | 8 | ||||
-rw-r--r-- | share/functions/fish_vi_key_bindings.fish | 1 | ||||
-rw-r--r-- | src/input.cpp | 2 | ||||
-rw-r--r-- | src/input_common.h | 1 | ||||
-rw-r--r-- | src/reader.cpp | 11 |
5 files changed, 23 insertions, 0 deletions
diff --git a/doc_src/bind.txt b/doc_src/bind.txt index 813026c3..9b1f34a0 100644 --- a/doc_src/bind.txt +++ b/doc_src/bind.txt @@ -75,6 +75,8 @@ The following special input functions are available: - `beginning-of-line`, move to the beginning of the line +- `begin-selection`, start selecting text + - `capitalize-word`, make the current word begin with a capital letter - `complete`, guess the remainder of the current token @@ -93,6 +95,8 @@ The following special input functions are available: - `end-of-line`, move to the end of the line +- `end-selection`, end selecting text + - `explain`, print a description of possible problems with the current command - `forward-bigword`, move one whitespace-delimited word to the right @@ -109,12 +113,16 @@ The following special input functions are available: - `kill-line`, move everything from the cursor to the end of the line to the killring +- `kill-selection`, move the selected text to the killring + - `kill-whole-line`, move the line to the killring - `kill-word`, move the next word to the killring - `suppress-autosuggestion`, remove the current autosuggestion +- `swap-selection-start-stop`, go to the other end of the highlighted text without changing the selection + - `transpose-chars`, transpose two characters to the left of the cursor - `transpose-words`, transpose two words to the left of the cursor diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 10551832..de0f8bd6 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -200,6 +200,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind -M visual W forward-bigword bind -M visual e forward-word bind -M visual E forward-bigword + bind -M visual o swap-selection-start-stop force-repaint for key in $eol_keys bind -M visual $key end-of-line 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; |