summaryrefslogtreecommitdiff
path: root/dwm/patch/bar_statuscolors.c
diff options
context:
space:
mode:
authorcoasteen <coasteen@proton.me>2026-07-09 10:42:28 +0330
committercoasteen <coasteen@proton.me>2026-07-09 10:42:28 +0330
commit8cbadb61604667b407b53ee1258433994fa4765a (patch)
tree97765fb29418fd6278fcb4cbb9760893afaf7a58 /dwm/patch/bar_statuscolors.c
Diffstat (limited to 'dwm/patch/bar_statuscolors.c')
-rwxr-xr-xdwm/patch/bar_statuscolors.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/dwm/patch/bar_statuscolors.c b/dwm/patch/bar_statuscolors.c
new file mode 100755
index 0000000..7ecb049
--- /dev/null
+++ b/dwm/patch/bar_statuscolors.c
@@ -0,0 +1,102 @@
+int
+width_statuscolors(Bar *bar, BarArg *a)
+{
+ #if BAR_STATUSCMD_PATCH
+ return textw_wosc(rawstext);
+ #else
+ return textw_wosc(stext);
+ #endif // BAR_STATUSCMD_PATCH
+}
+
+#if BAR_EXTRASTATUS_PATCH
+int
+width_statuscolors_es(Bar *bar, BarArg *a)
+{
+ #if BAR_STATUSCMD_PATCH
+ return textw_wosc(rawestext);
+ #else
+ return textw_wosc(estext);
+ #endif // BAR_STATUSCMD_PATCH
+}
+#endif // BAR_EXTRASTATUS_PATCH
+
+int
+draw_statuscolors(Bar *bar, BarArg *a)
+{
+ #if BAR_STATUSCMD_PATCH
+ return draw_wosc(bar, a, rawstext);
+ #else
+ return draw_wosc(bar, a, stext);
+ #endif // BAR_STATUSCMD_PATCH
+}
+
+#if BAR_EXTRASTATUS_PATCH
+int
+draw_statuscolors_es(Bar *bar, BarArg *a)
+{
+ #if BAR_STATUSCMD_PATCH
+ return draw_wosc(bar, a, rawestext);
+ #else
+ return draw_wosc(bar, a, estext);
+ #endif // BAR_STATUSCMD_PATCH
+}
+#endif // BAR_EXTRASTATUS_PATCH
+
+#if !BAR_STATUSCMD_PATCH
+int
+click_statuscolors(Bar *bar, Arg *arg, BarArg *a)
+{
+ return ClkStatusText;
+}
+#endif // BAR_STATUSCMD_PATCH
+
+int
+textw_wosc(char *s)
+{
+ char *ts = s;
+ char *tp = s;
+ int sw = 0;
+ char ctmp;
+ while (1) {
+ if ((unsigned int)*ts > LENGTH(colors)) {
+ ts++;
+ continue;
+ }
+ ctmp = *ts;
+ *ts = '\0';
+ sw += drw_fontset_getwidth(drw, tp, True);
+ *ts = ctmp;
+ if (ctmp == '\0')
+ break;
+ tp = ++ts;
+ }
+
+ return sw;
+}
+
+int
+draw_wosc(Bar *bar, BarArg *a, char *s)
+{
+ char *ts = s;
+ char *tp = s;
+ int tx = 0;
+ char ctmp;
+
+ while (1) {
+ if ((unsigned int)*ts > LENGTH(colors)) {
+ ts++;
+ continue;
+ }
+ ctmp = *ts;
+ *ts = '\0';
+ drw_text(drw, a->x + tx, a->y, a->w - tx, a->h, 0, tp, 0, True);
+ tx += TEXTW(tp) - lrpad;
+ if (ctmp == '\0')
+ break;
+ drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]);
+ *ts = ctmp;
+ tp = ++ts;
+ }
+
+ return 1;
+} \ No newline at end of file