diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-25 17:55:24 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-26 00:42:15 +0300 |
commit | 574b46657cd5b752597384b31f37dd6a07f063d8 (patch) | |
tree | 78423ce3b0426c7541de0ed393c1f9cf7f6a9577 /src/stdio-commands.c | |
parent | 24c3bfc4f18f06a465b70afa45783d568402abdf (diff) | |
download | sciteco-574b46657cd5b752597384b31f37dd6a07f063d8.tar.gz |
support <:^A> to force raw ANSI output
* ^A uses the default code page without colon, just like ^U/EU.
This is usually UTF8, unless you run with --8bit.
It would make just as little sense to inherit the codepage from the
current document.
* Ensures that code like `:^A^E<0xFF>^A` really outputs byte 0xFF.
* DEC TECO doesn't have the colon modifier, but it has a colon modifier
for ^T to enforce raw output.
In SciTECO, the ^T vs. :^T distinction will also be between default codepage
and ANSI. It makes sense because ^T should treat its numeric arguments like <I>
for consistency.
Diffstat (limited to 'src/stdio-commands.c')
-rw-r--r-- | src/stdio-commands.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/stdio-commands.c b/src/stdio-commands.c index 30f3808..0c8d20c 100644 --- a/src/stdio-commands.c +++ b/src/stdio-commands.c @@ -218,8 +218,13 @@ teco_state_print_string_initial(teco_machine_main_t *ctx, GError **error) teco_undo_gunichar(ctx->expectstring.machine.escape_char); ctx->expectstring.machine.escape_char = TECO_CTL_KEY('A'); - /* chain to the default initial_cb */ - return teco_state_expectstring_initial(ctx, error); + if (ctx->flags.mode > TECO_MODE_NORMAL) + return TRUE; + + teco_machine_stringbuilding_set_codepage(&ctx->expectstring.machine, + teco_machine_main_eval_colon(ctx) + ? SC_CHARSET_ANSI : teco_default_codepage()); + return TRUE; } static teco_state_t * @@ -229,9 +234,10 @@ teco_state_print_string_done(teco_machine_main_t *ctx, const teco_string_t *str, return &teco_state_start; } -/*$ "^A" print "print string" +/*$ "^A" ":^A" print "print string" * ^A<string>^A -- Print string as message * @^A/string/ + * :^A<string>^A * * Print <string> as a message, i.e. in the message line * in interactive mode and if possible on the terminal (stdout) as well. @@ -245,6 +251,12 @@ teco_state_print_string_done(teco_machine_main_t *ctx, const teco_string_t *str, * by \fB@\fP-modifying the command. * * String-building characters are enabled for this command. + * \fB^A\fP outputs strings in the default codepage, + * but when colon modified raw ANSI encoding is enforced. + */ +/* + * NOTE: Codepage is among other things important for + * ^EUq, ^E<...> and case folding. */ TECO_DEFINE_STATE_EXPECTSTRING(teco_state_print_string, .initial_cb = (teco_state_initial_cb_t)teco_state_print_string_initial |