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.
This commit is contained in:
Federico Ferri 2016-03-20 02:08:23 +01:00 committed by Kurtis Rader
parent 879ee61a30
commit 168a156e58
5 changed files with 23 additions and 0 deletions

View file

@ -75,6 +75,8 @@ The following special input functions are available:
- `beginning-of-line`, move to the beginning of the line - `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 - `capitalize-word`, make the current word begin with a capital letter
- `complete`, guess the remainder of the current token - `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-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 - `explain`, print a description of possible problems with the current command
- `forward-bigword`, move one whitespace-delimited word to the right - `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-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-whole-line`, move the line to the killring
- `kill-word`, move the next word to the killring - `kill-word`, move the next word to the killring
- `suppress-autosuggestion`, remove the current autosuggestion - `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-chars`, transpose two characters to the left of the cursor
- `transpose-words`, transpose two words to the left of the cursor - `transpose-words`, transpose two words to the left of the cursor

View file

@ -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 W forward-bigword
bind -M visual e forward-word bind -M visual e forward-word
bind -M visual E forward-bigword bind -M visual E forward-bigword
bind -M visual o swap-selection-start-stop force-repaint
for key in $eol_keys for key in $eol_keys
bind -M visual $key end-of-line bind -M visual $key end-of-line

View file

@ -132,6 +132,7 @@ static const wchar_t * const name_arr[] =
L"suppress-autosuggestion", L"suppress-autosuggestion",
L"accept-autosuggestion", L"accept-autosuggestion",
L"begin-selection", L"begin-selection",
L"swap-selection-start-stop",
L"end-selection", L"end-selection",
L"kill-selection", L"kill-selection",
L"forward-jump", L"forward-jump",
@ -242,6 +243,7 @@ static const wchar_t code_arr[] =
R_SUPPRESS_AUTOSUGGESTION, R_SUPPRESS_AUTOSUGGESTION,
R_ACCEPT_AUTOSUGGESTION, R_ACCEPT_AUTOSUGGESTION,
R_BEGIN_SELECTION, R_BEGIN_SELECTION,
R_SWAP_SELECTION_START_STOP,
R_END_SELECTION, R_END_SELECTION,
R_KILL_SELECTION, R_KILL_SELECTION,
R_FORWARD_JUMP, R_FORWARD_JUMP,

View file

@ -68,6 +68,7 @@ enum
R_SUPPRESS_AUTOSUGGESTION, R_SUPPRESS_AUTOSUGGESTION,
R_ACCEPT_AUTOSUGGESTION, R_ACCEPT_AUTOSUGGESTION,
R_BEGIN_SELECTION, R_BEGIN_SELECTION,
R_SWAP_SELECTION_START_STOP,
R_END_SELECTION, R_END_SELECTION,
R_KILL_SELECTION, R_KILL_SELECTION,
R_FORWARD_JUMP, R_FORWARD_JUMP,

View file

@ -4026,6 +4026,17 @@ const wchar_t *reader_readline(int nchars)
break; 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: case R_END_SELECTION:
{ {
data->sel_active = false; data->sel_active = false;