curses status highlighting

window.doc states that the colormasks argument to status_update() is
only relevant for BL_CONDITION, but curses was relying on it to be
passed for BL_FLUSH as well.  Yesterday's changes stopped the latter
and broke highlighting of status conditions.  Other interfaces appear
to honor the description in window.doc.
This commit is contained in:
PatR
2019-03-31 07:04:23 -07:00
parent c63d3fbfbb
commit c8fdb040cb
2 changed files with 27 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.291 $ $NHDT-Date: 1554017610 2019/03/31 07:33:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.292 $ $NHDT-Date: 1554041056 2019/03/31 14:04:16 $
This fixes36.2 file is here to capture information about updates in the 3.6.x This fixes36.2 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.1 in April 2018. Please note, however, lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -527,6 +527,8 @@ curses: popup window to show ^P output was removed from screen but never
deleted; further ^P's repeated that cycle; likewise for help which deleted; further ^P's repeated that cycle; likewise for help which
displays an external text file displays an external text file
curses: preserve ^P message history across save/restore curses: preserve ^P message history across save/restore
curses: highlighting of status conditions was broken by the fix for timing out
of temporary highlights setting off unnecessary status updates
vms: add compile of isaac64.c to Makefile.src and vmsbuild.com vms: add compile of isaac64.c to Makefile.src and vmsbuild.com
vms+curses: add compile support but it is known to fail to build vms+curses: add compile support but it is known to fail to build

View File

@@ -25,6 +25,7 @@ extern boolean status_activefields[MAXBLSTATS];
static char *status_vals_long[MAXBLSTATS]; static char *status_vals_long[MAXBLSTATS];
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
static unsigned long *curses_colormasks;
static long curses_condition_bits; static long curses_condition_bits;
static int curses_status_colors[MAXBLSTATS]; static int curses_status_colors[MAXBLSTATS];
static int hpbar_percent, hpbar_color; static int hpbar_percent, hpbar_color;
@@ -36,12 +37,11 @@ static int FDECL(condcolor, (long, unsigned long *));
static int FDECL(condattr, (long, unsigned long *)); static int FDECL(condattr, (long, unsigned long *));
static int FDECL(nhattr2curses, (int)); static int FDECL(nhattr2curses, (int));
#endif /* STATUS_HILITES */ #endif /* STATUS_HILITES */
static void FDECL(draw_status, (unsigned long *)); static void NDECL(draw_status);
static void FDECL(draw_vertical, (BOOLEAN_P, unsigned long *)); static void FDECL(draw_vertical, (BOOLEAN_P));
static void FDECL(draw_horizontal, (BOOLEAN_P, unsigned long *)); static void FDECL(draw_horizontal, (BOOLEAN_P));
static void curs_HPbar(char *, int); static void curs_HPbar(char *, int);
static void curs_stat_conds(int, int *, int *, unsigned long *, static void curs_stat_conds(int, int *, int *, char *, boolean *);
char *, boolean *);
static void curs_vert_status_vals(int); static void curs_vert_status_vals(int);
/* width of a single line in vertical status orientation (one field per line; /* width of a single line in vertical status orientation (one field per line;
@@ -162,6 +162,7 @@ unsigned long *colormasks;
return; return;
if (fldidx == BL_CONDITION) { if (fldidx == BL_CONDITION) {
curses_condition_bits = *condptr; curses_condition_bits = *condptr;
curses_colormasks = colormasks;
} else { } else {
#ifndef TEXTCOLOR #ifndef TEXTCOLOR
color_and_attr = (color_and_attr & ~0x00FF) | NO_COLOR; color_and_attr = (color_and_attr & ~0x00FF) | NO_COLOR;
@@ -204,19 +205,13 @@ unsigned long *colormasks;
} }
} }
} else { /* BL_FLUSH */ } else { /* BL_FLUSH */
if (!changed_fields && !context.botlx) { draw_status();
; /* TODO: this isn't impossible but we want to track
* down the circumstances where it happens in order to
* minimize occurrences */
}
draw_status(colormasks);
changed_fields = 0; changed_fields = 0;
} }
} }
void static void
draw_status(colormasks) draw_status()
unsigned long *colormasks;
{ {
WINDOW *win = curses_get_nhwin(STATUS_WIN); WINDOW *win = curses_get_nhwin(STATUS_WIN);
int orient = curses_get_window_orientation(STATUS_WIN); int orient = curses_get_window_orientation(STATUS_WIN);
@@ -242,9 +237,9 @@ unsigned long *colormasks;
werase(win); werase(win);
if (horiz) if (horiz)
draw_horizontal(border, colormasks); draw_horizontal(border);
else else
draw_vertical(border, colormasks); draw_vertical(border);
if (border) if (border)
box(win, 0, 0); box(win, 0, 0);
@@ -252,10 +247,9 @@ unsigned long *colormasks;
} }
/* horizontal layout on 2 or 3 lines */ /* horizontal layout on 2 or 3 lines */
void static void
draw_horizontal(border, colormasks) draw_horizontal(border)
boolean border; boolean border;
unsigned long *colormasks;
{ {
#define blPAD BL_FLUSH #define blPAD BL_FLUSH
/* almost all fields already come with a leading space; /* almost all fields already come with a leading space;
@@ -343,7 +337,7 @@ unsigned long *colormasks;
/* collect active conditions in cbuf[], space separated, suitable /* collect active conditions in cbuf[], space separated, suitable
for direct output if no highlighting is requested ('asis') but for direct output if no highlighting is requested ('asis') but
primarily used to measure the length */ primarily used to measure the length */
curs_stat_conds(0, &x, &y, colormasks, cbuf, &asis); curs_stat_conds(0, &x, &y, cbuf, &asis);
clen = (int) strlen(cbuf); clen = (int) strlen(cbuf);
cap_and_hunger = 0; cap_and_hunger = 0;
@@ -640,8 +634,7 @@ unsigned long *colormasks;
if (asis) if (asis)
waddstr(win, cbuf); waddstr(win, cbuf);
else /* cond by cond if any cond specifies highlighting */ else /* cond by cond if any cond specifies highlighting */
curs_stat_conds(0, &x, &y, colormasks, curs_stat_conds(0, &x, &y, (char *) 0, (boolean *) 0);
(char *) 0, (boolean *) 0);
} /* curses_condition_bits */ } /* curses_condition_bits */
} /* hitpointbar vs regular field vs conditions */ } /* hitpointbar vs regular field vs conditions */
} /* i (fld) */ } /* i (fld) */
@@ -651,10 +644,9 @@ unsigned long *colormasks;
} }
/* vertical layout, to left or right of map */ /* vertical layout, to left or right of map */
void static void
draw_vertical(border, colormasks) draw_vertical(border)
boolean border; boolean border;
unsigned long *colormasks;
{ {
/* for blank lines, the digit prefix is the order in which they get /* for blank lines, the digit prefix is the order in which they get
removed if we need to shrink to fit within height limit (very rare) */ removed if we need to shrink to fit within height limit (very rare) */
@@ -893,8 +885,7 @@ unsigned long *colormasks;
if (cond_count) { if (cond_count) {
/* output active conditions, three per line; /* output active conditions, three per line;
cursor is already positioned where they should start */ cursor is already positioned where they should start */
curs_stat_conds(1, &x, &y, colormasks, curs_stat_conds(1, &x, &y, (char *) 0, (boolean *) 0);
(char *) 0, (boolean *) 0);
} }
} /* hitpointbar vs regular field vs conditions */ } /* hitpointbar vs regular field vs conditions */
} /* fld loop */ } /* fld loop */
@@ -971,7 +962,6 @@ extern const struct condmap valid_conditions[]; /* botl.c */
static void static void
curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
int *x, int *y, /* real for vertical, ignored otherwise */ int *x, int *y, /* real for vertical, ignored otherwise */
unsigned long *colormasks, /* input */
char *condbuf, /* optional output; collect string of conds */ char *condbuf, /* optional output; collect string of conds */
boolean *nohilite) /* optional output; indicates whether -*/ boolean *nohilite) /* optional output; indicates whether -*/
{ /*+ condbuf[] could be used as-is */ { /*+ condbuf[] could be used as-is */
@@ -994,8 +984,8 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
Strcpy(condnam, valid_conditions[i].id); Strcpy(condnam, valid_conditions[i].id);
Strcat(strcat(condbuf, " "), upstart(condnam)); Strcat(strcat(condbuf, " "), upstart(condnam));
if (nohilite && *nohilite if (nohilite && *nohilite
&& (condcolor(bitmsk, colormasks) != NO_COLOR && (condcolor(bitmsk, curses_colormasks) != NO_COLOR
|| condattr(bitmsk, colormasks) != 0)) || condattr(bitmsk, curses_colormasks) != 0))
*nohilite = FALSE; *nohilite = FALSE;
} }
} }
@@ -1034,12 +1024,14 @@ curs_stat_conds(int vert_cond, /* 0 => horizontal, 1 => vertical */
if (!do_vert || (vert_cond % 3) != 1) if (!do_vert || (vert_cond % 3) != 1)
waddch(win, ' '); waddch(win, ' ');
if (iflags.hilite_delta) { if (iflags.hilite_delta) {
if ((attrmask = condattr(bitmsk, colormasks)) != 0) { if ((attrmask = condattr(bitmsk, curses_colormasks))
!= 0) {
attrmask = nhattr2curses(attrmask); attrmask = nhattr2curses(attrmask);
wattron(win, attrmask); wattron(win, attrmask);
} }
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
if ((color = condcolor(bitmsk, colormasks)) != NO_COLOR) if ((color = condcolor(bitmsk, curses_colormasks))
!= NO_COLOR)
curses_toggle_color_attr(win, color, NONE, ON); curses_toggle_color_attr(win, color, NONE, ON);
#endif #endif
} }