summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h3
-rw-r--r--patches_applied/st-alpha-osc11-20220222-0.8.5.diff142
-rw-r--r--todo.org98
-rw-r--r--x.c43
4 files changed, 259 insertions, 27 deletions
diff --git a/config.def.h b/config.def.h
index fee00f9..eb24bcc 100644
--- a/config.def.h
+++ b/config.def.h
@@ -93,6 +93,9 @@ char *termname = "st-256color";
*/
unsigned int tabspaces = 8;
+/* bg opacity */
+float alpha = 0.8;
+
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
diff --git a/patches_applied/st-alpha-osc11-20220222-0.8.5.diff b/patches_applied/st-alpha-osc11-20220222-0.8.5.diff
new file mode 100644
index 0000000..09a5533
--- /dev/null
+++ b/patches_applied/st-alpha-osc11-20220222-0.8.5.diff
@@ -0,0 +1,142 @@
+From f4c164a63fc34c9989af15db3c10e6b658586804 Mon Sep 17 00:00:00 2001
+From: Santtu Lakkala <inz@inz.fi>
+Date: Wed, 16 Feb 2022 21:23:44 +0200
+Subject: [PATCH] Alpha background
+
+Building on previous patches, but also apply alpha to the OSC 11, set
+background, sequence.
+---
+ config.def.h | 3 +++
+ x.c | 43 +++++++++++++++++++++++++++++++++----------
+ 2 files changed, 36 insertions(+), 10 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 91ab8ca..6af616e 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -93,6 +93,9 @@ char *termname = "st-256color";
+ */
+ unsigned int tabspaces = 8;
+
++/* bg opacity */
++float alpha = 0.8;
++
+ /* Terminal colors (16 first used in escape sequence) */
+ static const char *colorname[] = {
+ /* 8 normal colors */
+diff --git a/x.c b/x.c
+index 8a16faa..812af66 100644
+--- a/x.c
++++ b/x.c
+@@ -105,6 +105,7 @@ typedef struct {
+ XSetWindowAttributes attrs;
+ int scr;
+ int isfixed; /* is fixed geometry? */
++ int depth; /* bit depth */
+ int l, t; /* left and top offset */
+ int gm; /* geometry mask */
+ } XWindow;
+@@ -736,7 +737,7 @@ xresize(int col, int row)
+
+ XFreePixmap(xw.dpy, xw.buf);
+ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
+- DefaultDepth(xw.dpy, xw.scr));
++ xw.depth);
+ XftDrawChange(xw.draw, xw.buf);
+ xclear(0, 0, win.w, win.h);
+
+@@ -796,6 +797,10 @@ xloadcols(void)
+ else
+ die("could not allocate color %d\n", i);
+ }
++
++ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
++ dc.col[defaultbg].pixel &= 0x00FFFFFF;
++ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
+ loaded = 1;
+ }
+
+@@ -826,6 +831,12 @@ xsetcolorname(int x, const char *name)
+ XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]);
+ dc.col[x] = ncolor;
+
++ if (x == defaultbg) {
++ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
++ dc.col[defaultbg].pixel &= 0x00FFFFFF;
++ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
++ }
++
+ return 0;
+ }
+
+@@ -1118,11 +1129,23 @@ xinit(int cols, int rows)
+ Window parent;
+ pid_t thispid = getpid();
+ XColor xmousefg, xmousebg;
++ XWindowAttributes attr;
++ XVisualInfo vis;
+
+ if (!(xw.dpy = XOpenDisplay(NULL)))
+ die("can't open display\n");
+ xw.scr = XDefaultScreen(xw.dpy);
+- xw.vis = XDefaultVisual(xw.dpy, xw.scr);
++
++ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
++ parent = XRootWindow(xw.dpy, xw.scr);
++ xw.depth = 32;
++ } else {
++ XGetWindowAttributes(xw.dpy, parent, &attr);
++ xw.depth = attr.depth;
++ }
++
++ XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
++ xw.vis = vis.visual;
+
+ /* font */
+ if (!FcInit())
+@@ -1132,7 +1155,7 @@ xinit(int cols, int rows)
+ xloadfonts(usedfont, 0);
+
+ /* colors */
+- xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
++ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
+ xloadcols();
+
+ /* adjust fixed window geometry */
+@@ -1152,19 +1175,15 @@ xinit(int cols, int rows)
+ | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
+ xw.attrs.colormap = xw.cmap;
+
+- if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
+- parent = XRootWindow(xw.dpy, xw.scr);
+ xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
+- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
++ win.w, win.h, 0, xw.depth, InputOutput,
+ xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
+ | CWEventMask | CWColormap, &xw.attrs);
+
+ memset(&gcvalues, 0, sizeof(gcvalues));
+ gcvalues.graphics_exposures = False;
+- dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
+- &gcvalues);
+- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
+- DefaultDepth(xw.dpy, xw.scr));
++ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
++ dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
+ XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
+ XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
+
+@@ -2019,6 +2038,10 @@ main(int argc, char *argv[])
+ case 'a':
+ allowaltscreen = 0;
+ break;
++ case 'A':
++ alpha = strtof(EARGF(usage()), NULL);
++ LIMIT(alpha, 0.0, 1.0);
++ break;
+ case 'c':
+ opt_class = EARGF(usage());
+ break;
+--
+2.32.0
+
diff --git a/todo.org b/todo.org
index d2bc0c7..5c2e314 100644
--- a/todo.org
+++ b/todo.org
@@ -1,18 +1,67 @@
ST Patches
* ST Patches Open Work
-** TODO [#A] allows alpha transparency
-st-alpha-osc11-20220222-0.8.5.diff
-** TODO [#A] allows ligatures (must be applied after alpha and scrollback)
-st-ligatures-alpha-scrollback-20230105-0.9.diff
-** TODO [#B] allows setting of size of ST via the -G parameter
-st-anygeometry-0.8.1.diff
+** TODO [#A] ligatures (apply after alpha and scrollback)
+*** Description and URL
+This patch adds proper drawing of ligatures.
+The code uses Harfbuzz library to transform original text of a single line to a list of glyphs with ligatures included.
+
+Note
+ The patch adds additional dependency on Harfbuzz library and headers.
+ Original patch was made for vanilla version of ST from latest master commit. It is not 100% compatible with Scrollback and Alpha patches, so I made modified versions that you can apply on top of a Scrollback and/or Alpha patch.
+ Due to some limitations in drawing engine, ligatures will break when crossing colors, font styles or selection. They will still render properly as separate symbols, just not as ligatures.
+ Since 0.8.4 patch, there's now a way to enable additional font rendering features. Look into features array in hb.c for details.
+Boxdraw
+
+ The original patch does not work very well with the boxdraw patch. Since it requires some additional changes in the code to make ligatures compatible with boxdraw, a special version of the patch was added, that you can apply on top of the boxdraw patch.
+ It does not include Alpha or Scrollback patches.
+
+https://st.suckless.org/patches/ligatures/
+https://st.suckless.org/patches/ligatures/0.9/st-ligatures-alpha-scrollback-20230105-0.9.diff
+** TODO [#B] externalpipe
+*** Description and URLs
+Reading and writing st's screen through a pipe.
+Example
+
+config.h example, binding TERMMOD + U to extract all visible URLs and present dmenu to select and open one:
+
+static char *openurlcmd[] = { "/bin/sh", "-c",
+ "xurls | dmenu -l 10 -w $WINDOWID | xargs -r open",
+ "externalpipe", NULL };
+Shortcut shortcuts[] = {
+ ...
+ { TERMMOD, XK_U, externalpipe, { .v = openurlcmd } },
+};
+
+(xurls and open are external scripts)
+xurls: https://raw.github.com/bobrippling/perlbin/master/xurls
+open: https://github.com/bobrippling/open
+Example Shell Scripts
+
+ link grabber - similar to the function above, but without xurls dependency
+ https://st.suckless.org/patches/externalpipe/linkgrabber.sh
+ edit screen - open screen in $EDITOR for copying text
+ https://st.suckless.org/patches/externalpipe/editscreen.sh
+
+https://st.suckless.org/patches/externalpipe/
+https://st.suckless.org/patches/externalpipe/st-externalpipe-0.8.4.diff
+** TODO [#A] font2 (fallback font for glyphs + emojis)
+st-font2-0.8.5.diff
+** TODO [#A] right-click sends paste
+st-rightclickpaste-0.8.2.diff
+** TODO [#B] xresources with signal reloading
+*** Description and URLs
+This patch adds the ability to configure st via Xresources and signal reloading. This patch is not based on xresources patch and is extended from xst's commit on github.
+You can basically pass a USR1 signal to all st processes after updating your Xresources to reload the settings: ` pidof st | xargs kill -s USR1 `
+
+https://st.suckless.org/patches/xresources-with-reload-signal/
+https://st.suckless.org/patches/xresources-with-reload-signal/st-xresources-signal-reloading-20220407-ef05519.diff
** TODO [#B] swaps the color of the background with the character the cursor is on
st-dynamic-cursor-color-0.9.diff
-** TODO [#B] read and write st's screen via a pipe
-st-externalpipe-0.8.4.diff
-** TODO [#A] fallback font (for glyphs + emojis)
-st-font2-0.8.5.diff
-** TODO [#B] colorschemes
+** TODO [#C] .desktop entry
+st-desktopentry-0.8.5.diff
+** TODO [#C] netwmicon
+st-netwmicon-0.8.5-v2.diff
+** TODO [#C] colorschemes
This patch adds multiple color schemes and lets you change them without having to restart st.
Predefined color schemes:
@@ -37,15 +86,30 @@ Key bindings
https://st.suckless.org/patches/colorschemes/
https://st.suckless.org/patches/colorschemes/st-colorschemes-0.8.5.diff
-** TODO [#C] .desktop entry and icon
-st-netwmicon-0.8.5-v2.diff
-st-desktopentry-0.8.5.diff
-** TODO [#C] right-click sends paste
-st-rightclickpaste-0.8.2.diff
** TODO [#D] allows for 2 transparencies: based on window focus state
st-focus-20200731-patch_alpha.diff
-
* ST Patches Completed
+** DONE [#A] alpha
+*** 2023-07-23 @ 15:00:52 -0500 Patch applied successfully without issue
+*** Patch Description and URL
+This patch allows users to change the opacity of the background. Note that you need an X composite manager (e.g. compton, xcompmgr) to make this patch effective.
+Notes
+
+ The alpha value affects the default background only.
+ The color designated by 'defaultbg' should not be used elsewhere.
+ Embedding might fail after applying this patch.
+
+Changes in 0.8.2
+
+ The internal method for querying X visual is changed. St will respect the visual of its parent window, allowing it to be embedded easily.
+ Opacity value is now typed in float.
+ -A option is added to allow changing the opacity value without compiling.
+
+https://st.suckless.org/patches/alpha/
+https://st.suckless.org/patches/alpha/st-alpha-osc11-20220222-0.8.5.diff
+*** A Note on OSC 11
+'\e]11;?\007' can be used to query the background color of a terminal (OSC 11).
+OSC 11 is used by Neovim to automatically set its background setting to "dark" or "light".
** DONE [#A] prefers system (browser) clipboard instead of terminal clipboard
*** 2023-07-23 @ 13:56:02 -0500 patch applied successfully w/o issue
*** Description and URL
diff --git a/x.c b/x.c
index 66ccab0..821e81e 100644
--- a/x.c
+++ b/x.c
@@ -106,6 +106,7 @@ typedef struct {
XSetWindowAttributes attrs;
int scr;
int isfixed; /* is fixed geometry? */
+ int depth; /* bit depth */
int l, t; /* left and top offset */
int gm; /* geometry mask */
} XWindow;
@@ -755,7 +756,7 @@ xresize(int col, int row)
XFreePixmap(xw.dpy, xw.buf);
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
- DefaultDepth(xw.dpy, xw.scr));
+ xw.depth);
XftDrawChange(xw.draw, xw.buf);
xclear(0, 0, win.w, win.h);
@@ -815,6 +816,10 @@ xloadcols(void)
else
die("could not allocate color %d\n", i);
}
+
+ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
+ dc.col[defaultbg].pixel &= 0x00FFFFFF;
+ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
loaded = 1;
}
@@ -845,6 +850,12 @@ xsetcolorname(int x, const char *name)
XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]);
dc.col[x] = ncolor;
+ if (x == defaultbg) {
+ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
+ dc.col[defaultbg].pixel &= 0x00FFFFFF;
+ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
+ }
+
return 0;
}
@@ -1137,11 +1148,23 @@ xinit(int cols, int rows)
Window parent;
pid_t thispid = getpid();
XColor xmousefg, xmousebg;
+ XWindowAttributes attr;
+ XVisualInfo vis;
if (!(xw.dpy = XOpenDisplay(NULL)))
die("can't open display\n");
xw.scr = XDefaultScreen(xw.dpy);
- xw.vis = XDefaultVisual(xw.dpy, xw.scr);
+
+ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
+ parent = XRootWindow(xw.dpy, xw.scr);
+ xw.depth = 32;
+ } else {
+ XGetWindowAttributes(xw.dpy, parent, &attr);
+ xw.depth = attr.depth;
+ }
+
+ XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
+ xw.vis = vis.visual;
/* font */
if (!FcInit())
@@ -1151,7 +1174,7 @@ xinit(int cols, int rows)
xloadfonts(usedfont, 0);
/* colors */
- xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
+ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
xloadcols();
/* adjust fixed window geometry */
@@ -1171,19 +1194,15 @@ xinit(int cols, int rows)
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
xw.attrs.colormap = xw.cmap;
- if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
- parent = XRootWindow(xw.dpy, xw.scr);
xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
+ win.w, win.h, 0, xw.depth, InputOutput,
xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
| CWEventMask | CWColormap, &xw.attrs);
memset(&gcvalues, 0, sizeof(gcvalues));
gcvalues.graphics_exposures = False;
- dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
- &gcvalues);
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
- DefaultDepth(xw.dpy, xw.scr));
+ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
+ dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
@@ -2041,6 +2060,10 @@ main(int argc, char *argv[])
case 'a':
allowaltscreen = 0;
break;
+ case 'A':
+ alpha = strtof(EARGF(usage()), NULL);
+ LIMIT(alpha, 0.0, 1.0);
+ break;
case 'c':
opt_class = EARGF(usage());
break;