diff options
author | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2024-06-30 12:18:47 +0900 |
---|---|---|
committer | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2024-06-30 12:18:47 +0900 |
commit | 7c46728fe1bf4948c1e5f1635395b212b3482a24 (patch) | |
tree | a52ab18e9b7cbd8d962b9ac45b75775e51bd7cfe | |
parent | 0856d2961d9e7b3a9e36ddfdfc1985ca5cab13a0 (diff) |
Fix handling of backspace
-rw-r--r-- | src/tui.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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; |