add_menu follow-up, part 2 of interface adjustment

Remove menu_color support from the window port side of the interface.
The window port just has to honor the color parameter that was added
to the add_menu() interface definition in June 2022 commit
2770223d10, and let the core-side of
the interface handle things.

To that end, this does the following:

Removes the #define of add_menu() from include/winprocs.h and add a
real core-side add_menu() function to windows.c which acts as a
trampoline to the window port win_add_menu() function, while providing
a single location to adjust the parameters passed to the window port
function. get_menu_coloring() is now called in there.

Moves get_menu_coloring() from options.c into windows.c and makes it
static.

Removes all the calls to get_menu_coloring() from the tty, Qt, X11,
curses, and win32 interfaces and adjusts their code to simply honor
the color parameter in add_menu, similar to what the menu_headings
change from earlier today did.
This commit is contained in:
nhmall
2023-11-13 12:56:38 -05:00
parent 59a74a00fd
commit 4b79baa55b
11 changed files with 72 additions and 78 deletions

View File

@@ -8014,21 +8014,6 @@ add_menu_coloring(char *tmpstr) /* never Null but could be empty */
return add_menu_coloring_parsed(tmps, c, a);
}
boolean
get_menu_coloring(const char *str, int *color, int *attr)
{
struct menucoloring *tmpmc;
if (iflags.use_menu_color)
for (tmpmc = gm.menu_colorings; tmpmc; tmpmc = tmpmc->next)
if (regex_match(str, tmpmc->match)) {
*color = tmpmc->color;
*attr = tmpmc->attr;
return TRUE;
}
return FALSE;
}
/* release all menu color patterns */
void
free_menu_coloring(void)

View File

@@ -61,6 +61,7 @@ extern void *trace_procs_chain(int, int, void *, void *, void *);
static void def_raw_print(const char *s);
static void def_wait_synch(void);
static boolean get_menu_coloring(const char *, int *, int *);
#ifdef DUMPLOG
static winid dump_create_nhwindow(int);
@@ -1592,4 +1593,46 @@ mixed_to_glyphinfo(const char *str, glyph_info *gip)
return str;
}
/*
* Common code point leading into the interface-specifc
* add_menu() to allow single-spot adjustments to the parameters,
* such as those done by menu_colors.
*/
void
add_menu(
winid window, /* window to use, must be of type NHW_MENU */
const glyph_info *glyphinfo, /* glyph info with glyph to
* display with item */
const anything *identifier, /* what to return if selected */
char ch, /* selector letter (0 = pick our own) */
char gch, /* group accelerator (0 = no group) */
int attr, /* attribute for menu text (str) */
int color, /* color for menu text (str) */
const char *str, /* menu text */
unsigned int itemflags) /* itemflags such as MENU_ITEMFLAGS_SELECTED */
{
if (iflags.use_menu_color)
(void) get_menu_coloring(str, &color, &attr);
(*windowprocs.win_add_menu)(window, glyphinfo, identifier,
ch, gch, attr, color, str, itemflags);
}
static boolean
get_menu_coloring(const char *str, int *color, int *attr)
{
struct menucoloring *tmpmc;
if (iflags.use_menu_color)
for (tmpmc = gm.menu_colorings; tmpmc; tmpmc = tmpmc->next)
if (regex_match(str, tmpmc->match)) {
*color = tmpmc->color;
*attr = tmpmc->attr;
return TRUE;
}
return FALSE;
}
/*windows.c*/