diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-26 00:37:43 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-07-26 00:42:15 +0300 |
commit | eb6f7a82045ad78553fca98c54a51366c55bd7a4 (patch) | |
tree | ff0cca8d3dfb71afe832e73616867cd09fdac22c /src/stdio-commands.c | |
parent | 574b46657cd5b752597384b31f37dd6a07f063d8 (diff) | |
download | sciteco-eb6f7a82045ad78553fca98c54a51366c55bd7a4.tar.gz |
implemented the <T> (typeout) command for printing to the terminal from the current buffer
* refactored some code that is common with Xq into teco_get_range_args().
Diffstat (limited to 'src/stdio-commands.c')
-rw-r--r-- | src/stdio-commands.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/stdio-commands.c b/src/stdio-commands.c index 0c8d20c..1a64db9 100644 --- a/src/stdio-commands.c +++ b/src/stdio-commands.c @@ -261,3 +261,39 @@ teco_state_print_string_done(teco_machine_main_t *ctx, const teco_string_t *str, TECO_DEFINE_STATE_EXPECTSTRING(teco_state_print_string, .initial_cb = (teco_state_initial_cb_t)teco_state_print_string_initial ); + +/*$ T type typeout + * [lines]T -- Type out buffer contents as messages + * -T + * from,toT + * + * Type out the next or previous number of <lines> from the buffer + * as a message, i.e. in the message line in interactive mode + * and if possible on the terminal (stdout) as well.. + * If <lines> is omitted, the sign prefix is implied. + * If two arguments are specified, the characters beginning + * at position <from> up to the character at position <to> + * are copied. + * + * The semantics of the arguments is analogous to the \fBK\fP + * command's arguments. + */ +void +teco_state_start_typeout(teco_machine_main_t *ctx, GError **error) +{ + gsize from, len; + + if (!teco_get_range_args("T", &from, &len, error)) + return; + + /* + * NOTE: This may remove the buffer gap since we need a consecutive + * piece of memory to log as a single message. + * FIXME: In batch mode even this could theoretically be avoided. + * Need to add a function like teco_interface_is_batch(). + * Still, this is probably more efficient than using a temporary + * allocation with SCI_GETTEXTRANGEFULL. + */ + const gchar *str = (const gchar *)teco_interface_ssm(SCI_GETRANGEPOINTER, from, len); + teco_interface_msg_literal(TECO_MSG_USER, str, len); +} |