selection colors patch
This commit is contained in:
parent
42f4340730
commit
6d3746db8a
4 changed files with 35 additions and 51 deletions
|
@ -134,6 +134,7 @@ static const char *colorname[] = {
|
||||||
"#555555",
|
"#555555",
|
||||||
"gray90", /* default foreground colour */
|
"gray90", /* default foreground colour */
|
||||||
"black", /* default background colour */
|
"black", /* default background colour */
|
||||||
|
"#2e3440",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,6 +146,12 @@ unsigned int defaultfg = 258;
|
||||||
unsigned int defaultbg = 259;
|
unsigned int defaultbg = 259;
|
||||||
unsigned int defaultcs = 256;
|
unsigned int defaultcs = 256;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs = 257;
|
||||||
|
static unsigned int defaultrcs = 256;
|
||||||
|
unsigned int selectionbg = 260;
|
||||||
|
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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
|
* https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
|
||||||
|
|
|
@ -1,44 +1,26 @@
|
||||||
From 0750c0b8c91579ec871c70c8990527bebc86a56e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Ashish Kumar Yadav <ashishkumar.yadav@students.iiserpune.ac.in>
|
|
||||||
Date: Sat, 31 Jul 2021 22:21:11 +0530
|
|
||||||
Subject: [PATCH] Add settings for selection-colors
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Additionally, a third setting *ingnoreselfg* exists. If true then the setting
|
|
||||||
*selectionfg* is ignored and the original foreground-colors of each cell are
|
|
||||||
not changed during selection. Basically only the background-color would change.
|
|
||||||
This might be more visually appealing to some folks.
|
|
||||||
---
|
|
||||||
config.def.h | 11 ++++++++---
|
|
||||||
st.h | 1 +
|
|
||||||
x.c | 30 +++++++++++++-----------------
|
|
||||||
3 files changed, 22 insertions(+), 20 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index 6f05dce..3679af8 100644
|
index 91ab8ca..a382605 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -119,18 +119,23 @@ static const char *colorname[] = {
|
@@ -119,7 +119,7 @@ static const char *colorname[] = {
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
"#cccccc",
|
"#cccccc",
|
||||||
- "#555555",
|
- "#555555",
|
||||||
+ "#2e3440",
|
+ "#2e3440",
|
||||||
|
"gray90", /* default foreground colour */
|
||||||
|
"black", /* default background colour */
|
||||||
};
|
};
|
||||||
|
@@ -127,12 +127,17 @@ static const char *colorname[] = {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
- * foreground, background, cursor, reverse cursor
|
- * foreground, background, cursor, reverse cursor
|
||||||
+ * foreground, background, cursor, reverse cursor, selection
|
+ * foreground, background, cursor, reverse cursor, selection
|
||||||
*/
|
*/
|
||||||
unsigned int defaultfg = 7;
|
unsigned int defaultfg = 258;
|
||||||
unsigned int defaultbg = 0;
|
unsigned int defaultbg = 259;
|
||||||
static unsigned int defaultcs = 256;
|
unsigned int defaultcs = 256;
|
||||||
-static unsigned int defaultrcs = 257;
|
-static unsigned int defaultrcs = 257;
|
||||||
+static unsigned int defaultrcs = 256;
|
+static unsigned int defaultrcs = 256;
|
||||||
+unsigned int selectionbg = 257;
|
+unsigned int selectionbg = 257;
|
||||||
|
@ -50,7 +32,7 @@ index 6f05dce..3679af8 100644
|
||||||
/*
|
/*
|
||||||
* Default shape of cursor
|
* Default shape of cursor
|
||||||
diff --git a/st.h b/st.h
|
diff --git a/st.h b/st.h
|
||||||
index 3d351b6..e1a28c3 100644
|
index fd3b0d8..1d56e54 100644
|
||||||
--- a/st.h
|
--- a/st.h
|
||||||
+++ b/st.h
|
+++ b/st.h
|
||||||
@@ -33,6 +33,7 @@ enum glyph_attribute {
|
@@ -33,6 +33,7 @@ enum glyph_attribute {
|
||||||
|
@ -62,10 +44,10 @@ index 3d351b6..e1a28c3 100644
|
||||||
};
|
};
|
||||||
|
|
||||||
diff --git a/x.c b/x.c
|
diff --git a/x.c b/x.c
|
||||||
index 210f184..7a6c70e 100644
|
index b36fb8c..bba8be5 100644
|
||||||
--- a/x.c
|
--- a/x.c
|
||||||
+++ b/x.c
|
+++ b/x.c
|
||||||
@@ -1425,6 +1425,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
@@ -1457,6 +1457,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||||
bg = temp;
|
bg = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +60,7 @@ index 210f184..7a6c70e 100644
|
||||||
if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
|
if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
|
||||||
fg = bg;
|
fg = bg;
|
||||||
|
|
||||||
@@ -1491,7 +1497,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
@@ -1523,7 +1529,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))
|
||||||
|
@ -87,7 +69,7 @@ index 210f184..7a6c70e 100644
|
||||||
xdrawglyph(og, ox, oy);
|
xdrawglyph(og, ox, oy);
|
||||||
|
|
||||||
if (IS_SET(MODE_HIDE))
|
if (IS_SET(MODE_HIDE))
|
||||||
@@ -1504,23 +1510,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
@@ -1536,23 +1542,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;
|
||||||
|
@ -116,7 +98,7 @@ index 210f184..7a6c70e 100644
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw the new one */
|
/* draw the new one */
|
||||||
@@ -1612,7 +1608,7 @@ xdrawline(Line line, int x1, int y1, int x2)
|
@@ -1659,7 +1655,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))
|
||||||
|
@ -125,6 +107,4 @@ index 210f184..7a6c70e 100644
|
||||||
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;
|
||||||
--
|
|
||||||
2.32.0
|
|
||||||
|
|
1
st.h
1
st.h
|
@ -35,6 +35,7 @@ enum glyph_attribute {
|
||||||
ATTR_WIDE = 1 << 9,
|
ATTR_WIDE = 1 << 9,
|
||||||
ATTR_WDUMMY = 1 << 10,
|
ATTR_WDUMMY = 1 << 10,
|
||||||
ATTR_BOXDRAW = 1 << 11,
|
ATTR_BOXDRAW = 1 << 11,
|
||||||
|
ATTR_SELECTED = 1 << 11,
|
||||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
30
x.c
30
x.c
|
@ -1523,6 +1523,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;
|
||||||
|
|
||||||
|
@ -1593,7 +1599,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
|
||||||
|
|
||||||
/* remove the old cursor */
|
/* remove the old cursor */
|
||||||
if (selected(ox, oy))
|
if (selected(ox, oy))
|
||||||
og.mode ^= ATTR_REVERSE;
|
og.mode |= ATTR_SELECTED;
|
||||||
|
|
||||||
/* Redraw the line where cursor was previously.
|
/* Redraw the line where cursor was previously.
|
||||||
* It will restore the ligatures broken by the cursor. */
|
* It will restore the ligatures broken by the cursor. */
|
||||||
|
@ -1609,23 +1615,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -1776,7 +1772,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)) {
|
||||||
numspecs = xmakeglyphfontspecs(specs, &line[ox], x - ox, ox, y1);
|
numspecs = xmakeglyphfontspecs(specs, &line[ox], x - ox, ox, y1);
|
||||||
xdrawglyphfontspecs(specs, base, numspecs, ox, y1);
|
xdrawglyphfontspecs(specs, base, numspecs, ox, y1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue