--- config.def.h | 8 ++++++++ dwm.c | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index 1c0b587..eaae845 100644 --- a/config.def.h +++ b/config.def.h _AT_@ -12,10 +12,18 @@ static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_cyan[] = "#005577"; +static const char col_black[] = "#000000"; +static const char col_red[] = "#ff0000"; +static const char col_yellow[] = "#ffff00"; +static const char col_white[] = "#ffffff"; +static const char col_green[] = "#009900"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeWarn] = { col_black, col_yellow, col_red }, + [SchemeUrgent]= { col_white, col_red, col_red }, + [SchemeFine]= { col_green, col_gray1, col_gray2 }, }; /* tagging */ diff --git a/dwm.c b/dwm.c index 4465af1..8e09b8a 100644 --- a/dwm.c +++ b/dwm.c _AT_@ -59,7 +59,7 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent, SchemeFine }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ _AT_@ -699,14 +699,41 @@ drawbar(Monitor *m) int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; - Client *c; + char *ts = stext; + char *tp = stext; + int tx = 0; + char ctmp; + Client *c; /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); - } + /* Chain length computed between escape sequence which slow down too + * much TEXTW function */ + while(1) { + if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue; } + ctmp = *ts; + *ts = '\0'; + sw += TEXTW(tp) - lrpad; + if (ctmp == '\0') { break; } + *ts = ctmp; + tp = ++ts; + } + sw = sw + 2; /* 2px right padding */ + ts = stext; + tp = stext; + while (1) { + if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue; } + ctmp = *ts; + *ts = '\0'; + drw_text(drw, m->ww - sw + tx, 0, sw - tx, 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) { occ |= c->tags; -- 2.27.0Received on Wed Jul 01 2020 - 20:53:57 CEST
This archive was generated by hypermail 2.3.0 : Wed Jul 01 2020 - 21:00:34 CEST