From bb10f9a5d07cbc100fe6ac7f24ea0bc60a86586e Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 16 Nov 2023 13:41:07 -0500 Subject: [PATCH] more menu header tweaking re options off: map, menu items, menu headings, menu prompt/title all, everything should have color suppressed. on: map, menu items, menu headings, menu prompt/title can all feature color, as can menu borders, menu-selector letters. off: map, menu headings, menu prompt and menu items (menucolors on) can still feature color, but all other non-map features such as menu borders, menu-selector letters will not have color. on: menu items can have colors if they match one of the regex in config file; menu headings, menu prompt can also be in color (based on menu_headings option). off: menu items won't have colors, but menu headings, menu prompt still will feature colors (based on menu_headings option); those are not impacted by turning off menucolors. --- include/decl.h | 1 + src/decl.c | 1 + src/options.c | 7 +++++++ src/windows.c | 8 ++++++-- win/curses/cursdial.c | 4 ++-- win/curses/cursmisc.c | 3 ++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/decl.h b/include/decl.h index dba448c71..96a0ce9c7 100644 --- a/include/decl.h +++ b/include/decl.h @@ -721,6 +721,7 @@ struct instance_globals_o { boolean opt_from_file; boolean opt_need_redraw; /* for doset() */ boolean opt_need_glyph_reset; + boolean opt_need_promptstyle; /* pickup.c */ int oldcap; /* last encumberance */ diff --git a/src/decl.c b/src/decl.c index 9a949f9bc..c47879468 100644 --- a/src/decl.c +++ b/src/decl.c @@ -628,6 +628,7 @@ const struct instance_globals_o g_init_o = { FALSE, /* opt_from_file */ FALSE, /* opt_need_redraw */ FALSE, /* opt_need_glyph_reset */ + FALSE, /* opt_need_promptstyle */ /* pickup.c */ 0, /* oldcap */ /* restore.c */ diff --git a/src/options.c b/src/options.c index dba81eaea..479fe24dd 100644 --- a/src/options.c +++ b/src/options.c @@ -5071,10 +5071,12 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) #endif go.opt_need_redraw = TRUE; go.opt_need_glyph_reset = TRUE; + go.opt_need_promptstyle = TRUE; break; case opt_menucolors: case opt_guicolor: update_inventory(); + go.opt_need_promptstyle = TRUE; break; case opt_mention_decor: iflags.prev_decor = STONE; @@ -8693,6 +8695,8 @@ doset_simple(void) docrt(); flush_screen(1); } + if (go.opt_need_promptstyle) + adjust_menu_promptstyle(WIN_INVEN, &iflags.menu_headings); if (gc.context.botl || gc.context.botlx) { bot(); } @@ -8943,6 +8947,9 @@ doset(void) /* changing options via menu by Per Liboriussen */ reglyph_darkroom(); docrt(); } + if (go.opt_need_promptstyle) { + adjust_menu_promptstyle(WIN_INVEN, &iflags.menu_headings); + } if (gc.context.botl || gc.context.botlx) { bot(); } diff --git a/src/windows.c b/src/windows.c index f9ab36221..42a533367 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1602,10 +1602,12 @@ void adjust_menu_promptstyle(winid window, color_attr *style) { win_request_info wri = zerowri; - wri.fromcore.menu_promptstyle.color = style->color; + wri.fromcore.menu_promptstyle.color = + (iflags.wc_color) ? style->color : NO_COLOR; wri.fromcore.menu_promptstyle.attr = style->attr; /* relay the style change to the window port */ (void) ctrl_nhwindow(window, set_menu_promptstyle, &wri); + go.opt_need_promptstyle = FALSE; } /* @@ -1626,13 +1628,15 @@ add_menu( const char *str, /* menu text */ unsigned int itemflags) /* itemflags such as MENU_ITEMFLAGS_SELECTED */ { - if (iflags.use_menu_color) { + if (iflags.wc_color && iflags.use_menu_color) { if ((itemflags & MENU_ITEMFLAGS_SKIPMENUCOLORS) == 0) (void) get_menu_coloring(str, &color, &attr); } /* this is the only function that cared about this flag; remove it now */ itemflags &= ~MENU_ITEMFLAGS_SKIPMENUCOLORS; + if (!iflags.wc_color) + color = NO_COLOR; (*windowprocs.win_add_menu)(window, glyphinfo, identifier, ch, gch, attr, color, str, itemflags); } diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 2b558112a..62532df6f 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -1209,10 +1209,10 @@ menu_display_page( for (count = 0; count < num_lines; count++) { tmpstr = curses_break_str(menu->prompt, menu->width, count + 1); - curses_toggle_color_attr(win, curses_menu_promptstyle.color, + curses_menu_color_attr(win, curses_menu_promptstyle.color, curses_menu_promptstyle.attr, ON); mvwprintw(win, count + 1, 1, "%s", tmpstr); - curses_toggle_color_attr(win, curses_menu_promptstyle.color, + curses_menu_color_attr(win, curses_menu_promptstyle.color, curses_menu_promptstyle.attr, OFF); free(tmpstr); } diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 18536d08c..b350ea6da 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -169,7 +169,8 @@ curses_menu_color_attr(WINDOW *win, int color, int attr, int onoff) /* curses_toggle_color_attr() uses 'guicolor' to decide whether to honor specified color, but menu windows have their own more-specific control, 'menucolors', so override with that here */ - iflags.wc2_guicolor = iflags.use_menu_color; +/* iflags.wc2_guicolor = iflags.use_menu_color; */ + iflags.wc2_guicolor = (color != NONE); curses_toggle_color_attr(win, color, attr, onoff); iflags.wc2_guicolor = save_guicolor; }