cleanup last commit a bit

This commit is contained in:
speedie 2023-02-14 16:34:57 +01:00
parent b828b27adf
commit 3fdb45a0e4
3 changed files with 49 additions and 33 deletions

14
st.c
View file

@ -179,6 +179,8 @@ static void sigchld(int);
static void sigusr1(int); static void sigusr1(int);
static void ttywriteraw(const char *, size_t); static void ttywriteraw(const char *, size_t);
static void reloadalpha(void);
static void csidump(void); static void csidump(void);
static void dcshandle(void); static void dcshandle(void);
static void scroll_images(int n); static void scroll_images(int n);
@ -2271,21 +2273,15 @@ strhandle(void)
tfulldirt(); tfulldirt();
} }
return; return;
#if RELOADCOLORS
case 4: case 4:
if (narg < 3) { if (narg < 3) {
reloadalpha();
break; break;
} }
p = strescseq.args[2];
reloadalpha();
break; p = strescseq.args[2];
#else
case 4:
reloadalpha(); reloadalpha();
break; break;
#endif
case 104: /* color reset */ case 104: /* color reset */
j = (narg > 1) ? atoi(strescseq.args[1]) : -1; j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
@ -2302,8 +2298,6 @@ strhandle(void)
tfulldirt(); tfulldirt();
} }
reloadalpha();
return; return;
} }
break; break;

26
x.c
View file

@ -873,9 +873,29 @@ xloadcolor(int i, const char *name, Color *ncolor)
void void
reloadalpha(void) reloadalpha(void)
{ {
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); int i = 0;
dc.col[defaultbg].pixel &= 0x00FFFFFF;
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; for (i = 0; i < dc.collen; i++)
if (!xloadcolor(i, NULL, &dc.col[i])) {
if (colorname[i])
die("could not allocate color '%s'\n", colorname[i]);
else
die("could not allocate color %d\n", i);
}
/* set alpha */
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
dc.col[defaultbg].pixel &= 0x00FFFFFF;
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
dc.col[selectionbg].color.alpha = (unsigned short)(0xffff * alpha);
dc.col[selectionbg].color.red =
((unsigned short)(dc.col[selectionbg].color.red * alpha)) & 0xff00;
dc.col[selectionbg].color.green =
((unsigned short)(dc.col[selectionbg].color.green * alpha)) & 0xff00;
dc.col[selectionbg].color.blue =
((unsigned short)(dc.col[selectionbg].color.blue * alpha)) & 0xff00;
dc.col[selectionbg].pixel &= 0x00FFFFFF;
dc.col[selectionbg].pixel |= (unsigned char)(0xff * alpha) << 24;
} }
void void

View file

@ -1,26 +1,6 @@
/* .Xresources array, you can add values to it that will be read on startup */ /* .Xresources array, you can add values to it that will be read on startup */
ResourcePref resources[] = { ResourcePref resources[] = {
{ "font", STRING, &font }, { "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] },
{ "curcolor", STRING, &colorname[258] },
{ "cursorColor", STRING, &colorname[258] },
{ "termname", STRING, &termname }, { "termname", STRING, &termname },
{ "shell", STRING, &shell }, { "shell", STRING, &shell },
{ "understyle", STRING, &understyle }, { "understyle", STRING, &understyle },
@ -51,4 +31,26 @@ ResourcePref resources[] = {
{ "chscale", FLOAT, &chscale }, { "chscale", FLOAT, &chscale },
{ "cyoffset", FLOAT, &cyoffset }, { "cyoffset", FLOAT, &cyoffset },
{ "cxoffset", FLOAT, &cxoffset }, { "cxoffset", FLOAT, &cxoffset },
/* pywal colors */
{ "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] },
{ "curcolor", STRING, &colorname[258] },
{ "cursorColor", STRING, &colorname[258] },
}; };