diff --git a/curspriv.h b/curspriv.h index d16460bf..5697a42d 100644 --- a/curspriv.h +++ b/curspriv.h @@ -120,4 +120,6 @@ size_t PDC_wcstombs(char *, const wchar_t *, size_t); #define PDC_CLICK_PERIOD 150 /* time to wait for a click, if not set by mouseinterval() */ +#define PDC_MAXCOL 768 /* maximum possible COLORS; may be less */ + #endif /* __CURSES_INTERNALS__ */ diff --git a/sdl1/pdcscrn.c b/sdl1/pdcscrn.c index 519a4ca9..76d9d4e9 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[MAX_COLORS]; -Uint32 pdc_mapped[MAX_COLORS]; +SDL_Color pdc_color[PDC_MAXCOL]; +Uint32 pdc_mapped[PDC_MAXCOL]; int pdc_fheight, pdc_fwidth, pdc_fthick, pdc_flastc; bool pdc_own_screen; diff --git a/sdl1/pdcsdl.h b/sdl1/pdcsdl.h index 58108e83..25209275 100644 --- a/sdl1/pdcsdl.h +++ b/sdl1/pdcsdl.h @@ -14,12 +14,10 @@ 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[MAX_COLORS]; /* colors for font palette */ -extern Uint32 pdc_mapped[MAX_COLORS]; /* colors for FillRect(), as +extern SDL_Color pdc_color[PDC_MAXCOL]; /* colors for font palette */ +extern Uint32 pdc_mapped[PDC_MAXCOL]; /* 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 diff --git a/sdl1/pdcsetsc.c b/sdl1/pdcsetsc.c index 3b96c7ff..4ed939de 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 = MAX_COLORS; + COLORS = PDC_MAXCOL; if (blinkon) { diff --git a/sdl2/pdcscrn.c b/sdl2/pdcscrn.c index d16a0805..15c9e808 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[MAX_COLORS]; -Uint32 pdc_mapped[MAX_COLORS]; +SDL_Color pdc_color[PDC_MAXCOL]; +Uint32 pdc_mapped[PDC_MAXCOL]; int pdc_fheight, pdc_fwidth, pdc_fthick, pdc_flastc; bool pdc_own_window; diff --git a/sdl2/pdcsdl.h b/sdl2/pdcsdl.h index 1fd3b2c4..357b4429 100644 --- a/sdl2/pdcsdl.h +++ b/sdl2/pdcsdl.h @@ -15,12 +15,10 @@ 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[MAX_COLORS]; /* colors for font palette */ -extern Uint32 pdc_mapped[MAX_COLORS]; /* colors for FillRect(), as +extern SDL_Color pdc_color[PDC_MAXCOL]; /* colors for font palette */ +extern Uint32 pdc_mapped[PDC_MAXCOL]; /* 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 diff --git a/sdl2/pdcsetsc.c b/sdl2/pdcsetsc.c index 318f6eed..c30f6984 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 = MAX_COLORS; + COLORS = PDC_MAXCOL; if (blinkon) { diff --git a/wincon/pdcscrn.c b/wincon/pdcscrn.c index adec04c7..7f0525ba 100644 --- a/wincon/pdcscrn.c +++ b/wincon/pdcscrn.c @@ -10,7 +10,7 @@ static struct {short f, b;} atrtab[PDC_COLOR_PAIRS]; /* Color component table */ -PDCCOLOR pdc_color[MAX_COLORS]; +PDCCOLOR pdc_color[PDC_MAXCOL]; HANDLE std_con_out = INVALID_HANDLE_VALUE; HANDLE pdc_con_out = INVALID_HANDLE_VALUE; diff --git a/wincon/pdcsetsc.c b/wincon/pdcsetsc.c index 9e021119..c61e2922 100644 --- a/wincon/pdcsetsc.c +++ b/wincon/pdcsetsc.c @@ -96,7 +96,7 @@ int PDC_set_blink(bool blinkon) else if (PDC_can_change_color()) /* is_nt */ { if (SetConsoleMode(pdc_con_out, 0x0004)) /* VT */ - COLORS = MAX_COLORS; + COLORS = PDC_MAXCOL; SetConsoleMode(pdc_con_out, 0x0010); /* LVB */ } diff --git a/wincon/pdcwin.h b/wincon/pdcwin.h index 329fbb95..dab1f76b 100644 --- a/wincon/pdcwin.h +++ b/wincon/pdcwin.h @@ -13,11 +13,9 @@ # define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ #endif -#define MAX_COLORS 768 - typedef struct {short r, g, b; bool mapped;} PDCCOLOR; -extern PDCCOLOR pdc_color[MAX_COLORS]; +extern PDCCOLOR pdc_color[PDC_MAXCOL]; extern HANDLE pdc_con_out, pdc_con_in; extern DWORD pdc_quick_edit; diff --git a/x11/pdcsetsc.c b/x11/pdcsetsc.c index 9d195fde..d2db7672 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 = MAX_COLORS; + COLORS = PDC_MAXCOL; XCursesInstruct(blinkon ? CURSES_BLINK_ON : CURSES_BLINK_OFF); diff --git a/x11/pdcx11.h b/x11/pdcx11.h index cefea1e2..abaece07 100644 --- a/x11/pdcx11.h +++ b/x11/pdcx11.h @@ -187,5 +187,3 @@ enum }; extern short *xc_atrtab; - -#define MAX_COLORS 768 diff --git a/x11/x11.c b/x11/x11.c index 68596dcb..425677ea 100644 --- a/x11/x11.c +++ b/x11/x11.c @@ -33,8 +33,8 @@ XCursesAppData xc_app_data; # define PDC_SCROLLBAR_TYPE float #endif -#define COLOR_CURSOR MAX_COLORS /* color of cursor */ -#define COLOR_BORDER MAX_COLORS + 1 /* color of border */ +#define COLOR_CURSOR PDC_MAXCOL /* color of cursor */ +#define COLOR_BORDER PDC_MAXCOL + 1 /* color of border */ #define XCURSESDISPLAY (XtDisplay(drawing)) #define XCURSESWIN (XtWindow(drawing)) @@ -373,7 +373,7 @@ static XtActionsRec action_table[] = }; static bool after_first_curses_request = FALSE; -static Pixel colors[MAX_COLORS + 2]; +static Pixel colors[PDC_MAXCOL + 2]; static bool vertical_cursor = FALSE; static XIM Xim = NULL; @@ -2283,7 +2283,7 @@ static void _get_color(void) Colormap cmap = DefaultColormap(XCURSESDISPLAY, DefaultScreen(XCURSESDISPLAY)); - if (index < 0 || index >= MAX_COLORS) + if (index < 0 || index >= PDC_MAXCOL) _exit_process(4, SIGKILL, "exiting from _get_color"); tmp->pixel = colors[index]; @@ -2299,7 +2299,7 @@ static void _set_color(void) Colormap cmap = DefaultColormap(XCURSESDISPLAY, DefaultScreen(XCURSESDISPLAY)); - if (index < 0 || index >= MAX_COLORS) + if (index < 0 || index >= PDC_MAXCOL) _exit_process(4, SIGKILL, "exiting from _set_color"); if (XAllocColor(XCURSESDISPLAY, cmap, tmp)) diff --git a/x11new/pdcsetsc.c b/x11new/pdcsetsc.c index 7c84021a..393a3790 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 = MAX_COLORS; + COLORS = PDC_MAXCOL; XCursesInstruct(blinkon ? CURSES_BLINK_ON : CURSES_BLINK_OFF); diff --git a/x11new/pdcx11.h b/x11new/pdcx11.h index 2db684af..1e30ecf4 100644 --- a/x11new/pdcx11.h +++ b/x11new/pdcx11.h @@ -176,5 +176,3 @@ 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 9c34a87d..ec5c217a 100644 --- a/x11new/x11.c +++ b/x11new/x11.c @@ -33,8 +33,8 @@ XCursesAppData xc_app_data; # define PDC_SCROLLBAR_TYPE float #endif -#define COLOR_CURSOR MAX_COLORS /* color of cursor */ -#define COLOR_BORDER MAX_COLORS + 1 /* color of border */ +#define COLOR_CURSOR PDC_MAXCOL /* color of cursor */ +#define COLOR_BORDER PDC_MAXCOL + 1 /* color of border */ #define XCURSESDISPLAY (XtDisplay(drawing)) #define XCURSESWIN (XtWindow(drawing)) @@ -373,7 +373,7 @@ static XtActionsRec action_table[] = {"string", (XtActionProc)XCursesHandleString} }; -static Pixel colors[MAX_COLORS + 2]; +static Pixel colors[PDC_MAXCOL + 2]; static bool vertical_cursor = FALSE; static XIM Xim = NULL; @@ -2067,7 +2067,7 @@ static void _get_color(void) Colormap cmap = DefaultColormap(XCURSESDISPLAY, DefaultScreen(XCURSESDISPLAY)); - if (index < 0 || index >= MAX_COLORS) + if (index < 0 || index >= PDC_MAXCOL) _exit_process(4, SIGKILL, "exiting from _get_color"); tmp->pixel = colors[index]; @@ -2083,7 +2083,7 @@ static void _set_color(void) Colormap cmap = DefaultColormap(XCURSESDISPLAY, DefaultScreen(XCURSESDISPLAY)); - if (index < 0 || index >= MAX_COLORS) + if (index < 0 || index >= PDC_MAXCOL) _exit_process(4, SIGKILL, "exiting from _set_color"); if (XAllocColor(XCURSESDISPLAY, cmap, tmp))