alternative fix for menu search (':')

This avoids clearing core context variables within a window port.
This commit is contained in:
nhmall
2023-11-17 08:37:54 -05:00
parent a49c872f47
commit 8d1001842d
6 changed files with 19 additions and 11 deletions

View File

@@ -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 ### */

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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*/

View File

@@ -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