Move patches and readd .Xresources patch
This commit is contained in:
parent
482279846d
commit
ad5e5c4004
|
@ -18,10 +18,4 @@
|
|||
!/win.h
|
||||
!/x.c
|
||||
|
||||
!/st-anysize-0.8.1.diff
|
||||
!/st-blinking_cursor-20200531-a2a7044.diff
|
||||
!/st-clipboard-0.8.3.diff
|
||||
!/st-dracula-0.8.2.diff
|
||||
!/st-hidecursor-0.8.3.diff
|
||||
!/st-scrollback-20200419-72e3f6c.diff
|
||||
!/st-scrollback-mouse-20191024-a2c479c.diff
|
||||
!/patches/
|
||||
|
|
44
config.def.h
44
config.def.h
|
@ -129,8 +129,8 @@ static const char *colorname[] = {
|
|||
*/
|
||||
unsigned int defaultfg = 257;
|
||||
unsigned int defaultbg = 256;
|
||||
static unsigned int defaultcs = 258;
|
||||
static unsigned int defaultrcs = 259;
|
||||
unsigned int defaultcs = 258;
|
||||
unsigned int defaultrcs = 259;
|
||||
|
||||
/*
|
||||
* Colors used, when the specific fg == defaultfg. So in reverse mode this
|
||||
|
@ -183,6 +183,39 @@ 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] },
|
||||
{ "cursor", STRING, &colorname[258] },
|
||||
{ "text", STRING, &colorname[259] },
|
||||
{ "termName", STRING, &termname },
|
||||
{ "shell", STRING, &shell },
|
||||
{ "tabspaces", INTEGER, &tabspaces },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
{ "cwscale", FLOAT, &cwscale },
|
||||
{ "chscale", FLOAT, &chscale },
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal mouse shortcuts.
|
||||
* Beware that overloading Button1 will disable the selection.
|
||||
|
@ -219,6 +252,7 @@ static Shortcut shortcuts[] = {
|
|||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
||||
{ TERMMOD, XK_X, invert, { } },
|
||||
{ TERMMOD, XK_R, forceRedraw, { } },
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -487,6 +521,6 @@ static uint selmasks[] = {
|
|||
* of single wide characters.
|
||||
*/
|
||||
static char ascii_printable[] =
|
||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
From 66520e1c3b0a6f30ce1cde033a1aec04e5a0f1a2 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Tenllado <ctenllado@gmail.com>
|
||||
Date: Sat, 18 Apr 2020 09:26:46 +0200
|
||||
Subject: [PATCH] OSC 10/11/12 fg, bg and cursor colors
|
||||
|
||||
Support for OSC escape sequences 10, 11 and 12 to modify the bg, fg and
|
||||
cursor colors. I selected entries in the colorname table after the 255
|
||||
position for defaultfg, defaultbg and defaultcs
|
||||
---
|
||||
config.def.h | 4 ++--
|
||||
st.c | 17 ++++++++++++++---
|
||||
st.h | 1 +
|
||||
3 files changed, 17 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 546edda..7d20fdf 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -118,8 +118,8 @@ static const char *colorname[] = {
|
||||
*/
|
||||
unsigned int defaultfg = 7;
|
||||
unsigned int defaultbg = 0;
|
||||
-static unsigned int defaultcs = 256;
|
||||
-static unsigned int defaultrcs = 257;
|
||||
+unsigned int defaultcs = 256;
|
||||
+unsigned int defaultrcs = 257;
|
||||
|
||||
/*
|
||||
* Default shape of cursor
|
||||
diff --git a/st.c b/st.c
|
||||
index 3e48410..ec7970c 100644
|
||||
--- a/st.c
|
||||
+++ b/st.c
|
||||
@@ -1862,12 +1862,23 @@ strhandle(void)
|
||||
}
|
||||
return;
|
||||
case 4: /* color set */
|
||||
- if (narg < 3)
|
||||
+ case 10: /* foreground set */
|
||||
+ case 11: /* background set */
|
||||
+ case 12: /* cursor color */
|
||||
+ if ((par == 4 && narg < 3) || narg < 2)
|
||||
break;
|
||||
- p = strescseq.args[2];
|
||||
+ p = strescseq.args[((par == 4) ? 2 : 1)];
|
||||
/* FALLTHROUGH */
|
||||
case 104: /* color reset, here p = NULL */
|
||||
- j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
|
||||
+ if (par == 10)
|
||||
+ j = defaultfg;
|
||||
+ else if (par == 11)
|
||||
+ j = defaultbg;
|
||||
+ else if (par == 12)
|
||||
+ j = defaultcs;
|
||||
+ else
|
||||
+ j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
|
||||
+
|
||||
if (xsetcolorname(j, p)) {
|
||||
if (par == 104 && narg <= 1)
|
||||
return; /* color reset without parameter */
|
||||
diff --git a/st.h b/st.h
|
||||
index a1928ca..bd79875 100644
|
||||
--- a/st.h
|
||||
+++ b/st.h
|
||||
@@ -121,3 +121,4 @@ extern char *termname;
|
||||
extern unsigned int tabspaces;
|
||||
extern unsigned int defaultfg;
|
||||
extern unsigned int defaultbg;
|
||||
+extern unsigned int defaultcs;
|
||||
--
|
||||
2.20.1
|
||||
|
|
@ -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
|
||||
|
15
st.c
15
st.c
|
@ -1932,12 +1932,23 @@ strhandle(void)
|
|||
}
|
||||
return;
|
||||
case 4: /* color set */
|
||||
if (narg < 3)
|
||||
case 10: /* foreground set */
|
||||
case 11: /* background set */
|
||||
case 12: /* cursor color */
|
||||
if ((par == 4 && narg < 3) || narg < 2)
|
||||
break;
|
||||
p = strescseq.args[2];
|
||||
p = strescseq.args[((par == 4) ? 2 : 1)];
|
||||
/* FALLTHROUGH */
|
||||
case 104: /* color reset, here p = NULL */
|
||||
if (par == 10)
|
||||
j = defaultfg;
|
||||
else if (par == 11)
|
||||
j = defaultbg;
|
||||
else if (par == 12)
|
||||
j = defaultcs;
|
||||
else
|
||||
j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
|
||||
|
||||
if (xsetcolorname(j, p)) {
|
||||
if (par == 104 && narg <= 1)
|
||||
return; /* color reset without parameter */
|
||||
|
|
1
st.h
1
st.h
|
@ -125,3 +125,4 @@ extern char *termname;
|
|||
extern unsigned int tabspaces;
|
||||
extern unsigned int defaultfg;
|
||||
extern unsigned int defaultbg;
|
||||
extern unsigned int defaultcs;
|
||||
|
|
85
x.c
85
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
|
||||
|
@ -60,6 +74,7 @@ static void zoomabs(const Arg *);
|
|||
static void zoomreset(const Arg *);
|
||||
static void ttysend(const Arg *);
|
||||
static void invert(const Arg *);
|
||||
static void forceRedraw(const Arg *);
|
||||
|
||||
/* config.h for applying patches and the configuration. */
|
||||
#include "config.h"
|
||||
|
@ -263,6 +278,12 @@ static int invertcolors = 0;
|
|||
static int oldbutton = 3; /* button event on startup: 3 = release */
|
||||
static int cursorblinks = 0;
|
||||
|
||||
void
|
||||
forceRedraw(const Arg *dummy)
|
||||
{
|
||||
redraw();
|
||||
}
|
||||
|
||||
void
|
||||
invert(const Arg *dummy)
|
||||
{
|
||||
|
@ -870,8 +891,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;
|
||||
|
||||
|
@ -1146,8 +1167,6 @@ xinit(int cols, int rows)
|
|||
XColor xmousefg, xmousebg;
|
||||
Pixmap blankpm;
|
||||
|
||||
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||
die("can't open display\n");
|
||||
xw.scr = XDefaultScreen(xw.dpy);
|
||||
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||
|
||||
|
@ -2046,6 +2065,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)
|
||||
{
|
||||
|
@ -2119,6 +2191,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);
|
||||
|
|
Loading…
Reference in New Issue