diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index f32e31730..39e1b9329 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2080,6 +2080,8 @@ curses: if user's terminal was set to 'application keypad mode' (DEC VTxxx "ESC SPC G"), nethack wasn't recognizing number pad keys curses: change petattr attributes, dropping support for curses-only ones curses: swap the grey and no-color color initialization +curses: allow changing default colors with the 'palette' config option + (only if compiled with CHANGE_COLOR) macOS: Xcode project was failing to build if the path to the NetHack source tree contained a space; the issue was within some shell script code contained within the project diff --git a/include/extern.h b/include/extern.h index 87c1d3547..85ec516c2 100644 --- a/include/extern.h +++ b/include/extern.h @@ -327,6 +327,7 @@ extern boolean onlyhexdigits(const char *buf); extern uint32 get_nhcolor_from_256_index(int idx); #ifdef CHANGE_COLOR extern int count_alt_palette(void); +extern int alternative_palette(char *); extern void change_palette(void); #endif diff --git a/include/optlist.h b/include/optlist.h index e7009ae68..1a3235822 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -536,11 +536,11 @@ static int optfn_##a(int, int, boolean, char *, char *); #ifdef CHANGE_COLOR #ifndef MAC /* not old Mac OS9 */ NHOPTC(palette, Advanced, 15, opt_in, set_gameview, - No, Yes, No, No, "hicolor", + No, Yes, Yes, No, "hicolor", "palette (adjust an RGB color in palette (color/R-G-B)") #else NHOPTC(palette, Advanced, 15, opt_in, set_in_game, - No, Yes, No, No, "hicolor", + No, Yes, Yes, No, "hicolor", "palette (00c/880/-fff is blue/yellow/reverse white)") #endif #endif diff --git a/src/windows.c b/src/windows.c index 3af946b96..3bb8004b9 100644 --- a/src/windows.c +++ b/src/windows.c @@ -790,7 +790,7 @@ hup_cliparound(int x UNUSED, int y UNUSED) #ifdef CHANGE_COLOR /*ARGSUSED*/ staticfn void -hup_change_color(int color, long rgb, int reverse) +hup_change_color(int color UNUSED, long rgb UNUSED, int reverse UNUSED) { return; } @@ -798,7 +798,7 @@ hup_change_color(int color, long rgb, int reverse) #ifdef MAC /*ARGSUSED*/ staticfn short -hup_set_font_name(winid window, char *fontname) +hup_set_font_name(winid window UNUSED, char *fontname UNUSED) { return 0; } diff --git a/sys/unix/hints/linux.370 b/sys/unix/hints/linux.370 index 06c69b7be..c46f271ef 100755 --- a/sys/unix/hints/linux.370 +++ b/sys/unix/hints/linux.370 @@ -141,6 +141,7 @@ NHCFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\" #NHCFLAGS+=-DTTY_SOUND_ESCCODES #NHCFLAGS+=-DNO_CHRONICLE #NHCFLAGS+=-DLIVELOG +#NHCFLAGS+=-DCHANGE_COLOR NHCFLAGS+=-DSELF_RECOVER ifdef WANT_WIN_CURSES ifeq "$(HAVE_NCURSESW)" "1" diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 253bb3e75..b6af48ca5 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -44,8 +44,8 @@ extern glyph_info mesg_gi; static void dummy_update_position_bar(char *); #endif #ifdef CHANGE_COLOR -static void dummy_change_color(int, long, int); -static char *dummy_get_color_string(void); +static void curses_change_color(int, long, int); +static char *curses_get_color_string(void); #endif /* Public functions for curses NetHack interface */ @@ -119,12 +119,12 @@ struct window_procs curses_procs = { curses_number_pad, curses_delay_output, #ifdef CHANGE_COLOR - dummy_change_color, + curses_change_color, #ifdef MAC /* old OS 9, not OSX */ (void (*)(int)) 0, (short (*)(winid, char *)) 0, #endif - dummy_get_color_string, + curses_get_color_string, #endif curses_start_screen, curses_end_screen, @@ -1278,13 +1278,21 @@ dummy_update_position_bar(char *arg UNUSED) #ifdef CHANGE_COLOR static void -dummy_change_color(int a1 UNUSED, long a2 UNUSED, int a3 UNUSED) +curses_change_color(int color, long rgb, int reverse UNUSED) { - return; + short r, g, b; + + if (!can_change_color()) + return; + + r = (rgb >> 16) & 0xFF; + g = (rgb >> 8) & 0xFF; + b = rgb & 0xFF; + init_color(color % 16, r * 4, g * 4, b * 4); } static char * -dummy_get_color_string(void) +curses_get_color_string(void) { return (char *) 0; } diff --git a/win/tty/termcap.c b/win/tty/termcap.c index 1830fffad..b3b141881 100644 --- a/win/tty/termcap.c +++ b/win/tty/termcap.c @@ -1495,6 +1495,15 @@ term_curs_set(int visibility) xputs(nh_VE); } +#ifdef CHANGE_COLOR +void +tty_change_color(int color UNUSED, long rgb UNUSED, int reverse UNUSED) +{ + return; +} +#endif /* CHANGE_COLOR */ + + #ifndef SEP2 #define tcfmtstr "\033[38;2;%ld;%ld;%ldm" #ifdef UNIX diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 0ef7eb44d..f738fc46d 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -803,6 +803,14 @@ tty_resume_nhwindows(void) docrt(); } +#ifdef CHANGE_COLOR +char * +tty_get_color_string(void) +{ + return (char *) 0; +} +#endif /* CHANGE_COLOR */ + void tty_exit_nhwindows(const char *str) { @@ -3941,6 +3949,14 @@ term_curs_set(int visibility UNUSED) /* nothing */ } +#ifdef CHANGE_COLOR +void +tty_change_color(int color UNUSED, long rgb UNUSED, int reverse UNUSED) +{ + /* nothing */ +} +#endif /* CHANGE_COLOR */ + #endif /* NO_TERMS */ void