From 188eedc65458e9646569c794f816515f5cb3a35b Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 11 Jul 2019 01:02:34 -0700 Subject: [PATCH] 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. --- doc/fixes36.3 | 3 ++- win/curses/cursdial.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 3d8a5ed9e..391e849da 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -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; diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 7dccffa78..cb65610f5 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -17,6 +17,10 @@ #define strncasecmp strncmpi #endif +/* defined in sys//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; }