spmenu/libs/schemes.c

86 lines
3.3 KiB
C
Raw Normal View History

char sixd_to_8bit(int x) {
2023-05-08 23:00:45 +02:00
return x == 0 ? 0 : 0x37 + 0x28 * x;
}
void init_appearance(void) {
2023-05-08 18:15:20 +02:00
int i = 0;
char cbuf[8];
2023-04-17 14:14:58 +02:00
// set alpha
alphas[SchemeLArrow][ColFg] = alpha_larrowfg;
alphas[SchemeLArrow][ColBg] = alpha_larrowbg;
alphas[SchemeRArrow][ColFg] = alpha_rarrowfg;
alphas[SchemeRArrow][ColBg] = alpha_rarrowbg;
alphas[SchemeItemNorm][ColFg] = alpha_itemnormfg;
alphas[SchemeItemNorm][ColBg] = alpha_itemnormbg;
alphas[SchemeItemSel][ColFg] = alpha_itemselfg;
alphas[SchemeItemSel][ColBg] = alpha_itemselbg;
alphas[SchemeItemNormPri][ColFg] = alpha_itemnormprifg;
alphas[SchemeItemNormPri][ColBg] = alpha_itemnormpribg;
alphas[SchemeItemSelPri][ColFg] = alpha_itemselprifg;
alphas[SchemeItemSelPri][ColBg] = alpha_itemselpribg;
alphas[SchemeMenu][ColBg] = alpha_menu;
alphas[SchemeInput][ColFg] = alpha_inputfg;
alphas[SchemeInput][ColBg] = alpha_inputbg;
alphas[SchemePrompt][ColFg] = alpha_promptfg;
alphas[SchemePrompt][ColBg] = alpha_promptbg;
2023-04-17 16:57:09 +02:00
alphas[SchemeNormHighlight][ColFg] = alpha_hlnormfg;
alphas[SchemeNormHighlight][ColBg] = alpha_hlnormbg;
alphas[SchemeSelHighlight][ColFg] = alpha_hlselfg;
alphas[SchemeSelHighlight][ColBg] = alpha_hlselbg;
alphas[SchemeCaret][ColFg] = alpha_caretfg;
alphas[SchemeCaret][ColBg] = alpha_caretbg;
alphas[SchemeNumber][ColFg] = alpha_numfg;
alphas[SchemeNumber][ColBg] = alpha_numbg;
alphas[SchemeMode][ColFg] = alpha_modefg;
alphas[SchemeMode][ColBg] = alpha_modebg;
alphas[SchemeCaps][ColFg] = alpha_capsfg;
alphas[SchemeCaps][ColBg] = alpha_capsbg;
alphas[SchemeBorder][ColBg] = alpha_border;
2023-04-17 14:14:58 +02:00
// create color schemes from array
2023-05-08 17:50:48 +02:00
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
2023-05-08 23:00:45 +02:00
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], alphas[i], 2);
2023-05-08 17:50:48 +02:00
for (i = 0; i < LENGTH(colors) && i < LENGTH(alphas); i++)
2023-05-08 23:00:45 +02:00
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 2);
for (i = 0; i < LENGTH(textcolors) && i < LENGTH(textclrs); i++)
2023-05-08 23:00:45 +02:00
drw_clr_create(drw, &textclrs[i], textcolors[i], 0);
if (i == 0)
drw_clr_create(drw, &textclrs[i++], "#000000", 0);
for (; i < 7; i++) {
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)
drw_clr_create(drw, &textclrs[i++], "#000000", 0);
if (i == 8)
drw_clr_create(drw, &textclrs[i++], "#333333", 0);
for (; i < 16; i++) {
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++) {
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++) {
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);
}
}