curses: hilite_pet, hilite_pile without color

The curses interface was ignoring video attributes (bold, inverse, &c)
when color is toggled off or if built with TEXTCOLOR disabled.  Honor
attributes regardless of whether color is displayed.

Also, toggling 'hilite_pet' On during play wouldn't do anything if the
curses-specific 'petattr' option had been left as None.  (It worked as
intended if set in starting options.)
This commit is contained in:
PatR
2019-03-13 16:50:56 -07:00
parent 62a34040bd
commit ccd6d1407e
6 changed files with 36 additions and 18 deletions

View File

@@ -358,8 +358,7 @@ putstr(window, attr, str)
-- Print str on the window with the given attribute. Only
printable ASCII characters (040-0126) must be supported.
Multiple putstr()s are output on separate lines.
Attributes
can be one of
Attributes can be one of
ATR_NONE (or 0)
ATR_ULINE
ATR_BOLD
@@ -616,7 +615,10 @@ curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph,
} else
*/
if ((special & MG_OBJPILE) && iflags.hilite_pile) {
color = 16 + (color * 2) + 1;
if (iflags.wc_color)
color = 16 + (color * 2) + 1;
else
attr = A_REVERSE;
}
}

View File

@@ -81,19 +81,22 @@ curses_read_char()
/* Turn on or off the specified color and / or attribute */
void
curses_toggle_color_attr(WINDOW * win, int color, int attr, int onoff)
curses_toggle_color_attr(WINDOW *win, int color, int attr, int onoff)
{
#ifdef TEXTCOLOR
int curses_color;
/* Map color disabled */
if ((!iflags.wc_color) && (win == mapwin)) {
return;
}
/* GUI color disabled */
if ((!iflags.wc2_guicolor) && (win != mapwin)) {
/* if color is disabled, just show attribute */
if ((win == mapwin) ? !iflags.wc_color : !iflags.wc2_guicolor) {
#endif
if (attr != NONE) {
if (onoff == ON)
wattron(win, attr);
else
wattroff(win, attr);
}
return;
#ifdef TEXTCOLOR
}
if (color == 0) { /* make black fg visible */
@@ -149,6 +152,8 @@ curses_toggle_color_attr(WINDOW * win, int color, int attr, int onoff)
wattroff(win, attr);
}
}
#else
nhUse(color);
#endif /* TEXTCOLOR */
}
@@ -685,7 +690,7 @@ curses_convert_attr(int attr)
success (might be 0), or -1 if not found. */
int
curses_read_attrs(char *attrs)
curses_read_attrs(const char *attrs)
{
int retattr = 0;

View File

@@ -26,7 +26,7 @@ void curses_view_file(const char *filename, boolean must_exist);
void curses_rtrim(char *str);
int curses_get_count(int first_digit);
int curses_convert_attr(int attr);
int curses_read_attrs(char *attrs);
int curses_read_attrs(const char *attrs);
char *curses_fmt_attrs(char *);
int curses_convert_keys(int key);
int curses_get_mouse(int *mousex, int *mousey, int *mod);