mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-02 09:11:15 -03:00
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword, kill-bigword, backward-kill-bigword - Add new enum move_word_style_whitespace and related state machine method - Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW, daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB, ygE
This commit is contained in:
committed by
ridiculousfish
parent
7efbcc039d
commit
cb984cf761
40
reader.cpp
40
reader.cpp
@@ -1172,6 +1172,8 @@ static bool command_ends_paging(wchar_t c, bool focused_on_search_field)
|
||||
case R_END_OF_LINE:
|
||||
case R_FORWARD_WORD:
|
||||
case R_BACKWARD_WORD:
|
||||
case R_FORWARD_BIGWORD:
|
||||
case R_BACKWARD_BIGWORD:
|
||||
case R_DELETE_CHAR:
|
||||
case R_BACKWARD_DELETE_CHAR:
|
||||
case R_KILL_LINE:
|
||||
@@ -1180,8 +1182,10 @@ static bool command_ends_paging(wchar_t c, bool focused_on_search_field)
|
||||
case R_BACKWARD_KILL_LINE:
|
||||
case R_KILL_WHOLE_LINE:
|
||||
case R_KILL_WORD:
|
||||
case R_KILL_BIGWORD:
|
||||
case R_BACKWARD_KILL_WORD:
|
||||
case R_BACKWARD_KILL_PATH_COMPONENT:
|
||||
case R_BACKWARD_KILL_BIGWORD:
|
||||
case R_SELF_INSERT:
|
||||
case R_TRANSPOSE_CHARS:
|
||||
case R_TRANSPOSE_WORDS:
|
||||
@@ -3775,9 +3779,12 @@ const wchar_t *reader_readline(int nchars)
|
||||
/* kill one word left */
|
||||
case R_BACKWARD_KILL_WORD:
|
||||
case R_BACKWARD_KILL_PATH_COMPONENT:
|
||||
case R_BACKWARD_KILL_BIGWORD:
|
||||
{
|
||||
move_word_style_t style = (c == R_BACKWARD_KILL_PATH_COMPONENT ? move_word_style_path_components : move_word_style_punctuation);
|
||||
bool newv = (last_char != R_BACKWARD_KILL_WORD && last_char != R_BACKWARD_KILL_PATH_COMPONENT);
|
||||
move_word_style_t style =
|
||||
(c == R_BACKWARD_KILL_BIGWORD ? move_word_style_whitespace :
|
||||
c == R_BACKWARD_KILL_PATH_COMPONENT ? move_word_style_path_components : move_word_style_punctuation);
|
||||
bool newv = (last_char != R_BACKWARD_KILL_WORD && last_char != R_BACKWARD_KILL_PATH_COMPONENT && last_char != R_BACKWARD_KILL_BIGWORD);
|
||||
move_word(data->active_edit_line(), MOVE_DIR_LEFT, true /* erase */, style, newv);
|
||||
break;
|
||||
}
|
||||
@@ -3789,6 +3796,13 @@ const wchar_t *reader_readline(int nchars)
|
||||
break;
|
||||
}
|
||||
|
||||
/* kill one bigword right */
|
||||
case R_KILL_BIGWORD:
|
||||
{
|
||||
move_word(data->active_edit_line(), MOVE_DIR_RIGHT, true /* erase */, move_word_style_whitespace, last_char!=R_KILL_BIGWORD);
|
||||
break;
|
||||
}
|
||||
|
||||
/* move one word left*/
|
||||
case R_BACKWARD_WORD:
|
||||
{
|
||||
@@ -3796,6 +3810,13 @@ const wchar_t *reader_readline(int nchars)
|
||||
break;
|
||||
}
|
||||
|
||||
/* move one bigword left */
|
||||
case R_BACKWARD_BIGWORD:
|
||||
{
|
||||
move_word(data->active_edit_line(), MOVE_DIR_LEFT, false /* do not erase */, move_word_style_whitespace, false);
|
||||
break;
|
||||
}
|
||||
|
||||
/* move one word right*/
|
||||
case R_FORWARD_WORD:
|
||||
{
|
||||
@@ -3811,6 +3832,21 @@ const wchar_t *reader_readline(int nchars)
|
||||
break;
|
||||
}
|
||||
|
||||
/* move one bigword right */
|
||||
case R_FORWARD_BIGWORD:
|
||||
{
|
||||
editable_line_t *el = data->active_edit_line();
|
||||
if (el->position < el->size())
|
||||
{
|
||||
move_word(el, MOVE_DIR_RIGHT, false /* do not erase */, move_word_style_whitespace, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
accept_autosuggestion(false /* accept only one word */);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case R_BEGINNING_OF_HISTORY:
|
||||
{
|
||||
if (data->is_navigating_pager_contents())
|
||||
|
||||
Reference in New Issue
Block a user