From ca0d7656b606703f1b5b52e59f0b46ca0038477e Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 29 Mar 2025 15:15:26 +0300 Subject: 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. --- src/core-commands.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/core-commands.c') 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} }; @@ -769,6 +765,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 */ -- cgit v1.2.3