diff options
-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; |