diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-08-01 22:53:54 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-08-01 22:53:54 +0300 |
commit | daead48672e56af966911abc4efe1e54573c02cc (patch) | |
tree | 897a7e525882adb0e24cddcafd17bdddd0f0695d /src/core-commands.c | |
parent | ca70c9061146386ce0986631cd7fc9209a935a34 (diff) | |
download | sciteco-daead48672e56af966911abc4efe1e54573c02cc.tar.gz |
implemented the ^W command for refreshing the screen in loops, for sleeping and also the CTRL+L immediate editing command
* ^W can be added to loops in order to view progress in interactive mode.
It also sleeps for a given number of milliseconds (10ms by default).
* In batch mode it is therefore the sleep command.
* Since CTRL+W is an immediate editing command, you will usually type it Caret+W.
ASCII 23 however will also be accepted.
* While ^W only updates the screen, you can force a complete redraw by pressing CTRL+L.
This is what most terminal applications use for redrawing.
It will make it harder to insert ASCII 12, but this is seldom necessary since it
is a form feed.
^L (ASCII 12 and the upcaret variant ) is still a whitespace character and therefore treated as a NOP.
* DEC TECO had CTRL+W as the refresh immediate editing command.
Video TECO uses <ET> as a regular command for refreshign in loops.
I'd rather keep ET reserved as a potential terminal configuration command
as in DEC TECO, though.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r-- | src/core-commands.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index a2d3c92..c71ee95 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -1605,6 +1605,46 @@ teco_state_control_time(teco_machine_main_t *ctx, GError **error) } } +/*$ ^W refresh sleep delay wait + * [n]^W -- Wait and refresh screen + * + * First sleep <n> milliseconds before refreshing the view, + * i.e. drawing it. + * By default it sleeps for 10ms. + * This can be added to loops to make progress visible + * in interactive mode. + * In batch mode this command is useful as a sleep command. + * Sleeps can of course be interrupted with CTRL+C. + * + * Since CTRL+W is an immediate editing command, you may + * have to type this command in upcaret mode. + * To enforce a complete screen redraw you can also + * press CTRL+L. + */ +static void +teco_state_control_refresh(teco_machine_main_t *ctx, GError **error) +{ + teco_int_t ms; + + if (!teco_expressions_pop_num_calc(&ms, 10, error)) + return; + + while (ms > 0 && !teco_interface_is_interrupted()) { + /* + * UNIX' usleep() would also be interrupted by + * SIGINT, but polling for interruptions is + * probably precise enough. + * We need this as a fallback anyway. + */ + g_usleep(MIN(ms*1000, TECO_POLL_INTERVAL)); + ms -= TECO_POLL_INTERVAL/1000; + } + + teco_interface_unfold(); + teco_interface_ssm(SCI_SCROLLCARET, 0, 0); + teco_interface_refresh(FALSE); +} + static teco_state_t * teco_state_control_input(teco_machine_main_t *ctx, gunichar chr, GError **error) { @@ -1647,7 +1687,8 @@ teco_state_control_input(teco_machine_main_t *ctx, gunichar chr, GError **error) ['Y'] = {&teco_state_start, teco_state_control_last_range}, ['S'] = {&teco_state_start, teco_state_control_last_length}, ['T'] = {&teco_state_start, teco_state_control_typeout, - .modifier_colon = 1} + .modifier_colon = 1}, + ['W'] = {&teco_state_start, teco_state_control_refresh} }; /* |