statuscmd compatibility with powerline

This commit is contained in:
speedie 2022-12-05 20:30:07 +01:00
parent d1d0554d7d
commit 7629d9537a
2 changed files with 50 additions and 12 deletions

View file

@ -1,21 +1,56 @@
static Clr **powerlinescheme;
int
click_status_pwl(Bar *bar, Arg *arg, BarClickArg *a)
{
if (selmon->hidestatus) {
return 0;
} else {
return click_status_text(arg, a->rel_x, rawstext);
}
}
int
click_status_text_pwl(Arg *arg, int rel_x, char *text)
{
int dpad = drw->font->h;
int i = -1;
int x = dpad / 2 - (TEXTW("_") - lrpad);
char ch;
clickstatusn = 0;
while (text[++i]) {
if ((unsigned char)text[i] < ' ') {
ch = text[i];
text[i] = '\0';
x += textlength(text) + dpad;
text[i] = ch;
text += i+1;
i = -1;
if (x >= rel_x)
break;
if (ch <= LENGTH(clickstatuss))
clickstatusn = ch;
}
}
return ClkStatusText;
}
int
width_status_pwl(Bar *bar, BarWidthArg *a)
{
return widthpowerlinestatus(rawstext);
if (selmon->hidestatus) {
return 0;
} else {
return widthpowerlinestatus(rawstext);
}
}
int
draw_status_pwl(Bar *bar, BarDrawArg *a)
{
return drawpowerlinestatus(a->x + a->w, rawstext);
}
int
click_status_pwl(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkStatusText;
if (selmon->hidestatus) {
return 0;
} else {
return drawpowerlinestatus(a->x + a->w, rawstext);
}
}
int
@ -55,11 +90,13 @@ drawpowerlinestatus(int xpos, char *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;
int offset = 3;
cn = *(bs + offset - 1) - 1;
if (cn < LENGTH(powerlinecolors)) {
drw_settrans(drw, prevscheme, (nxtscheme = powerlinescheme[cn]));
} else {
offset--;
drw_settrans(drw, prevscheme, (nxtscheme = powerlinescheme[0]));
}
@ -70,8 +107,8 @@ drawpowerlinestatus(int xpos, char *stext)
}
drw_setscheme(drw, nxtscheme);
w = TEXTW(bs+2);
drw_text(drw, x - w, 0, w, bh, lrpad / 2, bs+2, 0, False);
w = TEXTW(bs+offset);
drw_text(drw, x - w, 0, w, bh, lrpad / 2, bs+offset, 0, False);
x -= w;
bp = *bs;

View file

@ -1,5 +1,6 @@
static int width_status_pwl(Bar *bar, BarWidthArg *a);
static int draw_status_pwl(Bar *bar, BarDrawArg *a);
static int click_status_pwl(Bar *bar, Arg *arg, BarClickArg *a);
static int click_status_text_pwl(Arg *arg, int rel_x, char *text);
static int drawpowerlinestatus(int x, char *stext);
static int widthpowerlinestatus(char *stext);