From 7c46728fe1bf4948c1e5f1635395b212b3482a24 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sun, 30 Jun 2024 12:18:47 +0900 Subject: Fix handling of backspace --- src/tui.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/tui.c b/src/tui.c index b7fb20f..aa08d52 100644 --- a/src/tui.c +++ b/src/tui.c @@ -31,8 +31,6 @@ void init(void) { win = initscr(); - echo(); - cbreak(); clear(); refresh(); } @@ -87,6 +85,7 @@ display_calc(int x, int y) case digit: \ calcs[current_idx].input = \ add_input_digit(calcs[current_idx].input, digit - '0'); \ + redraw(); \ break; int @@ -106,11 +105,12 @@ read_input(void) return DISP_QUIT; case '\n': case KEY_ENTER: - printf("ENTER PRESSED\n\r"); return calcs[current_idx].input; case KEY_BACKSPACE: + case 0177: /* ASCII DEL character */ calcs[current_idx].input = rm_input_digit(calcs[current_idx].input); + redraw(); break; case_digit ('0') case_digit ('1') @@ -123,11 +123,10 @@ read_input(void) case_digit ('8') case_digit ('9') default: - return DISP_ERR; + break; } - redraw(); - c = getchar(); + c = getch(); } return DISP_ERR; -- cgit v1.2.3