From 48308687979f26a3498e7af94eacc8fe34307a78 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 4 Dec 2024 16:43:51 +0300 Subject: the command now supports the @ modifier for cutting into the register * Can be freely combined with the colon-modifier as well. :@Xq cut-appends to register q. * This simply deletes the given buffer range after the copy or append operation as if followed by another command. * This has indeed been a very annoying missing feature, as you often have to retype the range for a K or D command. At the same time, this cannot be reasonably solved with a macro since macros do not accept Q-Register arguments -- so we would have to restrict ourselves to one or a few selected registers. I was also considering to solve this with a special stack operation that duplicates the top values, so that Xq leaves arguments for K, but this couldn't work for cutting lines and would also be longer to type. * It's the first non-string command that accepts @. Others may follow in the future. We're approaching ITS TECO madness levels. --- src/parser.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index 729fe42..e1bf576 100644 --- a/src/parser.c +++ b/src/parser.c @@ -332,6 +332,18 @@ teco_machine_main_eval_colon(teco_machine_main_t *ctx) return TRUE; } +gboolean +teco_machine_main_eval_at(teco_machine_main_t *ctx) +{ + if (!ctx->modifier_at) + return FALSE; + + if (ctx->parent.must_undo) + teco_undo_guint(ctx->__flags); + ctx->modifier_at = FALSE; + return TRUE; +} + teco_state_t * teco_machine_main_transition_input(teco_machine_main_t *ctx, teco_machine_main_transition_t *transitions, @@ -935,11 +947,9 @@ teco_state_expectstring_input(teco_machine_main_t *ctx, gunichar chr, GError **e * String termination handling */ if (ctx->modifier_at) { - if (current->expectstring.last) { - if (ctx->parent.must_undo) - teco_undo_guint(ctx->__flags); - ctx->modifier_at = FALSE; - } + if (current->expectstring.last) + /* also clears the "@" modifier flag */ + teco_machine_main_eval_at(ctx); /* * FIXME: Exclude setting at least whitespace characters as the -- cgit v1.2.3