updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / nethack-x11-patch / nh343-menucolor.diff
blobe782809f4f4307b637e37800833af71852f92e36
1 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/include/color.h nethack-3.4.3-menucolors/include/color.h
2 --- nethack-3.4.3-orig/include/color.h 2006-08-08 23:07:19.000000000 +0300
3 +++ nethack-3.4.3-menucolors/include/color.h 2005-02-18 18:01:56.000000000 +0200
4 @@ -5,6 +5,12 @@
5 #ifndef COLOR_H
6 #define COLOR_H
8 +#ifdef MENU_COLOR
9 +# ifdef MENU_COLOR_REGEX
10 +# include <regex.h>
11 +# endif
12 +#endif
15 * The color scheme used is tailored for an IBM PC. It consists of the
16 * standard 8 colors, folowed by their bright counterparts. There are
17 @@ -49,4 +55,20 @@
18 #define DRAGON_SILVER CLR_BRIGHT_CYAN
19 #define HI_ZAP CLR_BRIGHT_BLUE
21 +#ifdef MENU_COLOR
22 +struct menucoloring {
23 +# ifdef MENU_COLOR_REGEX
24 +# ifdef MENU_COLOR_REGEX_POSIX
25 + regex_t match;
26 +# else
27 + struct re_pattern_buffer match;
28 +# endif
29 +# else
30 + char *match;
31 +# endif
32 + int color, attr;
33 + struct menucoloring *next;
34 +};
35 +#endif /* MENU_COLOR */
37 #endif /* COLOR_H */
38 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/include/config.h nethack-3.4.3-menucolors/include/config.h
39 --- nethack-3.4.3-orig/include/config.h 2006-08-08 23:07:19.000000000 +0300
40 +++ nethack-3.4.3-menucolors/include/config.h 2006-09-20 23:25:49.000000000 +0300
41 @@ -348,6 +348,18 @@
42 * bugs left here.
45 +#if defined(TTY_GRAPHICS) || defined(MSWIN_GRAPHICS)
46 +# define MENU_COLOR
47 +# define MENU_COLOR_REGEX
48 +/*# define MENU_COLOR_REGEX_POSIX */
49 +/* if MENU_COLOR_REGEX is defined, use regular expressions (regex.h,
50 + * GNU specific functions by default, POSIX functions with
51 + * MENU_COLOR_REGEX_POSIX).
52 + * otherwise use pmatch() to match menu color lines.
53 + * pmatch() provides basic globbing: '*' and '?' wildcards.
54 + */
55 +#endif
57 /*#define GOLDOBJ */ /* Gold is kept on obj chains - Helge Hafting */
58 /*#define AUTOPICKUP_EXCEPTIONS */ /* exceptions to autopickup */
60 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/include/extern.h nethack-3.4.3-menucolors/include/extern.h
61 --- nethack-3.4.3-orig/include/extern.h 2006-08-08 23:07:19.000000000 +0300
62 +++ nethack-3.4.3-menucolors/include/extern.h 2005-02-18 18:01:56.000000000 +0200
63 @@ -1405,6 +1405,9 @@
64 E int FDECL(add_autopickup_exception, (const char *));
65 E void NDECL(free_autopickup_exceptions);
66 #endif /* AUTOPICKUP_EXCEPTIONS */
67 +#ifdef MENU_COLOR
68 +E boolean FDECL(add_menu_coloring, (char *));
69 +#endif /* MENU_COLOR */
71 /* ### pager.c ### */
73 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/include/flag.h nethack-3.4.3-menucolors/include/flag.h
74 --- nethack-3.4.3-orig/include/flag.h 2006-08-08 23:07:19.000000000 +0300
75 +++ nethack-3.4.3-menucolors/include/flag.h 2005-02-18 18:01:56.000000000 +0200
76 @@ -183,6 +183,9 @@
77 char prevmsg_window; /* type of old message window to use */
78 boolean extmenu; /* extended commands use menu interface */
79 #endif
80 +#ifdef MENU_COLOR
81 + boolean use_menu_color; /* use color in menus; only if wc_color */
82 +#endif
83 #ifdef MFLOPPY
84 boolean checkspace; /* check disk space before writing files */
85 /* (in iflags to allow restore after moving
86 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/README.menucolor nethack-3.4.3-menucolors/README.menucolor
87 --- nethack-3.4.3-orig/README.menucolor 1970-01-01 02:00:00.000000000 +0200
88 +++ nethack-3.4.3-menucolors/README.menucolor 2006-09-20 23:27:08.000000000 +0300
89 @@ -0,0 +1,106 @@
91 + This is version 1.5 of the menucolors patch.
93 + This patch allows the user to define in what color menus are shown.
94 + For example, putting
96 + OPTIONS=menucolors
97 + MENUCOLOR=" blessed "=green
98 + MENUCOLOR=" holy "=green
99 + MENUCOLOR=" cursed "=red
100 + MENUCOLOR=" unholy "=red
101 + MENUCOLOR=" cursed .* (being worn)"=orange&underline
103 + in the configuration file makes all known blessed items
104 + show up in green, all cursed items show up in red and
105 + all cursed worn items show up in orange and underlined
106 + when viewing inventory.
108 + If you have regex.h but it is not GNU (e.g. DJGPP, *BSD), uncomment
109 + #define MENU_COLOR_REGEX_POSIX in include/config.h
111 + If you do not have regex.h, comment
112 + #define MENU_COLOR_REGEX out from include/config.h
113 + and replace the MENUCOLOR lines in your config file with these:
115 + MENUCOLOR="* blessed *"=green
116 + MENUCOLOR="* holy *"=green
117 + MENUCOLOR="* cursed *"=red
118 + MENUCOLOR="* unholy *"=red
119 + MENUCOLOR="* cursed * (being worn)"=orange&underline
122 + Colors: black, red, green, brown, blue, magenta, cyan, gray, orange,
123 + lightgreen, yellow, lightblue, lightmagenta, lightcyan, white.
124 + Attributes: none, bold, dim, underline, blink, inverse.
126 + Note that the terminal is free to interpret the attributes however
127 + it wants.
130 + TODO/BUGS:
132 + o Only works with TTY and Windows GUI.
133 + o You can't use '=' or '&' in the match-string.
134 + o Maybe add color-field to tty_menu_item in include/wintty.h
135 + (so there's no need to find the color for the line again)
136 + o Guidebook is not up to date
137 + o Better place to put the functions, colornames[] and attrnames[]?
138 + o Some menus do not need coloring; maybe add new parameter
139 + to process_menu_window()?
142 + FIXES:
144 + v1.5:
145 + o Partial support for Windows GUI windowport; supports colors,
146 + but not attributes.
148 + v1.4:
149 + o Option to use standard instead of GNU regex functions.
151 + v1.3:
152 + o Updated to use 3.4.3 codebase.
153 + o Added a text to #version to show menucolors is compiled in.
155 + v1.2:
156 + o Updated to use 3.4.2 codebase.
158 + v1.1:
159 + o Updated to use 3.4.1 codebase.
160 + o replaced USE_REGEX_MATCH with MENU_COLOR_REGEX
162 + v1.04:
163 + o Oops! 1.03 worked only on *nixes... (GNU regex.h)
164 + o Compile-time option USE_REGEX_MATCH: if it's defined, use regex,
165 + otherwise use globbing. ('?' and '*' wildcards)
167 + v1.03:
169 + o Now using Nethack 3.4.0 codebase
170 + o Compile-time option MENU_COLOR
171 + o Strings match using regular expressions instead of globbing
172 + o You can use attribute with color (attr must come after '&')
173 + o Use ``MENUCOLOR="foo"=color'' instead of ``OPTIONS=menucolor=...''
174 + (Both work, but OPTIONS complains if you define menucolor
175 + more than once)
177 + v1.02:
179 + o Should now work with OS/2, thanks to Jukka Lahtinen
180 + o Strings match now using simple globbing. ('?' and '*' wildcards)
182 + v1.01:
184 + o Moved 'menucolors' boolean option, so now the options-menu
185 + is in alphabetical order.
186 + o Fixed 'menucolor' description in dat/opthelp.
187 + o menu_colorings is now initialized to null in src/decl.c.
189 + v1.0:
191 + o Initial release
194 + Pasi Kallinen
195 + paxed@alt.org
196 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/src/decl.c nethack-3.4.3-menucolors/src/decl.c
197 --- nethack-3.4.3-orig/src/decl.c 2006-08-08 23:07:19.000000000 +0300
198 +++ nethack-3.4.3-menucolors/src/decl.c 2005-02-18 18:01:56.000000000 +0200
199 @@ -235,6 +235,10 @@
200 "white", /* CLR_WHITE */
203 +#ifdef MENU_COLOR
204 +struct menucoloring *menu_colorings = 0;
205 +#endif
207 struct c_common_strings c_common_strings = {
208 "Nothing happens.", "That's enough tries!",
209 "That is a silly thing to %s.", "shudder for a moment.",
210 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/src/files.c nethack-3.4.3-menucolors/src/files.c
211 --- nethack-3.4.3-orig/src/files.c 2006-08-08 23:07:19.000000000 +0300
212 +++ nethack-3.4.3-menucolors/src/files.c 2005-02-18 18:01:56.000000000 +0200
213 @@ -1794,6 +1794,10 @@
214 } else if (match_varname(buf, "BOULDER", 3)) {
215 (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE,
216 1, "BOULDER");
217 + } else if (match_varname(buf, "MENUCOLOR", 9)) {
218 +#ifdef MENU_COLOR
219 + (void) add_menu_coloring(bufp);
220 +#endif
221 } else if (match_varname(buf, "GRAPHICS", 4)) {
222 len = get_uchars(fp, buf, bufp, translate, FALSE,
223 MAXPCHARS, "GRAPHICS");
224 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/src/options.c nethack-3.4.3-menucolors/src/options.c
225 --- nethack-3.4.3-orig/src/options.c 2006-08-08 23:07:19.000000000 +0300
226 +++ nethack-3.4.3-menucolors/src/options.c 2005-02-18 18:01:56.000000000 +0200
227 @@ -125,6 +125,15 @@
228 #else
229 {"mail", (boolean *)0, TRUE, SET_IN_FILE},
230 #endif
231 +#ifdef MENU_COLOR
232 +# ifdef MICRO
233 + {"menucolors", &iflags.use_menu_color, TRUE, SET_IN_GAME},
234 +# else
235 + {"menucolors", &iflags.use_menu_color, FALSE, SET_IN_GAME},
236 +# endif
237 +#else
238 + {"menucolors", (boolean *)0, FALSE, SET_IN_GAME},
239 +#endif
240 #ifdef WIZARD
241 /* for menu debugging only*/
242 {"menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_GAME},
243 @@ -246,6 +255,7 @@
244 { "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
245 PL_PSIZ, DISP_IN_GAME },
246 { "map_mode", "map display mode under Windows", 20, DISP_IN_GAME }, /*WC*/
247 + { "menucolor", "set menu colors", PL_PSIZ, SET_IN_FILE },
248 { "menustyle", "user interface for object selection",
249 MENUTYPELEN, SET_IN_GAME },
250 { "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE },
251 @@ -964,6 +974,133 @@
255 +#ifdef MENU_COLOR
256 +extern struct menucoloring *menu_colorings;
258 +static const struct {
259 + const char *name;
260 + const int color;
261 +} colornames[] = {
262 + {"black", CLR_BLACK},
263 + {"red", CLR_RED},
264 + {"green", CLR_GREEN},
265 + {"brown", CLR_BROWN},
266 + {"blue", CLR_BLUE},
267 + {"magenta", CLR_MAGENTA},
268 + {"cyan", CLR_CYAN},
269 + {"gray", CLR_GRAY},
270 + {"orange", CLR_ORANGE},
271 + {"lightgreen", CLR_BRIGHT_GREEN},
272 + {"yellow", CLR_YELLOW},
273 + {"lightblue", CLR_BRIGHT_BLUE},
274 + {"lightmagenta", CLR_BRIGHT_MAGENTA},
275 + {"lightcyan", CLR_BRIGHT_CYAN},
276 + {"white", CLR_WHITE}
279 +static const struct {
280 + const char *name;
281 + const int attr;
282 +} attrnames[] = {
283 + {"none", ATR_NONE},
284 + {"bold", ATR_BOLD},
285 + {"dim", ATR_DIM},
286 + {"underline", ATR_ULINE},
287 + {"blink", ATR_BLINK},
288 + {"inverse", ATR_INVERSE}
292 +/* parse '"regex_string"=color&attr' and add it to menucoloring */
293 +boolean
294 +add_menu_coloring(str)
295 +char *str;
297 + int i, c = NO_COLOR, a = ATR_NONE;
298 + struct menucoloring *tmp;
299 + char *tmps, *cs = strchr(str, '=');
300 +#ifdef MENU_COLOR_REGEX_POSIX
301 + int errnum;
302 + char errbuf[80];
303 +#endif
304 + const char *err = (char *)0;
306 + if (!cs || !str) return FALSE;
308 + tmps = cs;
309 + tmps++;
310 + while (*tmps && isspace(*tmps)) tmps++;
312 + for (i = 0; i < SIZE(colornames); i++)
313 + if (strstri(tmps, colornames[i].name) == tmps) {
314 + c = colornames[i].color;
315 + break;
317 + if ((i == SIZE(colornames)) && (*tmps >= '0' && *tmps <='9'))
318 + c = atoi(tmps);
320 + if (c > 15) return FALSE;
322 + tmps = strchr(str, '&');
323 + if (tmps) {
324 + tmps++;
325 + while (*tmps && isspace(*tmps)) tmps++;
326 + for (i = 0; i < SIZE(attrnames); i++)
327 + if (strstri(tmps, attrnames[i].name) == tmps) {
328 + a = attrnames[i].attr;
329 + break;
331 + if ((i == SIZE(attrnames)) && (*tmps >= '0' && *tmps <='9'))
332 + a = atoi(tmps);
335 + *cs = '\0';
336 + tmps = str;
337 + if ((*tmps == '"') || (*tmps == '\'')) {
338 + cs--;
339 + while (isspace(*cs)) cs--;
340 + if (*cs == *tmps) {
341 + *cs = '\0';
342 + tmps++;
346 + tmp = (struct menucoloring *)alloc(sizeof(struct menucoloring));
347 +#ifdef MENU_COLOR_REGEX
348 +#ifdef MENU_COLOR_REGEX_POSIX
349 + errnum = regcomp(&tmp->match, tmps, REG_EXTENDED | REG_NOSUB);
350 + if (errnum != 0)
352 + regerror(errnum, &tmp->match, errbuf, sizeof(errbuf));
353 + err = errbuf;
355 +#else
356 + tmp->match.translate = 0;
357 + tmp->match.fastmap = 0;
358 + tmp->match.buffer = 0;
359 + tmp->match.allocated = 0;
360 + tmp->match.regs_allocated = REGS_FIXED;
361 + err = re_compile_pattern(tmps, strlen(tmps), &tmp->match);
362 +#endif
363 +#else
364 + tmp->match = (char *)alloc(strlen(tmps)+1);
365 + (void) memcpy((genericptr_t)tmp->match, (genericptr_t)tmps, strlen(tmps)+1);
366 +#endif
367 + if (err) {
368 + raw_printf("\nMenucolor regex error: %s\n", err);
369 + wait_synch();
370 + free(tmp);
371 + return FALSE;
372 + } else {
373 + tmp->next = menu_colorings;
374 + tmp->color = c;
375 + tmp->attr = a;
376 + menu_colorings = tmp;
377 + return TRUE;
380 +#endif /* MENU_COLOR */
382 void
383 parseoptions(opts, tinitial, tfrom_file)
384 register char *opts;
385 @@ -1133,6 +1270,18 @@
386 return;
389 + /* menucolor:"regex_string"=color */
390 + fullname = "menucolor";
391 + if (match_optname(opts, fullname, 9, TRUE)) {
392 +#ifdef MENU_COLOR
393 + if (negated) bad_negation(fullname, FALSE);
394 + else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
395 + if (!add_menu_coloring(op))
396 + badoption(opts);
397 +#endif
398 + return;
401 fullname = "msghistory";
402 if (match_optname(opts, fullname, 3, TRUE)) {
403 op = string_for_env_opt(fullname, opts, negated);
404 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/src/save.c nethack-3.4.3-menucolors/src/save.c
405 --- nethack-3.4.3-orig/src/save.c 2006-08-08 23:07:19.000000000 +0300
406 +++ nethack-3.4.3-menucolors/src/save.c 2005-02-18 18:01:56.000000000 +0200
407 @@ -48,6 +48,10 @@
408 #define HUP
409 #endif
411 +#ifdef MENU_COLOR
412 +extern struct menucoloring *menu_colorings;
413 +#endif
415 /* need to preserve these during save to avoid accessing freed memory */
416 static unsigned ustuck_id = 0, usteed_id = 0;
418 @@ -953,12 +957,34 @@
419 return;
422 +#ifdef MENU_COLOR
423 +void
424 +free_menu_coloring()
426 + struct menucoloring *tmp = menu_colorings;
428 + while (tmp) {
429 + struct menucoloring *tmp2 = tmp->next;
430 +# ifdef MENU_COLOR_REGEX
431 + (void) regfree(&tmp->match);
432 +# else
433 + free(tmp->match);
434 +# endif
435 + free(tmp);
436 + tmp = tmp2;
439 +#endif /* MENU_COLOR */
441 void
442 freedynamicdata()
444 unload_qtlist();
445 free_invbuf(); /* let_to_name (invent.c) */
446 free_youbuf(); /* You_buf,&c (pline.c) */
447 +#ifdef MENU_COLOR
448 + free_menu_coloring();
449 +#endif
450 tmp_at(DISP_FREEMEM, 0); /* temporary display effects */
451 #ifdef FREE_ALL_MEMORY
452 # define freeobjchn(X) (saveobjchn(0, X, FREE_SAVE), X = 0)
453 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/util/makedefs.c nethack-3.4.3-menucolors/util/makedefs.c
454 --- nethack-3.4.3-orig/util/makedefs.c 2006-08-08 23:07:20.000000000 +0300
455 +++ nethack-3.4.3-menucolors/util/makedefs.c 2005-02-18 18:01:56.000000000 +0200
456 @@ -679,6 +679,13 @@
457 #ifdef MAIL
458 "mail daemon",
459 #endif
460 +#ifdef MENU_COLOR
461 +# ifdef MENU_COLOR_REGEX
462 + "menu colors via regular expressions",
463 +# else
464 + "menu colors via pmatch",
465 +# endif
466 +#endif
467 #ifdef GNUDOS
468 "MSDOS protected mode",
469 #endif
470 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/win/tty/wintty.c nethack-3.4.3-menucolors/win/tty/wintty.c
471 --- nethack-3.4.3-orig/win/tty/wintty.c 2006-08-08 23:07:20.000000000 +0300
472 +++ nethack-3.4.3-menucolors/win/tty/wintty.c 2005-02-18 18:01:57.000000000 +0200
473 @@ -125,6 +125,10 @@
474 static char winpanicstr[] = "Bad window id %d";
475 char defmorestr[] = "--More--";
477 +#ifdef MENU_COLOR
478 +extern struct menucoloring *menu_colorings;
479 +#endif
481 #ifdef CLIPPING
482 # if defined(USE_TILES) && defined(MSDOS)
483 boolean clipping = FALSE; /* clipping on? */
484 @@ -1128,6 +1132,32 @@
488 +#ifdef MENU_COLOR
489 +STATIC_OVL boolean
490 +get_menu_coloring(str, color, attr)
491 +char *str;
492 +int *color, *attr;
494 + struct menucoloring *tmpmc;
495 + if (iflags.use_menu_color)
496 + for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
497 +# ifdef MENU_COLOR_REGEX
498 +# ifdef MENU_COLOR_REGEX_POSIX
499 + if (regexec(&tmpmc->match, str, 0, NULL, 0) == 0) {
500 +# else
501 + if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
502 +# endif
503 +# else
504 + if (pmatch(tmpmc->match, str)) {
505 +# endif
506 + *color = tmpmc->color;
507 + *attr = tmpmc->attr;
508 + return TRUE;
510 + return FALSE;
512 +#endif /* MENU_COLOR */
514 STATIC_OVL void
515 process_menu_window(window, cw)
516 winid window;
517 @@ -1204,6 +1234,10 @@
518 for (page_lines = 0, curr = page_start;
519 curr != page_end;
520 page_lines++, curr = curr->next) {
521 +#ifdef MENU_COLOR
522 + int color = NO_COLOR, attr = ATR_NONE;
523 + boolean menucolr = FALSE;
524 +#endif
525 if (curr->selector)
526 *rp++ = curr->selector;
528 @@ -1219,6 +1253,13 @@
529 * actually output the character. We're faster doing
530 * this.
532 +#ifdef MENU_COLOR
533 + if (iflags.use_menu_color &&
534 + (menucolr = get_menu_coloring(curr->str, &color,&attr))) {
535 + term_start_attr(attr);
536 + if (color != NO_COLOR) term_start_color(color);
537 + } else
538 +#endif
539 term_start_attr(curr->attr);
540 for (n = 0, cp = curr->str;
541 #ifndef WIN32CON
542 @@ -1236,6 +1277,12 @@
543 (void) putchar('#'); /* count selected */
544 } else
545 (void) putchar(*cp);
546 +#ifdef MENU_COLOR
547 + if (iflags.use_menu_color && menucolr) {
548 + if (color != NO_COLOR) term_end_color();
549 + term_end_attr(attr);
550 + } else
551 +#endif
552 term_end_attr(curr->attr);
554 } else {
555 diff -Nurd --exclude-from=diff_ignore_files.txt nethack-3.4.3-orig/win/win32/mhmenu.c nethack-3.4.3-menucolors/win/win32/mhmenu.c
556 --- nethack-3.4.3-orig/win/win32/mhmenu.c 2006-08-08 23:07:20.000000000 +0300
557 +++ nethack-3.4.3-menucolors/win/win32/mhmenu.c 2006-09-20 23:24:21.000000000 +0300
558 @@ -63,6 +63,10 @@
560 extern short glyph2tile[];
562 +#ifdef MENU_COLOR
563 +extern struct menucoloring *menu_colorings;
564 +#endif
566 static WNDPROC wndProcListViewOrig = NULL;
567 static WNDPROC editControlWndProc = NULL;
569 @@ -83,6 +87,58 @@
570 static void reset_menu_count(HWND hwndList, PNHMenuWindow data);
571 static BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch);
573 +#ifdef MENU_COLOR
574 +/* FIXME: nhcolor_to_RGB copied from mhmap.c */
575 +/* map nethack color to RGB */
576 +COLORREF nhcolor_to_RGB(int c)
578 + switch(c) {
579 + case CLR_BLACK: return RGB(0x55, 0x55, 0x55);
580 + case CLR_RED: return RGB(0xFF, 0x00, 0x00);
581 + case CLR_GREEN: return RGB(0x00, 0x80, 0x00);
582 + case CLR_BROWN: return RGB(0xA5, 0x2A, 0x2A);
583 + case CLR_BLUE: return RGB(0x00, 0x00, 0xFF);
584 + case CLR_MAGENTA: return RGB(0xFF, 0x00, 0xFF);
585 + case CLR_CYAN: return RGB(0x00, 0xFF, 0xFF);
586 + case CLR_GRAY: return RGB(0xC0, 0xC0, 0xC0);
587 + case NO_COLOR: return RGB(0xFF, 0xFF, 0xFF);
588 + case CLR_ORANGE: return RGB(0xFF, 0xA5, 0x00);
589 + case CLR_BRIGHT_GREEN: return RGB(0x00, 0xFF, 0x00);
590 + case CLR_YELLOW: return RGB(0xFF, 0xFF, 0x00);
591 + case CLR_BRIGHT_BLUE: return RGB(0x00, 0xC0, 0xFF);
592 + case CLR_BRIGHT_MAGENTA: return RGB(0xFF, 0x80, 0xFF);
593 + case CLR_BRIGHT_CYAN: return RGB(0x80, 0xFF, 0xFF); /* something close to aquamarine */
594 + case CLR_WHITE: return RGB(0xFF, 0xFF, 0xFF);
595 + default: return RGB(0x00, 0x00, 0x00); /* black */
600 +STATIC_OVL boolean
601 +get_menu_coloring(str, color, attr)
602 +char *str;
603 +int *color, *attr;
605 + struct menucoloring *tmpmc;
606 + if (iflags.use_menu_color)
607 + for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
608 +# ifdef MENU_COLOR_REGEX
609 +# ifdef MENU_COLOR_REGEX_POSIX
610 + if (regexec(&tmpmc->match, str, 0, NULL, 0) == 0) {
611 +# else
612 + if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
613 +# endif
614 +# else
615 + if (pmatch(tmpmc->match, str)) {
616 +# endif
617 + *color = tmpmc->color;
618 + *attr = tmpmc->attr;
619 + return TRUE;
621 + return FALSE;
623 +#endif /* MENU_COLOR */
625 /*-----------------------------------------------------------------------------*/
626 HWND mswin_init_menu_window (int type) {
627 HWND ret;
628 @@ -767,6 +823,11 @@
629 char *p, *p1;
630 int column;
632 +#ifdef MENU_COLOR
633 + int color = NO_COLOR, attr;
634 + boolean menucolr = FALSE;
635 +#endif
637 lpdis = (LPDRAWITEMSTRUCT) lParam;
639 /* If there are no list box items, skip this message. */
640 @@ -813,6 +874,15 @@
641 buf[0] = item->accelerator;
642 buf[1] = '\x0';
644 +#ifdef MENU_COLOR
645 + if (iflags.use_menu_color &&
646 + (menucolr = get_menu_coloring(item->str, &color,&attr))) {
647 + /* TODO: use attr too */
648 + if (color != NO_COLOR)
649 + SetTextColor(lpdis->hDC, nhcolor_to_RGB(color));
651 +#endif
653 SetRect( &drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom );
654 DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);