X-Original-To: alpine-user@lists.alpinelinux.org Received: from sdaoden.eu (sdaoden.eu [217.144.132.164]) by lists.alpinelinux.org (Postfix) with ESMTP id D51FF5C5937 for ; Wed, 7 Nov 2018 22:23:04 +0000 (GMT) Received: by sdaoden.eu (Postfix, from userid 1000) id A22BD1604A; Wed, 7 Nov 2018 23:23:03 +0100 (CET) Date: Wed, 07 Nov 2018 23:23:02 +0100 From: Steffen Nurpmeso To: =?utf-8?B?Q8OhZw==?= Cc: alpine-user@lists.alpinelinux.org Subject: Re: [alpine-user] st(1): a version with light background would be cool! Message-ID: <20181107222302.XSAEe%steffen@sdaoden.eu> In-Reply-To: <6538c9b026b2121b9a071b4e0ffe64c5@bitmessage.ch> References: <20181103195449.CdVpC%steffen@sdaoden.eu> <6538c9b026b2121b9a071b4e0ffe64c5@bitmessage.ch> Mail-Followup-To: =?utf-8?B?Q8OhZw==?= , alpine-user@lists.alpinelinux.org User-Agent: s-nail v14.9.11-76-g38917986 OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs. X-Mailinglist: alpine-user Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=LUrna26yruZdZMoxJ85NYrITu-RbAYbIVBDV=-=" This is a multi-part message in MIME format. --=-=LUrna26yruZdZMoxJ85NYrITu-RbAYbIVBDV=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-ID: <20181107222302.-tW77%steffen@sdaoden.eu> Hello C=C3=A1g, all! C=C3=A1g wrote in <6538c9b026b2121b9a071b4e0ffe64c5@bitmessage.ch>: |> Would it be possible to have a st(1) port with a light background? |> Or would that need to be a completely new port by itself? |> I compile it here only with the patch below applied for this. |> Just an idea, but would be cool to have a binary available. |> Thanks! | |I wonder how many people use pre-compiled versions st (or dwm for |that matter). Patches to use .Xresources exist though. Oh, thanks for pointing this out! Cool!! But.. not working for st.background, st.foreground and st.cursorColor, please find attached the original patch plus one which gets this stuff going! Would be tremendous to have this like so in Alpine! --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) --=-=LUrna26yruZdZMoxJ85NYrITu-RbAYbIVBDV=-= Content-Type: application/mbox; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patch.mbox" Content-ID: <20181107222302.7vm-h%steffen@sdaoden.eu> =46rom 35f6daad6b53882e33dc26bddde93fabda7b9c8c Mon Sep 17 00:00:00 2001 Message-Id: <35f6daad6b53882e33dc26bddde93fabda7b9c8c.1541627514.git.steffe= n@sdaoden.eu> From: Steffen Nurpmeso Date: Wed, 7 Nov 2018 22:02:59 +0100 Subject: [PATCH 1/2] Import st-xresources patch, 2018-11-07 --- config.def.h | 35 +++++++++++++++++++++++ x.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 823e79f..2c07b07 100644 --- a/config.def.h +++ b/config.def.h @@ -150,6 +150,41 @@ static unsigned int mousebg =3D 0; */ static unsigned int defaultattr =3D 11; =20 +/* + * Xresources preferences to load at startup + */ +ResourcePref resources[] =3D { + { "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 }, + { "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. diff --git a/x.c b/x.c index 00cb6b1..3652979 100644 --- a/x.c +++ b/x.c @@ -14,6 +14,7 @@ #include #include #include +#include =20 static char *argv0; #include "arg.h" @@ -43,6 +44,19 @@ typedef struct { signed char appcursor; /* application cursor */ } Key; =20 +/* Xresources preferences */ +enum resource_type { + STRING =3D 0, + INTEGER =3D 1, + FLOAT =3D 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 @@ -783,8 +797,8 @@ xclear(int x1, int y1, int x2, int y2) void xhints(void) { - XClassHint class =3D {opt_name ? opt_name : termname, - opt_class ? opt_class : termname}; + XClassHint class =3D {opt_name ? opt_name : "st", + opt_class ? opt_class : "St"}; XWMHints wm =3D {.flags =3D InputHint, .input =3D 1}; XSizeHints *sizeh; =20 @@ -1005,8 +1019,6 @@ xinit(int cols, int rows) pid_t thispid =3D getpid(); XColor xmousefg, xmousebg; =20 - if (!(xw.dpy =3D XOpenDisplay(NULL))) - die("can't open display\n"); xw.scr =3D XDefaultScreen(xw.dpy); xw.vis =3D XDefaultVisual(xw.dpy, xw.scr); =20 @@ -1870,6 +1882,59 @@ run(void) } } =20 +int +resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *= dst) +{ + char **sdst =3D dst; + int *idst =3D dst; + float *fdst =3D 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] =3D fullclass[sizeof(fullclass) - 1] =3D '= \0'; + + XrmGetResource(db, fullname, fullclass, &type, &ret); + if (ret.addr =3D=3D NULL || strncmp("String", type, 64)) + return 1; + + switch (rtype) { + case STRING: + *sdst =3D ret.addr; + break; + case INTEGER: + *idst =3D strtoul(ret.addr, NULL, 10); + break; + case FLOAT: + *fdst =3D strtof(ret.addr, NULL); + break; + } + return 0; +} + +void +config_init(void) +{ + char *resm; + XrmDatabase db; + ResourcePref *p; + + XrmInitialize(); + resm =3D XResourceManagerString(xw.dpy); + if (!resm) + return; + + db =3D XrmGetStringDatabase(resm); + for (p =3D resources; p < resources + LEN(resources); p++) + resource_load(db, p->name, p->type, p->dst); +} + void usage(void) { @@ -1943,6 +2008,11 @@ run: =20 setlocale(LC_CTYPE, ""); XSetLocaleModifiers(""); + + if(!(xw.dpy =3D XOpenDisplay(NULL))) + die("Can't open display\n"); + + config_init(); cols =3D MAX(cols, 1); rows =3D MAX(rows, 1); tnew(cols, rows); --=20 2.19.1 =46rom 1f57f28bb71e9049e41dfd6e5e084413cebe2541 Mon Sep 17 00:00:00 2001 Message-Id: <1f57f28bb71e9049e41dfd6e5e084413cebe2541.1541627514.git.steffe= n@sdaoden.eu> In-Reply-To: <35f6daad6b53882e33dc26bddde93fabda7b9c8c.1541627514.git.steff= en@sdaoden.eu> References: <35f6daad6b53882e33dc26bddde93fabda7b9c8c.1541627514.git.steffe= n@sdaoden.eu> From: Steffen Nurpmeso Date: Wed, 7 Nov 2018 22:50:36 +0100 Subject: [PATCH 2/2] Modifications to make .background,.foreground,.cursorColor work --- config.def.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index 2c07b07..3f384c8 100644 --- a/config.def.h +++ b/config.def.h @@ -109,6 +109,8 @@ static const char *colorname[] =3D { /* more colors can be added after 255 to use with DefaultXX */ "#cccccc", "#555555", + "gray90", + "black" }; =20 =20 @@ -116,8 +118,8 @@ static const char *colorname[] =3D { * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultfg =3D 7; -unsigned int defaultbg =3D 0; +unsigned int defaultfg =3D 258; +unsigned int defaultbg =3D 259; static unsigned int defaultcs =3D 256; static unsigned int defaultrcs =3D 257; =20 @@ -171,9 +173,9 @@ ResourcePref resources[] =3D { { "color13", STRING, &colorname[13] }, { "color14", STRING, &colorname[14] }, { "color15", STRING, &colorname[15] }, - { "background", STRING, &colorname[256] }, - { "foreground", STRING, &colorname[257] }, - { "cursorColor", STRING, &colorname[258] }, + { "background", STRING, &colorname[259] }, + { "foreground", STRING, &colorname[258] }, + { "cursorColor", STRING, &colorname[256] }, { "termname", STRING, &termname }, { "shell", STRING, &shell }, { "xfps", INTEGER, &xfps }, --=20 2.19.1 --=-=LUrna26yruZdZMoxJ85NYrITu-RbAYbIVBDV=-=-- --- Unsubscribe: alpine-user+unsubscribe@lists.alpinelinux.org Help: alpine-user+help@lists.alpinelinux.org ---