diff --git a/config.def.h b/config.def.h index 631933d..5794b5a 100644 --- a/config.def.h +++ b/config.def.h @@ -152,7 +152,7 @@ static const char *colorname[] = { /* more colors can be added after 255 to use with DefaultXX */ "#add8e6", /* 256 -> cursor */ - "#555555", /* 257 -> rev cursor*/ + "#2e3440" /* 267 -> rev cursor */ "#000000", /* 258 -> bg */ "#e5e5e5", /* 259 -> fg */ }; @@ -160,13 +160,18 @@ static const char *colorname[] = { /* * Default colors (colorname index) - * foreground, background, cursor, reverse cursor + * foreground, background, cursor, reverse cursor, selection */ unsigned int defaultbg = 0; unsigned int bg = 17, bgUnfocused = 16; unsigned int defaultfg = 259; unsigned int defaultcs = 256; -unsigned int defaultrcs = 257; +unsigned int defaultrcs = 256; +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; /* diff --git a/config.h b/config.h index 4c988d2..394c194 100644 --- a/config.h +++ b/config.h @@ -122,8 +122,8 @@ char *termname = "st-256color"; unsigned int tabspaces = 8; /* bg opacity */ -float alpha = 0.85; -float alphaUnfocused = 0.75; +float alpha = 0.9; +float alphaUnfocused = 0.8; /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { @@ -150,14 +150,14 @@ static const char *colorname[] = { [255] = 0, /* more colors can be added after 255 to use with DefaultXX */ - "#c0caf5", /* default cursor colour */ - "#1a1b26", /* default inverted cursor colour */ - "#c0caf5", /* default foreground colour */ - "#1a1b26", /* default background colour */ - "#abb7ed", /* unfocused foreground colour */ - "#14141a", /* unfocused background colour */ - // "#c0caf5", /* default selection foreground colour */ - // "#33467C", /* default selection background colour */ + "#c0caf5", /* 256 -> default cursor colour */ + "#1a1b26", /* 257 -> default inverted cursor colour */ + "#c0caf5", /* 258 -> default foreground colour */ + "#1a1b26", /* 259 -> default background colour */ + "#abb7ed", /* 260 -> unfocused foreground colour */ + "#14141a", /* 261 -> unfocused background colour */ + "#c0caf5", /* 262 -> default selection foreground colour */ + "#33467C", /* 263 -> default selection background colour */ }; @@ -165,11 +165,15 @@ static const char *colorname[] = { * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultbg = 0; -unsigned int bg = 259, bgUnfocused = 261; -unsigned int defaultfg = 258; -unsigned int defaultcs = 256; -unsigned int defaultrcs = 257; +unsigned int defaultcs = 256; +unsigned int defaultrcs = 257; +unsigned int defaultfg = 258; +unsigned int defaultbg = 0; +unsigned int bg = 259; +unsigned int bgUnfocused = 261; +unsigned int selectionfg = 262; +unsigned int selectionbg = 263; +static int ignoreselfg = 0; /* diff --git a/st.h b/st.h index 66343d1..02792e0 100644 --- 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, }; diff --git a/x.c b/x.c index 13dd9b2..418ac5f 100644 --- a/x.c +++ b/x.c @@ -1567,6 +1567,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i } } + 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; @@ -2006,7 +2012,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_REVERSE; /* Redraw the line where cursor was previously. * It will restore the ligatures broken by the cursor. */ xdrawline(line, 0, oy, len); @@ -2021,25 +2027,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 */ @@ -2197,7 +2191,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;