75 lines
1.9 KiB
Diff
75 lines
1.9 KiB
Diff
--- a/st.h
|
|
+++ b/st.h
|
|
@@ -43,6 +43,7 @@ enum glyph_attribute {
|
|
ATTR_BOXDRAW = 1 << 11,
|
|
ATTR_LIGA = 1 << 12,
|
|
ATTR_SIXEL = 1 << 13,
|
|
+ ATTR_SELECTED = 1 << 14,
|
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
|
ATTR_DIRTYUNDERLINE = 1 << 15,
|
|
};
|
|
--- a/x.c
|
|
+++ b/x.c
|
|
@@ -1568,6 +1568,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|
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;
|
|
|
|
@@ -2008,7 +2014,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
|
|
|
|
/* 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. */
|
|
xdrawline(line, 0, oy, len);
|
|
@@ -2023,25 +2029,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
|
|
|
|
if (IS_SET(MODE_REVERSE)) {
|
|
g.mode |= ATTR_REVERSE;
|
|
+ g.fg = defaultcs;
|
|
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 */
|
|
@@ -2199,7 +2193,7 @@ xdrawline(Line line, int x1, int y1, int x2)
|
|
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, dmode);
|
|
specs += i;
|