Adding powerline patch

This commit is contained in:
bakkeby
2020-07-19 16:57:30 +02:00
parent 23c0e9450f
commit 023aa218e4
16 changed files with 409 additions and 67 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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);

127
patch/bar_powerline_tags.c Normal file
View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);
static int drawstatusbar(int x, char *text);
static int status2dtextlength(char *stext);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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