curses: #extended command vs erase/kill chars

Support erase char and kill char when getting an extended command.

Also, show the cursor so that it's obvious where input focus is.
This commit is contained in:
PatR
2019-07-11 01:02:34 -07:00
parent 08a1910867
commit 188eedc654
2 changed files with 22 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.92 $ $NHDT-Date: 1562806584 2019/07/11 00:56:24 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.93 $ $NHDT-Date: 1562832141 2019/07/11 08:02:21 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -175,6 +175,7 @@ curses: when map window was clipped, the 'scrollbars' shown to indicate which
the 2nd and 3rd fifths (for example) were currently within view
curses: support users's setting for erase char and kill char when getting a
line of input with 'popup_dialog' Off (already supported for popup On)
curses: support erase char and kill char when choosing an extended command
curses: attempting to use ^H to rush left actually executed ^G (#wizgenesis)
curses: disable the attempt to support Ctrl+Left_click as an alternate way
to generate Right_click for systems with one-button mouse or trackpad;

View File

@@ -17,6 +17,10 @@
#define strncasecmp strncmpi
#endif
/* defined in sys/<foo>/<foo>tty.c or cursmain.c as last resort;
set up by curses_init_nhwindows() */
extern char erase_char, kill_char;
/*
* Note:
*
@@ -412,7 +416,7 @@ curses_ext_cmd()
wmove(extwin, starty, startx + 2);
waddstr(extwin, cur_choice);
wmove(extwin, starty, (int) strlen(cur_choice) + startx + 2);
wprintw(extwin, " ");
wclrtoeol(extwin);
/* if we have an autocomplete command, AND it matches uniquely */
if (matches == 1) {
@@ -421,12 +425,12 @@ curses_ext_cmd()
wprintw(extwin, "%s",
extcmdlist[ret].ef_txt + (int) strlen(cur_choice));
curses_toggle_color_attr(extwin, NONE, A_UNDERLINE, OFF);
mvwprintw(extwin, starty,
(int) strlen(extcmdlist[ret].ef_txt) + 2, " ");
}
curs_set(1);
wrefresh(extwin);
letter = getch();
curs_set(0);
prompt_width = (int) strlen(cur_choice);
matches = 0;
@@ -448,8 +452,9 @@ curses_ext_cmd()
}
if (letter == '\177') /* DEL/Rubout */
letter = '\b';
if (letter == '\b' || letter == KEY_BACKSPACE) {
letter = '\b';
if (letter == '\b' || letter == KEY_BACKSPACE
|| (erase_char && letter == (int) (uchar) erase_char)) {
if (prompt_width == 0) {
ret = -1;
break;
@@ -458,7 +463,15 @@ curses_ext_cmd()
letter = '*';
prompt_width--;
}
/* honor kill_char if it's ^U or similar, but not if it's '@' */
} else if (kill_char && letter == (int) (uchar) kill_char
&& (letter < ' ' || letter >= '\177')) { /*ASCII*/
cur_choice[0] = '\0';
letter = '*';
prompt_width = 0;
}
if (letter != '*' && prompt_width < maxlen) {
cur_choice[prompt_width] = letter;
cur_choice[prompt_width + 1] = '\0';
@@ -486,7 +499,8 @@ curses_ext_cmd()
}
curses_destroy_win(extwin);
if (extwin2) curses_destroy_win(extwin2);
if (extwin2)
curses_destroy_win(extwin2);
return ret;
}