mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
Add selectioncolors patch (#110)
https://st.suckless.org/patches/selectioncolors/ Closes #91
This commit is contained in:
parent
74f19eafe9
commit
2e0e84d56a
@ -206,6 +206,13 @@ unsigned int defaultbg = 258;
|
||||
unsigned int defaultfg = 259;
|
||||
unsigned int defaultcs = 256;
|
||||
unsigned int defaultrcs = 257;
|
||||
#if SELECTION_COLORS_PATCH
|
||||
unsigned int selectionfg = 258;
|
||||
unsigned int selectionbg = 259;
|
||||
/* 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;
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
|
||||
#if VIM_BROWSE_PATCH
|
||||
unsigned int const currentBg = 6, buffSize = 2048;
|
||||
|
@ -293,6 +293,13 @@
|
||||
*/
|
||||
#define SCROLLBACK_MOUSE_ALTSCREEN_PATCH 0
|
||||
|
||||
/* This patch adds the two color-settings selectionfg and selectionbg to config.def.h.
|
||||
* Those define the fore- and background colors which are used when text on the screen is selected
|
||||
* with the mouse. This removes the default behaviour which would simply reverse the colors.
|
||||
* https://st.suckless.org/patches/selectioncolors/
|
||||
*/
|
||||
#define SELECTION_COLORS_PATCH 0
|
||||
|
||||
/* This is the single drawable buffer patch as outlined in the FAQ to get images
|
||||
* in w3m to display. While this patch does not break the alpha patch it images
|
||||
* are not shown in w3m if the alpha patch is applied.
|
||||
|
3
st.h
3
st.h
@ -62,6 +62,9 @@ enum glyph_attribute {
|
||||
ATTR_SIXEL = 1 << 13,
|
||||
#endif // SIXEL_PATCH
|
||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||
#if SELECTION_COLORS_PATCH
|
||||
ATTR_SELECTED = 1 << 14,
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
#if UNDERCURL_PATCH
|
||||
ATTR_DIRTYUNDERLINE = 1 << 15,
|
||||
#endif // UNDERCURL_PATCH
|
||||
|
31
x.c
31
x.c
@ -2078,6 +2078,14 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||
#endif // SPOILER_PATCH
|
||||
}
|
||||
|
||||
#if SELECTION_COLORS_PATCH
|
||||
if (base.mode & ATTR_SELECTED) {
|
||||
bg = &dc.col[selectionbg];
|
||||
if (!ignoreselfg)
|
||||
fg = &dc.col[selectionfg];
|
||||
}
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
|
||||
if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
|
||||
fg = bg;
|
||||
|
||||
@ -2605,7 +2613,11 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
||||
|
||||
/* remove the old cursor */
|
||||
if (selected(ox, oy))
|
||||
#if SELECTION_COLORS_PATCH
|
||||
og.mode |= ATTR_SELECTED;
|
||||
#else
|
||||
og.mode ^= ATTR_REVERSE;
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
#if LIGATURES_PATCH
|
||||
/* Redraw the line where cursor was previously.
|
||||
* It will restore the ligatures broken by the cursor. */
|
||||
@ -2634,6 +2646,10 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
||||
if (IS_SET(MODE_REVERSE)) {
|
||||
g.mode |= ATTR_REVERSE;
|
||||
g.bg = defaultfg;
|
||||
#if SELECTION_COLORS_PATCH
|
||||
g.fg = defaultcs;
|
||||
drawcol = dc.col[defaultrcs];
|
||||
#else
|
||||
if (selected(cx, cy)) {
|
||||
drawcol = dc.col[defaultcs];
|
||||
g.fg = defaultrcs;
|
||||
@ -2641,7 +2657,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
||||
drawcol = dc.col[defaultrcs];
|
||||
g.fg = defaultcs;
|
||||
}
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
} else {
|
||||
#if SELECTION_COLORS_PATCH
|
||||
g.fg = defaultbg;
|
||||
g.bg = defaultcs;
|
||||
drawcol = dc.col[defaultcs];
|
||||
#else
|
||||
if (selected(cx, cy)) {
|
||||
g.fg = defaultfg;
|
||||
g.bg = defaultrcs;
|
||||
@ -2669,6 +2691,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
||||
} else
|
||||
drawcol = dc.col[g.bg];
|
||||
#endif // DYNAMIC_CURSOR_COLOR_PATCH
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
}
|
||||
|
||||
/* draw the new one */
|
||||
@ -2898,7 +2921,11 @@ xdrawline(Line line, int x1, int y1, int x2)
|
||||
if (new.mode == ATTR_WDUMMY)
|
||||
continue;
|
||||
if (selected(x, y1))
|
||||
#if SELECTION_COLORS_PATCH
|
||||
new.mode |= ATTR_SELECTED;
|
||||
#else
|
||||
new.mode ^= ATTR_REVERSE;
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
if (i > 0 && ATTRCMP(base, new)) {
|
||||
xdrawglyphfontspecs(specs, base, i, ox, y1, dmode);
|
||||
specs += i;
|
||||
@ -2927,7 +2954,11 @@ xdrawline(Line line, int x1, int y1, int x2)
|
||||
if (new.mode == ATTR_WDUMMY)
|
||||
continue;
|
||||
if (selected(x, y1))
|
||||
#if SELECTION_COLORS_PATCH
|
||||
new.mode |= ATTR_SELECTED;
|
||||
#else
|
||||
new.mode ^= ATTR_REVERSE;
|
||||
#endif // SELECTION_COLORS_PATCH
|
||||
if (i > 0 && ATTRCMP(base, new)) {
|
||||
xdrawglyphfontspecs(specs, base, i, ox, y1);
|
||||
specs += i;
|
||||
|
Loading…
Reference in New Issue
Block a user