fix #H9164 - menu colors for curses perm_invent
Commit e3af33c9db in June changed
curses handling for perm_invent to strip off doname()'s "a ", "an ",
or "the " prefix in order to shorten inventory entries and get a
couple of significant extra characters before end-of-line truncation.
That had an unintended impact on menu colors pattern matching for
patterns which expected the article prefix. Do the matching before
stripping off the prefix instead of after so that the matching gives
the same results as when used on a normal inventory menu (even though
this means that from the user's perspective most perm_invent entries
will have invisible text at the start).
Also for menu colors, don't require curses-specific 'guicolor' option
be enabled when the general, more-specific 'menucolors' option exists
to control menu coloring. (curses was requiring that both be True.)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.105 $ $NHDT-Date: 1567240693 2019/08/31 08:38:13 $
|
||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.106 $ $NHDT-Date: 1567273590 2019/08/31 17:46:30 $
|
||||
|
||||
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,
|
||||
@@ -155,6 +155,10 @@ curses: sometimes the message window would show a blank line after a prompt
|
||||
curses: the change to show map in columns 1..79 instead of 2..80 made the
|
||||
highlight for '@' show up in the wrong place if clipped map had been
|
||||
panned horizontally
|
||||
curses+'perm_invent': menu coloring patterns which match ordinary inventory
|
||||
menu might fail to match persistent inventory window because leading
|
||||
article and space ("a ", "an ", "the ") is stripped off for brevity;
|
||||
perform the pattern matching tests before stripping doname() prefix
|
||||
tty: revert the attempt to fix "message line anomaly: if autodecribe feedback
|
||||
wrapped to second line, the wrapped portion wasn't erased when a
|
||||
shorter line was shown or getpos was dismissed" because it disrupted
|
||||
@@ -228,6 +232,8 @@ 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
|
||||
|
||||
@@ -60,8 +60,9 @@ 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,
|
||||
int x = 0, width, height, available_width, stroffset = 0,
|
||||
border = curses_window_has_border(INV_WIN) ? 1 : 0;
|
||||
|
||||
/* Figure out where to draw the line */
|
||||
@@ -101,19 +102,22 @@ curses_add_inv(int y,
|
||||
persistent inventory window so don't highlight inventory letters */
|
||||
wprintw(win, "%c) ", accelerator);
|
||||
#endif
|
||||
available_width -= 3;
|
||||
available_width -= 3; /* letter+parenthesis+space */
|
||||
|
||||
/* narrow the entries to fit more of the interesting text; do so
|
||||
unconditionally rather than trying to figure whether it's needed;
|
||||
when 'sortpack' is enabled we could also strip out "<class> of"
|
||||
from "<prefix><class> of <item><suffix> but if that's to be done,
|
||||
core ought to do it */
|
||||
core ought to do it;
|
||||
'stroffset': defer skipping the article prefix until after menu
|
||||
color pattern matching has taken place so that the persistent
|
||||
inventory window always gets same coloring as regular inventory */
|
||||
if (!strncmpi(str, "a ", 2))
|
||||
str += 2;
|
||||
stroffset = 2;
|
||||
else if (!strncmpi(str, "an ", 3))
|
||||
str += 3;
|
||||
stroffset = 3;
|
||||
else if (!strncmpi(str, "the ", 4))
|
||||
str +=4;
|
||||
stroffset = 4;
|
||||
}
|
||||
#if 0 /* FIXME: MENU GLYPHS */
|
||||
if (accelerator && glyph != NO_GLYPH && iflags.use_menu_glyphs) {
|
||||
@@ -138,10 +142,16 @@ 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); */
|
||||
wprintw(win, "%.*s", available_width, str);
|
||||
wprintw(win, "%.*s", available_width, str + stroffset);
|
||||
/* wattroff(win, attr); */
|
||||
curses_toggle_color_attr(win, color, attr, OFF);
|
||||
iflags.wc2_guicolor = save_guicolor;
|
||||
wclrtoeol(win);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user