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

@@ -1176,7 +1176,6 @@ menu_display_page(
char *tmpstr;
boolean first_accel = TRUE;
int color = NO_COLOR, attr = A_NORMAL;
boolean menu_color = FALSE;
/* letters assigned to entries on current page */
if (selectors)
@@ -1281,19 +1280,15 @@ menu_display_page(
start_col += 2;
}
#endif
color = NONE;
menu_color = iflags.use_menu_color
&& get_menu_coloring(menu_item_ptr->str, &color, &attr);
if (menu_color) {
attr = curses_convert_attr(attr);
if (color != NONE || attr != A_NORMAL)
curses_menu_color_attr(win, color, attr, ON);
} else {
attr = menu_item_ptr->attr;
if (color != NO_COLOR)
color = menu_item_ptr->color;
if (color != NONE || attr != A_NORMAL)
curses_toggle_color_attr(win, color, attr, ON);
}
if (color == NO_COLOR)
color = NONE;
attr = menu_item_ptr->attr;
attr = curses_convert_attr(attr);
if (color != NONE || attr != A_NORMAL)
curses_menu_color_attr(win, color, attr, ON);
num_lines = curses_num_lines(menu_item_ptr->str, entry_cols);
for (count = 0; count < num_lines; count++) {
@@ -1306,12 +1301,8 @@ menu_display_page(
}
}
if (color != NONE || attr != A_NORMAL) {
if (menu_color)
curses_menu_color_attr(win, color, attr, OFF);
else
curses_toggle_color_attr(win, color, attr, OFF);
curses_menu_color_attr(win, color, attr, OFF);
}
menu_item_ptr = menu_item_ptr->next_item;
}

View File

@@ -375,8 +375,10 @@ curs_show_invt(WINDOW *win)
for (lineno = pi.rowoffset; lineno < pi.inuseindx; ++lineno) {
str = pi.array[lineno].invtxt;
accelerator = pi.array[lineno].letter;
attr = pi.array[lineno].c_attr;
attr = curses_convert_attr(pi.array[lineno].c_attr);
color = pi.array[lineno].color;
if (color == NO_COLOR)
color = NONE;
if (accelerator)
++item_count;
@@ -413,17 +415,9 @@ curs_show_invt(WINDOW *win)
stroffset = pi_article_skip(str); /* to skip "a "/"an "/"the " */
/* if/when scrolled right, invtxt for item lines gets shifted */
stroffset += pi.coloffset;
/* only perform menu coloring on item entries, not subtitles */
if (iflags.use_menu_color) {
get_menu_coloring(str, &color, (int *) &attr);
attr = curses_convert_attr(attr);
}
}
if (stroffset < strlen(str)) {
if (color == NO_COLOR)
color = NONE;
curses_menu_color_attr(win, color, attr, ON);
wprintw(win, "%.*s", available_width, str + stroffset);
curses_menu_color_attr(win, color, attr, OFF);