st-selectioncolors patch

This commit is contained in:
Ashish Kumar Yadav 2021-07-21 23:15:11 +05:30
parent 1fe0f6fe71
commit dd8067b901
3 changed files with 20 additions and 18 deletions

View file

@ -129,16 +129,21 @@ static const char *colorname[] = {
"#1d2021", /* default background */ "#1d2021", /* default background */
"#ebdbb2", /* default foreground */ "#ebdbb2", /* default foreground */
"#bdae93", /* cursor */ "#bdae93", /* cursor */
"#504945", /* selection */
}; };
/* /*
* Default colors (colorname index) * Default colors (colorname index)
* foreground, background, cursor, reverse cursor * foreground, background, cursor, reverse cursor, selection
*/ */
unsigned int defaultfg = 257; unsigned int defaultfg = 257;
unsigned int defaultbg = 256; unsigned int defaultbg = 256;
static unsigned int defaultcs = 258; static unsigned int defaultcs = 258;
static unsigned int defaultrcs = 256; static unsigned int defaultrcs = 256;
static unsigned int selectionbg = 257;
static unsigned int selectionfg = 7;
/* Owerwrite selection foreground colours with selectionfg */
static int ignoreselfg = 1;
/* /*
* Default shape of cursor * Default shape of cursor

View file

@ -33,6 +33,7 @@ enum glyph_attribute {
ATTR_WRAP = 1 << 8, ATTR_WRAP = 1 << 8,
ATTR_WIDE = 1 << 9, ATTR_WIDE = 1 << 9,
ATTR_WDUMMY = 1 << 10, ATTR_WDUMMY = 1 << 10,
ATTR_SELECTED = 1 << 11,
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
}; };

View file

@ -1429,6 +1429,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
bg = temp; 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) if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
fg = bg; fg = bg;
@ -1495,7 +1501,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
/* remove the old cursor */ /* remove the old cursor */
if (selected(ox, oy)) if (selected(ox, oy))
og.mode ^= ATTR_REVERSE; og.mode ^= ATTR_SELECTED;
xdrawglyph(og, ox, oy); xdrawglyph(og, ox, oy);
if (IS_SET(MODE_HIDE)) if (IS_SET(MODE_HIDE))
@ -1508,23 +1514,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
if (IS_SET(MODE_REVERSE)) { if (IS_SET(MODE_REVERSE)) {
g.mode |= ATTR_REVERSE; g.mode |= ATTR_REVERSE;
g.fg = defaultcs;
g.bg = defaultfg; g.bg = defaultfg;
if (selected(cx, cy)) { drawcol = dc.col[defaultrcs];
drawcol = dc.col[defaultcs];
g.fg = defaultrcs;
} else {
drawcol = dc.col[defaultrcs];
g.fg = defaultcs;
}
} else { } else {
if (selected(cx, cy)) { g.fg = defaultbg;
g.fg = defaultfg; g.bg = defaultcs;
g.bg = defaultrcs; drawcol = dc.col[defaultcs];
} else {
g.fg = defaultbg;
g.bg = defaultcs;
}
drawcol = dc.col[g.bg];
} }
/* draw the new one */ /* draw the new one */
@ -1629,7 +1625,7 @@ xdrawline(Line line, int x1, int y1, int x2)
if (new.mode == ATTR_WDUMMY) if (new.mode == ATTR_WDUMMY)
continue; continue;
if (selected(x, y1)) if (selected(x, y1))
new.mode ^= ATTR_REVERSE; new.mode ^= ATTR_SELECTED;
if (i > 0 && ATTRCMP(base, new)) { if (i > 0 && ATTRCMP(base, new)) {
xdrawglyphfontspecs(specs, base, i, ox, y1); xdrawglyphfontspecs(specs, base, i, ox, y1);
specs += i; specs += i;