statuscmd compatibility with powerline
This commit is contained in:
parent
d1d0554d7d
commit
7629d9537a
|
@ -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
|
int
|
||||||
width_status_pwl(Bar *bar, BarWidthArg *a)
|
width_status_pwl(Bar *bar, BarWidthArg *a)
|
||||||
{
|
{
|
||||||
return widthpowerlinestatus(rawstext);
|
if (selmon->hidestatus) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return widthpowerlinestatus(rawstext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
draw_status_pwl(Bar *bar, BarDrawArg *a)
|
draw_status_pwl(Bar *bar, BarDrawArg *a)
|
||||||
{
|
{
|
||||||
return drawpowerlinestatus(a->x + a->w, rawstext);
|
if (selmon->hidestatus) {
|
||||||
}
|
return 0;
|
||||||
|
} else {
|
||||||
int
|
return drawpowerlinestatus(a->x + a->w, rawstext);
|
||||||
click_status_pwl(Bar *bar, Arg *arg, BarClickArg *a)
|
}
|
||||||
{
|
|
||||||
return ClkStatusText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -55,11 +90,13 @@ drawpowerlinestatus(int xpos, char *stext)
|
||||||
|
|
||||||
for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) {
|
for (i = n, bs = &status[n-1]; i >= 0; i--, bs--) {
|
||||||
if (*bs == '<' || *bs == '/' || *bs == '\\' || *bs == '>' || *bs == '|') { /* block start */
|
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)) {
|
if (cn < LENGTH(powerlinecolors)) {
|
||||||
drw_settrans(drw, prevscheme, (nxtscheme = powerlinescheme[cn]));
|
drw_settrans(drw, prevscheme, (nxtscheme = powerlinescheme[cn]));
|
||||||
} else {
|
} else {
|
||||||
|
offset--;
|
||||||
drw_settrans(drw, prevscheme, (nxtscheme = powerlinescheme[0]));
|
drw_settrans(drw, prevscheme, (nxtscheme = powerlinescheme[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +107,8 @@ drawpowerlinestatus(int xpos, char *stext)
|
||||||
}
|
}
|
||||||
|
|
||||||
drw_setscheme(drw, nxtscheme);
|
drw_setscheme(drw, nxtscheme);
|
||||||
w = TEXTW(bs+2);
|
w = TEXTW(bs+offset);
|
||||||
drw_text(drw, x - w, 0, w, bh, lrpad / 2, bs+2, 0, False);
|
drw_text(drw, x - w, 0, w, bh, lrpad / 2, bs+offset, 0, False);
|
||||||
x -= w;
|
x -= w;
|
||||||
|
|
||||||
bp = *bs;
|
bp = *bs;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
static int width_status_pwl(Bar *bar, BarWidthArg *a);
|
static int width_status_pwl(Bar *bar, BarWidthArg *a);
|
||||||
static int draw_status_pwl(Bar *bar, BarDrawArg *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_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 drawpowerlinestatus(int x, char *stext);
|
||||||
static int widthpowerlinestatus(char *stext);
|
static int widthpowerlinestatus(char *stext);
|
||||||
|
|
Loading…
Reference in a new issue