diff options
| author | bakkeby <[email protected]> | 2021-08-25 12:18:01 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2021-08-25 12:18:01 +0200 |
| commit | 036421845ff585b87304e70e1168f24aab80ccdd (patch) | |
| tree | f3be6db055677330354fae7b996e6ef8bf984b42 /patch | |
| parent | c2e4fed9182c84c713b24e6f3c60754c950bcf9b (diff) | |
| download | dwm-flexipatch-036421845ff585b87304e70e1168f24aab80ccdd.tar.gz dwm-flexipatch-036421845ff585b87304e70e1168f24aab80ccdd.zip | |
Adding separate statuscolors bar module ref. #180
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/bar_statuscmd.c | 6 | ||||
| -rw-r--r-- | patch/bar_statuscolors.c | 78 | ||||
| -rw-r--r-- | patch/bar_statuscolors.h | 13 | ||||
| -rw-r--r-- | patch/include.h | 3 |
4 files changed, 99 insertions, 1 deletions
diff --git a/patch/bar_statuscmd.c b/patch/bar_statuscmd.c index 5b26932..8a6393d 100644 --- a/patch/bar_statuscmd.c +++ b/patch/bar_statuscmd.c @@ -31,9 +31,13 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text) #endif // BAR_DWMBLOCKS_PATCH while (text[++i]) { if ((unsigned char)text[i] < ' ') { + #if BAR_STATUSCOLORS_PATCH + if (text[i] < 17) + continue; + #endif // BAR_STATUSCOLORS_PATCH ch = text[i]; text[i] = '\0'; - #if BAR_STATUS2D_PATCH && !BAR_BAR_STATUSCOLORS_PATCH + #if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH x += status2dtextlength(text); #else x += TEXTWM(text) - lrpad; diff --git a/patch/bar_statuscolors.c b/patch/bar_statuscolors.c index 4ade4df..7ecb049 100644 --- a/patch/bar_statuscolors.c +++ b/patch/bar_statuscolors.c @@ -1,4 +1,56 @@ 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; @@ -22,3 +74,29 @@ textw_wosc(char *s) 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 diff --git a/patch/bar_statuscolors.h b/patch/bar_statuscolors.h new file mode 100644 index 0000000..f4880a6 --- /dev/null +++ b/patch/bar_statuscolors.h @@ -0,0 +1,13 @@ +static int width_statuscolors(Bar *bar, BarArg *a); +#if BAR_EXTRASTATUS_PATCH +static int width_statuscolors_es(Bar *bar, BarArg *a); +#endif // BAR_EXTRASTATUS_PATCH +static int draw_statuscolors(Bar *bar, BarArg *a); +#if BAR_EXTRASTATUS_PATCH +static int draw_statuscolors_es(Bar *bar, BarArg *a); +#endif // BAR_EXTRASTATUS_PATCH +#if !BAR_STATUSCMD_PATCH +static int click_statuscolors(Bar *bar, Arg *arg, BarArg *a); +#endif // BAR_STATUSCMD_PATCH +static int textw_wosc(char *s); +static int draw_wosc(Bar *bar, BarArg *a, char *s);
\ No newline at end of file diff --git a/patch/include.h b/patch/include.h index c913a27..eea37a8 100644 --- a/patch/include.h +++ b/patch/include.h @@ -44,6 +44,9 @@ #if BAR_STATUSCMD_PATCH #include "bar_statuscmd.h" #endif +#if BAR_STATUSCOLORS_PATCH +#include "bar_statuscolors.h" +#endif #if BAR_WINICON_PATCH #include "bar_winicon.h" #endif |
