From 27bb9ccc06b715ea8f76c269e8bc2fab03110155 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Tue, 7 May 2024 04:42:24 -0400 Subject: Only update ncurses display on activity or keypress Previously, the test UI logic would constantly regenerate and print the screen's contents every iteration of the main processing loop to naively ensure that changes to the underlying system were reflected immediately. Sometimes, this would result in a screen flicker due to the rapid clearing and printing. This makes the UI a bit smarter about when refreshes occur, by monitoring activity results from the debugger and console modules in addition to user input. This should improve the screen flicker performance. This also addresses an issue selecting text on the screen, which was previously not possible due to the rapid refreshing as well. Signed-off-by: Malfurious --- console.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'console.c') diff --git a/console.c b/console.c index 6c1ae53..4ab263d 100644 --- a/console.c +++ b/console.c @@ -55,11 +55,12 @@ void console_leave(struct console *cons, PANEL *pan) { cbreak(); } -void console_update(struct console *cons, PANEL *pan) { - ssize_t nb; +int console_update(struct console *cons, PANEL *pan) { char c; + int did_read = 0; - while ((nb = read(cons->master, &c, 1)) > 0) { + while (read(cons->master, &c, 1) > 0) { + did_read = 1; if (!cons->isesc) { if (c == 0x1b) { cons->isesc = 1; @@ -72,6 +73,8 @@ void console_update(struct console *cons, PANEL *pan) { } } } + + return did_read; } void console_input(struct console *cons, int ch) { -- cgit v1.2.3