mirror of
https://github.com/alrayyes/st
synced 2023-11-14 15:56:30 +00:00
feat: added xresources patch
This commit is contained in:
parent
15bbc038d5
commit
f97a902461
4
PKGBUILD
4
PKGBUILD
@ -19,6 +19,7 @@ _patches=("st-clipboard-0.8.3.diff"
|
|||||||
"st-alpha-0.8.2.diff"
|
"st-alpha-0.8.2.diff"
|
||||||
"st-ligatures-alpha-scrollback-20200430-0.8.3.diff"
|
"st-ligatures-alpha-scrollback-20200430-0.8.3.diff"
|
||||||
"st-font2-20190416-ba72400.diff"
|
"st-font2-20190416-ba72400.diff"
|
||||||
|
"st-xresources-20200604-9ba7ecf.diff"
|
||||||
)
|
)
|
||||||
|
|
||||||
source=("http://dl.suckless.org/st/st-$pkgver.tar.gz"
|
source=("http://dl.suckless.org/st/st-$pkgver.tar.gz"
|
||||||
@ -34,7 +35,8 @@ sha256sums=('d42d3ceceb4d6a65e32e90a5336e3d446db612c3fbd9ebc1780bc6c9a03346a6'
|
|||||||
'04e6a4696293f668260b2f54a7240e379dbfabbc209de07bd5d4d57e9f513360'
|
'04e6a4696293f668260b2f54a7240e379dbfabbc209de07bd5d4d57e9f513360'
|
||||||
'9c5b4b4f23de80de78ca5ec3739dc6ce5e7f72666186cf4a9c6b614ac90fb285'
|
'9c5b4b4f23de80de78ca5ec3739dc6ce5e7f72666186cf4a9c6b614ac90fb285'
|
||||||
'a7b3681d849fd8cca75cd38022a14fef2e26dc085bed1ebd8dcf0a65baa14898'
|
'a7b3681d849fd8cca75cd38022a14fef2e26dc085bed1ebd8dcf0a65baa14898'
|
||||||
'7279c787dba23d72a8a0a4613c0917e03d0087f0254f56a530cd9c521857d20b')
|
'7279c787dba23d72a8a0a4613c0917e03d0087f0254f56a530cd9c521857d20b'
|
||||||
|
'5be9b40d2b51761685f6503e92028a7858cc6571a8867b88612fce8a70514d5b')
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
cd $srcdir/st-$pkgver
|
cd $srcdir/st-$pkgver
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
- [[https://st.suckless.org/patches/scrollback/][scrollback-mouse]]
|
- [[https://st.suckless.org/patches/scrollback/][scrollback-mouse]]
|
||||||
- [[https://st.suckless.org/patches/scrollback/][scrollback-mouse-altscreen]]
|
- [[https://st.suckless.org/patches/scrollback/][scrollback-mouse-altscreen]]
|
||||||
- [[https://st.suckless.org/patches/vertcenter/][vertcenter]]
|
- [[https://st.suckless.org/patches/vertcenter/][vertcenter]]
|
||||||
|
- [[https://st.suckless.org/patches/xresources/][xresources]]
|
||||||
|
|
||||||
** Terminal-specific mappings
|
** Terminal-specific mappings
|
||||||
- Scroll through history -- Shift+PageUp/PageDown or Shift+Mouse wheel
|
- Scroll through history -- Shift+PageUp/PageDown or Shift+Mouse wheel
|
||||||
|
33
config.h
33
config.h
@ -169,6 +169,39 @@ static unsigned int mousebg = 0;
|
|||||||
*/
|
*/
|
||||||
static unsigned int defaultattr = 11;
|
static unsigned int defaultattr = 11;
|
||||||
|
|
||||||
|
ResourcePref resources[] = {
|
||||||
|
{ "font", STRING, &font },
|
||||||
|
{ "color0", STRING, &colorname[0] },
|
||||||
|
{ "color1", STRING, &colorname[1] },
|
||||||
|
{ "color2", STRING, &colorname[2] },
|
||||||
|
{ "color3", STRING, &colorname[3] },
|
||||||
|
{ "color4", STRING, &colorname[4] },
|
||||||
|
{ "color5", STRING, &colorname[5] },
|
||||||
|
{ "color6", STRING, &colorname[6] },
|
||||||
|
{ "color7", STRING, &colorname[7] },
|
||||||
|
{ "color8", STRING, &colorname[8] },
|
||||||
|
{ "color9", STRING, &colorname[9] },
|
||||||
|
{ "color10", STRING, &colorname[10] },
|
||||||
|
{ "color11", STRING, &colorname[11] },
|
||||||
|
{ "color12", STRING, &colorname[12] },
|
||||||
|
{ "color13", STRING, &colorname[13] },
|
||||||
|
{ "color14", STRING, &colorname[14] },
|
||||||
|
{ "color15", STRING, &colorname[15] },
|
||||||
|
{ "background", STRING, &colorname[256] },
|
||||||
|
{ "foreground", STRING, &colorname[257] },
|
||||||
|
{ "cursorColor", STRING, &colorname[258] },
|
||||||
|
{ "termname", STRING, &termname },
|
||||||
|
{ "shell", STRING, &shell },
|
||||||
|
{ "minlatency", INTEGER, &minlatency },
|
||||||
|
{ "maxlatency", INTEGER, &maxlatency },
|
||||||
|
{ "blinktimeout", INTEGER, &blinktimeout },
|
||||||
|
{ "bellvolume", INTEGER, &bellvolume },
|
||||||
|
{ "tabspaces", INTEGER, &tabspaces },
|
||||||
|
{ "borderpx", INTEGER, &borderpx },
|
||||||
|
{ "cwscale", FLOAT, &cwscale },
|
||||||
|
{ "chscale", FLOAT, &chscale },
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
||||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
||||||
|
@ -169,6 +169,39 @@ static unsigned int mousebg = 0;
|
|||||||
*/
|
*/
|
||||||
static unsigned int defaultattr = 11;
|
static unsigned int defaultattr = 11;
|
||||||
|
|
||||||
|
ResourcePref resources[] = {
|
||||||
|
{ "font", STRING, &font },
|
||||||
|
{ "color0", STRING, &colorname[0] },
|
||||||
|
{ "color1", STRING, &colorname[1] },
|
||||||
|
{ "color2", STRING, &colorname[2] },
|
||||||
|
{ "color3", STRING, &colorname[3] },
|
||||||
|
{ "color4", STRING, &colorname[4] },
|
||||||
|
{ "color5", STRING, &colorname[5] },
|
||||||
|
{ "color6", STRING, &colorname[6] },
|
||||||
|
{ "color7", STRING, &colorname[7] },
|
||||||
|
{ "color8", STRING, &colorname[8] },
|
||||||
|
{ "color9", STRING, &colorname[9] },
|
||||||
|
{ "color10", STRING, &colorname[10] },
|
||||||
|
{ "color11", STRING, &colorname[11] },
|
||||||
|
{ "color12", STRING, &colorname[12] },
|
||||||
|
{ "color13", STRING, &colorname[13] },
|
||||||
|
{ "color14", STRING, &colorname[14] },
|
||||||
|
{ "color15", STRING, &colorname[15] },
|
||||||
|
{ "background", STRING, &colorname[256] },
|
||||||
|
{ "foreground", STRING, &colorname[257] },
|
||||||
|
{ "cursorColor", STRING, &colorname[258] },
|
||||||
|
{ "termname", STRING, &termname },
|
||||||
|
{ "shell", STRING, &shell },
|
||||||
|
{ "minlatency", INTEGER, &minlatency },
|
||||||
|
{ "maxlatency", INTEGER, &maxlatency },
|
||||||
|
{ "blinktimeout", INTEGER, &blinktimeout },
|
||||||
|
{ "bellvolume", INTEGER, &bellvolume },
|
||||||
|
{ "tabspaces", INTEGER, &tabspaces },
|
||||||
|
{ "borderpx", INTEGER, &borderpx },
|
||||||
|
{ "cwscale", FLOAT, &cwscale },
|
||||||
|
{ "chscale", FLOAT, &chscale },
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
||||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
||||||
|
184
st-xresources-20200604-9ba7ecf.diff
Normal file
184
st-xresources-20200604-9ba7ecf.diff
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
From 2752a599ee01305a435729bfacf43b1dde7cf0ef Mon Sep 17 00:00:00 2001
|
||||||
|
From: Benji Encalada Mora <benji@encalada.dev>
|
||||||
|
Date: Thu, 4 Jun 2020 00:41:10 -0500
|
||||||
|
Subject: [PATCH] fix: replace xfps and actionfps variables
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 36 ++++++++++++++++++++++++
|
||||||
|
x.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||||
|
2 files changed, 110 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 6f05dce..9b99782 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -168,6 +168,42 @@ static unsigned int defaultattr = 11;
|
||||||
|
*/
|
||||||
|
static uint forcemousemod = ShiftMask;
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+ * Xresources preferences to load at startup
|
||||||
|
+ */
|
||||||
|
+ResourcePref resources[] = {
|
||||||
|
+ { "font", STRING, &font },
|
||||||
|
+ { "color0", STRING, &colorname[0] },
|
||||||
|
+ { "color1", STRING, &colorname[1] },
|
||||||
|
+ { "color2", STRING, &colorname[2] },
|
||||||
|
+ { "color3", STRING, &colorname[3] },
|
||||||
|
+ { "color4", STRING, &colorname[4] },
|
||||||
|
+ { "color5", STRING, &colorname[5] },
|
||||||
|
+ { "color6", STRING, &colorname[6] },
|
||||||
|
+ { "color7", STRING, &colorname[7] },
|
||||||
|
+ { "color8", STRING, &colorname[8] },
|
||||||
|
+ { "color9", STRING, &colorname[9] },
|
||||||
|
+ { "color10", STRING, &colorname[10] },
|
||||||
|
+ { "color11", STRING, &colorname[11] },
|
||||||
|
+ { "color12", STRING, &colorname[12] },
|
||||||
|
+ { "color13", STRING, &colorname[13] },
|
||||||
|
+ { "color14", STRING, &colorname[14] },
|
||||||
|
+ { "color15", STRING, &colorname[15] },
|
||||||
|
+ { "background", STRING, &colorname[256] },
|
||||||
|
+ { "foreground", STRING, &colorname[257] },
|
||||||
|
+ { "cursorColor", STRING, &colorname[258] },
|
||||||
|
+ { "termname", STRING, &termname },
|
||||||
|
+ { "shell", STRING, &shell },
|
||||||
|
+ { "minlatency", INTEGER, &minlatency },
|
||||||
|
+ { "maxlatency", INTEGER, &maxlatency },
|
||||||
|
+ { "blinktimeout", INTEGER, &blinktimeout },
|
||||||
|
+ { "bellvolume", INTEGER, &bellvolume },
|
||||||
|
+ { "tabspaces", INTEGER, &tabspaces },
|
||||||
|
+ { "borderpx", INTEGER, &borderpx },
|
||||||
|
+ { "cwscale", FLOAT, &cwscale },
|
||||||
|
+ { "chscale", FLOAT, &chscale },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Internal mouse shortcuts.
|
||||||
|
* Beware that overloading Button1 will disable the selection.
|
||||||
|
diff --git a/x.c b/x.c
|
||||||
|
index 210f184..76f167f 100644
|
||||||
|
--- a/x.c
|
||||||
|
+++ b/x.c
|
||||||
|
@@ -14,6 +14,7 @@
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
#include <X11/XKBlib.h>
|
||||||
|
+#include <X11/Xresource.h>
|
||||||
|
|
||||||
|
char *argv0;
|
||||||
|
#include "arg.h"
|
||||||
|
@@ -45,6 +46,19 @@ typedef struct {
|
||||||
|
signed char appcursor; /* application cursor */
|
||||||
|
} Key;
|
||||||
|
|
||||||
|
+/* Xresources preferences */
|
||||||
|
+enum resource_type {
|
||||||
|
+ STRING = 0,
|
||||||
|
+ INTEGER = 1,
|
||||||
|
+ FLOAT = 2
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ char *name;
|
||||||
|
+ enum resource_type type;
|
||||||
|
+ void *dst;
|
||||||
|
+} ResourcePref;
|
||||||
|
+
|
||||||
|
/* X modifiers */
|
||||||
|
#define XK_ANY_MOD UINT_MAX
|
||||||
|
#define XK_NO_MOD 0
|
||||||
|
@@ -828,8 +842,8 @@ xclear(int x1, int y1, int x2, int y2)
|
||||||
|
void
|
||||||
|
xhints(void)
|
||||||
|
{
|
||||||
|
- XClassHint class = {opt_name ? opt_name : termname,
|
||||||
|
- opt_class ? opt_class : termname};
|
||||||
|
+ XClassHint class = {opt_name ? opt_name : "st",
|
||||||
|
+ opt_class ? opt_class : "St"};
|
||||||
|
XWMHints wm = {.flags = InputHint, .input = 1};
|
||||||
|
XSizeHints *sizeh;
|
||||||
|
|
||||||
|
@@ -1104,8 +1118,6 @@ xinit(int cols, int rows)
|
||||||
|
pid_t thispid = getpid();
|
||||||
|
XColor xmousefg, xmousebg;
|
||||||
|
|
||||||
|
- if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
|
- die("can't open display\n");
|
||||||
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
|
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||||
|
|
||||||
|
@@ -1964,6 +1976,59 @@ run(void)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+int
|
||||||
|
+resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
||||||
|
+{
|
||||||
|
+ char **sdst = dst;
|
||||||
|
+ int *idst = dst;
|
||||||
|
+ float *fdst = dst;
|
||||||
|
+
|
||||||
|
+ char fullname[256];
|
||||||
|
+ char fullclass[256];
|
||||||
|
+ char *type;
|
||||||
|
+ XrmValue ret;
|
||||||
|
+
|
||||||
|
+ snprintf(fullname, sizeof(fullname), "%s.%s",
|
||||||
|
+ opt_name ? opt_name : "st", name);
|
||||||
|
+ snprintf(fullclass, sizeof(fullclass), "%s.%s",
|
||||||
|
+ opt_class ? opt_class : "St", name);
|
||||||
|
+ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0';
|
||||||
|
+
|
||||||
|
+ XrmGetResource(db, fullname, fullclass, &type, &ret);
|
||||||
|
+ if (ret.addr == NULL || strncmp("String", type, 64))
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
+ switch (rtype) {
|
||||||
|
+ case STRING:
|
||||||
|
+ *sdst = ret.addr;
|
||||||
|
+ break;
|
||||||
|
+ case INTEGER:
|
||||||
|
+ *idst = strtoul(ret.addr, NULL, 10);
|
||||||
|
+ break;
|
||||||
|
+ case FLOAT:
|
||||||
|
+ *fdst = strtof(ret.addr, NULL);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+config_init(void)
|
||||||
|
+{
|
||||||
|
+ char *resm;
|
||||||
|
+ XrmDatabase db;
|
||||||
|
+ ResourcePref *p;
|
||||||
|
+
|
||||||
|
+ XrmInitialize();
|
||||||
|
+ resm = XResourceManagerString(xw.dpy);
|
||||||
|
+ if (!resm)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ db = XrmGetStringDatabase(resm);
|
||||||
|
+ for (p = resources; p < resources + LEN(resources); p++)
|
||||||
|
+ resource_load(db, p->name, p->type, p->dst);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
@@ -2037,6 +2102,11 @@ run:
|
||||||
|
|
||||||
|
setlocale(LC_CTYPE, "");
|
||||||
|
XSetLocaleModifiers("");
|
||||||
|
+
|
||||||
|
+ if(!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
|
+ die("Can't open display\n");
|
||||||
|
+
|
||||||
|
+ config_init();
|
||||||
|
cols = MAX(cols, 1);
|
||||||
|
rows = MAX(rows, 1);
|
||||||
|
tnew(cols, rows);
|
||||||
|
--
|
||||||
|
2.26.2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user