forked from speedie/spmenu
Move color scheme initialization to schemes.c
This commit is contained in:
parent
395dc3dfe0
commit
1354159042
63
libs/schemes.c
Normal file
63
libs/schemes.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
char
|
||||
sixd_to_8bit(int x)
|
||||
{
|
||||
return x == 0 ? 0 : 0x37 + 0x28 * x;
|
||||
}
|
||||
|
||||
void
|
||||
init_appearance(void)
|
||||
{
|
||||
int x, y, i, j;
|
||||
|
||||
char cbuf[8];
|
||||
|
||||
/* init appearance */
|
||||
for (j = 0; j < SchemeLast; j++) {
|
||||
scheme[j] = drw_scm_create(drw, colors[j], alphas[j], 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < LENGTH(textcolors) && i < LENGTH(textclrs); i++)
|
||||
drw_clr_create(drw, &textclrs[i], textcolors[i], 0);
|
||||
if (i == 0 && colorsupport)
|
||||
drw_clr_create(drw, &textclrs[i++], "#000000", 0);
|
||||
for (; i < 7; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
!!(i & 1) * 0x7f,
|
||||
!!(i & 2) * 0x7f,
|
||||
!!(i & 4) * 0x7f);
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
if (i == 7 && colorsupport)
|
||||
drw_clr_create(drw, &textclrs[i++], "#000000", 0);
|
||||
if (i == 8 && colorsupport)
|
||||
drw_clr_create(drw, &textclrs[i++], "#333333", 0);
|
||||
for (; i < 16; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
!!(i & 1) * 0xff,
|
||||
!!(i & 2) * 0xff,
|
||||
!!(i & 4) * 0xff);
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
for (; i < 6 * 6 * 6 + 16; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
sixd_to_8bit(((i - 16) / 36) % 6),
|
||||
sixd_to_8bit(((i - 16) / 6) % 6),
|
||||
sixd_to_8bit(((i - 16)) % 6));
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
for (; i < 256; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
|
||||
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
|
||||
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a);
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
static void init_appearance(void);
|
||||
/* color schemes */
|
||||
enum { SchemeLArrow,
|
||||
SchemeRArrow,
|
||||
|
|
57
spmenu.c
57
spmenu.c
|
@ -192,6 +192,7 @@ static int longestedge = 0; /* longest edge */
|
|||
#include "libs/rtl.c"
|
||||
#endif
|
||||
#include "libs/draw.c"
|
||||
#include "libs/schemes.c"
|
||||
|
||||
void
|
||||
setimgsize(const Arg *arg)
|
||||
|
@ -307,12 +308,6 @@ cistrstr(const char *h, const char *n)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char
|
||||
sixd_to_8bit(int x)
|
||||
{
|
||||
return x == 0 ? 0 : 0x37 + 0x28 * x;
|
||||
}
|
||||
|
||||
void
|
||||
grabfocus(void)
|
||||
{
|
||||
|
@ -1300,55 +1295,9 @@ setup(void)
|
|||
int a, di, n, area = 0;
|
||||
#endif
|
||||
char cbuf[8];
|
||||
/* init appearance */
|
||||
for (j = 0; j < SchemeLast; j++) {
|
||||
scheme[j] = drw_scm_create(drw, colors[j], alphas[j], 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < LENGTH(textcolors) && i < LENGTH(textclrs); i++)
|
||||
drw_clr_create(drw, &textclrs[i], textcolors[i], 0);
|
||||
if (i == 0 && colorsupport)
|
||||
drw_clr_create(drw, &textclrs[i++], "#000000", 0);
|
||||
for (; i < 7; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
!!(i & 1) * 0x7f,
|
||||
!!(i & 2) * 0x7f,
|
||||
!!(i & 4) * 0x7f);
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
if (i == 7 && colorsupport)
|
||||
drw_clr_create(drw, &textclrs[i++], "#000000", 0);
|
||||
if (i == 8 && colorsupport)
|
||||
drw_clr_create(drw, &textclrs[i++], "#333333", 0);
|
||||
for (; i < 16; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
!!(i & 1) * 0xff,
|
||||
!!(i & 2) * 0xff,
|
||||
!!(i & 4) * 0xff);
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
for (; i < 6 * 6 * 6 + 16; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
sixd_to_8bit(((i - 16) / 36) % 6),
|
||||
sixd_to_8bit(((i - 16) / 6) % 6),
|
||||
sixd_to_8bit(((i - 16)) % 6));
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
for (; i < 256; i++) {
|
||||
if (!colorsupport)
|
||||
break;
|
||||
snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
|
||||
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
|
||||
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
|
||||
0x08 + (i - 6 * 6 * 6 - 16) * 0x0a);
|
||||
drw_clr_create(drw, &textclrs[i], cbuf, 0);
|
||||
}
|
||||
/* init appearance */
|
||||
init_appearance();
|
||||
|
||||
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
|
|
Loading…
Reference in a new issue