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 --- misplays.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'misplays.c') diff --git a/misplays.c b/misplays.c index a2535c3..3e3ae20 100644 --- a/misplays.c +++ b/misplays.c @@ -193,10 +193,12 @@ static void info_update(struct thread *th, PANEL *pan) { disasm(th, pan); } -static void wait_all_threads(struct list *processes) { +static int wait_all_threads(struct list *processes) { + int action = 0; for (struct process *proc = processes->head; proc != processes->end; proc = proc->next) { - dbg_sync(proc); + action |= dbg_sync(proc); } + return action; } static void layout(struct list *processes, struct thread *th) { @@ -286,14 +288,11 @@ int main(int argc, char **argv) { int quit = 0; int mode = 0; + int dirty = 1; + int pressed = 0; while (!quit) { - wait_all_threads(&processes); - layout(&processes, th); - console_update(&cons, right); - info_update(th, left); - cursupdate(); - int ch = getch(); + pressed = 1; if (mode == 0) { switch (ch) { @@ -406,6 +405,9 @@ int main(int argc, char **argv) { b->enabled = en; b->tid = tid; break; + case ERR: + pressed = 0; + break; } } else { switch (ch) { @@ -417,12 +419,23 @@ int main(int argc, char **argv) { console_leave(&cons, right); break; case ERR: + pressed = 0; break; default: console_input(&cons, ch); break; } } + + dirty |= wait_all_threads(&processes); + dirty |= console_update(&cons, right); + + if (dirty || pressed) { + layout(&processes, th); + info_update(th, left); + cursupdate(); + dirty = 0; + } } for (struct process *p = processes.head; p != processes.end; p = p->next) { -- cgit v1.2.3