aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core-commands.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-29 15:15:26 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-29 15:29:34 +0300
commitca0d7656b606703f1b5b52e59f0b46ca0038477e (patch)
treefda68826bfaa8ebe2b7f9e5134254515c1d845e6 /src/core-commands.c
parentf4114aeaeeeea37145e2cb11b81c2f74f51349fc (diff)
downloadsciteco-ca0d7656b606703f1b5b52e59f0b46ca0038477e.tar.gz
added `@W`, `@P`, `@V` and `@Y` command variants
* They swap the default order of skipping characters. For positive arguments: first non-word chars, then word chars. * This is especially useful after executing the non-at-modified versions. For instance, at the beginning of a word, `@W` jumps to its end. `@V` would delete the remainder of the word. * Since they have to evaluate the at-modifier, which has syntactic significance, the command implementations can no longer use transition tables, so they are in the switch-statements instead.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r--src/core-commands.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/core-commands.c b/src/core-commands.c
index 950127a..5d6e3b9 100644
--- a/src/core-commands.c
+++ b/src/core-commands.c
@@ -659,13 +659,9 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
['R'] = {&teco_state_start, teco_state_start_reverse},
['L'] = {&teco_state_start, teco_state_start_line},
['B'] = {&teco_state_start, teco_state_start_back},
- ['W'] = {&teco_state_start, teco_state_start_words},
- ['P'] = {&teco_state_start, teco_state_start_words_back},
- ['V'] = {&teco_state_start, teco_state_start_delete_words},
- ['Y'] = {&teco_state_start, teco_state_start_delete_words_back},
- ['='] = {&teco_state_start, teco_state_start_print},
['K'] = {&teco_state_start, teco_state_start_kill_lines},
['D'] = {&teco_state_start, teco_state_start_delete_chars},
+ ['='] = {&teco_state_start, teco_state_start_print},
['A'] = {&teco_state_start, teco_state_start_get}
};
@@ -770,6 +766,20 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
return &teco_state_start;
/*
+ * Word movement and deletion commands.
+ * These are not in the transitions table, so we can
+ * evaluate the @-modifier.
+ */
+ case 'w':
+ case 'W': return teco_state_start_words(ctx, "W", 1, error);
+ case 'p':
+ case 'P': return teco_state_start_words(ctx, "P", -1, error);
+ case 'v':
+ case 'V': return teco_state_start_delete_words(ctx, "V", 1, error);
+ case 'y':
+ case 'Y': return teco_state_start_delete_words(ctx, "Y", -1, error);
+
+ /*
* Modifiers
*/
case '@':