From 0efbb7dc4be93b16a6db754ce34f1c268074e6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Tue, 15 Oct 2024 21:32:37 +0200 Subject: patches: add statuscolors --- dwm.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 6b5503a..d05fd9d 100644 --- a/dwm.c +++ b/dwm.c @@ -58,7 +58,7 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ @@ -729,7 +729,17 @@ drawbar(Monitor *m) int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; + char *ts = stext; + char *tp = stext; + int tx = 0; + char ctmp; Client *c; + int correct = 0; /* correction for colours */ + + for ( ; *ts != '\0' ; ts++) + if (*ts <= LENGTH(colors)) + correct += TEXTW("A") - lrpad; + ts = stext; if (!m->showbar) return; @@ -738,7 +748,17 @@ drawbar(Monitor *m) if (m == selmon || 1) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); + while (1) { + if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; } + ctmp = *ts; + *ts = '\0'; + drw_text(drw, m->ww - tw + tx + correct, 0, tw - tx - correct, bh, 0, tp, 0); + tx += TEXTW(tp) -lrpad; + if (ctmp == '\0') { break; } + drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); + *ts = ctmp; + tp = ++ts; + } } for (c = m->clients; c; c = c->next) { @@ -764,12 +784,12 @@ drawbar(Monitor *m) if ((w = m->ww - tw - x) > bh) { if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); + drw_text(drw, x, 0, w + correct, bh, lrpad / 2, m->sel->name, 0); if (m->sel->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); } else { drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x, 0, w, bh, 1, 1); + drw_rect(drw, x, 0, w + correct, bh, 1, 1); } } drw_map(drw, m->barwin, 0, 0, m->ww, bh); -- cgit v1.2.3