aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses/interface.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-08-01 22:53:54 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-08-01 22:53:54 +0300
commitdaead48672e56af966911abc4efe1e54573c02cc (patch)
tree897a7e525882adb0e24cddcafd17bdddd0f0695d /src/interface-curses/interface.c
parentca70c9061146386ce0986631cd7fc9209a935a34 (diff)
downloadsciteco-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/interface-curses/interface.c')
-rw-r--r--src/interface-curses/interface.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c
index d92eade..381c188 100644
--- a/src/interface-curses/interface.c
+++ b/src/interface-curses/interface.c
@@ -134,7 +134,6 @@ teco_console_ctrl_handler(DWORD type)
static gint teco_xterm_version(void) G_GNUC_UNUSED;
-static void teco_interface_refresh(void);
static gint teco_interface_blocking_getch(void);
#define UNNAMED_FILE "(Unnamed)"
@@ -924,7 +923,7 @@ teco_interface_getch(gboolean widechar)
if (!teco_interface.cmdline_window) /* batch mode */
return teco_interface_stdio_getch(widechar);
- teco_interface_refresh();
+ teco_interface_refresh(FALSE);
/*
* Signal that we accept input by drawing a real cursor in the message bar.
@@ -1819,8 +1818,8 @@ teco_interface_is_interrupted(void)
* filtering out CTRL+C.
* It's currently necessary as a fallback e.g. for PDCURSES_GUI or XCurses.
*
- * NOTE: Theoretically, this can be optimized by doing wgetch() only every X
- * microseconds like on Gtk+.
+ * NOTE: Theoretically, this can be optimized by doing wgetch() only every
+ * TECO_POLL_INTERVAL microseconds like on Gtk+.
* But this turned out to slow things down, at least on PDCurses/WinGUI.
*/
gboolean
@@ -1848,9 +1847,16 @@ teco_interface_is_interrupted(void)
#endif
-static void
-teco_interface_refresh(void)
+void
+teco_interface_refresh(gboolean force)
{
+ if (!teco_interface.cmdline_window)
+ /* batch mode */
+ return;
+
+ if (G_UNLIKELY(force))
+ clearok(curscr, TRUE);
+
/*
* Info window is updated very often which is very
* costly, especially when using PDC_set_title(),
@@ -2124,7 +2130,7 @@ teco_interface_event_loop_iter(void)
* in the ^KMOUSE macro, allowing dot to be outside of the view.
*/
teco_interface_unfold();
- teco_interface_refresh();
+ teco_interface_refresh(FALSE);
return;
#endif
@@ -2183,7 +2189,7 @@ teco_interface_event_loop_iter(void)
teco_interface_unfold();
teco_interface_ssm(SCI_SCROLLCARET, 0, 0);
- teco_interface_refresh();
+ teco_interface_refresh(FALSE);
}
gboolean
@@ -2199,7 +2205,7 @@ teco_interface_event_loop(GError **error)
teco_interface_cmdline_update(&empty_cmdline);
teco_interface_msg_clear();
teco_interface_ssm(SCI_SCROLLCARET, 0, 0);
- teco_interface_refresh();
+ teco_interface_refresh(FALSE);
#ifdef EMCURSES
PDC_emscripten_set_handler(teco_interface_event_loop_iter, TRUE);