[Pkg-nethack-devel] nethack/debian/patches 90_enh_hpmon.dpatch,NONE,1.1 91_enh_menucolors.dpatch,NONE,1.1 00list,1.4,1.5

Joshua Kwan joshk-guest@quantz.debian.org
Mon, 13 Oct 2003 01:05:54 +0000


Update of /cvsroot/pkg-nethack/nethack/debian/patches
In directory quantz:/tmp/cvs-serv22609/debian/patches

Modified Files:
	00list 
Added Files:
	90_enh_hpmon.dpatch 91_enh_menucolors.dpatch 
Log Message:
Add menucolors and hpmon patches, non-intrusive to bones/save files, and
disabled as options _by default_. Add reasonable defaults for debian
nethackrcs.


Index: 00list
===================================================================
RCS file: /cvsroot/pkg-nethack/nethack/debian/patches/00list,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- 00list	12 Oct 2003 06:41:17 -0000	1.4
+++ 00list	13 Oct 2003 01:05:52 -0000	1.5
@@ -10,3 +10,5 @@
 12_lisp_windowing
 13_qt_warning_fixes
 14_common_config
+90_enh_hpmon
+91_enh_menucolors

--- NEW FILE: 90_enh_hpmon.dpatch ---
#! /bin/sh -e
## 90_enh_hpmon.dpatch by Joshua Kwan <joshk@triplehelix.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Enables color HP monitor for textmode NetHack.

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1;;
esac

exit 0

--- nh342orig/src/botl.c	2003-08-30 03:07:27.000000000 +0300
+++ nh342hpmon/src/botl.c	2003-09-05 18:17:09.000000000 +0300
@@ -248,6 +248,9 @@
 	char  newbot2[MAXCO];
 	register char *nb;
 	int hp, hpmax;
+#ifdef HPMON
+	int hpcolor, hpattr;
+#endif
 	int cap = near_capacity();
 
 	hp = Upolyd ? u.mh : u.uhp;
@@ -256,6 +259,15 @@
 	if(hp < 0) hp = 0;
 	(void) describe_level(newbot2);
 	Sprintf(nb = eos(newbot2),
+#ifdef HPMON
+		"%c:%-2ld HP:", oc_syms[COIN_CLASS],
+#ifndef GOLDOBJ
+		u.ugold
+#else
+		money_cnt(invent)
+#endif
+		);
+#else /* HPMON */
 		"%c:%-2ld HP:%d(%d) Pw:%d(%d) AC:%-2d", oc_syms[COIN_CLASS],
 #ifndef GOLDOBJ
 		u.ugold,
@@ -263,6 +275,39 @@
 		money_cnt(invent),
 #endif
 		hp, hpmax, u.uen, u.uenmax, u.uac);
+#endif /* HPMON */
+#ifdef HPMON
+	curs(WIN_STATUS, 1, 1);
+	putstr(WIN_STATUS, 0, newbot2);
+
+	Sprintf(nb = eos(newbot2), "%d(%d)", hp, hpmax);
+#if defined(TEXTCOLOR) && !defined(LISP_GRAPHICS)
+	if (iflags.use_color && iflags.use_hpmon) {
+	  curs(WIN_STATUS, 1, 1);
+	  hpattr = ATR_NONE;
+	  if(hp == hpmax){
+	    hpcolor = NO_COLOR;
+	  } else if(hp > (hpmax*2/3)) {
+	    hpcolor = CLR_GREEN;
+	  } else if(hp <= (hpmax/3)) {
+	    hpcolor = CLR_RED;
+	    if(hp<=(hpmax/10)) 
+	      hpattr = ATR_BLINK;
+	  } else {
+	    hpcolor = CLR_YELLOW;
+	  }
+	  if (hpcolor != NO_COLOR)
+	    term_start_color(hpcolor);
+	  if(hpattr!=ATR_NONE)term_start_attr(hpattr);
+	  putstr(WIN_STATUS, hpattr, newbot2);
+	  if(hpattr!=ATR_NONE)term_end_attr(hpattr);
+	  if (hpcolor != NO_COLOR)
+	    term_end_color();
+	}
+#endif /* TEXTCOLOR */
+	Sprintf(nb = eos(newbot2), " Pw:%d(%d) AC:%-2d",
+		u.uen, u.uenmax, u.uac);
+#endif /* HPMON */
 
 	if (Upolyd)
 		Sprintf(nb = eos(nb), " HD:%d", mons[u.umonnum].mlevel);
--- nethack/include/config.h~	2003-10-12 15:47:13.000000000 -0700
+++ nethack/include/config.h	2003-10-12 15:49:18.000000000 -0700
@@ -345,6 +345,9 @@
 
 #define EXP_ON_BOTL	/* Show experience on bottom line */
 #define PARANOID        /* Confirm hitting peaceful monsters */
+
+#define HPMON           /* Color HP monitor */
+
 /* #define SCORE_ON_BOTL */	/* added by Gary Erickson (erickson@ucivax) */
 
 /*
--- nethack/src/options.c~	2003-10-12 16:05:42.000000000 -0700
+++ nethack/src/options.c	2003-10-12 16:06:44.000000000 -0700
@@ -86,6 +86,9 @@
 #else
 	{"extmenu", (boolean *)0, FALSE, SET_IN_FILE},
 #endif
+#if defined(TEXTCOLOR) && defined(HPMON)
+        { "hpmon", &iflags.use_hpmon, FALSE, SET_IN_GAME},
+#endif
 #ifdef OPT_DISPMAP
 	{"fast_map", &flags.fast_map, TRUE, SET_IN_GAME},
 #else
--- nethack/include/flag.h~	2003-10-12 16:04:12.000000000 -0700
+++ nethack/include/flag.h	2003-10-12 16:05:17.000000000 -0700
@@ -217,6 +217,11 @@
 	boolean lan_mail;	/* mail is initialized */
 	boolean lan_mail_fetched; /* mail is awaiting display */
 #endif
+
+#if defined(HPMON) && defined(TEXTCOLOR)
+        boolean use_hpmon;
+#endif
+
 /*
  * Window capability support.
  */
--- nethack/dat/opthelp~	2003-10-12 16:16:39.000000000 -0700
+++ nethack/dat/opthelp	2003-10-12 16:16:09.000000000 -0700
@@ -71,6 +71,9 @@
 color      use different colors for objects on screen   [TRUE for micros]
 hilite_pet display pets in a highlighted manner                   [FALSE]
 
+Boolean option if HPMON was set at compile time:
+hpmon      color HP readout depending on how low it is            [FALSE]
+
 Boolean option if TIMED_DELAY was set at compile time (tty interface only):
 timed_delay    on unix and VMS, use a timer instead of sending
                extra screen output when attempting to pause for
--- nethack/doc/Guidebook.txt~	2003-10-12 16:10:21.000000000 -0700
+++ nethack/doc/Guidebook.txt	2003-10-12 16:14:39.000000000 -0700
@@ -2338,6 +2338,11 @@
                Name  your starting horse (ex. ``horsename:Trigger'').  Can-
                not be set with the `O' command.
 
+          hpmon
+               Colors your hitpoint reading green when you attain <= 2/3  of
+               your total HP, yellow when you reach <= 1/3 of total, and red
+               when you are at or below 1/10 of your total HP.
+               
           IBMgraphics
                Use a predefined selection of IBM extended ASCII  characters
                to  display  the  dungeon/effects/traps instead of having to
--- nethack/doc/Guidebook.mn~	2003-10-12 16:10:32.000000000 -0700
+++ nethack/doc/Guidebook.mn	2003-10-12 16:15:11.000000000 -0700
@@ -1800,6 +1800,10 @@
 .lp horsename
 Name your starting horse (ex. ``horsename:Trigger'').
 Cannot be set with the `O' command.
+.lp hpmon
+Colors your HP reading green when you attain <= 2/3 of your total HP,
+yellow when you reach <= 1/3 of total, and red when you are at or below
+1/10 of your total HP.
 .lp IBMgraphics
 Use a predefined selection of IBM extended ASCII characters to display the
 dungeon/effects/traps instead of having to define a full graphics set
--- nethack/doc/Guidebook.tex~	2003-10-12 16:10:38.000000000 -0700
+++ nethack/doc/Guidebook.tex	2003-10-12 16:15:28.000000000 -0700
@@ -2229,6 +2229,11 @@
 Name your starting horse (ex.\ ``{\tt horsename:Trigger}'').
 Cannot be set with the `{\tt O}' command.
 %.lp
+\item[\ib{hpmon}]
+Colors your HP reading green when you attain <= 2/3 of your total HP,
+yellow when you reach <= 1/3 of total, and red when you are at or below
+1/10 of your total HP.
+%.lp
 \item[\ib{IBMgraphics}]
 Use a predefined selection of IBM extended ASCII characters to display the
 dungeon/effects/traps instead of having to define a full graphics set

--- NEW FILE: 91_enh_menucolors.dpatch ---
#! /bin/sh -e
## 91_enh_menucolors.dpatch by Joshua Kwan <joshk@triplehelix.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Pasi Kallinen's patch to add colors to inventory items.

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1;;
esac

exit 0

diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/dat/opthelp nethack-3.4.2-menucolor/dat/opthelp
--- nethack-3.4.2-orig/dat/opthelp	2003-08-30 03:07:07.000000000 +0300
+++ nethack-3.4.2-menucolor/dat/opthelp	2003-09-04 21:06:26.000000000 +0300
@@ -71,6 +71,9 @@
 color      use different colors for objects on screen   [TRUE for micros]
 hilite_pet display pets in a highlighted manner                   [FALSE]
 
+Boolean option if TEXTCOLOR and MENU_COLOR were set at compile time:
+menucolors use different colors for menus               [TRUE for micros]
+
 Boolean option if TIMED_DELAY was set at compile time (tty interface only):
 timed_delay    on unix and VMS, use a timer instead of sending
                extra screen output when attempting to pause for
@@ -169,6 +172,21 @@
            still denote your gender using the "male" and "female"
            options, the "gender" option will take precedence.  [RANDOM]
 horsename  the name of your first horse  [NONE]
+menucolor  Set colors for menus. (menucolor:"regex_string"=color)
+           If boolean option ``menucolors'' is true, menus will be shown
+	   with different colors.
+	   For example, setting ``menucolor:" blessed "=green'' shows
+	   all lines in a menu with the text " blessed " in green.
+	   The string is matched using regular expressions.
+	   Valid values for the color are black, red, green, brown, blue,
+	   magenta, cyan, gray, orange, lightgreen, yellow, lightblue, 
+	   lightmagenta, lightcyan and white.
+	   You can define menucolor as many times as you wish; those
+	   defined later will take precedence.
+	   Instead of using this with OPTIONS, consider using 
+	   MENUCOLOR="regex_string"=color in the configuration file.
+	   Setting menucolor has effect only if TEXTCOLOR and MENU_COLOR
+	   were set at compile time.  [NONE]
 menu_*     create single character accelerators for menu commands.  Below
            is a list of all commands.  Each is followed by a list of window-
            ports that implement them:  'x' is X11, 't' is tty, 'g' is Gem,
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/include/color.h nethack-3.4.2-menucolor/include/color.h
--- nethack-3.4.2-orig/include/color.h	2003-08-30 03:07:15.000000000 +0300
+++ nethack-3.4.2-menucolor/include/color.h	2003-09-04 21:06:26.000000000 +0300
@@ -5,6 +5,12 @@
 #ifndef COLOR_H
 #define COLOR_H
 
+#ifdef MENU_COLOR
+# ifdef MENU_COLOR_REGEX
+#  include <regex.h>
+# endif  
+#endif
+
 /*
  * The color scheme used is tailored for an IBM PC.  It consists of the
  * standard 8 colors, folowed by their bright counterparts.  There are
@@ -49,4 +55,16 @@
 #define DRAGON_SILVER	CLR_BRIGHT_CYAN
 #define HI_ZAP		CLR_BRIGHT_BLUE
 
+#ifdef MENU_COLOR
+struct menucoloring {
+# ifdef MENU_COLOR_REGEX
+   struct re_pattern_buffer match;
+# else
+   char *match;
+# endif
+   int color, attr;
+   struct menucoloring *next;
+};
+#endif
+
 #endif /* COLOR_H */
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/include/config.h nethack-3.4.2-menucolor/include/config.h
--- nethack-3.4.2-orig/include/config.h	2003-08-30 03:07:15.000000000 +0300
+++ nethack-3.4.2-menucolor/include/config.h	2003-09-04 21:06:26.000000000 +0300
@@ -350,6 +350,14 @@
  * bugs left here.
  */
 
+#ifdef TTY_GRAPHICS
+# define MENU_COLOR
+# define MENU_COLOR_REGEX
+/* if MENU_COLOR_REGEX is defined, use regular expressions (GNU regex.h)
+ * otherwise use pmatch() to match menu color lines.
+ * pmatch() provides basic globbing: '*' and '?' wildcards.
+ */
+#endif
 /*#define GOLDOBJ */	/* Gold is kept on obj chains - Helge Hafting */
 
 /* End of Section 5 */
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/include/extern.h nethack-3.4.2-menucolor/include/extern.h
--- nethack-3.4.2-orig/include/extern.h	2003-08-30 03:07:17.000000000 +0300
+++ nethack-3.4.2-menucolor/include/extern.h	2003-09-04 21:06:26.000000000 +0300
@@ -1395,6 +1395,9 @@
 E void FDECL(set_wc_option_mod_status, (unsigned long, int));
 E void FDECL(set_wc2_option_mod_status, (unsigned long, int));
 E void FDECL(set_option_mod_status, (const char *,int));
+#ifdef MENU_COLOR
+E boolean FDECL(add_menu_coloring, (char *));
+#endif
 
 /* ### pager.c ### */
 
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/include/flag.h nethack-3.4.2-menucolor/include/flag.h
--- nethack-3.4.2-orig/include/flag.h	2003-08-30 03:07:17.000000000 +0300
+++ nethack-3.4.2-menucolor/include/flag.h	2003-09-04 21:06:26.000000000 +0300
@@ -181,6 +181,9 @@
 	char prevmsg_window;	/* type of old message window to use */
 	boolean  extmenu;	/* extended commands use menu interface */
 #endif
+#ifdef MENU_COLOR
+	boolean use_menu_color;	/* use color in menus; only if wc_color */
+#endif
 #ifdef MFLOPPY
 	boolean  checkspace;	/* check disk space before writing files */
 				/* (in iflags to allow restore after moving
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/README.menucolor nethack-3.4.2-menucolor/README.menucolor
--- nethack-3.4.2-orig/README.menucolor	1970-01-01 02:00:00.000000000 +0200
+++ nethack-3.4.2-menucolor/README.menucolor	2003-09-04 21:33:09.000000000 +0300
@@ -0,0 +1,92 @@
+
+   This is version 1.2 of the menucolors patch.
+
+   This patch allows the user to define in what color menus are shown.
+   For example, putting
+
+   OPTIONS=menucolors
+   MENUCOLOR=" blessed "=green
+   MENUCOLOR=" holy "=green
+   MENUCOLOR=" cursed "=red
+   MENUCOLOR=" unholy "=red
+   MENUCOLOR=" cursed .* (being worn)"=orange&underline
+
+   in the configuration file makes all known blessed items
+   show up in green, all cursed items show up in red and
+   all cursed worn items show up in orange and underlined
+   when viewing inventory.
+
+   If you do not have GNU regex.h, comment
+   #define MENU_COLOR_REGEX out from include/config.h
+   and replace the MENUCOLOR lines in your config file with these:
+
+   MENUCOLOR="* blessed *"=green
+   MENUCOLOR="* holy *"=green
+   MENUCOLOR="* cursed *"=red
+   MENUCOLOR="* unholy *"=red
+   MENUCOLOR="* cursed * (being worn)"=orange&underline
+
+
+   Colors: black, red, green, brown, blue, magenta, cyan, gray, orange,
+           lightgreen, yellow, lightblue, lightmagenta, lightcyan, white.
+   Attributes: none, bold, dim, underline, blink, inverse.
+
+   Note that the terminal is free to interpret the attributes however
+   it wants.
+
+
+   TODO/BUGS:
+
+    o Only works with TTY
+    o You can't use '=' or '&' in the match-string.
+    o Maybe add color-field to tty_menu_item in include/wintty.h
+      (so there's no need to find the color for the line again)
+    o Guidebook is not up to date
+    o Better place to put the functions, colornames[] and attrnames[]?
+    o Some menus do not need coloring; maybe add new parameter
+      to process_menu_window()?
+
+
+   FIXES:
+
+   v1.2:
+    o Updated to use 3.4.2 codebase.
+
+   v1.1:
+    o Updated to use 3.4.1 codebase.
+    o replaced USE_REGEX_MATCH with MENU_COLOR_REGEX
+
+   v1.04:
+    o Oops! 1.03 worked only on *nixes... (GNU regex.h)
+    o Compile-time option USE_REGEX_MATCH: if it's defined, use regex,
+      otherwise use globbing. ('?' and '*' wildcards)
+
+   v1.03:
+
+    o Now using Nethack 3.4.0 codebase
+    o Compile-time option MENU_COLOR
+    o Strings match using regular expressions instead of globbing
+    o You can use attribute with color (attr must come after '&')
+    o Use ``MENUCOLOR="foo"=color'' instead of ``OPTIONS=menucolor=...''
+      (Both work, but OPTIONS complains if you define menucolor
+      more than once)
+
+   v1.02:
+
+    o Should now work with OS/2, thanks to Jukka Lahtinen
+    o Strings match now using simple globbing. ('?' and '*' wildcards)
+
+   v1.01:
+
+    o Moved 'menucolors' boolean option, so now the options-menu
+      is in alphabetical order.
+    o Fixed 'menucolor' description in dat/opthelp.
+    o menu_colorings is now initialized to null in src/decl.c.
+
+   v1.0:
+
+    o Initial release
+
+--
+ Pasi Kallinen
+ pkalli@cs.joensuu.fi
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/src/decl.c nethack-3.4.2-menucolor/src/decl.c
--- nethack-3.4.2-orig/src/decl.c	2003-08-30 03:07:28.000000000 +0300
+++ nethack-3.4.2-menucolor/src/decl.c	2003-09-04 21:06:26.000000000 +0300
@@ -235,6 +235,10 @@
 	"white",		/* CLR_WHITE */
 };
 
+#ifdef MENU_COLOR
+struct menucoloring *menu_colorings = 0;
+#endif
+
 struct c_common_strings c_common_strings = {
 	"Nothing happens.",		"That's enough tries!",
 	"That is a silly thing to %s.",	"shudder for a moment.",
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/src/files.c nethack-3.4.2-menucolor/src/files.c
--- nethack-3.4.2-orig/src/files.c	2003-08-30 03:07:31.000000000 +0300
+++ nethack-3.4.2-menucolor/src/files.c	2003-09-04 21:06:26.000000000 +0300
@@ -1779,6 +1779,10 @@
 	} else if (match_varname(buf, "BOULDER", 3)) {
 	    (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE,
 			      1, "BOULDER");
+	} else if (match_varname(buf, "MENUCOLOR", 9)) {
+#ifdef MENU_COLOR
+	   add_menu_coloring(bufp);
+#endif
 	} else if (match_varname(buf, "GRAPHICS", 4)) {
 	    len = get_uchars(fp, buf, bufp, translate, FALSE,
 			     MAXPCHARS, "GRAPHICS");
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/src/options.c nethack-3.4.2-menucolor/src/options.c
--- nethack-3.4.2-orig/src/options.c	2003-08-30 03:07:36.000000000 +0300
+++ nethack-3.4.2-menucolor/src/options.c	2003-09-04 21:06:26.000000000 +0300
@@ -125,6 +125,15 @@
 #else
 	{"mail", (boolean *)0, TRUE, SET_IN_FILE},
 #endif
+#ifdef MENU_COLOR
+# ifdef MICRO
+	{"menucolors", &iflags.use_menu_color, TRUE,  SET_IN_GAME},
+# else
+	{"menucolors", &iflags.use_menu_color, FALSE, SET_IN_GAME},
+# endif
+#else
+	{"menucolors", (boolean *)0, FALSE, SET_IN_GAME},
+#endif
 #ifdef WIZARD
 	/* for menu debugging only*/
 	{"menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_GAME},
@@ -246,6 +255,7 @@
 	{ "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
 						PL_PSIZ, DISP_IN_GAME },
 	{ "map_mode", "map display mode under Windows", 20, DISP_IN_GAME },	/*WC*/
+	{ "menucolor", "set menu colors", PL_PSIZ, SET_IN_FILE },
 	{ "menustyle", "user interface for object selection",
 						MENUTYPELEN, SET_IN_GAME },
 	{ "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE },
@@ -958,6 +968,120 @@
 	}
 }
 
+#ifdef MENU_COLOR
+extern struct menucoloring *menu_colorings;
+
+static const struct {
+   const char *name;
+   const int color;
+} colornames[] = {
+   {"black", CLR_BLACK},
+   {"red", CLR_RED},
+   {"green", CLR_GREEN},
+   {"brown", CLR_BROWN},
+   {"blue", CLR_BLUE},
+   {"magenta", CLR_MAGENTA},
+   {"cyan", CLR_CYAN},
+   {"gray", CLR_GRAY},
+   {"orange", CLR_ORANGE},
+   {"lightgreen", CLR_BRIGHT_GREEN},
+   {"yellow", CLR_YELLOW},
+   {"lightblue", CLR_BRIGHT_BLUE},
+   {"lightmagenta", CLR_BRIGHT_MAGENTA},
+   {"lightcyan", CLR_BRIGHT_CYAN},
+   {"white", CLR_WHITE}
+};
+
+static const struct {
+   const char *name;
+   const int attr;
+} attrnames[] = {
+     {"none", ATR_NONE},
+     {"bold", ATR_BOLD},
+     {"dim", ATR_DIM},
+     {"underline", ATR_ULINE},
+     {"blink", ATR_BLINK},
+     {"inverse", ATR_INVERSE}
+
+};
+
+/* parse '"regex_string"=color&attr' and add it to menucoloring */
+boolean
+add_menu_coloring(str)
+char *str;
+{
+   int i, c = NO_COLOR, a = ATR_NONE;
+   struct menucoloring *tmp;
+   char *tmps, *cs = strchr(str, '=');
+   const char *err = (char *)0;
+   
+   if (!cs || !str) return FALSE;
+   
+   tmps = cs;
+   tmps++;
+   while (*tmps && isspace(*tmps)) tmps++;
+
+   for (i = 0; i < SIZE(colornames); i++)
+     if (strstri(tmps, colornames[i].name) == tmps) {
+	c = colornames[i].color;
+	break;
+     }
+   if ((i == SIZE(colornames)) && (*tmps >= '0' && *tmps <='9'))
+     c = atoi(tmps);
+   
+   if (c > 15) return FALSE;
+   
+   tmps = strchr(str, '&');
+   if (tmps) {
+      tmps++;
+      while (*tmps && isspace(*tmps)) tmps++;
+      for (i = 0; i < SIZE(attrnames); i++)
+	if (strstri(tmps, attrnames[i].name) == tmps) {
+	   a = attrnames[i].attr;
+	   break;
+	}
+      if ((i == SIZE(attrnames)) && (*tmps >= '0' && *tmps <='9'))
+	a = atoi(tmps);
+   }
+   
+   *cs = '\0';
+   tmps = str;
+   if ((*tmps == '"') || (*tmps == '\'')) {
+      cs--;
+      while (isspace(*cs)) cs--;
+      if (*cs == *tmps) {
+	 *cs = '\0';
+	 tmps++;
+      }
+   }
+   
+   tmp = (struct menucoloring *)alloc(sizeof(struct menucoloring));
+#ifdef MENU_COLOR_REGEX
+   tmp->match.translate = 0;
+   tmp->match.fastmap = 0;
+   tmp->match.buffer = 0;
+   tmp->match.allocated = 0;
+   tmp->match.regs_allocated = REGS_FIXED;
+   err = re_compile_pattern(tmps, strlen(tmps), &tmp->match);
+#else
+   tmp->match = (char *)alloc(strlen(tmps)+1);
+   (void) memcpy((genericptr_t)tmp->match, (genericptr_t)tmps, strlen(tmps)+1);
+#endif
+   if (err) {
+      raw_printf("\nMenucolor regex error: %s\n", err);
+      wait_synch();
+      free(tmp);
+      return FALSE;
+   } else {
+      tmp->next = menu_colorings;
+      tmp->color = c;
+      tmp->attr = a;
+      menu_colorings = tmp;
+      return TRUE;
+   }
+}
+#endif /* MENU_COLOR */
+
 void
 parseoptions(opts, tinitial, tfrom_file)
 register char *opts;
@@ -1127,6 +1251,18 @@
 		return;
 	}
 
+	/* menucolor:"regex_string"=color */
+	fullname = "menucolor";
+	if (match_optname(opts, fullname, 9, TRUE)) {
+#ifdef MENU_COLOR
+		if (negated) bad_negation(fullname, FALSE);
+		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
+			if (!add_menu_coloring(op))
+				badoption(opts);
+#endif
+ 		return;
+	}
+
 	fullname = "msghistory";
 	if (match_optname(opts, fullname, 3, TRUE)) {
 		op = string_for_env_opt(fullname, opts, negated);
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/src/save.c nethack-3.4.2-menucolor/src/save.c
--- nethack-3.4.2-orig/src/save.c	2003-08-30 03:07:39.000000000 +0300
+++ nethack-3.4.2-menucolor/src/save.c	2003-09-04 21:06:26.000000000 +0300
@@ -48,6 +48,10 @@
 #define HUP
 #endif
 
+#ifdef MENU_COLOR
+extern struct menucoloring *menu_colorings;
+#endif
+
 /* need to preserve these during save to avoid accessing freed memory */
 static unsigned ustuck_id = 0, usteed_id = 0;
 
@@ -953,12 +957,35 @@
 	return;
 }
 
+#ifdef MENU_COLOR
+void
+free_menu_coloring()
+{
+   struct menucoloring *tmp = menu_colorings;
+   
+   while (tmp) {
+      struct menucoloring *tmp2 = tmp->next;
+# ifdef MENU_COLOR_REGEX
+      (void) regfree(&tmp->match);
+# else
+      free(tmp->match);
+# endif
+      free(tmp);
+      tmp = tmp2;
+   }
+   return;
+}
+#endif
+
 void
 freedynamicdata()
 {
 	unload_qtlist();
 	free_invbuf();	/* let_to_name (invent.c) */
 	free_youbuf();	/* You_buf,&c (pline.c) */
+#ifdef MENU_COLOR
+	free_menu_coloring();
+#endif
 	tmp_at(DISP_FREEMEM, 0);	/* temporary display effects */
 #ifdef FREE_ALL_MEMORY
 # define freeobjchn(X)	(saveobjchn(0, X, FREE_SAVE),  X = 0)
diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.2-orig/win/tty/wintty.c nethack-3.4.2-menucolor/win/tty/wintty.c
--- nethack-3.4.2-orig/win/tty/wintty.c	2003-08-30 03:08:26.000000000 +0300
+++ nethack-3.4.2-menucolor/win/tty/wintty.c	2003-09-04 21:06:26.000000000 +0300
@@ -125,6 +125,10 @@
 static char winpanicstr[] = "Bad window id %d";
 char defmorestr[] = "--More--";
 
+#ifdef MENU_COLOR
+extern struct menucoloring *menu_colorings;
+#endif
+
 #ifdef CLIPPING
 # if defined(USE_TILES) && defined(MSDOS)
 boolean clipping = FALSE;	/* clipping on? */
@@ -1122,6 +1126,28 @@
     }
 }
 
+#ifdef MENU_COLOR
+STATIC_OVL boolean
+get_menu_coloring(str, color, attr)
+char *str;
+int *color, *attr;
+{
+   struct menucoloring *tmpmc;
+   if (iflags.use_menu_color)
+     for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
+# ifdef MENU_COLOR_REGEX
+       if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
+# else
+       if (pmatch(tmpmc->match, str)) {
+# endif
+	  *color = tmpmc->color;
+	  *attr = tmpmc->attr;
+	 return TRUE;
+       }
+   return FALSE;
+}
+#endif /* MENU_COLOR */
+
 STATIC_OVL void
 process_menu_window(window, cw)
 winid window;
@@ -1198,6 +1224,10 @@
 		for (page_lines = 0, curr = page_start;
 			curr != page_end;
 			page_lines++, curr = curr->next) {
+#ifdef MENU_COLOR
+		   int color = NO_COLOR, attr = ATR_NONE;
+		   boolean menucolr = FALSE;
+#endif
 		    if (curr->selector)
 			*rp++ = curr->selector;
 
@@ -1213,6 +1243,13 @@
 		     * actually output the character.  We're faster doing
 		     * this.
 		     */
+#ifdef MENU_COLOR
+		   if (iflags.use_menu_color &&
+		       (menucolr = get_menu_coloring(curr->str, &color,&attr))) {
+		      term_start_attr(attr);
+		      if (color != NO_COLOR) term_start_color(color);
+		   } else
+#endif
 		    term_start_attr(curr->attr);
 		    for (n = 0, cp = curr->str;
 			  *cp && (int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
@@ -1225,6 +1262,12 @@
 				(void) putchar('#'); /* count selected */
 			} else
 			    (void) putchar(*cp);
+#ifdef MENU_COLOR
+		   if (iflags.use_menu_color && menucolr) {
+		      if (color != NO_COLOR) term_end_color();
+		      term_end_attr(attr);
+		   } else
+#endif
 		    term_end_attr(curr->attr);
 		}
 	    } else {