curses menu coloring
Have the 'menucolors' option control menu color pattern matching (instead of curses-specific 'guicolor') for all menus, not just for the persistent inventory window.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.106 $ $NHDT-Date: 1567273590 2019/08/31 17:46:30 $
|
||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.107 $ $NHDT-Date: 1567302620 2019/09/01 01:50:20 $
|
||||
|
||||
This fixes36.3 file is here to capture information about updates in the 3.6.x
|
||||
lineage following the release of 3.6.2 in May 2019. Please note, however,
|
||||
@@ -219,6 +219,8 @@ curses: disable the attempt to support Ctrl+Left_click as an alternate way
|
||||
to generate Right_click for systems with one-button mouse or trackpad;
|
||||
the mouse data passed to nethack didn't match the curses (ncurses on
|
||||
OSX 10.11) documentation and things didn't work as intended
|
||||
curses: menu coloring required that both 'menucolors' and 'guicolor' be On;
|
||||
for menus, override guicolor with more-specific menucolors
|
||||
curses+'perm_invent': entries were wrapping without any control; usually not
|
||||
noticeable because next entry overwrote, but visible for final entry
|
||||
when whole inventory fit within the available height; looked ok with
|
||||
@@ -232,8 +234,6 @@ curses+'perm_invent': don't highlight inventory letters since nothing is
|
||||
curses+'perm_invent': could crash during restore if game was saved while
|
||||
hero was swallowed (invalid u.ustuck pointer; suppressing attempts to
|
||||
update persistent inventory window during restore hides the problem)
|
||||
curses+'perm_invent': menu coloring required that both 'menucolors' and
|
||||
'guicolor' be On; override guicolor with more-specific menucolors
|
||||
curses+'popup_dialog': show the text cursor at the end of prompts for single
|
||||
character input
|
||||
curses+DUMPLOG: pass along old messages from save file and quest message
|
||||
|
||||
@@ -143,6 +143,7 @@ extern boolean curses_map_borders(int *sx, int *sy, int *ex, int *ey,
|
||||
extern int curses_read_char(void);
|
||||
extern void curses_toggle_color_attr(WINDOW *win, int color, int attr,
|
||||
int onoff);
|
||||
extern void curses_menu_color_attr(WINDOW *, int, int, int);
|
||||
extern void curses_bail(const char *mesg);
|
||||
extern winid curses_get_wid(int type);
|
||||
extern char *curses_copy_of(const char *s);
|
||||
|
||||
@@ -1185,21 +1185,20 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num, char *selectors)
|
||||
start_col += 2;
|
||||
}
|
||||
#endif
|
||||
if (iflags.use_menu_color
|
||||
&& (menu_color = get_menu_coloring(menu_item_ptr->str,
|
||||
&color, &attr)) != 0) {
|
||||
if (color != NO_COLOR) {
|
||||
curses_toggle_color_attr(win, color, NONE, ON);
|
||||
}
|
||||
color = NO_COLOR;
|
||||
menu_color = iflags.use_menu_color
|
||||
&& get_menu_coloring(menu_item_ptr->str, &color, &attr);
|
||||
if (menu_color) {
|
||||
attr = curses_convert_attr(attr);
|
||||
if (attr != A_NORMAL) {
|
||||
menu_item_ptr->attr = menu_item_ptr->attr | attr;
|
||||
}
|
||||
if (color != NO_COLOR || attr != A_NORMAL)
|
||||
curses_menu_color_attr(win, color, attr, ON);
|
||||
} else {
|
||||
attr = menu_item_ptr->attr;
|
||||
if (color != NO_COLOR || attr != A_NORMAL)
|
||||
curses_toggle_color_attr(win, color, attr, ON);
|
||||
}
|
||||
curses_toggle_color_attr(win, NONE, menu_item_ptr->attr, ON);
|
||||
|
||||
num_lines = curses_num_lines(menu_item_ptr->str, entry_cols);
|
||||
|
||||
for (count = 0; count < num_lines; count++) {
|
||||
if (menu_item_ptr->str && *menu_item_ptr->str) {
|
||||
tmpstr = curses_break_str(menu_item_ptr->str,
|
||||
@@ -1209,10 +1208,13 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num, char *selectors)
|
||||
free(tmpstr);
|
||||
}
|
||||
}
|
||||
if (menu_color && (color != NO_COLOR)) {
|
||||
curses_toggle_color_attr(win, color, NONE, OFF);
|
||||
if (color != NO_COLOR || attr != A_NORMAL) {
|
||||
if (menu_color)
|
||||
curses_menu_color_attr(win, color, attr, OFF);
|
||||
else
|
||||
curses_toggle_color_attr(win, color, attr, OFF);
|
||||
}
|
||||
curses_toggle_color_attr(win, NONE, menu_item_ptr->attr, OFF);
|
||||
|
||||
menu_item_ptr = menu_item_ptr->next_item;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ curses_add_inv(int y,
|
||||
CHAR_P accelerator, attr_t attr, const char *str)
|
||||
{
|
||||
WINDOW *win = curses_get_nhwin(INV_WIN);
|
||||
boolean save_guicolor;
|
||||
int color = NO_COLOR;
|
||||
int x = 0, width, height, available_width, stroffset = 0,
|
||||
border = curses_window_has_border(INV_WIN) ? 1 : 0;
|
||||
@@ -142,16 +141,8 @@ curses_add_inv(int y,
|
||||
}
|
||||
if (color == NO_COLOR)
|
||||
color = NONE;
|
||||
/* curses_toggle_color_attr() uses 'guicolor' to decide whether to
|
||||
honor specified color, but persistent inventory window has its own
|
||||
more-specific control, 'menucolors', so override with that here */
|
||||
save_guicolor = iflags.wc2_guicolor;
|
||||
iflags.wc2_guicolor = iflags.use_menu_color;
|
||||
curses_toggle_color_attr(win, color, attr, ON);
|
||||
/* wattron(win, attr); */
|
||||
curses_menu_color_attr(win, color, attr, ON);
|
||||
wprintw(win, "%.*s", available_width, str + stroffset);
|
||||
/* wattroff(win, attr); */
|
||||
curses_toggle_color_attr(win, color, attr, OFF);
|
||||
iflags.wc2_guicolor = save_guicolor;
|
||||
curses_menu_color_attr(win, color, attr, OFF);
|
||||
wclrtoeol(win);
|
||||
}
|
||||
|
||||
@@ -163,6 +163,22 @@ curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff)
|
||||
#endif /* TEXTCOLOR */
|
||||
}
|
||||
|
||||
/* call curses_toggle_color_attr() with 'menucolors' instead of 'guicolor'
|
||||
as the control flag */
|
||||
|
||||
void
|
||||
curses_menu_color_attr(WINDOW *win, int color, int attr, int onoff)
|
||||
{
|
||||
boolean save_guicolor = iflags.wc2_guicolor;
|
||||
|
||||
/* 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;
|
||||
curses_toggle_color_attr(win, color, attr, onoff);
|
||||
iflags.wc2_guicolor = save_guicolor;
|
||||
}
|
||||
|
||||
|
||||
/* clean up and quit - taken from tty port */
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
/* Global declarations */
|
||||
|
||||
int curses_read_char(void);
|
||||
void curses_toggle_color_attr(WINDOW * win, int color, int attr, int onoff);
|
||||
void curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff);
|
||||
void curses_menu_color_attr(WINDOW *win, int color, int attr, int onoff);
|
||||
void curses_bail(const char *mesg);
|
||||
winid curses_get_wid(int type);
|
||||
char *curses_copy_of(const char *s);
|
||||
|
||||
Reference in New Issue
Block a user