Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-sgrstatus256-20220223-6.3.diff - sites - public wiki contents of suckless.o…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-sgrstatus256-20220223-6.3.diff (3430B)
---
1 From 7be41dd26e562072afc11621432aa71d2ea5622a Mon Sep 17 00:00:00 2001
2 From: Santtu Lakkala <[email protected]>
3 Date: Wed, 23 Feb 2022 16:22:59 +0200
4 Subject: [PATCH 2/2] 256 colors SGR support
5
6 ---
7 dwm.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
8 1 file changed, 64 insertions(+), 3 deletions(-)
9
10 diff --git a/dwm.c b/dwm.c
11 index cb9484a..e2dc586 100644
12 --- a/dwm.c
13 +++ b/dwm.c
14 @@ -264,7 +264,7 @@ static Atom wmatom[WMLast], netatom[NetLast];
15 static int running = 1;
16 static Cur *cursor[CurLast];
17 static Clr **scheme;
18 -static Clr *barclrs;
19 +static Clr barclrs[256];
20 static Display *dpy;
21 static Drw *drw;
22 static Monitor *mons, *selmon;
23 @@ -804,8 +804,25 @@ drawbar(Monitor *m)
24 lp = 0;
25
26 char *ep = stext + rd + 1;
27 + int ignore = 0;
28 + int bgfg = 0;
29 while (*ep != 'm') {
30 unsigned v = strtoul(ep…
31 + if (ignore)
32 + continue;
33 + if (bgfg) {
34 + if (bgfg < 4 &&…
35 + bgfg <<…
36 + continu…
37 + }
38 + if (bgfg == 4)
39 + scm[0] …
40 + else if (bgfg =…
41 + scm[1] …
42 + ignore = 1;
43 +
44 + continue;
45 + }
46 if (v == 0) {
47 memcpy(scm, sch…
48 fg = 7;
49 @@ -850,9 +867,13 @@ drawbar(Monitor *m)
50 } else if (v >= 30 && v…
51 fg = v % 10 | (…
52 scm[0] = barclr…
53 + } else if (v == 38) {
54 + bgfg = 2;
55 } else if (v >= 40 && v…
56 bg = v % 10;
57 scm[1] = barclr…
58 + } else if (v == 48) {
59 + bgfg = 3;
60 } else if (v == 53) {
61 fmt |= OVERLINE;
62 } else if (v == 55) {
63 @@ -1701,12 +1722,19 @@ setmfact(const Arg *arg)
64 arrange(selmon);
65 }
66
67 +unsigned char
68 +sixd_to_8bit(int x)
69 +{
70 + return x == 0 ? 0 : 0x37 + 0x28 * x;
71 +}
72 +
73 void
74 setup(void)
75 {
76 int i;
77 XSetWindowAttributes wa;
78 Atom utf8string;
79 + char cbuf[8];
80
81 /* clean up any zombies immediately */
82 sigchld(0);
83 @@ -1746,9 +1774,42 @@ setup(void)
84 for (i = 0; i < LENGTH(colors); i++)
85 scheme[i] = drw_scm_create(drw, colors[i], 3);
86
87 - barclrs = ecalloc(LENGTH(barcolors), sizeof(Clr));
88 - for (i = 0; i < LENGTH(barcolors); i++)
89 + for (i = 0; i < LENGTH(barcolors) && i < LENGTH(barclrs); i++)
90 drw_clr_create(drw, &barclrs[i], barcolors[i]);
91 + if (i == 0)
92 + drw_clr_create(drw, &barclrs[i++], "#000000");
93 + for (; i < 7; i++) {
94 + snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
95 + !!(i & 1) * 0x7f,
96 + !!(i & 2) * 0x7f,
97 + !!(i & 4) * 0x7f);
98 + drw_clr_create(drw, &barclrs[i], cbuf);
99 + }
100 + if (i == 7)
101 + drw_clr_create(drw, &barclrs[i++], "#000000");
102 + if (i == 8)
103 + drw_clr_create(drw, &barclrs[i++], "#333333");
104 + for (; i < 16; i++) {
105 + snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
106 + !!(i & 1) * 0xff,
107 + !!(i & 2) * 0xff,
108 + !!(i & 4) * 0xff);
109 + drw_clr_create(drw, &barclrs[i], cbuf);
110 + }
111 + for (; i < 6 * 6 * 6 + 16; i++) {
112 + snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
113 + sixd_to_8bit(((i - 16) / 36) % 6),
114 + sixd_to_8bit(((i - 16) / 6) % 6),
115 + sixd_to_8bit(((i - 16)) % 6));
116 + drw_clr_create(drw, &barclrs[i], cbuf);
117 + }
118 + for (; i < 256; i++) {
119 + snprintf(cbuf, sizeof(cbuf), "#%02x%02x%02x",
120 + 0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
121 + 0x08 + (i - 6 * 6 * 6 - 16) * 0x0a,
122 + 0x08 + (i - 6 * 6 * 6 - 16) * 0x0a);
123 + drw_clr_create(drw, &barclrs[i], cbuf);
124 + }
125
126 /* init bars */
127 updatebars();
128 --
129 2.32.0
130
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.