From bed5570e3baaa4c5203014e76ec9f2edc38c7e3b Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 28 Jun 2019 12:28:40 -0700 Subject: [PATCH] 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. --- doc/fixes36.3 | 4 +++- win/curses/cursdial.c | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index b27d8e64b..a46c815b8 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -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 diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 793e6d81c..ccd962fc1 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -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;