diff options
author | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2024-06-30 15:44:08 +0900 |
---|---|---|
committer | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2024-06-30 15:45:31 +0900 |
commit | 5d5ff4076abe2e8aeb40980ec1b3ef9ee5fa92e6 (patch) | |
tree | faaf80e5d0eb18f167d45e5f8cdcab226563c206 /src | |
parent | 7c46728fe1bf4948c1e5f1635395b212b3482a24 (diff) |
Fix TUI drawing
Diffstat (limited to 'src')
-rw-r--r-- | src/tui.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -27,20 +27,13 @@ static struct calc_data calcs[CALC_COUNT] = {0}; static int current_idx = 0; static WINDOW *win; -void -init(void) -{ - win = initscr(); - clear(); - refresh(); -} - static void draw_res(void) { - int j = current_idx; + int j = loop_backwards(current_idx); + int drawn = 0; - while (calcs[j].ms != 0) + while ((calcs[j].ms != 0) && (drawn < CALC_COUNT)) { printw("%d + %d = %d\t%s\t%dms\n", calcs[j].x, calcs[j].y, @@ -49,6 +42,7 @@ draw_res(void) calcs[j].ms); j = loop_backwards(j); + drawn++; } } @@ -71,6 +65,15 @@ redraw(void) } void +init(void) +{ + win = initscr(); + noecho(); + clear(); + redraw(); +} + +void display_calc(int x, int y) { current_idx = next_calc(current_idx); @@ -135,8 +138,9 @@ read_input(void) void display_res(bool right, int ms) { - (void) right; - (void) ms; + calcs[current_idx].right = right; + calcs[current_idx].ms = ms; + redraw(); } void @@ -164,5 +168,6 @@ post_reload(void *state) memcpy(¤t_idx, data + sizeof(calcs), sizeof(current_idx)); free(data); init(); + redraw(); } #endif |