aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@bordeaux-inp.fr>2024-06-30 12:18:47 +0900
committerTristan Riehs <tristan.riehs@bordeaux-inp.fr>2024-06-30 12:18:47 +0900
commit7c46728fe1bf4948c1e5f1635395b212b3482a24 (patch)
treea52ab18e9b7cbd8d962b9ac45b75775e51bd7cfe
parent0856d2961d9e7b3a9e36ddfdfc1985ca5cab13a0 (diff)
Fix handling of backspace
-rw-r--r--src/tui.c11
1 files 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;