aboutsummaryrefslogtreecommitdiffhomepage
path: root/tokenizer.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 /tokenizer.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 'tokenizer.cpp')
-rw-r--r--tokenizer.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp
index 07253328..65908466 100644
--- a/tokenizer.cpp
+++ b/tokenizer.cpp
@@ -913,6 +913,59 @@ bool move_word_state_machine_t::consume_char_path_components(wchar_t c)
return consumed;
}
+bool move_word_state_machine_t::consume_char_whitespace(wchar_t c)
+{
+ enum
+ {
+ s_always_one = 0,
+ s_blank,
+ s_graph,
+ s_end
+ };
+
+ bool consumed = false;
+ while (state != s_end && ! consumed)
+ {
+ switch (state)
+ {
+ case s_always_one:
+ /* Always consume the first character */
+ consumed = true;
+ state = s_blank;
+ break;
+
+ case s_blank:
+ if (iswblank(c))
+ {
+ /* Consumed whitespace */
+ consumed = true;
+ }
+ else
+ {
+ state = s_graph;
+ }
+ break;
+
+ case s_graph:
+ if (iswgraph(c))
+ {
+ /* Consumed printable non-space */
+ consumed = true;
+ }
+ else
+ {
+ state = s_end;
+ }
+ break;
+
+ case s_end:
+ default:
+ break;
+ }
+ }
+ return consumed;
+}
+
bool move_word_state_machine_t::consume_char(wchar_t c)
{
switch (style)
@@ -921,6 +974,8 @@ bool move_word_state_machine_t::consume_char(wchar_t c)
return consume_char_punctuation(c);
case move_word_style_path_components:
return consume_char_path_components(c);
+ case move_word_style_whitespace:
+ return consume_char_whitespace(c);
default:
return false;
}