curses popup single char input

With 'popup_dialog' On, a one line popup with question and likely
responses and default answer was shown, but without having the
cursor displayed at the end of emphasize that it was waiting for an
answer.  Make the popup be one character wider so that there is room
to show the cursor.  No effect when 'popup_dialog' is Off and prompts
are shown at the bottom of the message window; those already have the
cursor sitting at the end.
This commit is contained in:
PatR
2019-06-28 12:28:40 -07:00
parent 2145387ac8
commit bed5570e3b
2 changed files with 7 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.75 $ $NHDT-Date: 1561748351 2019/06/28 18:59:11 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.76 $ $NHDT-Date: 1561750114 2019/06/28 19:28:34 $
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,
@@ -168,6 +168,8 @@ curses+'perm_invent': if too many entries for window height, last one which
curses+'perm_invent': top line was wasted (left blank) when borders Off
curses+'perm_invent': don't highlight inventory letters since nothing is
selectable from the menu comprising the persistent inventory window
curses+'popup_dialog': show the text cursor at the end of prompts for single
character input
curses+EDIT_GETLIN: when a prompt's answer was preloaded, using ESC to discard
it deleted it from the answer buffer but didn't erase it from screen
tty: re-do one optimization used when status conditions have all been removed

View File

@@ -264,7 +264,8 @@ curses_character_input_dialog(const char *prompt, const char *choices,
any_choice = TRUE;
}
prompt_width = (int) strlen(askstr);
/* +1: room for a trailing space where the cursor will rest */
prompt_width = (int) strlen(askstr) + 1;
if ((prompt_width + 2) > maxwidth) {
prompt_height = curses_num_lines(askstr, maxwidth);
@@ -284,11 +285,11 @@ curses_character_input_dialog(const char *prompt, const char *choices,
/* TODO: add SUPPRESS_HISTORY flag, then after getting a response,
append it and use put_msghistory() on combined prompt+answer */
custompline(OVERRIDE_MSGTYPE, "%s", askstr);
curs_set(1);
}
/*curses_stupid_hack = 0; */
curs_set(1);
while (1) {
#ifdef PDCURSES
answer = wgetch(message_window);
@@ -342,6 +343,7 @@ curses_character_input_dialog(const char *prompt, const char *choices,
if (choices != NULL && answer != '\0' && index(choices, answer))
break;
}
curs_set(0);
if (iflags.wc_popup_dialog) {
/* Kludge to make prompt visible after window is dismissed
@@ -354,7 +356,6 @@ curses_character_input_dialog(const char *prompt, const char *choices,
curses_destroy_win(askwin);
} else {
curses_clear_unhighlight_message_window();
curs_set(0);
}
return answer;