Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/st-xrdb: new aport (based on main/st, with XRDB support)

From: Steffen Nurpmeso <steffen_at_sdaoden.eu>
Date: Mon, 11 Mar 2019 19:31:34 +0100

---
 testing/st-xrdb/APKBUILD      |  36 ++++++
 testing/st-xrdb/st-xrdb.patch | 209 ++++++++++++++++++++++++++++++++++
 2 files changed, 245 insertions(+)
 create mode 100644 testing/st-xrdb/APKBUILD
 create mode 100644 testing/st-xrdb/st-xrdb.patch
diff --git a/testing/st-xrdb/APKBUILD b/testing/st-xrdb/APKBUILD
new file mode 100644
index 0000000..95239d8
--- /dev/null
+++ b/testing/st-xrdb/APKBUILD
_at_@ -0,0 +1,36 @@
+# Base-Contributor: Sören Tempel <soeren+alpine_at_soeren-tempel.net>
+# Base-Maintainer: Natanael Copa <ncopa_at_alpinelinux.org>
+# Maintainer: Steffen Nurpmeso <steffen_at_sdaoden.eu>
+pkgname=st-xrdb
+pkgname_base=st
+pkgver=0.8.2
+pkgrel=0
+pkgdesc="Simple terminal emulator for X, with X resource support"
+url="https://st.suckless.org"
+arch="all"
+license="MIT"
+depends="ncurses-terminfo"
+makedepends="fontconfig-dev freetype-dev libx11-dev libxext-dev libxft-dev"
+subpackages="$pkgname-doc $pkgname-dbg"
+source="https://dl.suckless.org/$pkgname_base/$pkgname_base-$pkgver.tar.gz st-xrdb.patch"
+options="!check"
+builddir="$srcdir/$pkgname_base-$pkgver"
+
+prepare() {
+	default_prepare
+	cd "$builddir"
+	sed -i '/tic/d' Makefile
+}
+
+build() {
+	make -C "$builddir"
+}
+
+package() {
+	cd "$builddir"
+
+	make install PREFIX=/usr DESTDIR="$pkgdir"
+}
+
+sha512sums="eaaf5f2fe050ee768d16a9c8c295ba13315775b3a8a3201e020237a3dd217bfb811832d58477249000596289a6cb3287fbb39d6327fc90986af1c363e4b5bf8d  st-0.8.2.tar.gz
+1b21e819d187eb186f940d92dd9055de5259bf18bc9c798b10884fde949ff3ab6b9ecf428c85ccd0bc0e20ddf42cc9d015535b36deb839a616d25ae2a047fe27  st-xrdb.patch"
diff --git a/testing/st-xrdb/st-xrdb.patch b/testing/st-xrdb/st-xrdb.patch
new file mode 100644
index 0000000..f953028
--- /dev/null
+++ b/testing/st-xrdb/st-xrdb.patch
_at_@ -0,0 +1,209 @@
+diff --git a/config.def.h b/config.def.h
+index 0e01717..6a33ef7 100644
+--- a/config.def.h
++++ b/config.def.h
+_at_@ -60,7 +60,7 @@ static unsigned int cursorthickness = 2;
+  * bell volume. It must be a value between -100 and 100. Use 0 for disabling
+  * it
+  */
+-static int bellvolume = 0;
++static int bellvolume = 100;
+ 
+ /* default TERM value */
+ char *termname = "st-256color";
+_at_@ -109,6 +109,8 @@ static const char *colorname[] = {
+ 	/* more colors can be added after 255 to use with DefaultXX */
+ 	"#cccccc",
+ 	"#555555",
++	"gray90",
++	"black"
+ };
+ 
+ 
+_at_@ -116,8 +118,8 @@ static const char *colorname[] = {
+  * Default colors (colorname index)
+  * foreground, background, cursor, reverse cursor
+  */
+-unsigned int defaultfg = 7;
+-unsigned int defaultbg = 0;
++unsigned int defaultfg = 258;
++unsigned int defaultbg = 259;
+ static unsigned int defaultcs = 256;
+ static unsigned int defaultrcs = 257;
+ 
+_at_@ -150,14 +152,51 @@ static unsigned int mousebg = 0;
+  */
+ static unsigned int defaultattr = 11;
+ 
++/*
++ * 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[259] },
++		{ "foreground",   STRING,  &colorname[258] },
++		{ "cursorColor",  STRING,  &colorname[256] },
++		{ "termname",     STRING,  &termname },
++		{ "shell",        STRING,  &shell },
++		{ "xfps",         INTEGER, &xfps },
++		{ "actionfps",    INTEGER, &actionfps },
++		{ "blinktimeout", INTEGER, &blinktimeout },
++		{ "bellvolume",   INTEGER, &bellvolume },
++		{ "tabspaces",    INTEGER, &tabspaces },
++		{ "cwscale",      FLOAT,   &cwscale },
++		{ "chscale",      FLOAT,   &chscale },
++};
++
+ /*
+  * Internal mouse shortcuts.
+  * Beware that overloading Button1 will disable the selection.
+  */
+ static MouseShortcut mshortcuts[] = {
+ 	/* button               mask            string */
++	/*
+ 	{ Button4,              XK_ANY_MOD,     "\031" },
+ 	{ Button5,              XK_ANY_MOD,     "\005" },
++	*/
+ };
+ 
+ /* Internal keyboard shortcuts. */
+diff --git a/x.c b/x.c
+index 5828a3b..90f3614 100644
+--- a/x.c
++++ b/x.c
+_at_@ -14,6 +14,7 @@
+ #include <X11/keysym.h>
+ #include <X11/Xft/Xft.h>
+ #include <X11/XKBlib.h>
++#include <X11/Xresource.h>
+ 
+ static char *argv0;
+ #include "arg.h"
+_at_@ -43,6 +44,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
+_at_@ -786,8 +800,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;
+ 
+_at_@ -1045,8 +1059,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);
+ 
+_at_@ -1901,6 +1913,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)
+ {
+_at_@ -1974,6 +2039,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.21.0
--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Mon Mar 11 2019 - 19:37:45 UTC