# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/st/08-background_color.patch # Copyright (C) 2025 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- --- a/config.def.h 2020-12-16 12:08:04.219843684 +0100 +++ b/config.def.h 2020-12-16 12:08:11.643843099 +0100 @@ -134,7 +134,7 @@ /* more colors can be added after 255 to use with DefaultXX */ "#cccccc", - "#555555", + "#2e3440", "gray90", /* default foreground colour */ "black", /* default background colour */ }; @@ -147,7 +147,14 @@ unsigned int defaultfg = 258; unsigned int defaultbg = 259; unsigned int defaultcs = 256; -static unsigned int defaultrcs = 257; +static unsigned int defaultrcs = 256; + +/* Colors used for selection */ +unsigned int selectionbg = 257; +unsigned int selectionfg = 7; +/* If 0 use selectionfg as foreground in order to have a uniform foreground-color */ +/* Else if 1 keep original foreground-color of each cell => more colors :) */ +static int ignoreselfg = 1; /* * Default shape of cursor --- a/st.h 2020-12-16 11:45:00.629952598 +0100 +++ b/st.h 2020-12-16 12:08:25.852841981 +0100 @@ -34,6 +34,7 @@ enum glyph_attribute { ATTR_WRAP = 1 << 8, ATTR_WIDE = 1 << 9, ATTR_WDUMMY = 1 << 10, + ATTR_SELECTED = 1 << 13, ATTR_BOXDRAW = 1 << 11, ATTR_LIGA = 1 << 12, ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, --- a/x.c 2020-12-16 11:45:25.411950647 +0100 +++ b/x.c 2020-12-16 12:08:30.042841651 +0100 @@ -1469,6 +1469,12 @@ xdrawglyphfontspecs(const XftGlyphFontSp fg = bg; bg = temp; } + + if (base.mode & ATTR_SELECTED) { + bg = &dc.col[selectionbg]; + if (!ignoreselfg) + fg = &dc.col[selectionfg]; + } if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK) fg = bg; @@ -1540,7 +1546,7 @@ xdrawcursor(int cx, int cy, Glyph g, int /* remove the old cursor */ if (selected(ox, oy)) - og.mode ^= ATTR_REVERSE; + og.mode ^= ATTR_SELECTED; /* Redraw the line where cursor was previously. * It will restore the ligatures broken by the cursor. */ @@ -1557,22 +1563,11 @@ xdrawcursor(int cx, int cy, Glyph g, int if (IS_SET(MODE_REVERSE)) { g.mode |= ATTR_REVERSE; g.bg = defaultfg; - if (selected(cx, cy)) { - drawcol = dc.col[defaultcs]; - g.fg = defaultrcs; - } else { - drawcol = dc.col[defaultrcs]; - g.fg = defaultcs; - } + drawcol = dc.col[defaultrcs]; } else { - if (selected(cx, cy)) { - g.fg = defaultfg; - g.bg = defaultrcs; - } else { - g.fg = defaultbg; - g.bg = defaultcs; - } - drawcol = dc.col[g.bg]; + g.fg = defaultbg; + g.bg = defaultcs; + drawcol = dc.col[defaultcs]; } /* draw the new one */ @@ -1664,7 +1659,7 @@ xdrawline(Line line, int x1, int y1, int if (new.mode == ATTR_WDUMMY) continue; if (selected(x, y1)) - new.mode ^= ATTR_REVERSE; + new.mode ^= ATTR_SELECTED; if (i > 0 && ATTRCMP(base, new)) { xdrawglyphfontspecs(specs, base, i, ox, y1); specs += i;