dwm-like colorscheme creation

This commit is contained in:
speedie 2023-05-08 17:50:48 +02:00
parent 5c36c25f99
commit c7e0e5d74b
4 changed files with 9 additions and 8 deletions

View file

@ -20,7 +20,7 @@ static unsigned int alphas[][2] = {
};
// colorscheme array
static char *colors[SchemeLast][2] = {
static char *colors[][2] = {
// fg bg
[SchemeLArrow] = { col_larrowfg, col_larrowbg },
[SchemeRArrow] = { col_rarrowfg, col_rarrowbg },

View file

@ -3,7 +3,7 @@ char sixd_to_8bit(int x) {
}
void init_appearance(void) {
int i, j;
int i = 0, j = 0;
char cbuf[8];
@ -40,9 +40,11 @@ void init_appearance(void) {
alphas[SchemeBorder][ColBg] = alpha_border;
// create color schemes from array
for (j = 0; j < SchemeLast; j++) {
scheme[j] = drw_scm_create(drw, colors[j], alphas[j], 2);
}
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], alphas[i], 2);
for (i = 0; i < LENGTH(colors) && i < LENGTH(alphas); i++)
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 2);
for (i = 0; i < LENGTH(textcolors) && i < LENGTH(textclrs); i++)
drw_clr_create(drw, &textclrs[i], textcolors[i], 0);

View file

@ -17,5 +17,4 @@ enum { SchemeLArrow,
SchemeMode,
SchemeBorder,
SchemeCaps,
SchemeLast,
};

View file

@ -216,7 +216,7 @@ static Visual *visual;
static int depth;
static Colormap cmap;
static Drw *drw;
static Clr *scheme[SchemeLast];
static Clr **scheme;
static Clr textclrs[256];
// declare functions
@ -368,7 +368,7 @@ void cleanup(void) {
XUngrabKey(dpy, AnyKey, AnyModifier, root); // ungrab keys
// free color scheme
for (i = 0; i < SchemeLast; i++)
for (i = 0; i < LENGTH(colors) + 1; i++)
free(scheme[i]);
// free high priority items