From e34674cb6dfa79c94f8e3fd78604974e707e23cc Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sun, 12 May 2019 23:18:32 -0400 Subject: [PATCH] Raise the maximum number of colors to 768 in SDL and X11. The logic is that each color pair can have a unique foreground and background color defined via init_color(), without altering any of the first (preset) 256 colors. --- sdl1/pdcscrn.c | 4 ++-- sdl1/pdcsdl.h | 8 +++++--- sdl1/pdcsetsc.c | 2 +- sdl2/pdcscrn.c | 4 ++-- sdl2/pdcsdl.h | 8 +++++--- sdl2/pdcsetsc.c | 2 +- x11/pdcsetsc.c | 2 +- x11/pdcx11.h | 2 ++ x11/x11.c | 1 - x11new/pdcsetsc.c | 2 +- x11new/pdcx11.h | 2 ++ x11new/x11.c | 1 - 12 files changed, 22 insertions(+), 16 deletions(-) diff --git a/sdl1/pdcscrn.c b/sdl1/pdcscrn.c index 6920402f..519a4ca9 100644 --- a/sdl1/pdcscrn.c +++ b/sdl1/pdcscrn.c @@ -20,8 +20,8 @@ SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL, *pdc_back = NULL, *pdc_tileback = NULL; int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0; -SDL_Color pdc_color[256]; -Uint32 pdc_mapped[256]; +SDL_Color pdc_color[MAX_COLORS]; +Uint32 pdc_mapped[MAX_COLORS]; int pdc_fheight, pdc_fwidth, pdc_fthick, pdc_flastc; bool pdc_own_screen; diff --git a/sdl1/pdcsdl.h b/sdl1/pdcsdl.h index b8d5a7bb..58108e83 100644 --- a/sdl1/pdcsdl.h +++ b/sdl1/pdcsdl.h @@ -14,11 +14,13 @@ PDCEX int pdc_font_size; PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back; PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset; +#define MAX_COLORS 768 + extern SDL_Surface *pdc_tileback; /* used to regenerate the background of "transparent" cells */ -extern SDL_Color pdc_color[256]; /* colors for font palette */ -extern Uint32 pdc_mapped[256]; /* colors for FillRect(), as - used in _highlight() */ +extern SDL_Color pdc_color[MAX_COLORS]; /* colors for font palette */ +extern Uint32 pdc_mapped[MAX_COLORS]; /* colors for FillRect(), as + used in _highlight() */ extern int pdc_fheight, pdc_fwidth; /* font height and width */ extern int pdc_fthick; /* thickness for highlights and rendered ACS glyphs */ diff --git a/sdl1/pdcsetsc.c b/sdl1/pdcsetsc.c index 4029684e..3b96c7ff 100644 --- a/sdl1/pdcsetsc.c +++ b/sdl1/pdcsetsc.c @@ -62,7 +62,7 @@ void PDC_set_title(const char *title) int PDC_set_blink(bool blinkon) { if (pdc_color_started) - COLORS = 256; + COLORS = MAX_COLORS; if (blinkon) { diff --git a/sdl2/pdcscrn.c b/sdl2/pdcscrn.c index 8b9e48df..d16a0805 100644 --- a/sdl2/pdcscrn.c +++ b/sdl2/pdcscrn.c @@ -32,8 +32,8 @@ SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL, *pdc_back = NULL, *pdc_tileback = NULL; int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0; -SDL_Color pdc_color[256]; -Uint32 pdc_mapped[256]; +SDL_Color pdc_color[MAX_COLORS]; +Uint32 pdc_mapped[MAX_COLORS]; int pdc_fheight, pdc_fwidth, pdc_fthick, pdc_flastc; bool pdc_own_window; diff --git a/sdl2/pdcsdl.h b/sdl2/pdcsdl.h index de073ebe..1fd3b2c4 100644 --- a/sdl2/pdcsdl.h +++ b/sdl2/pdcsdl.h @@ -15,11 +15,13 @@ PDCEX SDL_Window *pdc_window; PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back; PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset; +#define MAX_COLORS 768 + extern SDL_Surface *pdc_tileback; /* used to regenerate the background of "transparent" cells */ -extern SDL_Color pdc_color[256]; /* colors for font palette */ -extern Uint32 pdc_mapped[256]; /* colors for FillRect(), as - used in _highlight() */ +extern SDL_Color pdc_color[MAX_COLORS]; /* colors for font palette */ +extern Uint32 pdc_mapped[MAX_COLORS]; /* colors for FillRect(), as + used in _highlight() */ extern int pdc_fheight, pdc_fwidth; /* font height and width */ extern int pdc_fthick; /* thickness for highlights and rendered ACS glyphs */ diff --git a/sdl2/pdcsetsc.c b/sdl2/pdcsetsc.c index e5694d4e..318f6eed 100644 --- a/sdl2/pdcsetsc.c +++ b/sdl2/pdcsetsc.c @@ -62,7 +62,7 @@ void PDC_set_title(const char *title) int PDC_set_blink(bool blinkon) { if (pdc_color_started) - COLORS = 256; + COLORS = MAX_COLORS; if (blinkon) { diff --git a/x11/pdcsetsc.c b/x11/pdcsetsc.c index a09edbe0..9d195fde 100644 --- a/x11/pdcsetsc.c +++ b/x11/pdcsetsc.c @@ -74,7 +74,7 @@ void PDC_set_title(const char *title) int PDC_set_blink(bool blinkon) { if (pdc_color_started) - COLORS = 256; + COLORS = MAX_COLORS; XCursesInstruct(blinkon ? CURSES_BLINK_ON : CURSES_BLINK_OFF); diff --git a/x11/pdcx11.h b/x11/pdcx11.h index abaece07..cefea1e2 100644 --- a/x11/pdcx11.h +++ b/x11/pdcx11.h @@ -187,3 +187,5 @@ enum }; extern short *xc_atrtab; + +#define MAX_COLORS 768 diff --git a/x11/x11.c b/x11/x11.c index df82400e..68596dcb 100644 --- a/x11/x11.c +++ b/x11/x11.c @@ -33,7 +33,6 @@ XCursesAppData xc_app_data; # define PDC_SCROLLBAR_TYPE float #endif -#define MAX_COLORS 256 /* maximum of "normal" colors */ #define COLOR_CURSOR MAX_COLORS /* color of cursor */ #define COLOR_BORDER MAX_COLORS + 1 /* color of border */ diff --git a/x11new/pdcsetsc.c b/x11new/pdcsetsc.c index a44a2dbc..7c84021a 100644 --- a/x11new/pdcsetsc.c +++ b/x11new/pdcsetsc.c @@ -64,7 +64,7 @@ void PDC_set_title(const char *title) int PDC_set_blink(bool blinkon) { if (pdc_color_started) - COLORS = 256; + COLORS = MAX_COLORS; XCursesInstruct(blinkon ? CURSES_BLINK_ON : CURSES_BLINK_OFF); diff --git a/x11new/pdcx11.h b/x11new/pdcx11.h index 1e30ecf4..2db684af 100644 --- a/x11new/pdcx11.h +++ b/x11new/pdcx11.h @@ -176,3 +176,5 @@ enum extern short *xc_atrtab; extern bool xc_resize_now; + +#define MAX_COLORS 768 diff --git a/x11new/x11.c b/x11new/x11.c index 6290475d..9c34a87d 100644 --- a/x11new/x11.c +++ b/x11new/x11.c @@ -33,7 +33,6 @@ XCursesAppData xc_app_data; # define PDC_SCROLLBAR_TYPE float #endif -#define MAX_COLORS 256 /* maximum of "normal" colors */ #define COLOR_CURSOR MAX_COLORS /* color of cursor */ #define COLOR_BORDER MAX_COLORS + 1 /* color of border */