From eee669a76b3c0b1928475d55d9e1333b3d15bb8c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 25 Jul 2025 01:41:37 +0300 Subject: implemented the <^A> command for printing arbitrary strings * Greatly improved usability as a scripting language. * The command is in DEC TECO, but in contrast to DEC TECO, we also support string building constructs in ^A. * Required some refactoring: As we want it to write everything verbatim to stdout, the per-interface method is now teco_interface_msg_literal() and it has to deal with unprintable characters. When displaying in the UI, we use teco_curses_format_str() and TecoGtkLabel functions/widgets to deal with possible control codes. * Numbers printed with `=` have to be written with a trailing linefeed, which would also be visible as a reverse "LF" in the UI. Not sure whether this is acceptable - the alternative would be to strip the strings before displaying them. * Messages written to stdout are also auto-flushed at the moment. In the future we might want to put flushing under control of the language. Perhaps :^A could inhibit the flushing. --- src/parser.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/parser.c') diff --git a/src/parser.c b/src/parser.c index 33d2e7f..347c1a6 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1047,8 +1047,12 @@ teco_state_expectstring_input(teco_machine_main_t *ctx, gunichar chr, GError **e * to the ANSI range (teco_ascii_toupper())? * This would be faster than case folding each and every character * of a string argument to check against the escape char. + * + * FIXME: This has undesired effects if you try to use one of + * of these characters with multiple string arguments. */ switch (ctx->expectstring.machine.escape_char) { + case TECO_CTL_KEY('A'): case '\e': case '{': if (ctx->parent.must_undo) -- cgit v1.2.3