commit ef994f3e6d0b59dcd7083a0f68a8f9fe73f96c6c
parent 8faa9f3c93cf2de93e03f0214baab15c3d7192cf
Author: bakkeby <bakkeby@gmail.com>
Date: Fri, 23 Oct 2020 10:14:00 +0200
Adding monochrome patch and anysize-nobar patch
Diffstat:
4 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
+2020-10-23 - Added the monochrome patch
+
2020-08-08 - Re-added the visualbell patch
2020-06-26 - Added the single drawable buffer patch as per the FAQ in order to get w3m images to display
@@ -53,6 +55,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [anysize](https://st.suckless.org/patches/anysize/)
- allows st to reize to any pixel size rather than snapping to character width / height
+ - [anysize_nobar](https://github.com/connor-brooks/st-anysize-nobar)
+ - a patch that aims to prevent black bars being drawn on the edges of st terminals using the anysize patch
+
- [bold-is-not-bright](https://st.suckless.org/patches/bold-is-not-bright/)
- by default bold text is rendered with a bold font in the bright variant of the current color
- this patch makes bold text rendered simply as bold, leaving the color unaffected
@@ -108,6 +113,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [ligatures](https://st.suckless.org/patches/ligatures/)
- adds support for drawing ligatures using the Harfbuzz library to transform original text of a single line to a list of glyphs with ligatures included
+ - [monochrome](https://www.reddit.com/r/suckless/comments/ixbx6z/how_to_use_black_and_white_only_for_st/)
+ - makes st ignore terminal color attributes to make for a monochrome look
+
- [newterm](https://st.suckless.org/patches/newterm/)
- allows you to spawn a new st terminal using Ctrl-Shift-Return
- it will have the same CWD (current working directory) as the original st instance
diff --git a/patches.def.h b/patches.def.h
@@ -21,6 +21,15 @@
*/
#define ANYSIZE_PATCH 0
+/* This patch aims to prevent black bars being drawn on the edges of st terminals using the anysize
+ * patch. This generally only occurs when the terminal background color doesn't match the colors
+ * set in st's config.h file, for example when using terminal theming scripts such as base16.
+ * (I have not found this to be working, but adding for reference. May reduce flickering on
+ * terminal resizes.)
+ * https://github.com/connor-brooks/st-anysize-nobar
+ */
+#define ANYSIZE_NOBAR_PATCH 0
+
/* By default bold text is rendered with a bold font in the bright variant of the current color.
* This patch makes bold text rendered simply as bold, leaving the color unaffected.
* https://st.suckless.org/patches/bold-is-not-bright/
@@ -137,6 +146,12 @@
*/
#define LIGATURES_PATCH 0
+/* This patch makes st ignore terminal color attributes by forcing display of the default
+ * foreground and background colors only - making for a monochrome look. Idea ref.
+ * https://www.reddit.com/r/suckless/comments/ixbx6z/how_to_use_black_and_white_only_for_st/
+ */
+#define MONOCHROME_PATCH 0
+
/* This patch allows you to spawn a new st terminal using Ctrl-Shift-Return. It will have the
* same CWD (current working directory) as the original st instance.
* https://st.suckless.org/patches/newterm/
diff --git a/st.c b/st.c
@@ -1576,27 +1576,51 @@ tsetattr(int *attr, int l)
break;
case 38:
if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ #if MONOCHROME_PATCH
+ term.c.attr.fg = defaultfg;
+ #else
term.c.attr.fg = idx;
+ #endif // MONOCHROME_PATCH
break;
case 39:
term.c.attr.fg = defaultfg;
break;
case 48:
if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ #if MONOCHROME_PATCH
+ term.c.attr.bg = 0;
+ #else
term.c.attr.bg = idx;
+ #endif // MONOCHROME_PATCH
break;
case 49:
term.c.attr.bg = defaultbg;
break;
default:
if (BETWEEN(attr[i], 30, 37)) {
+ #if MONOCHROME_PATCH
+ term.c.attr.fg = defaultfg;
+ #else
term.c.attr.fg = attr[i] - 30;
+ #endif // MONOCHROME_PATCH
} else if (BETWEEN(attr[i], 40, 47)) {
+ #if MONOCHROME_PATCH
+ term.c.attr.bg = 0;
+ #else
term.c.attr.bg = attr[i] - 40;
+ #endif // MONOCHROME_PATCH
} else if (BETWEEN(attr[i], 90, 97)) {
+ #if MONOCHROME_PATCH
+ term.c.attr.fg = defaultfg;
+ #else
term.c.attr.fg = attr[i] - 90 + 8;
+ #endif // MONOCHROME_PATCH
} else if (BETWEEN(attr[i], 100, 107)) {
+ #if MONOCHROME_PATCH
+ term.c.attr.bg = 0;
+ #else
term.c.attr.bg = attr[i] - 100 + 8;
+ #endif // MONOCHROME_PATCH
} else {
fprintf(stderr,
"erresc(default): gfx attr %d unknown\n",
diff --git a/x.c b/x.c
@@ -1752,7 +1752,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
xclear(winx, winy + win.ch, winx + width, win.h);
#endif // ANYSIZE_PATCH
- /* Clean up the region we want to draw to. */
+ // /* Clean up the region we want to draw to. */
XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
/* Set the clip region because Xft is sometimes dirty. */
@@ -2394,6 +2394,13 @@ run(void)
}
}
+ #if ANYSIZE_NOBAR_PATCH
+ /* Refresh before drawing */
+ cresize(0, 0);
+ redraw();
+ xhints();
+ #endif // ANYSIZE_NOBAR_PATCH
+
#if VISUALBELL_1_PATCH
if (bellon) {
bellon++;