From 8d1001842dd873696454430b4683a3506cdb7f89 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 17 Nov 2023 08:37:54 -0500 Subject: [PATCH] alternative fix for menu search (':') This avoids clearing core context variables within a window port. --- include/extern.h | 1 + include/hack.h | 1 + include/winprocs.h | 7 ++++++- src/botl.c | 4 ++++ src/windows.c | 8 +++++++- win/tty/getline.c | 9 --------- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/extern.h b/include/extern.h index 3b0a2ff85..02bf047aa 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3442,6 +3442,7 @@ extern void add_menu(winid, const glyph_info *, const ANY_P *, char, char, int, int, const char *, unsigned int); extern void add_menu_heading(winid, const char *); extern void add_menu_str(winid, const char *); +extern void getlin(const char *, char *); /* ### windows.c ### */ diff --git a/include/hack.h b/include/hack.h index 7fb80fd24..1ad6027ca 100644 --- a/include/hack.h +++ b/include/hack.h @@ -763,6 +763,7 @@ struct sinfo { int in_checkpoint; /* saving insurance checkpoint */ int in_parseoptions; /* in parseoptions */ int in_role_selection; /* role/race/&c selection menus in progress */ + int in_getlin; /* inside interface getline routine */ int config_error_ready; /* config_error_add is ready, available */ int beyond_savefile_load; /* set when past savefile loading */ #ifdef PANICLOG diff --git a/include/winprocs.h b/include/winprocs.h index ed02d24a3..24c09b991 100644 --- a/include/winprocs.h +++ b/include/winprocs.h @@ -149,7 +149,12 @@ extern #define nh_poskey (*windowprocs.win_nh_poskey) #define nhbell (*windowprocs.win_nhbell) #define nh_doprev_message (*windowprocs.win_doprev_message) -#define getlin (*windowprocs.win_getlin) +/* 3.7: There is a real getlin() in the core now, which does + * some before and after activities. + * [alternative fix for menu search via ':'.] + * getlin() is in windows.c + */ +/* #define getlin (*windowprocs.win_getlin) */ #define get_ext_cmd (*windowprocs.win_get_ext_cmd) #define number_pad (*windowprocs.win_number_pad) #define nh_delay_output (*windowprocs.win_delay_output) diff --git a/src/botl.c b/src/botl.c index 04b69a24a..f0534b480 100644 --- a/src/botl.c +++ b/src/botl.c @@ -245,6 +245,8 @@ do_statusline2(void) void bot(void) { + if (gp.program_state.in_getlin) + return; /* dosave() flags completion by setting u.uhp to -1; suppress_map_output() covers program_state.restoring and is used for status as well as map */ if (u.uhp != -1 && gy.youmonst.data @@ -265,6 +267,8 @@ bot(void) void timebot(void) { + if (gp.program_state.in_getlin) + return; /* we're called when iflags.time_botl is set and general gc.context.botl is clear; iflags.time_botl gets set whenever gm.moves changes value so there's no benefit in tracking previous value to decide whether diff --git a/src/windows.c b/src/windows.c index 14bf0e95b..dbe96ee57 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1679,5 +1679,11 @@ get_menu_coloring(const char *str, int *color, int *attr) return FALSE; } - +void +getlin(const char *query, register char *bufp) +{ + gp.program_state.in_getlin = TRUE; + (*windowprocs.win_getlin)(query, bufp); + gp.program_state.in_getlin = FALSE; +} /*windows.c*/ diff --git a/win/tty/getline.c b/win/tty/getline.c index 0f3adca44..381c618e3 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -58,16 +58,7 @@ hooked_tty_getlin( /* * Issue the prompt. - * - * custompline() will call vpline() which calls flush_screen() which - * calls bot(). We don't want bot() modifying the screen during - * whatever this prompt is for. If the status area hasn't been - * overwritten, no update is needed, but if has been overwritten (by - * a menu or text window) we don't want status refresh to clobber that - * when the window hasn't finished yet. [Fix for menu search via ':'.] */ - if (ttyDisplay->lastwin != WIN_STATUS) - gc.context.botl = gc.context.botlx = iflags.time_botl = FALSE; custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s ", query); #ifdef EDIT_GETLIN