Menucolors

From NetHackWiki
Jump to navigation Jump to search

A user has suggested improving this page or section as follows:

"Update info from original patch features to NetHack 3.6"

Menucolors is a feature in NetHack 3.6 and above that allows you to colorize individual rows on a menu based on what regular expressions match its text. You can color the inventory menu, the spellcasting menu, the enhance menu, the options menu, and more.

For example, you could color all blessed items bright cyan, all cursed items bright orange, and all uncursed items dim green. From there you could underline dangerous items (loadstone, wand of cancellation, etc.), make the Amulet of Yendor magenta, all gold yellow, and so on, until you're satisfied.

The menucolors can also support globbing instead of regular expressions; the resulting menucolors are far less powerful, but are more portable.

Details

The menucolors are applied top to bottom, and each successive match replaces the colors and attributes.

Unfortunately, there's a bug in that setting an attribute (bold, underline, etc) resets the color of a line, and vice versa. You can work around this by setting color&attribute, but that's not a very general solution.

For the purposes of regex matching, the menu accelerator and the hyphen separating it from the menu entry are considered part of the entry by the menucolors patch. However, patches to NAO during May and June of 2012 altered this behavior, and these features are no longer part of the entry. In other words, "q - a club" or "a - autodig" will match a club in your inventory or the autodig option in the options menu as long as you aren't playing on NAO. If you are playing on NAO, you would need to use "a club" and "autodig".

The regular expressions match against menu entry separately, so you are free to use the ^ and $ operators to match the beginning and the end of the entries.

Examples

For examples of extensive menucolors, see the .nethackrc files of Eidolos and itsblah. Here's an example nethackrc file that includes menucolors (which uses regular expressions, not globbing):

OPTIONS=color,menucolors

MENUCOLOR="blessed"=cyan&bold
MENUCOLOR="cursed"=orange&bold
MENUCOLOR="uncursed"=green

MENUCOLOR="loadstone\|wand \(of\|called\) cancellation"=underline
MENUCOLOR="Amulet of Yendor named"=magenta                           # color only the real Amulet
MENUCOLOR="gold piece"=yellow

MENUCOLOR="[a-zA-Z] - [a-zA-Z ]+[ ]+[0-9]+\*[ ]+[a-z]+[ ]+[0-9]+%"=magenta  # forgotten spell
# This version will work on NAO.
# MENUCOLOR="[a-zA-Z ]+[ ]+[0-9]+\*[ ]+[a-z]+[ ]+[0-9]+%"=magenta  # forgotten spell

and here is an example that uses globbing, that is, only ? and * wildcards.

OPTIONS=color,menucolors

MENUCOLOR="* cursed *"=red
MENUCOLOR="* unholy *"=red
MENUCOLOR="* blessed *"=green
MENUCOLOR="* holy *"=green

Valid color values

black
red
green
brown
blue
magenta
cyan
gray
orange
bright green
yellow
bright blue
bright magenta
bright cyan
white