diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-25 13:56:20 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-25 13:56:20 +0200 |
commit | dcaeb77ef2c5fad1810d242d7a96669e33c4b082 (patch) | |
tree | 0b0119ea5f420777f077ffe285d8dcccc5425da9 | |
parent | c2887621a37f429e2e05b561631fff01da8bd462 (diff) | |
download | sciteco-dcaeb77ef2c5fad1810d242d7a96669e33c4b082.tar.gz |
inhibit some immediate editing commands after ^Q/^R string building constructs
* This allows you to type ^Q^U (which would otherwise rub out the entire argument)
and ^Q^W (which would otherwise rub out the ^Q).
* ^Q^U coincidentally worked previously since the teco_state_stringbuilding_escaped
state would default to teco_state_process_edit_cmd().
But it's better to make this feauture explicit.
* This finally makes it possible to insert the ^W (23) char into a buffer.
In interactive mode, you can still only type Caret+W as a string building construct.
* ^G could also be inhibited after ^Q, but the control char is not used anywhere yet,
so there is no point in doing that.
-rw-r--r-- | doc/sciteco.7.template | 3 | ||||
-rw-r--r-- | src/cmdline.c | 21 | ||||
-rw-r--r-- | src/parser.c | 9 |
3 files changed, 32 insertions, 1 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template index a476091..ca93fa6 100644 --- a/doc/sciteco.7.template +++ b/doc/sciteco.7.template @@ -1694,6 +1694,9 @@ thus refers to the corresponding control code: Escape character \fIc\fP. The character is not handled as a string building or string termination character, so for instance \(lq^Q^Q\(rq translates to \(lq^Q\(rq. +Furthermore, some immediate editing commands are inhibited right after \fB^Q\fR, +so you can type \(lq^Q^U\(rq and \(lq^Q^W\(rq, which translate to control codes +21 and 23. .TP .SCITECO_TOPIC ^V^V ^Vc lower .B ^V^V diff --git a/src/cmdline.c b/src/cmdline.c index 0d32513..d024142 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -651,6 +651,27 @@ teco_state_stringbuilding_start_process_edit_cmd(teco_machine_stringbuilding_t * } gboolean +teco_state_stringbuilding_escaped_process_edit_cmd(teco_machine_stringbuilding_t *ctx, teco_machine_t *parent_ctx, + gunichar key, GError **error) +{ + /* + * Allow insertion of characters that would otherwise be interpreted as + * immediate editing commands after ^Q/^R. + */ + switch (key) { + //case TECO_CTL_KEY('G'): + case TECO_CTL_KEY('W'): + case TECO_CTL_KEY('U'): + teco_interface_popup_clear(); + + gchar c = key; + return teco_cmdline_insert(&c, sizeof(c), error); + } + + return teco_state_process_edit_cmd(parent_ctx, NULL, key, error); +} + +gboolean teco_state_stringbuilding_qreg_process_edit_cmd(teco_machine_stringbuilding_t *ctx, teco_machine_t *parent_ctx, gunichar chr, GError **error) { diff --git a/src/parser.c b/src/parser.c index 15d9f5e..7ba9876 100644 --- a/src/parser.c +++ b/src/parser.c @@ -499,7 +499,14 @@ teco_state_stringbuilding_escaped_input(teco_machine_stringbuilding_t *ctx, guni return &teco_state_stringbuilding_start; } -TECO_DEFINE_STATE(teco_state_stringbuilding_escaped); +/* in cmdline.c */ +gboolean teco_state_stringbuilding_escaped_process_edit_cmd(teco_machine_stringbuilding_t *ctx, teco_machine_t *parent_ctx, + gunichar key, GError **error); + +TECO_DEFINE_STATE(teco_state_stringbuilding_escaped, + .process_edit_cmd_cb = (teco_state_process_edit_cmd_cb_t) + teco_state_stringbuilding_escaped_process_edit_cmd +); static teco_state_t * teco_state_stringbuilding_lower_ctl_input(teco_machine_stringbuilding_t *ctx, gunichar chr, GError **error) |