Compare commits
1 Commits
feat/xreso
...
a148aa1f47
Author | SHA1 | Date | |
---|---|---|---|
a148aa1f47 |
36
config.def.h
36
config.def.h
@ -170,42 +170,6 @@ static unsigned int defaultattr = 11;
|
|||||||
*/
|
*/
|
||||||
static uint forcemousemod = ShiftMask;
|
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.
|
* Internal mouse shortcuts.
|
||||||
* Beware that overloading Button1 will disable the selection.
|
* Beware that overloading Button1 will disable the selection.
|
||||||
|
82
x.c
82
x.c
@ -14,7 +14,6 @@
|
|||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xresource.h>
|
|
||||||
|
|
||||||
char *argv0;
|
char *argv0;
|
||||||
#include "arg.h"
|
#include "arg.h"
|
||||||
@ -46,19 +45,6 @@ typedef struct {
|
|||||||
signed char appcursor; /* application cursor */
|
signed char appcursor; /* application cursor */
|
||||||
} Key;
|
} 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 */
|
/* X modifiers */
|
||||||
#define XK_ANY_MOD UINT_MAX
|
#define XK_ANY_MOD UINT_MAX
|
||||||
#define XK_NO_MOD 0
|
#define XK_NO_MOD 0
|
||||||
@ -873,8 +859,8 @@ xclear(int x1, int y1, int x2, int y2)
|
|||||||
void
|
void
|
||||||
xhints(void)
|
xhints(void)
|
||||||
{
|
{
|
||||||
XClassHint class = {opt_name ? opt_name : "st",
|
XClassHint class = {opt_name ? opt_name : termname,
|
||||||
opt_class ? opt_class : "St"};
|
opt_class ? opt_class : termname};
|
||||||
XWMHints wm = {.flags = InputHint, .input = 1};
|
XWMHints wm = {.flags = InputHint, .input = 1};
|
||||||
XSizeHints *sizeh;
|
XSizeHints *sizeh;
|
||||||
|
|
||||||
@ -1149,6 +1135,8 @@ xinit(int cols, int rows)
|
|||||||
pid_t thispid = getpid();
|
pid_t thispid = getpid();
|
||||||
XColor xmousefg, xmousebg;
|
XColor xmousefg, xmousebg;
|
||||||
|
|
||||||
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
|
die("can't open display\n");
|
||||||
xw.scr = XDefaultScreen(xw.dpy);
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||||
|
|
||||||
@ -1424,10 +1412,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|||||||
bg = &dc.col[base.bg];
|
bg = &dc.col[base.bg];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Change basic system colors [0-7] to bright system colors [8-15] */
|
|
||||||
if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7))
|
|
||||||
fg = &dc.col[base.fg + 8];
|
|
||||||
|
|
||||||
if (IS_SET(MODE_REVERSE)) {
|
if (IS_SET(MODE_REVERSE)) {
|
||||||
if (fg == &dc.col[defaultfg]) {
|
if (fg == &dc.col[defaultfg]) {
|
||||||
fg = &dc.col[defaultbg];
|
fg = &dc.col[defaultbg];
|
||||||
@ -2026,59 +2010,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
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
@ -2152,11 +2083,6 @@ run:
|
|||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
|
|
||||||
if(!(xw.dpy = XOpenDisplay(NULL)))
|
|
||||||
die("Can't open display\n");
|
|
||||||
|
|
||||||
config_init();
|
|
||||||
cols = MAX(cols, 1);
|
cols = MAX(cols, 1);
|
||||||
rows = MAX(rows, 1);
|
rows = MAX(rows, 1);
|
||||||
tnew(cols, rows);
|
tnew(cols, rows);
|
||||||
|
Reference in New Issue
Block a user