aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2023-11-30 11:58:44 -0700
committerJack Sangdahl <[email protected]>2023-11-30 11:58:44 -0700
commited37218285bd16d8b1adfb174a5c95d709cd6abc (patch)
treed2c94b5c6e04fd0f1f544e572937355dec13a9bb
parent8ce4a74ed37bea15e4dc1464a9dec04ff329fb42 (diff)
downloadst-ed37218285bd16d8b1adfb174a5c95d709cd6abc.tar.gz
st-ed37218285bd16d8b1adfb174a5c95d709cd6abc.zip
initial?
-rw-r--r--config.h23
-rw-r--r--x.c172
2 files changed, 12 insertions, 183 deletions
diff --git a/config.h b/config.h
index 7a43f8b..d5fe6ae 100644
--- a/config.h
+++ b/config.h
@@ -1,7 +1,6 @@
#pragma once
-static char *font =
- "JetBrainsMono Nerd Font:pixelsize=15:antialias=true:autohint=true";
+static char *font = "JetBrainsMono Nerd Font:pixelsize=15:antialias=true:autohint=true";
static int borderpx = 8;
static char *shell = "/bin/zsh";
char *utmp = NULL;
@@ -26,16 +25,18 @@ char *termname = "st";
unsigned int tabspaces = 4;
float alpha = 1.0;
-static const char *colorname[] = {"#1d2021", // or #1C1C1C
- "#cc241d", "#98971a", "#d79921", "#458588",
- "#b16286", "#689d6a", "#a89984", "#928374",
- "#fb4934", "#b8bb26", "#fabd2f", "#83a598",
- "#d3869b", "#8ec07c", "#ebdbb2"};
+static const char *colorname[] = {
+ "#45475A", "#F38BA8", "#A6E3A1", "#F9E2AF",
+ "#89B4FA", "#F5C2E7", "#94E2D5", "#BAC2DE",
+ "#585B70", "#F38BA8", "#A6E3A1", "#F9E2AF",
+ "#89B4FA", "#F5C2E7", "#94E2D5", "#A6ADC8",
+ [256] = "#CDD6F4", [257] = "#1E1E2E", [258] = "#F5E0DC"
+};
-unsigned int defaultfg = 15;
-unsigned int defaultbg = 0;
-unsigned int defaultcs = 15;
-static unsigned int defaultrcs = 0;
+unsigned int defaultfg = 256;
+unsigned int defaultbg = 257;
+unsigned int defaultcs = 258;
+static unsigned int defaultrcs = 258;
static unsigned int cursorshape = 2;
static unsigned int cols = 80;
static unsigned int rows = 24;
diff --git a/x.c b/x.c
index 91cd454..57cbc90 100644
--- a/x.c
+++ b/x.c
@@ -14,7 +14,6 @@
#include <X11/keysym.h>
#include <X11/Xft/Xft.h>
#include <X11/XKBlib.h>
-#include <X11/Xresource.h>
static char *argv0;
#include "arg.h"
@@ -45,19 +44,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
@@ -2014,114 +2000,9 @@ run(void)
}
}
-#define XRESOURCE_LOAD_META(NAME) \
- if(!XrmGetResource(xrdb, "st." NAME, "st." NAME, &type, &ret)) \
- XrmGetResource(xrdb, "*." NAME, "*." NAME, &type, &ret); \
- if (ret.addr != NULL && !strncmp("String", type, 64))
-
-#define XRESOURCE_LOAD_STRING(NAME, DST) \
- XRESOURCE_LOAD_META(NAME) \
- DST = ret.addr;
-
-#define XRESOURCE_LOAD_CHAR(NAME, DST) \
- XRESOURCE_LOAD_META(NAME) \
- DST = ret.addr[0];
-
-#define XRESOURCE_LOAD_INTEGER(NAME, DST) \
- XRESOURCE_LOAD_META(NAME) \
- DST = strtoul(ret.addr, NULL, 10);
-
-#define XRESOURCE_LOAD_FLOAT(NAME, DST) \
- XRESOURCE_LOAD_META(NAME) \
- DST = strtof(ret.addr, NULL);
-
-void
-xrdb_load(void)
-{
- /* XXX */
- char *xrm;
- char *type;
- XrmDatabase xrdb;
- XrmValue ret;
- Display *dpy;
-
- if(!(dpy = XOpenDisplay(NULL)))
- die("Can't open display\n");
-
- XrmInitialize();
- xrm = XResourceManagerString(dpy);
-
- if (xrm != NULL) {
- xrdb = XrmGetStringDatabase(xrm);
-
- /* handling colors here without macros to do via loop. */
- int i = 0;
- char loadValue[12] = "";
- for (i = 0; i < 256; i++)
- {
- sprintf(loadValue, "%s%d", "st.color", i);
-
- if(!XrmGetResource(xrdb, loadValue, loadValue, &type, &ret))
- {
- sprintf(loadValue, "%s%d", "*.color", i);
- if (!XrmGetResource(xrdb, loadValue, loadValue, &type, &ret))
- /* reset if not found (unless in range for defaults). */
- if (i > 15)
- colorname[i] = NULL;
- }
-
- if (ret.addr != NULL && !strncmp("String", type, 64))
- colorname[i] = ret.addr;
- }
-
- XRESOURCE_LOAD_STRING("foreground", colorname[defaultfg]);
- XRESOURCE_LOAD_STRING("background", colorname[defaultbg]);
- XRESOURCE_LOAD_STRING("cursorfg", colorname[defaultcs])
- else {
- // this looks confusing because we are chaining off of the if
- // in the macro. probably we should be wrapping everything blocks
- // so this isn't possible...
- defaultcs = defaultfg;
- }
- XRESOURCE_LOAD_STRING("reverse-cursor", colorname[defaultrcs])
- else {
- // see above.
- defaultrcs = defaultbg;
- }
-
- XRESOURCE_LOAD_STRING("font", font);
- XRESOURCE_LOAD_STRING("termname", termname);
-
- /* XRESOURCE_LOAD_INTEGER("xfps", xfps); */
- /* XRESOURCE_LOAD_INTEGER("actionfps", actionfps); */
- XRESOURCE_LOAD_INTEGER("blinktimeout", blinktimeout);
- XRESOURCE_LOAD_INTEGER("bellvolume", bellvolume);
- XRESOURCE_LOAD_INTEGER("borderpx", borderpx);
- /* XRESOURCE_LOAD_INTEGER("borderless", borderless); */
- XRESOURCE_LOAD_INTEGER("cursorshape", cursorshape);
-
- /* cursorblinkstate = 1; // in case if cursor shape was changed from a blinking one to a non-blinking */
- /* XRESOURCE_LOAD_INTEGER("cursorthickness", cursorthickness); */
- /* XRESOURCE_LOAD_INTEGER("cursorblinkstyle", cursorblinkstyle); */
- /* XRESOURCE_LOAD_INTEGER("cursorblinkontype", cursorblinkontype); */
-
- /* todo: https://github.com/gnotclub/xst/commit/1e82647b0e04077e975679a4b4cf1eb02b04e6bc */
- /* XRESOURCE_LOAD_INTEGER("mouseScrollLines", mousescrolllines); */
-
- XRESOURCE_LOAD_FLOAT("cwscale", cwscale);
- XRESOURCE_LOAD_FLOAT("chscale", chscale);
-
- /* XRESOURCE_LOAD_CHAR("prompt_char", prompt_char); */
-
- }
- XFlush(dpy);
-}
-
void
reload(int sig)
{
- xrdb_load();
-
/* colors, fonts */
xloadcols();
xunloadfonts();
@@ -2138,57 +2019,6 @@ reload(int sig)
signal(SIGUSR1, reload);
}
-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);
-}
-
void
usage(void)
{
@@ -2265,13 +2095,11 @@ run:
setlocale(LC_CTYPE, "");
XSetLocaleModifiers("");
- xrdb_load();
signal(SIGUSR1, reload);
if(!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n");
- config_init();
cols = MAX(cols, 1);
rows = MAX(rows, 1);
signal(SIGUSR1, reload);