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 | |
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.
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | doc/sciteco.7.template | 4 | ||||
-rw-r--r-- | src/parser.c | 25 |
3 files changed, 24 insertions, 7 deletions
@@ -509,8 +509,6 @@ Features: * ^^ in string building expanding to a single caret is not consistent. Perhaps we should allow only ^Q^ as a way to insert a single caret? - At the very least, Ctrl+^ should insert char 30 instead of a single - caret. * Support for non-ANSI single byte encodings is still incomplete. You can set them with EE and they will be correctly displayed (on Gtk at least), but there is no way diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template index 8486203..52fa742 100644 --- a/doc/sciteco.7.template +++ b/doc/sciteco.7.template @@ -1653,7 +1653,9 @@ stages: .IP 1. 4 Carets followed by characters are translated to control codes, so \(lq^a\(rq and \(lq^A\(rq are equivalent to CTRL+A (code 1). -A double caret \(lq^^\(rq is translated to a single caret. +\# FIXME: Should we change the double-caret behavior? +A double caret \(lq^^\(rq is translated to a single caret, +but Ctrl+caret (code 30) is not translated at all. This caret-handling is independent of the caret-handling in command names. .IP 2. 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; |