curses menu: support backspace/delete for counts

Have curses call the core get_count() routine instead rolling its
own so that backspace and delete are supported.  That part was
trivial to accomplish.  Unfortunately it brought the disappearing
menu phenomenon back so it became more complicated overall.
This commit is contained in:
PatR
2021-06-06 05:54:53 -07:00
parent 0280006d76
commit 41eecdf6b3
8 changed files with 48 additions and 33 deletions

View File

@@ -4340,6 +4340,7 @@ click_to_cmd(int x, int y, int mod)
return cmd;
}
/* gather typed digits into a number in *count; return the next non-digit */
char
get_count(char *allowchars, char inkey,
long maxcount, long *count,
@@ -4363,12 +4364,12 @@ get_count(char *allowchars, char inkey,
if (digit(key)) {
cnt = 10L * cnt + (long) (key - '0');
if (cnt < 0)
cnt = 0;
else if (maxcount > 0 && cnt > maxcount)
if (cnt < 0L)
cnt = 0L;
else if (maxcount > 0L && cnt > maxcount)
cnt = maxcount;
} else if (cnt && (key == '\b' || key == STANDBY_erase_char)) {
cnt = cnt / 10;
cnt = cnt / 10L;
backspaced = TRUE;
} else if (key == g.Cmd.spkeys[NHKF_ESC]) {
break;