From ef994f3e6d0b59dcd7083a0f68a8f9fe73f96c6c Mon Sep 17 00:00:00 2001 From: bakkeby Date: Fri, 23 Oct 2020 10:14:00 +0200 Subject: [PATCH] Adding monochrome patch and anysize-nobar patch --- README.md | 8 ++++++++ patches.def.h | 15 +++++++++++++++ st.c | 24 ++++++++++++++++++++++++ x.c | 9 ++++++++- 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3b55cd..e5c53a3 100644 --- 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 index 07b7deb..7f9397f 100644 --- 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 index 6ce8c4e..491cc54 100644 --- 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 index 5f99b3d..7d8288f 100644 --- 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++;