continue patch

This commit is contained in:
BitHeaven 2022-08-15 12:43:09 +05:00 committed by GitHub
parent ca8ea3f462
commit adc415215e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 107 additions and 3 deletions

110
dwm.c
View File

@ -702,10 +702,114 @@ dirtomon(int dir)
void void
drawstatusbar(Monitor *m, int bh, char* stext) { drawstatusbar(Monitor *m, int bh, char* stext) {
// drw_setscheme(drw, scheme[SchemeNorm]); int ret, i, w, x, len;
// tw = TEXTW(stext); /* - lrpad + 2; * 2px right padding */ short isCode = 0;
// drw_text(drw, m->ww - tw - 2 * hpb, 0, tw, bh, lrpad / 2, stext, 0); char *text;
char *p;
len = strlen(stext) + 1 ;
if (!(text = (char*) malloc(sizeof(char)*len)))
die("malloc");
p = text;
memcpy(text, stext, len);
/* compute width of the status text */
w = 0;
i = -1;
while (text[++i]) {
if (text[i] == '^') {
if (!isCode) {
isCode = 1;
text[i] = '\0';
w += TEXTW(text) - lrpad;
text[i] = '^';
if (text[++i] == 'f')
w += atoi(text + ++i);
} else {
isCode = 0;
text = text + i + 1;
i = -1;
}
}
}
if (!isCode)
w += TEXTW(text) - lrpad;
else
isCode = 0;
text = p;
w += 2; /* 1px pad on sides */ // MAYBE THAT DELETE
ret = x = m->ww - w;
drw_setscheme(drw, scheme[LENGTH(colors)]);
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
drw_rect(drw, x, 0, w, bh, 1, 1);
x++;
/* process status text */
i = -1;
while (text[++i]) {
if (text[i] == '^' && !isCode) {
isCode = 1;
text[i] = '\0';
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
x += w;
/* process code */
while (text[++i] != '^') {
if (text[i] == 'c') {
char buf[8];
memcpy(buf, (char*)text+i+1, 7);
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColFg], buf);
i += 7;
} else if (text[i] == 'b') {
char buf[8];
memcpy(buf, (char*)text+i+1, 7);
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColBg], buf);
i += 7;
} else if (text[i] == 'd') {
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
} else if (text[i] == 'r') {
int rx = atoi(text + ++i);
while (text[++i] != ',');
int ry = atoi(text + ++i);
while (text[++i] != ',');
int rw = atoi(text + ++i);
while (text[++i] != ',');
int rh = atoi(text + ++i);
drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
} else if (text[i] == 'f') {
x += atoi(text + ++i);
}
}
text = text + i + 1;
i=-1;
isCode = 0;
}
}
if (!isCode) {
// w = TEXTW(text) - lrpad;
w = TEXTW(text); // THIS ROW
// drw_text(drw, m->ww - tw , 0, tw, bh, 0 , text, 0);
// drw_text(drw, m->ww - tw - 2 * hpb, 0, tw, bh, lrpad / 2, text, 0);
// drw_text(drw, x , 0, w , bh, 0 , text, 0);
drw_text(drw, x - 2 * hpb , 0, w , bh, lrpad / 2, text, 0); // THIS ROW
}
drw_setscheme(drw, scheme[SchemeNorm]);
free(p);
return ret;
} }
void void