diff options
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/bar_fancybar.c | 5 | ||||
| -rw-r--r-- | patch/bar_powerline_status.c | 121 | ||||
| -rw-r--r-- | patch/bar_powerline_status.h | 11 | ||||
| -rw-r--r-- | patch/bar_powerline_tags.c | 127 | ||||
| -rw-r--r-- | patch/bar_powerline_tags.h | 3 | ||||
| -rw-r--r-- | patch/bar_status2d.h | 4 | ||||
| -rw-r--r-- | patch/bar_tags.c | 18 | ||||
| -rw-r--r-- | patch/bar_wintitle.c | 8 | ||||
| -rw-r--r-- | patch/include.c | 6 | ||||
| -rw-r--r-- | patch/include.h | 6 |
10 files changed, 281 insertions, 28 deletions
diff --git a/patch/bar_fancybar.c b/patch/bar_fancybar.c index a193876..810026d 100644 --- a/patch/bar_fancybar.c +++ b/patch/bar_fancybar.c @@ -12,13 +12,8 @@ draw_fancybar(Bar *bar, BarDrawArg *a) Client *c; Monitor *m = bar->mon; - #if BAR_PANGO_PATCH - int boxs = drw->font->h / 9; - int boxw = drw->font->h / 6 + 2; - #else int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; - #endif // BAR_PANGO_PATCH #if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD int x = a->x + lrpad / 2, w = a->w - lrpad; #elif BAR_TITLE_LEFT_PAD diff --git a/patch/bar_powerline_status.c b/patch/bar_powerline_status.c new file mode 100644 index 0000000..3e2ee6a --- /dev/null +++ b/patch/bar_powerline_status.c @@ -0,0 +1,121 @@ +static Clr **statusscheme; + +int +width_pwrl_status(Bar *bar, BarWidthArg *a) +{ + #if BAR_STATUSCMD_PATCH + return widthpowerlinestatus(rawstext); + #else + return widthpowerlinestatus(stext); + #endif // BAR_STATUSCMD_PATCH +} + +#if BAR_EXTRASTATUS_PATCH +int +width_pwrl_status_es(Bar *bar, BarWidthArg *a) +{ + #if BAR_STATUSCMD_PATCH + return widthpowerlinestatus(rawestext); + #else + return widthpowerlinestatus(estext); + #endif // BAR_STATUSCMD_PATCH +} +#endif // BAR_EXTRASTATUS_PATCH + +int +draw_pwrl_status(Bar *bar, BarDrawArg *a) +{ + #if BAR_STATUSCMD_PATCH + return drawpowerlinestatus(a->x + a->w, rawstext); + #else + return drawpowerlinestatus(a->x + a->w, stext); + #endif // BAR_STATUSCMD_PATCH +} + +#if BAR_EXTRASTATUS_PATCH +int +draw_pwrl_status_es(Bar *bar, BarDrawArg *a) +{ + #if BAR_STATUSCMD_PATCH + return drawpowerlinestatus(a->x + a->w, rawestext); + #else + return drawpowerlinestatus(a->x + a->w, estext); + #endif // BAR_STATUSCMD_PATCH +} +#endif // BAR_EXTRASTATUS_PATCH + +int +click_pwrl_status(Bar *bar, Arg *arg, BarClickArg *a) +{ + return ClkStatusText; +} + +int +widthpowerlinestatus(char *stext) +{ + char status[512]; + int w = 0, i, n = strlen(stext); + int plw = drw->fonts->h / 2 + 1; + char *bs, bp = '|'; + strcpy(status, stext); + + for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) { + if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */ + if (bp != '|') + w += plw; + w += TEXTW(bs+2); + bp = *bs; + *bs = 0; + } + } + if (bp != '|') + w += plw * 2; + + return w; +} + +int +drawpowerlinestatus(int xpos, char *stext) +{ + char status[512]; + int i, n = strlen(stext), cn = 0; + int x = xpos, w = 0; + int plw = drw->fonts->h / 2 + 1; + char *bs, bp = '|'; + Clr *prevscheme = statusscheme[0], *nxtscheme; + strcpy(status, stext); + + for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) { + if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */ + cn = ((int) *(bs+1)) - 1; + + if (cn < LENGTH(statuscolors)) { + drw_settrans(drw, prevscheme, (nxtscheme = statusscheme[cn])); + } else { + drw_settrans(drw, prevscheme, (nxtscheme = statusscheme[0])); + } + + if (bp != '|') { + drw_arrow(drw, x - plw, 0, plw, bh, bp == '\\' || bp == '>' ? 1 : 0, bp == '<' ? 0 : 1); + x -= plw; + } + + drw_setscheme(drw, nxtscheme); + w = TEXTW(bs+2); + drw_text(drw, x - w, 0, w, bh, lrpad / 2, bs+2, 0); + x -= w; + + bp = *bs; + *bs = 0; + prevscheme = nxtscheme; + } + } + if (bp != '|') { + drw_settrans(drw, prevscheme, scheme[SchemeNorm]); + drw_arrow(drw, x - plw, 0, plw, bh, bp == '\\' || bp == '>' ? 1 : 0, bp == '<' ? 0 : 1); + drw_rect(drw, x - 2 * plw, 0, plw, bh, 1, 1); + x -= plw * 2; + } + + return xpos - x; +}
\ No newline at end of file diff --git a/patch/bar_powerline_status.h b/patch/bar_powerline_status.h new file mode 100644 index 0000000..2ff5ad2 --- /dev/null +++ b/patch/bar_powerline_status.h @@ -0,0 +1,11 @@ +static int width_pwrl_status(Bar *bar, BarWidthArg *a); +#if BAR_EXTRASTATUS_PATCH +static int width_pwrl_status_es(Bar *bar, BarWidthArg *a); +#endif // BAR_EXTRASTATUS_PATCH +static int draw_pwrl_status(Bar *bar, BarDrawArg *a); +#if BAR_EXTRASTATUS_PATCH +static int draw_pwrl_status_es(Bar *bar, BarDrawArg *a); +#endif // BAR_EXTRASTATUS_PATCH +static int click_pwrl_status(Bar *bar, Arg *arg, BarClickArg *a); +static int drawpowerlinestatus(int x, char *stext); +static int widthpowerlinestatus(char *stext);
\ No newline at end of file diff --git a/patch/bar_powerline_tags.c b/patch/bar_powerline_tags.c new file mode 100644 index 0000000..a85559b --- /dev/null +++ b/patch/bar_powerline_tags.c @@ -0,0 +1,127 @@ +int +width_pwrl_tags(Bar *bar, BarWidthArg *a) +{ + int w, i; + int plw = drw->fonts->h / 2 + 1; + #if BAR_HIDEVACANTTAGS_PATCH + Client *c; + unsigned int occ = 0; + for (c = bar->mon->clients; c; c = c->next) + occ |= c->tags == 255 ? 0 : c->tags; + #endif // BAR_HIDEVACANTTAGS_PATCH + + for (w = 0, i = 0; i < LENGTH(tags); i++) { + #if BAR_HIDEVACANTTAGS_PATCH + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i)) + continue; + #endif // BAR_HIDEVACANTTAGS_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH + w += selmon->alttag ? TEXTW(tagsalt[i]) : TEXTW(tags[i]) + plw; + #else + w += TEXTW(tags[i]) + plw; + #endif // BAR_ALTERNATIVE_TAGS_PATCH + } + return w + lrpad; +} + +int +draw_pwrl_tags(Bar *bar, BarDrawArg *a) +{ + int x, w; + int invert; + int plw = drw->fonts->h / 2 + 1; + unsigned int i, occ = 0, urg = 0; + Client *c; + Clr *prevscheme, *nxtscheme; + #if !BAR_HIDEVACANTTAGS_PATCH + #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + int boxs = drw->fonts->h / 9; + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + int boxw = drw->fonts->h / 6 + 2; + #endif // BAR_HIDEVACANTTAGS_PATCH + + for (c = bar->mon->clients; c; c = c->next) { + #if BAR_HIDEVACANTTAGS_PATCH + occ |= c->tags == 255 ? 0 : c->tags; + #else + occ |= c->tags; + #endif // BAR_HIDEVACANTTAGS_PATCH + if (c->isurgent) + urg |= c->tags; + } + x = a->x; + prevscheme = scheme[SchemeNorm]; + for (i = 0; i < LENGTH(tags); i++) { + #if BAR_HIDEVACANTTAGS_PATCH + /* do not draw vacant tags */ + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i)) + continue; + #endif // BAR_HIDEVACANTTAGS_PATCH + #if URGENTBORDER_PATCH + invert = 0; + #else + invert = urg & 1 << i; + #endif // URGENTBORDER_PATCH + w = TEXTW(tags[i]); + drw_settrans(drw, prevscheme, (nxtscheme = scheme[bar->mon->tagset[bar->mon->seltags] & 1 << i ? SchemeSel : SchemeNorm])); + #if BAR_POWERLINE_TAGS_SLASH_PATCH + drw_arrow(drw, x, 0, plw, bh, 1, 1); + #else + drw_arrow(drw, x, 0, plw, bh, 1, 1); + #endif // BAR_POWERLINE_TAGS_SLASH_PATCH + x += plw; + drw_setscheme(drw, nxtscheme); + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert); + #if !BAR_HIDEVACANTTAGS_PATCH + if (occ & 1 << i) + #if BAR_ACTIVETAGINDICATORBAR_PATCH + drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, + #elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, + #else + drw_rect(drw, x + boxs, boxs, boxw, boxw, + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH + bar->mon == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); + #endif // BAR_HIDEVACANTTAGS_PATCH + x += w; + prevscheme = nxtscheme; + } + nxtscheme = scheme[SchemeNorm]; + + drw_settrans(drw, prevscheme, nxtscheme); + #if BAR_POWERLINE_TAGS_SLASH_PATCH + drw_arrow(drw, x, 0, plw, bh, 1, 1); + #else + drw_arrow(drw, x, 0, plw, bh, 1, 0); + #endif // BAR_POWERLINE_TAGS_SLASH_PATCH + return a->x + a->w; +} + +int +click_pwrl_tags(Bar *bar, Arg *arg, BarClickArg *a) +{ + int i = 0, x = lrpad / 2; + int plw = drw->fonts->h / 2 + 1; + #if BAR_HIDEVACANTTAGS_PATCH + Client *c; + unsigned int occ = 0; + for (c = bar->mon->clients; c; c = c->next) + occ |= c->tags == 255 ? 0 : c->tags; + #endif // BAR_HIDEVACANTTAGS_PATCH + + do { + #if BAR_HIDEVACANTTAGS_PATCH + if (!(occ & 1 << i || bar->mon->tagset[bar->mon->seltags] & 1 << i)) + continue; + #endif // BAR_HIDEVACANTTAGS_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH + x += selmon->alttag ? TEXTW(tagsalt[i]) : TEXTW(tags[i]) + plw; + #else + x += TEXTW(tags[i]) + plw; + #endif + } while (a->rel_x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + arg->ui = 1 << i; + } + return ClkTagBar; +}
\ No newline at end of file diff --git a/patch/bar_powerline_tags.h b/patch/bar_powerline_tags.h new file mode 100644 index 0000000..b1e0389 --- /dev/null +++ b/patch/bar_powerline_tags.h @@ -0,0 +1,3 @@ +static int width_pwrl_tags(Bar *bar, BarWidthArg *a); +static int draw_pwrl_tags(Bar *bar, BarDrawArg *a); +static int click_pwrl_tags(Bar *bar, Arg *arg, BarClickArg *a);
\ No newline at end of file diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h index cdaa2a8..ea48dd3 100644 --- a/patch/bar_status2d.h +++ b/patch/bar_status2d.h @@ -9,5 +9,5 @@ static int draw_status2d_es(Bar *bar, BarDrawArg *a); #if !BAR_STATUSCMD_PATCH static int click_status2d(Bar *bar, Arg *arg, BarClickArg *a); #endif // BAR_STATUSCMD_PATCH -static int drawstatusbar(int x, char* text); -static int status2dtextlength(char* stext);
\ No newline at end of file +static int drawstatusbar(int x, char *text); +static int status2dtextlength(char *stext);
\ No newline at end of file diff --git a/patch/bar_tags.c b/patch/bar_tags.c index 45c7e00..4d88784 100644 --- a/patch/bar_tags.c +++ b/patch/bar_tags.c @@ -33,17 +33,9 @@ draw_tags(Bar *bar, BarDrawArg *a) #endif // BAR_ALTERNATIVE_TAGS_PATCH #if !BAR_HIDEVACANTTAGS_PATCH #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - #if BAR_PANGO_PATCH - int boxs = drw->font->h / 9; - #else int boxs = drw->fonts->h / 9; - #endif // BAR_PANGO_PATCH #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - #if BAR_PANGO_PATCH - int boxw = drw->font->h / 6 + 2; - #else int boxw = drw->fonts->h / 6 + 2; - #endif // BAR_PANGO_PATCH #endif // BAR_HIDEVACANTTAGS_PATCH unsigned int i, occ = 0, urg = 0; Client *c; @@ -60,16 +52,16 @@ draw_tags(Bar *bar, BarDrawArg *a) } for (i = 0; i < LENGTH(tags); i++) { - #if URGENTBORDER_PATCH - invert = 0; - #else - invert = urg & 1 << i; - #endif // URGENTBORDER_PATCH #if BAR_HIDEVACANTTAGS_PATCH /* do not draw vacant tags */ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) continue; #endif // BAR_HIDEVACANTTAGS_PATCH + #if URGENTBORDER_PATCH + invert = 0; + #else + invert = urg & 1 << i; + #endif // URGENTBORDER_PATCH w = TEXTW(tags[i]); #if BAR_ALTERNATIVE_TAGS_PATCH wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0; diff --git a/patch/bar_wintitle.c b/patch/bar_wintitle.c index 70c42ce..7382e0f 100644 --- a/patch/bar_wintitle.c +++ b/patch/bar_wintitle.c @@ -8,17 +8,9 @@ int draw_wintitle(Bar *bar, BarDrawArg *a) { #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - #if BAR_PANGO_PATCH - int boxs = drw->font->h / 9; - #else int boxs = drw->fonts->h / 9; - #endif // BAR_PANGO_PATCH #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - #if BAR_PANGO_PATCH - int boxw = drw->font->h / 6 + 2; - #else int boxw = drw->fonts->h / 6 + 2; - #endif // BAR_PANGO_PATCH #if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD int x = a->x + lrpad / 2, w = a->w - lrpad; diff --git a/patch/include.c b/patch/include.c index cef9234..2964b98 100644 --- a/patch/include.c +++ b/patch/include.c @@ -20,6 +20,12 @@ #if BAR_LTSYMBOL_PATCH #include "bar_ltsymbol.c" #endif +#if BAR_POWERLINE_STATUS_PATCH +#include "bar_powerline_status.c" +#endif +#if BAR_POWERLINE_TAGS_PATCH +#include "bar_powerline_tags.c" +#endif #if BAR_STATUS_PATCH #include "bar_status.c" #endif diff --git a/patch/include.h b/patch/include.h index 8b1d470..b3bce6f 100644 --- a/patch/include.h +++ b/patch/include.h @@ -20,6 +20,12 @@ #if BAR_LTSYMBOL_PATCH #include "bar_ltsymbol.h" #endif +#if BAR_POWERLINE_STATUS_PATCH +#include "bar_powerline_status.h" +#endif +#if BAR_POWERLINE_TAGS_PATCH +#include "bar_powerline_tags.h" +#endif #if BAR_STATUS_PATCH #include "bar_status.h" #endif |
