diff --git a/README.md b/README.md index 2d0987a..d92bb77 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2020-04-16 - Upgraded the scratchpad patch to the multiple scratchpads patch \[[ref](https://lists.suckless.org/hackers/2004/17205.html)\] +2020-04-16 - Upgraded the scratchpad patch to the multiple scratchpads patch \[[ref](https://lists.suckless.org/hackers/2004/17205.html)\]. Updated the statuscolors patch with the width computation fix \[[ref](https://lists.suckless.org/hackers/2004/17207.html)\]. 2020-04-13 - Added statuscmd patch diff --git a/dwm.c b/dwm.c index 5b87c54..df1104f 100644 --- a/dwm.c +++ b/dwm.c @@ -1462,12 +1462,12 @@ drawbar(Monitor *m) #else drw_setscheme(drw, scheme[SchemeNorm]); #endif // VTCOLORS_PATCH - #if STATUSPADDING_PATCH - sw = TEXTW(stext); - #else - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - #endif // STATUSPADDING_PATCH #if STATUSCOLORS_PATCH + #if STATUSPADDING_PATCH + sw = textw_wosc(stext) + lrpad + 2; + #else + sw = textw_wosc(stext) + 2; + #endif // STATUSPADDING_PATCH while (1) { if ((unsigned int)*ts > LENGTH(colors)) { ts++; @@ -1477,14 +1477,18 @@ drawbar(Monitor *m) *ts = '\0'; drw_text(drw, m->ww - sw - stw + tx, 0, sw - tx, bh, stp, tp, 0); tx += TEXTW(tp) -lrpad; - if (ctmp == '\0') { + if (ctmp == '\0') break; - } drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); *ts = ctmp; tp = ++ts; } #else // STATUSCOLORS_PATCH + #if STATUSPADDING_PATCH + sw = TEXTW(stext); + #else + sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ + #endif // STATUSPADDING_PATCH drw_text(drw, m->ww - sw - stw, 0, sw, bh, stp, stext, 0); #endif // STATUSCOLORS_PATCH #if !STATUSALLMONS_PATCH diff --git a/patch/include.c b/patch/include.c index 72a840c..42b35f4 100644 --- a/patch/include.c +++ b/patch/include.c @@ -110,6 +110,9 @@ #if STACKER_PATCH #include "stacker.c" #endif +#if STATUSCOLORS_PATCH +#include "statuscolors.c" +#endif #if STATUSCMD_PATCH #include "statuscmd.c" #endif @@ -221,4 +224,4 @@ #endif #if TILE_LAYOUT #include "tile.c" -#endif +#endif \ No newline at end of file diff --git a/patch/statuscolors.c b/patch/statuscolors.c new file mode 100644 index 0000000..2f015ad --- /dev/null +++ b/patch/statuscolors.c @@ -0,0 +1,23 @@ +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); + *ts = ctmp; + if (ctmp == '\0') + break; + tp = ++ts; + } + + return sw; +} \ No newline at end of file