some Windows curses adjustments dialog on startup

This commit is contained in:
nhmall
2026-05-22 12:21:42 -04:00
parent 3f837939ba
commit 4c7f2dfaac
3 changed files with 32 additions and 12 deletions
+9
View File
@@ -303,7 +303,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
#ifdef WINCHAIN #ifdef WINCHAIN
commit_windowchain(); commit_windowchain();
#endif #endif
init_nhwindows(&argc, argv); init_nhwindows(&argc, argv);
#ifdef TTY_GRAPHICS #ifdef TTY_GRAPHICS
if WINDOWPORT(tty) { if WINDOWPORT(tty) {
int i; int i;
@@ -1265,7 +1267,11 @@ other_self_recover_prompt(void)
int c, ci, ct, pl, retval = 0; int c, ci, ct, pl, retval = 0;
boolean ismswin = WINDOWPORT(mswin), boolean ismswin = WINDOWPORT(mswin),
iscurses = WINDOWPORT(curses); iscurses = WINDOWPORT(curses);
int save_popupdialog = iflags.wc_popup_dialog;
if (WINDOWPORT(curses)) {
iflags.wc_popup_dialog = TRUE;
}
pl = 1; pl = 1;
c = 'n'; c = 'n';
ct = 0; ct = 0;
@@ -1316,6 +1322,9 @@ other_self_recover_prompt(void)
else else
retval = 1; /* yes, do recover the old game */ retval = 1; /* yes, do recover the old game */
} }
if (WINDOWPORT(curses)) {
iflags.wc_popup_dialog = save_popupdialog;
}
return retval; return retval;
} }
+22 -11
View File
@@ -205,10 +205,8 @@ curses_line_input_dialog(
/* Get a single character response from the player, such as a y/n prompt */ /* Get a single character response from the player, such as a y/n prompt */
int int
curses_character_input_dialog( curses_character_input_dialog(const char *prompt, const char *choices,
const char *prompt, char def)
const char *choices,
char def)
{ {
WINDOW *askwin = NULL; WINDOW *askwin = NULL;
#ifdef PDCURSES #ifdef PDCURSES
@@ -222,12 +220,15 @@ curses_character_input_dialog(
int prompt_height = 1; int prompt_height = 1;
boolean any_choice = FALSE; boolean any_choice = FALSE;
boolean accept_count = FALSE; boolean accept_count = FALSE;
#ifdef PDCURSES
int x, y;
#endif
/* if messages were being suppressed for the remainder of the turn, /* if messages were being suppressed for the remainder of the turn,
re-activate them now that input is being requested */ re-activate them now that input is being requested */
curses_got_input(); curses_got_input();
if (svm.moves > 0) { if (svm.moves > 0 || !program_state.beyond_savefile_load) {
curses_get_window_size(MAP_WIN, &map_height, &map_width); curses_get_window_size(MAP_WIN, &map_height, &map_width);
} else { } else {
map_height = term_rows; map_height = term_rows;
@@ -260,10 +261,10 @@ curses_character_input_dialog(
choicestr[count + 5] = def; choicestr[count + 5] = def;
choicestr[count + 6] = ')'; choicestr[count + 6] = ')';
choicestr[count + 7] = '\0'; choicestr[count + 7] = '\0';
} else { /* No usable default choice */ } else { /* No usable default choice */
choicestr[count + 3] = '\0'; choicestr[count + 3] = '\0';
def = '\0'; /* Mark as no default */ def = '\0'; /* Mark as no default */
} }
strcpy(askstr, prompt); strcpy(askstr, prompt);
strcat(askstr, choicestr); strcat(askstr, choicestr);
@@ -281,7 +282,8 @@ curses_character_input_dialog(
} }
if (iflags.wc_popup_dialog /*|| curses_stupid_hack*/) { if (iflags.wc_popup_dialog /*|| curses_stupid_hack*/) {
askwin = curses_create_window(TEXT_WIN, prompt_width, prompt_height, UP); askwin =
curses_create_window(TEXT_WIN, prompt_width, prompt_height, UP);
activemenu = askwin; activemenu = askwin;
for (count = 0; count < prompt_height; count++) { for (count = 0; count < prompt_height; count++) {
@@ -291,6 +293,11 @@ curses_character_input_dialog(
} }
curses_set_wid_colors(TEXT_WIN, askwin); curses_set_wid_colors(TEXT_WIN, askwin);
#ifdef PDCURSES
getyx(askwin, y, x);
wmove(askwin, y, x);
curs_set(1);
#endif
wrefresh(askwin); wrefresh(askwin);
} else { } else {
/* TODO: add SUPPRESS_HISTORY flag, then after getting a response, /* TODO: add SUPPRESS_HISTORY flag, then after getting a response,
@@ -299,11 +306,15 @@ curses_character_input_dialog(
} }
/*curses_stupid_hack = 0; */ /*curses_stupid_hack = 0; */
#ifndef PDCURSES
curs_set(1); curs_set(1);
#endif
while (1) { while (1) {
#ifdef PDCURSES #ifdef PDCURSES
answer = wgetch(message_window); if (WIN_MESSAGE != WIN_ERR)
answer = wgetch(message_window);
else
answer = wgetch(askwin);
#else #else
answer = curses_read_char(); answer = curses_read_char();
#endif #endif
@@ -321,7 +332,7 @@ curses_character_input_dialog(
} }
answer = def; answer = def;
for (count = 0; choices[count] != '\0'; count++) { for (count = 0; choices[count] != '\0'; count++) {
if (choices[count] == 'q') { /* q is preferred over n */ if (choices[count] == 'q') { /* q is preferred over n */
answer = 'q'; answer = 'q';
} else if ((choices[count] == 'n') && answer != 'q') { } else if ((choices[count] == 'n') && answer != 'q') {
answer = 'n'; answer = 'n';