aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar Michael Steed <msteed68@gmail.com>2015-05-30 16:44:25 -0600
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-06-04 12:09:02 -0700
commitcb984cf761debdc858db48065b2c1d94b31de49e (patch)
treeb12eb23ac8a9c8717ffe839f9ee427687569a3f4 /reader.cpp
parent7efbcc039d9e41369be590bb77d8ce7fd4a9b260 (diff)
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
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/reader.cpp b/reader.cpp
index 4fdd6ceb..086a2a5f 100644
--- a/reader.cpp
+++ b/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())