--- ./config.h.in.orig 2021-07-23 15:57:20.000000000 -0500 +++ ./config.h.in 2026-02-18 01:53:55.277627280 -0600 @@ -292,4 +292,7 @@ #undef USE_256_COLORS +/* Define if you want 24-bit color support */ +#undef USE_24_BIT_COLOR + /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE --- ./configure.ac.orig 2023-01-02 11:11:06.000000000 -0600 +++ ./configure.ac 2026-02-18 01:53:55.280627280 -0600 @@ -198,4 +198,14 @@ fi +support_24_bit_color=no +AC_ARG_ENABLE(24-bit-color, + [ --enable-24-bit-color enable 24-bit color support], + [if test x$enableval = xyes; then + support_24_bit_color=yes + fi]) +if test x$support_24_bit_color = xyes; then + AC_DEFINE(USE_24_BIT_COLOR, 1, Define if you want 24-bit color support) +fi + AC_ARG_ENABLE(unicode3, [ --enable-unicode3 use 21 instead of 16 bits to represent unicode characters], --- ./configure.orig 2023-01-02 16:40:04.000000000 -0600 +++ ./configure 2026-02-18 01:53:55.279627280 -0600 @@ -735,4 +735,5 @@ enable_warnings enable_256_color +enable_24_bit_color enable_unicode3 enable_combining @@ -1409,4 +1410,5 @@ --enable-warnings turn on g++ warnings --enable-256-color enable 256-color support + --enable-24-bit-color enable 24-bit color support --enable-unicode3 use 21 instead of 16 bits to represent unicode characters --enable-combining enable composition of base and combining characters @@ -5129,4 +5131,19 @@ fi + +support_24_bit_color=no +# Check whether --enable-24-bit-color was given. +if test ${enable_24_bit_color+y} +then : + enableval=$enable_24_bit_color; if test x$enableval = xyes; then + support_24_bit_color=yes + fi +fi + +if test x$support_24_bit_color = xyes; then + +printf "%s\n" "#define USE_24_BIT_COLOR 1" >>confdefs.h + +fi # Check whether --enable-unicode3 was given. --- ./README.configure.orig 2023-01-02 16:42:05.000000000 -0600 +++ ./README.configure 2026-02-18 01:53:55.280627280 -0600 @@ -10,6 +10,6 @@ --enable-everything Add (or remove) support for all non-multichoice options listed in - "./configure --help", except for "--enable-assert" and - "--enable-256-color". + "./configure --help", except for "--enable-assert", + "--enable-256-color" and "--enable-24-bit-color". You can specify this and then disable options you do not like by @@ -239,4 +239,18 @@ It also results in higher memory usage and can slow down urxvt + dramatically when more than six fonts are in use by a terminal + instance. + + --enable-24-bit-color (default: off) + Enable use of 24-bit colors through + SGR 38 ; 2 ; R ; G ; B m + SGR 48 ; 2 ; R ; G ; B m + + This switch should break termcap/terminfo compatibility to + "TERM=rxvt-unicode-256color", and consequently set "TERM" to + "rxvt-unicode-24bit" by default but there is no termcap/terminfo + for 24-bit color support + + It also results in higher memory usage and can slow down urxvt dramatically when more than six fonts are in use by a terminal instance. --- ./src/command.C.orig 2026-02-18 01:53:40.773626312 -0600 +++ ./src/command.C 2026-02-18 01:53:55.281627280 -0600 @@ -1809,9 +1809,9 @@ { if (!first_time) - pix_colors_focused [idx].free (this); + lookup_color(idx, pix_colors_focused).free (this); rgba c; - pix_colors [Color_fade].get (c); - pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); + lookup_color(Color_fade, pix_colors).get (c); + lookup_color(idx, pix_colors_focused).fade (this, atoi (rs[Rs_fade]), lookup_color(idx, pix_colors_unfocused), c); } #endif @@ -3400,5 +3400,5 @@ { rgba c; - pix_colors_focused[color].get (c); + lookup_color(color, pix_colors_focused).get (c); char rgba_str[32]; @@ -3909,5 +3909,5 @@ unsigned int i; short rendset; - int rendstyle; + rend_t rendstyle; if (nargs == 0) @@ -4015,4 +4015,18 @@ case 38: // set fg color, ISO 8613-6 +#if USE_24_BIT_COLOR + if (nargs > i + 2 && arg[i + 1] == 5) + { + scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); + i += 2; + } + else if (nargs > i + 4 && arg[i + 1] == 2) + { + unsigned int r = arg[i + 2], g = arg[i + 3], b = arg[i + 4]; + scr_color_rgb (r, g, b, Color_fg); + i += 4; + } +#endif + break; case 48: // set bg color, ISO 8613-6 { @@ -4027,4 +4041,12 @@ scr_color (idx, fgbg); } +#if USE_24_BIT_COLOR + else if (nargs > i + 4 && arg[i + 1] == 2) + { + unsigned int r = arg[i + 2], g = arg[i + 3], b = arg[i + 4]; + scr_color_rgb (r, g, b, Color_bg); + i += 4; + } +#endif else if (nargs > i + 4 && arg[i + 1] == 2) { --- ./src/init.C.orig 2022-12-23 15:37:56.000000000 -0600 +++ ./src/init.C 2026-02-18 01:53:55.282627280 -0600 @@ -1139,5 +1139,5 @@ for (i = 0; i < NRS_COLORS; i++) if (const char *name = rs[Rs_color + i]) - set_color (pix_colors [i], name); + set_color (lookup_color(i, pix_colors), name); /* @@ -1148,11 +1148,11 @@ */ #ifdef RXVT_SCROLLBAR - pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); + lookup_color(Color_scroll, pix_colors).fade (this, 50, lookup_color(Color_bottomShadow, pix_colors)); rgba cscroll; - pix_colors [Color_scroll].get (cscroll); + lookup_color(Color_scroll, pix_colors).get (cscroll); /* topShadowColor */ - if (!pix_colors[Color_topShadow].set (this, + if (!lookup_color(Color_topShadow, pix_colors).set (this, rgba ( min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), @@ -1396,6 +1396,6 @@ /* sub-window placement & size in rxvt_term::resize_all_windows () */ - attributes.background_pixel = pix_colors_focused [Color_border]; - attributes.border_pixel = pix_colors_focused [Color_border]; + attributes.background_pixel = lookup_color(Color_border, pix_colors_focused); + attributes.border_pixel = lookup_color(Color_border, pix_colors_focused); attributes.colormap = cmap; @@ -1494,6 +1494,6 @@ vt_width, vt_height, 0, - pix_colors_focused[Color_fg], - pix_colors_focused[Color_bg]); + lookup_color(Color_fg, pix_colors_focused), + lookup_color(Color_bg, pix_colors_focused)); attributes.bit_gravity = NorthWestGravity; @@ -1512,6 +1512,6 @@ /* graphics context for the vt window */ - gcvalue.foreground = pix_colors[Color_fg]; - gcvalue.background = pix_colors[Color_bg]; + gcvalue.foreground = lookup_color(Color_fg, pix_colors); + gcvalue.background = lookup_color(Color_bg, pix_colors); gcvalue.graphics_exposures = 0; --- ./src/main.C.orig 2026-02-18 01:53:40.774626313 -0600 +++ ./src/main.C 2026-02-18 01:53:55.282627280 -0600 @@ -252,8 +252,8 @@ if (ISSET_PIXCOLOR (i)) { - pix_colors_focused [i].free (this); + lookup_color(i, pix_colors_focused).free (this); #if OFF_FOCUS_FADING if (rs[Rs_fade]) - pix_colors_unfocused [i].free (this); + lookup_color(i, pix_colors_unfocused).free (this); #endif } @@ -971,6 +971,6 @@ } - pix_colors_focused[idx].free (this); - set_color (pix_colors_focused[idx], color); + lookup_color(idx, pix_colors_focused).free (this); + set_color (lookup_color(idx, pix_colors_focused), color); done: @@ -988,10 +988,10 @@ (ISSET_PIXCOLOR (Color_pointer_fg) - ? pix_colors_focused[Color_pointer_fg] - : pix_colors_focused[Color_fg]).get (fg); + ? lookup_color(Color_pointer_fg, pix_colors_focused) + : lookup_color(Color_fg, pix_colors_focused)).get (fg); (ISSET_PIXCOLOR (Color_pointer_bg) - ? pix_colors_focused[Color_pointer_bg] - : pix_colors_focused[Color_bg]).get (bg); + ? lookup_color(Color_pointer_bg, pix_colors_focused) + : lookup_color(Color_bg, pix_colors_focused)).get (bg); XRecolorCursor (dpy, TermWin_cursor, &fg, &bg); @@ -1012,5 +1012,5 @@ for (i = Color_Black; i <= Color_White; i++) - if (pix_colors[Color_fg] == pix_colors[i]) + if (lookup_color(Color_fg, pix_colors) == lookup_color(i, pix_colors)) { sprintf (fstr, "%d", i - Color_Black); @@ -1019,5 +1019,5 @@ for (i = Color_Black; i <= Color_White; i++) - if (pix_colors[Color_bg] == pix_colors[i]) + if (lookup_color(Color_bg, pix_colors) == lookup_color(i, pix_colors)) { sprintf (bstr, "%d", i - Color_Black); @@ -1048,6 +1048,6 @@ rxvt_term::alias_color (int dst, int src) { - pix_colors[dst].free (this); - pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); + lookup_color(dst, pix_colors).free (this); + lookup_color(dst, pix_colors).set (this, rs[Rs_color + dst] = rs[Rs_color + src]); } @@ -1203,6 +1203,6 @@ rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) { - fg = pix_colors [Color_fg]; - bg = pix_colors [Color_bg]; + fg = lookup_color(Color_fg, pix_colors); + bg = lookup_color(Color_bg, pix_colors); } --- ./src/rxvtfont.C.orig 2021-11-21 13:33:25.000000000 -0600 +++ ./src/rxvtfont.C 2026-02-18 01:53:55.283627280 -0600 @@ -244,18 +244,18 @@ # ifdef HAVE_IMG if (term->bg_img - && !term->pix_colors[color].is_opaque () + && !term->lookup_color(color, term->pix_colors).is_opaque () && ((dst = XftDrawPicture (d)))) { XClearArea (disp, d, x, y, w, h, false); - Picture solid_color_pict = XftDrawSrcPicture (d, &term->pix_colors[color].c); + Picture solid_color_pict = XftDrawSrcPicture (d, &term->lookup_color(color, term->pix_colors).c); XRenderComposite (disp, PictOpOver, solid_color_pict, None, dst, 0, 0, 0, 0, x, y, w, h); } else # endif - XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); + XftDrawRect (d, &term->lookup_color(color, term->pix_colors).c, x, y, w, h); #else - XSetForeground (disp, gc, term->pix_colors[color]); + XSetForeground (disp, gc, term->lookup_color(color, term->pix_colors)); XFillRectangle (disp, d, gc, x, y, w, h); #endif @@ -344,5 +344,5 @@ clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); - XSetForeground (disp, gc, term->pix_colors[fg]); + XSetForeground (disp, gc, term->lookup_color(fg, term->pix_colors)); while (len) @@ -1066,5 +1066,5 @@ XGCValues v; - v.foreground = term->pix_colors[fg]; + v.foreground = term->lookup_color(fg, term->pix_colors); v.font = f->fid; @@ -1075,5 +1075,5 @@ if (bg == Color_bg && !slow) { - v.background = term->pix_colors[bg]; + v.background = term->lookup_color(bg, term->pix_colors); XChangeGC (disp, gc, GCForeground | GCBackground | GCFont, &v); XDrawImageString16 (disp, d, gc, x, y + base, xc, len); @@ -1107,5 +1107,5 @@ if (bg == Color_bg && !slow) { - v.background = term->pix_colors[bg]; + v.background = term->lookup_color(bg, term->pix_colors); XChangeGC (disp, gc, GCForeground | GCBackground | GCFont, &v); XDrawImageString (disp, d, gc, x, y + base, xc, len); @@ -1529,5 +1529,5 @@ if (term->bg_img && (bg == Color_transparent || bg == Color_bg - || (bg >= 0 && !term->pix_colors[bg].is_opaque () && ((dst = XftDrawPicture (d2)))))) + || (bg >= 0 && !term->lookup_color(bg, term->pix_colors).is_opaque () && ((dst = XftDrawPicture (d2)))))) { int src_x = x, src_y = y; @@ -1566,5 +1566,5 @@ if (dst) { - Picture solid_color_pict = XftDrawSrcPicture (d2, &term->pix_colors[bg].c); + Picture solid_color_pict = XftDrawSrcPicture (d2, &term->lookup_color(bg, term->pix_colors).c); // dst can only be set when bg >= 0 @@ -1574,7 +1574,7 @@ else #endif - XftDrawRect (d2, &term->pix_colors[bg >= 0 ? bg : Color_bg].c, 0, 0, w, h); + XftDrawRect (d2, &term->lookup_color(bg >= 0 ? bg : Color_bg, term->pix_colors).c, 0, 0, w, h); - XftDrawGlyphSpec (d2, &term->pix_colors[fg].c, f, enc, ep - enc); + XftDrawGlyphSpec (d2, &term->lookup_color(fg, term->pix_colors).c, f, enc, ep - enc); XCopyArea (disp, d2, d, gc, 0, 0, w, h, x, y); } @@ -1585,5 +1585,5 @@ { clear_rect (d, x, y, w, h, bg); - XftDrawGlyphSpec (d, &term->pix_colors[fg].c, f, enc, ep - enc); + XftDrawGlyphSpec (d, &term->lookup_color(fg, term->pix_colors).c, f, enc, ep - enc); } } --- ./src/rxvtfont.h.orig 2021-06-17 14:33:35.000000000 -0500 +++ ./src/rxvtfont.h 2026-02-18 01:53:55.283627280 -0600 @@ -73,6 +73,8 @@ // must be power-of-two - 1, also has to match RS_fontMask in rxvt.h -#if USE_256_COLORS - enum { fontCount = 7 }; // 2 extra colors bits, 2 fewer fontcount bits +#if USE_24_BIT_COLOR + enum { fontCount = 7 }; // 36 extra colors bits, 2 fewer fontcount bits +#elif USE_256_COLORS + enum { fontCount = 7 }; // 2 extra colors bits, 2 fewer fontcount bits #else enum { fontCount = 31 }; --- ./src/rxvt.h.orig 2021-11-21 17:29:22.000000000 -0600 +++ ./src/rxvt.h 2026-02-18 01:53:55.284627280 -0600 @@ -42,5 +42,9 @@ typedef uint16_t text_t; // saves lots of memory #endif +#if USE_24_BIT_COLOR +typedef uint64_t rend_t; +#else typedef uint32_t rend_t; +#endif typedef int32_t tlen_t; // was int16_t, but this results in smaller code and memory use typedef int32_t tlen_t_; // specifically for use in the line_t structure @@ -352,41 +356,50 @@ // GET_BGATTR depends on RS_fgShift > RS_bgShift -#define RS_colorMask ((1UL << Color_Bits) - 1UL) -#define RS_bgShift 0 -#define RS_fgShift (RS_bgShift + Color_Bits) -#define RS_bgMask (RS_colorMask << RS_bgShift) -#define RS_fgMask (RS_colorMask << RS_fgShift) +#define RS_colorMask ((rend_t) ((1UL << Color_Bits) - 1UL)) +#define RS_bgShift 0 +#define RS_fgShift (RS_bgShift + Color_Bits) +#define RS_bgMask ((rend_t) (RS_colorMask << RS_bgShift)) +#define RS_fgMask ((rend_t) (RS_colorMask << RS_fgShift)) // must have space for rxvt_fontset::fontCount * 2 + 2 values #define RS_fontShift (RS_fgShift + Color_Bits) -#define RS_Careful (1UL << RS_fontShift) /* be careful when drawing these */ -#define RS_fontCount rxvt_fontset::fontCount -#define RS_fontMask ((RS_fontCount << (RS_fontShift + 1)) | RS_Careful) // includes RS_Careful +#define RS_Careful ((rend_t) (1UL << RS_fontShift)) /* be careful when drawing these */ +#define RS_fontCount ((rend_t) rxvt_fontset::fontCount) +#define RS_fontMask ((rend_t) ((RS_fontCount << (RS_fontShift + 1)) | RS_Careful)) // includes RS_Careful // toggle this to force redraw, must be != RS_Careful and otherwise "pretty neutral" -#define RS_redraw (2UL << RS_fontShift) +#define RS_redraw ((rend_t) (2UL << RS_fontShift)) -#define RS_Sel (1UL << 22) +#if USE_24_BIT_COLOR +# define RS_fontCountSize 4 +#elif USE_256_COLORS +# define RS_fontCountSize 4 +#else +# define RS_fontCountSize 8 +#endif + +#define RS_selShift (RS_fontShift + RS_fontCountSize) +#define RS_Sel ((rend_t) (1UL << RS_selShift)) // 4 custom bits for extensions #define RS_customCount 16UL -#define RS_customShift 23 -#define RS_customMask ((RS_customCount - 1UL) << RS_customShift) +#define RS_customShift (RS_selShift + 1) +#define RS_customMask ((rend_t) ((RS_customCount - 1UL) << RS_customShift)) // font styles -#define RS_Bold (1UL << RS_styleShift) -#define RS_Italic (2UL << RS_styleShift) +#define RS_Bold ((rend_t) (1UL << RS_styleShift)) +#define RS_Italic ((rend_t) (2UL << RS_styleShift)) -#define RS_styleCount 4 -#define RS_styleShift 27 -#define RS_styleMask (RS_Bold | RS_Italic) +#define RS_styleCount 4 +#define RS_styleShift (RS_customShift + RS_styleCount) +#define RS_styleMask ((rend_t) (RS_Bold | RS_Italic)) // fake styles -#define RS_Blink (1UL << 29) -#define RS_RVid (1UL << 30) // reverse video -#define RS_Uline (1UL << 31) // underline +#define RS_Blink ((rend_t) (1UL << (RS_styleShift + 2))) +#define RS_RVid ((rend_t) (1UL << (RS_styleShift + 3))) // reverse video +#define RS_Uline ((rend_t) (1UL << (RS_styleShift + 4))) // underline -#define RS_baseattrMask (RS_Italic | RS_Bold | RS_Blink | RS_RVid | RS_Uline) -#define RS_attrMask (RS_baseattrMask | RS_fontMask) +#define RS_baseattrMask ((rend_t) (RS_Italic | RS_Bold | RS_Blink | RS_RVid | RS_Uline)) +#define RS_attrMask ((rend_t) (RS_baseattrMask | RS_fontMask)) #define DEFAULT_RSTYLE (RS_None | (Color_fg << RS_fgShift) | (Color_bg << RS_bgShift)) @@ -539,5 +552,7 @@ }; -#if USE_256_COLORS +#if USE_24_BIT_COLOR +# define Color_Bits 25 +#elif USE_256_COLORS # define Color_Bits 9 // 0 .. maxTermCOLOR24 #else @@ -675,19 +690,19 @@ /* how to build & extract colors and attributes */ -#define GET_BASEFG(x) (((x) & RS_fgMask) >> RS_fgShift) -#define GET_BASEBG(x) (((x) & RS_bgMask) >> RS_bgShift) +#define GET_BASEFG(x) ((((rend_t) (x)) & RS_fgMask) >> RS_fgShift) +#define GET_BASEBG(x) ((((rend_t) (x)) & RS_bgMask) >> RS_bgShift) -#define GET_FONT(x) (((x) & RS_fontMask) >> RS_fontShift) -#define SET_FONT(x,fid) (((x) & ~RS_fontMask) | ((fid) << RS_fontShift)) +#define GET_FONT(x) ((((rend_t) (x)) & RS_fontMask) >> RS_fontShift) +#define SET_FONT(x,fid) ((((rend_t) (x)) & ~((rend_t) RS_fontMask)) | (((rend_t) (fid)) << RS_fontShift)) -#define GET_STYLE(x) (((x) & RS_styleMask) >> RS_styleShift) -#define SET_STYLE(x,style) (((x) & ~RS_styleMask) | ((style) << RS_styleShift)) +#define GET_STYLE(x) ((((rend_t) (x)) & RS_styleMask) >> RS_styleShift) +#define SET_STYLE(x,style) ((((rend_t) (x)) & ~((rend_t) RS_styleMask)) | (((rend_t) (style)) << RS_styleShift)) -#define GET_ATTR(x) (((x) & RS_attrMask)) -#define SET_FGCOLOR(x,fg) (((x) & ~RS_fgMask) | ((fg) << RS_fgShift)) -#define SET_BGCOLOR(x,bg) (((x) & ~RS_bgMask) | ((bg) << RS_bgShift)) -#define SET_ATTR(x,a) (((x) & ~RS_attrMask) | (a)) +#define GET_ATTR(x) ((((rend_t) (x)) & RS_attrMask)) +#define SET_FGCOLOR(x,fg) ((((rend_t) (x)) & ~((rend_t) RS_fgMask)) | (((rend_t) (fg)) << RS_fgShift)) +#define SET_BGCOLOR(x,bg) ((((rend_t) (x)) & ~((rend_t) RS_bgMask)) | (((rend_t) (bg)) << RS_bgShift)) +#define SET_ATTR(x,a) ((((rend_t) (x)) & ~((rend_t) RS_attrMask)) | ((rend_t) (a))) -#define RS_SAME(a,b) (!(((a) ^ (b)) & ~RS_Careful)) +#define RS_SAME(a,b) (!((((rend_t) (a)) ^ ((rend_t) (b))) & ~((rend_t) RS_Careful))) #define PIXCOLOR_NAME(idx) rs[Rs_color + (idx)] @@ -1489,5 +1504,10 @@ void scr_change_screen (int scrn); void scr_color (unsigned int color, int fgbg) noexcept; - void scr_rendition (int set, int style) noexcept; +#if USE_24_BIT_COLOR + void scr_color_24 (unsigned int color, int fgbg) noexcept; + void scr_color_rgb (unsigned int r, unsigned int g, unsigned int b, int fgbg) noexcept; +#endif + rxvt_color &lookup_color (unsigned int color, rxvt_color *table) noexcept; + void scr_rendition (int set, rend_t style) noexcept; void scr_add_lines (const wchar_t *str, int len, int minlines = 0) noexcept; void scr_backspace () noexcept; --- ./src/rxvtperl.xs.orig 2022-12-30 13:18:20.000000000 -0600 +++ ./src/rxvtperl.xs 2026-02-18 01:53:55.285627280 -0600 @@ -803,4 +803,16 @@ PROTOTYPES: ENABLE +TYPEMAP: <> RS_customShift; @@ -1164,6 +1176,6 @@ RETVAL -int -SET_CUSTOM (int rend, int new_value) +rend_t +SET_CUSTOM (rend_t rend, int new_value) CODE: { @@ -1620,6 +1632,6 @@ THIS->vt_select_input (); -U32 -rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) +UV +rxvt_term::rstyle (rend_t new_rstyle = THIS->rstyle) CODE: RETVAL = THIS->rstyle; @@ -2107,8 +2119,8 @@ void -rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline) +rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1 = RS_RVid, rend_t rstyle2 = RS_RVid | RS_Uline) void -rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) +rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle = RS_RVid) void @@ -2176,5 +2188,5 @@ SV * -rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) +rxvt_term::overlay (int x, int y, int w, int h, rend_t rstyle = OVERLAY_RSTYLE, int border = 2) CODE: { @@ -2298,6 +2310,6 @@ C_ARGS: term->dpy, (Window)parent, x, y, width, height, 0, - term->pix_colors_focused[Color_border], - term->pix_colors_focused[Color_border] + term->lookup_color(Color_border, term->pix_colors_focused), + term->lookup_color(Color_border, term->pix_colors_focused) #endif @@ -2433,5 +2445,5 @@ ->replace (img); - img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]) + img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->lookup_color(Color_bg, THIS->pix_colors)) ->replace (img); --- ./src/screen.C.orig 2022-08-08 05:33:08.000000000 -0500 +++ ./src/screen.C 2026-02-18 01:53:55.286627280 -0600 @@ -628,4 +628,43 @@ } +#if USE_24_BIT_COLOR +static rxvt_color *scr_colors[1 << 24]; + +void +rxvt_term::scr_color_24 (unsigned int color, int fgbg) noexcept +{ + color += TOTAL_COLORS; + if (fgbg == Color_fg) + rstyle = SET_FGCOLOR (rstyle, color); + else + rstyle = SET_BGCOLOR (rstyle, color); +} + +void +rxvt_term::scr_color_rgb (unsigned int r, unsigned int g, unsigned int b, int fgbg) noexcept +{ + unsigned int color = (r << 16) + (g << 8) + b; + scr_color_24(color, fgbg); +} +#endif + +rxvt_color +&rxvt_term::lookup_color (unsigned int color, rxvt_color *table) noexcept +{ +#if USE_24_BIT_COLOR + if (color >= TOTAL_COLORS) { + color -= TOTAL_COLORS; + if (scr_colors[color] == NULL) { + scr_colors[color] = new rxvt_color(); + char name[1+2*3+1]; + sprintf(name, "#%02x%02x%02x", (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); + scr_colors[color]->set(this, name); + } + return *scr_colors[color]; + } else +#endif + return table[color]; +} + /* ------------------------------------------------------------------------- */ /* @@ -633,5 +672,5 @@ */ void -rxvt_term::scr_rendition (int set, int style) noexcept +rxvt_term::scr_rendition (int set, rend_t style) noexcept { if (set) @@ -1391,5 +1430,5 @@ if (mapped) { - gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; + gcvalue.foreground = lookup_color(bgcolor_of (rstyle), pix_colors); XChangeGC (dpy, gc, GCForeground, &gcvalue); XFillRectangle (dpy, vt, gc, @@ -1397,5 +1436,5 @@ (unsigned int)vt_width, (unsigned int)Height2Pixel (num)); - gcvalue.foreground = pix_colors[Color_fg]; + gcvalue.foreground = lookup_color(Color_fg, pix_colors); XChangeGC (dpy, gc, GCForeground, &gcvalue); } @@ -1726,13 +1765,13 @@ else #endif - ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); + ::swap (lookup_color(Color_fg, pix_colors), lookup_color(Color_bg, pix_colors)); #ifdef HAVE_IMG if (bg_img == 0) #endif - XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); + XSetWindowBackground (dpy, vt, lookup_color(Color_bg, pix_colors)); XGCValues gcvalue; - gcvalue.foreground = pix_colors[Color_fg]; - gcvalue.background = pix_colors[Color_bg]; + gcvalue.foreground = lookup_color(Color_fg, pix_colors); + gcvalue.background = lookup_color(Color_bg, pix_colors); XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue); @@ -2432,12 +2471,12 @@ if (showcursor && focus && row == screen.cur.row && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth)) - XSetForeground (dpy, gc, pix_colors[ccol1]); + XSetForeground (dpy, gc, lookup_color(ccol1, pix_colors)); else #if ENABLE_FRILLS if (ISSET_PIXCOLOR (Color_underline)) - XSetForeground (dpy, gc, pix_colors[Color_underline]); + XSetForeground (dpy, gc, lookup_color(Color_underline, pix_colors)); else #endif - XSetForeground (dpy, gc, pix_colors[fore]); + XSetForeground (dpy, gc, lookup_color(fore, pix_colors)); XDrawLine (dpy, vt, gc, @@ -2459,5 +2498,5 @@ else if (oldcursor.row >= 0) { - XSetForeground (dpy, gc, pix_colors[ccol1]); + XSetForeground (dpy, gc, lookup_color(ccol1, pix_colors)); if (cursor_type == 1) XFillRectangle (dpy, vt, gc, @@ -2476,5 +2515,5 @@ else if (oldcursor.row >= 0) { - XSetForeground (dpy, gc, pix_colors[ccol1]); + XSetForeground (dpy, gc, lookup_color(ccol1, pix_colors)); XDrawRectangle (dpy, vt, gc, @@ -2545,5 +2584,5 @@ # endif { - XSetWindowBackground (dpy, parent, pix_colors[Color_border]); + XSetWindowBackground (dpy, parent, lookup_color(Color_border, pix_colors)); XSetWindowBackgroundPixmap (dpy, vt, bg_img->pm); } @@ -2552,6 +2591,6 @@ #endif { - XSetWindowBackground (dpy, parent, pix_colors[Color_border]); - XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); + XSetWindowBackground (dpy, parent, lookup_color(Color_border, pix_colors)); + XSetWindowBackground (dpy, vt, lookup_color(Color_bg, pix_colors)); } @@ -2563,5 +2602,5 @@ XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); else - XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); + XSetWindowBackground (dpy, scrollBar.win, lookup_color(scrollBar.color (), pix_colors)); scrollBar.state = SB_STATE_IDLE; scrollBar.show (0); --- ./src/scrollbar.C.orig 2026-02-18 01:53:40.774626313 -0600 +++ ./src/scrollbar.C 2026-02-18 01:53:55.287627280 -0600 @@ -73,6 +73,6 @@ term->szHint.height, 0, - term->pix_colors[Color_fg], - term->pix_colors[color ()]); + term->lookup_color(Color_fg, term->pix_colors), + term->lookup_color(color (), term->pix_colors)); XSelectInput (term->dpy, win, --- ./src/scrollbar-next.C.orig 2016-06-29 08:47:19.000000000 -0500 +++ ./src/scrollbar-next.C 2026-02-18 01:53:55.287627280 -0600 @@ -155,13 +155,13 @@ gcvalue.graphics_exposures = False; - gcvalue.foreground = term->pix_colors_focused[Color_Black]; + gcvalue.foreground = term->lookup_color(Color_Black, term->pix_colors_focused); blackGC = XCreateGC (term->dpy, win, GCForeground | GCGraphicsExposures, &gcvalue); - gcvalue.foreground = term->pix_colors_focused[Color_White]; + gcvalue.foreground = term->lookup_color(Color_White, term->pix_colors_focused); whiteGC = XCreateGC (term->dpy, win, GCForeground | GCGraphicsExposures, &gcvalue); - light = term->pix_colors_focused[Color_scroll]; + light = term->lookup_color(Color_scroll, term->pix_colors_focused); #if 0 //color used by rxvt @@ -173,5 +173,5 @@ GCForeground | GCGraphicsExposures, &gcvalue); - dark = term->pix_colors_focused[Color_Grey25]; + dark = term->lookup_color(Color_Grey25, term->pix_colors_focused); #if 0 //color used by rxvt --- ./src/scrollbar-plain.C.orig 2016-06-29 08:47:19.000000000 -0500 +++ ./src/scrollbar-plain.C 2026-02-18 01:53:55.287627280 -0600 @@ -39,5 +39,5 @@ init |= SB_STYLE_PLAIN; - gcvalue.foreground = term->pix_colors_focused[Color_scroll]; + gcvalue.foreground = term->lookup_color(Color_scroll, term->pix_colors_focused); pscrollbarGC = XCreateGC (term->dpy, win, GCForeground, &gcvalue); --- ./src/scrollbar-rxvt.C.orig 2016-06-29 08:47:19.000000000 -0500 +++ ./src/scrollbar-rxvt.C 2026-02-18 01:53:55.287627280 -0600 @@ -159,9 +159,9 @@ init |= SB_STYLE_RXVT; - gcvalue.foreground = term->pix_colors[Color_topShadow]; + gcvalue.foreground = term->lookup_color(Color_topShadow, term->pix_colors); topShadowGC = XCreateGC (term->dpy, term->vt, GCForeground, &gcvalue); - gcvalue.foreground = term->pix_colors[Color_bottomShadow]; + gcvalue.foreground = term->lookup_color(Color_bottomShadow, term->pix_colors); botShadowGC = XCreateGC (term->dpy, term->vt, GCForeground, &gcvalue); - gcvalue.foreground = term->pix_colors[ (term->depth <= 2 ? Color_fg : Color_scroll)]; + gcvalue.foreground = term->lookup_color( (term->depth <= 2 ? Color_fg : Color_scroll), term->pix_colors); scrollbarGC = XCreateGC (term->dpy, term->vt, GCForeground, &gcvalue); } --- ./src/scrollbar-xterm.C.orig 2016-06-29 08:47:19.000000000 -0500 +++ ./src/scrollbar-xterm.C 2026-02-18 01:53:55.288627281 -0600 @@ -50,11 +50,11 @@ gcvalue.fill_style = FillOpaqueStippled; - gcvalue.foreground = term->pix_colors_focused[Color_scroll]; - gcvalue.background = term->pix_colors_focused[Color_bg]; + gcvalue.foreground = term->lookup_color(Color_scroll, term->pix_colors_focused); + gcvalue.background = term->lookup_color(Color_bg, term->pix_colors_focused); xscrollbarGC = XCreateGC (term->dpy, win, GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue); - gcvalue.foreground = term->pix_colors_focused[Color_border]; + gcvalue.foreground = term->lookup_color(Color_border, term->pix_colors_focused); ShadowGC = XCreateGC (term->dpy, win, GCForeground, &gcvalue); }