curses line-of-input prompting

Redo the fake ESC handling for curses' wgetnstr() so that it
applies to all popup prompts rather than just to "Who are you?",
in case the player sets the 'popup_dialog' option.
This commit is contained in:
PatR
2021-01-06 15:59:55 -08:00
parent 2df4f08c0b
commit 7ba7873a41
3 changed files with 33 additions and 31 deletions
+8 -24
View File
@@ -240,9 +240,6 @@ curses_player_selection()
void
curses_askname()
{
const char *bail_msg = "Until next time then...";
int trylimit = 10;
#ifdef SELECTSAVED
if (iflags.wc2_selectsaved && !iflags.renameinprogress)
switch (restore_menu(MAP_WIN)) {
@@ -255,29 +252,16 @@ curses_askname()
}
#endif /* SELECTSAVED */
do {
if (--trylimit < 0) {
bail_msg = "A name is required; giving up.";
goto bail;
}
g.plname[0] = '\0';
/* for askname(), this will use wgetnstr() which treats ESC like
an ordinary character; fake the behavior we want: as kill_char
if it follows any input or as cancel if it is at the start;
player has to type <escape><return> to get back here though */
curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ);
if (g.plname[0] == '\033')
goto bail;
(void) mungspaces(g.plname);
} while (!g.plname[0] || index(g.plname, '\033') != 0);
/* we get here if input is non-empty and doesn't contain ESC */
return;
curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ);
(void) mungspaces(g.plname);
if (g.plname[0] && g.plname[0] != '\033') {
iflags.renameallowed = TRUE; /* tty uses this, we don't [yet?] */
return;
}
bail:
curses_bail(bail_msg);
/* message is delivered via raw_print() */
curses_bail("\nUntil next time then...\n");
/*NOTREACHED*/
}