diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-19 12:53:14 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-19 12:53:14 +0200 |
commit | fcf962edded2d6a7cb638909587167261e4f2bb0 (patch) | |
tree | 9e29f3b39d5dcacae0b57be770a2d44fa862ecc9 /src/parser.c | |
parent | 5b3906f9255f43018c2bd9683cedddf3df37fa61 (diff) | |
download | sciteco-fcf962edded2d6a7cb638909587167261e4f2bb0.tar.gz |
Ctrl+^ is no longer translated to a single caret in string building (refs #20)
* Ctrl+^ (30) and Caret+caret (^^) were both translated to a single caret.
While there might be some reason to keep this behavior for double-caret,
it is certainly pointless for Ctrl+^.
* That gives you an easy way to insert Ctrl+^ (code 30) into documents with <I>.
Perviously, you either had to insert a double-caret, typing 4 carets in a row,
or you had to use <EI> or 30I$.
* The special handling of double-caret could perhaps be abolished altogether,
as we also have ^Q^ to escape plain carets.
The double-caret syntax is very archaic from the time that there was no proper
^Q as far as I recall correctly.
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/parser.c b/src/parser.c index 45e31cf..e73c877 100644 --- a/src/parser.c +++ b/src/parser.c @@ -383,10 +383,20 @@ TECO_DECLARE_STATE(teco_state_stringbuilding_ctle_n); static teco_state_t * teco_state_stringbuilding_start_input(teco_machine_stringbuilding_t *ctx, gunichar chr, GError **error) { - if (chr == '^') + switch (chr) { + case '^': return &teco_state_stringbuilding_ctl; - if (TECO_IS_CTL(chr)) - return teco_state_stringbuilding_ctl_input(ctx, TECO_CTL_ECHO(chr), error); + case TECO_CTL_KEY('^'): + /* + * Ctrl+^ is inserted verbatim as code 30. + * Otherwise it would expand to a single caret + * just like caret+caret (^^). + */ + break; + default: + if (TECO_IS_CTL(chr)) + return teco_state_stringbuilding_ctl_input(ctx, TECO_CTL_ECHO(chr), error); + } return teco_state_stringbuilding_escaped_input(ctx, chr, error); } @@ -407,7 +417,14 @@ teco_state_stringbuilding_ctl_input(teco_machine_stringbuilding_t *ctx, gunichar chr = teco_ascii_toupper(chr); switch (chr) { - case '^': break; + case '^': + /* + * Double-caret expands to a single caret. + * Ctrl+^ (30) is handled separately and inserts code 30. + * The special handling of the double-caret should perhaps + * be abolished altogether. + */ + break; case 'Q': case 'R': return &teco_state_stringbuilding_escaped; case 'V': return &teco_state_stringbuilding_lower; |