st

git clone git://mattcarlson.org/repos/st.git
Log | Files | Refs

commit dfbcbfb7e0c155591137da1143ba8d970da2f66f
parent 6e38435d5dcb9bcc13b567c8a97a95f54a64ebb9
Author: Matthew Carlson <matt@mcarlson.xyz>
Date:   Fri, 23 Jul 2021 17:17:43 -0400

Revert "Merge branch 'xresources' into st"

This reverts commit dd8bbb881b0fb221f66c2facc9e005ad49329175, reversing
changes made to 68e0f6c31ed98f47e8db709e529f03f98182fb1e.

Diffstat:
Mconfig.h | 58----------------------------------------------------------
Mx.c | 79++++---------------------------------------------------------------------------
2 files changed, 4 insertions(+), 133 deletions(-)

diff --git a/config.h b/config.h @@ -135,64 +135,6 @@ static unsigned int defaultattr = 11; // force mouse select/shortcuts while mask is active (when mode_mouse is set) static uint forcemousemod = ShiftMask; -// xresources -ResourcePref resources[] = { - { "font", STRING, &font }, - { "font2", STRING, &font2[0] }, - { "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[258] }, - { "foreground", STRING, &colorname[257] }, - { "cursorColor", STRING, &colorname[256] }, - { "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 }, - { "doubleclicktimeout", INTEGER, &doubleclicktimeout }, - { "tripleclicktimeout", INTEGER, &tripleclicktimeout }, - { "allowaltscreen", INTEGER, &allowaltscreen }, - { "allowwindowops", INTEGER, &allowwindowops }, - { "cursorthickness", INTEGER, &cursorthickness }, - { "boxdraw", INTEGER, &boxdraw }, - { "boxdraw_bold", INTEGER, &boxdraw_bold }, - { "boxdraw_braille", INTEGER, &boxdraw_braille }, - { "bellvolume", INTEGER, &bellvolume }, - { "alpha", FLOAT, &alpha }, - { "alphaUnfocused", FLOAT, &alphaUnfocused }, - { "defaultfg", INTEGER, &defaultfg }, - { "defaultbg", INTEGER, &defaultbg }, - { "defaultcs", INTEGER, &defaultcs }, - { "defaultrcs", INTEGER, &defaultrcs }, - { "bg", INTEGER, &bg }, - { "bgUnfocused", INTEGER, &bgUnfocused }, - { "cursorstyle", INTEGER, &cursorstyle }, - { "cols", INTEGER, &cols }, - { "rows", INTEGER, &rows }, - { "mousefg", INTEGER, &mousefg }, - { "mousebg", INTEGER, &mousebg }, - { "defaultattr", INTEGER, &defaultattr }, -}; - // internal mouse shortcuts const unsigned int mousescrollincrement = 1; static MouseShortcut mshortcuts[] = { diff --git a/x.c b/x.c @@ -10,7 +10,6 @@ #include <unistd.h> #include <libgen.h> #include <X11/Xatom.h> -#include <X11/Xresource.h> #include <X11/Xlib.h> #include <X11/cursorfont.h> #include <X11/keysym.h> @@ -49,20 +48,6 @@ 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 @@ -891,8 +876,8 @@ xclear(int x1, int y1, int x2, int y2) void xhints(void) { - XClassHint class = {opt_name ? opt_name : "st", - opt_class ? opt_class : "St"}; + XClassHint class = {opt_name ? opt_name : termname, + opt_class ? opt_class : termname}; XWMHints wm = {.flags = InputHint, .input = 1}; XSizeHints *sizeh; @@ -1267,6 +1252,8 @@ xinit(int cols, int rows) XVisualInfo vis; Pixmap blankpm; + if (!(xw.dpy = XOpenDisplay(NULL))) + die("can't open display\n"); xw.scr = XDefaultScreen(xw.dpy); if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) { @@ -2292,59 +2279,6 @@ 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) { @@ -2426,11 +2360,6 @@ 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); defaultbg = MAX(LEN(colorname), 256);