2020-08-28 05:17:52 +00:00
|
|
|
#if BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
|
|
|
static char termcol0[] = "#000000"; /* black */
|
|
|
|
static char termcol1[] = "#ff0000"; /* red */
|
|
|
|
static char termcol2[] = "#33ff00"; /* green */
|
|
|
|
static char termcol3[] = "#ff0099"; /* yellow */
|
|
|
|
static char termcol4[] = "#0066ff"; /* blue */
|
|
|
|
static char termcol5[] = "#cc00ff"; /* magenta */
|
|
|
|
static char termcol6[] = "#00ffff"; /* cyan */
|
|
|
|
static char termcol7[] = "#d0d0d0"; /* white */
|
|
|
|
static char termcol8[] = "#808080"; /* black */
|
|
|
|
static char termcol9[] = "#ff0000"; /* red */
|
|
|
|
static char termcol10[] = "#33ff00"; /* green */
|
|
|
|
static char termcol11[] = "#ff0099"; /* yellow */
|
|
|
|
static char termcol12[] = "#0066ff"; /* blue */
|
|
|
|
static char termcol13[] = "#cc00ff"; /* magenta */
|
|
|
|
static char termcol14[] = "#00ffff"; /* cyan */
|
|
|
|
static char termcol15[] = "#ffffff"; /* white */
|
|
|
|
static char *termcolor[] = {
|
|
|
|
termcol0, termcol1, termcol2, termcol3, termcol4, termcol5, termcol6, termcol7,
|
|
|
|
termcol8, termcol9, termcol10, termcol11, termcol12, termcol13, termcol14, termcol15,
|
|
|
|
};
|
|
|
|
#endif // BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
|
|
|
|
2020-05-26 18:53:53 +00:00
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
width_status2d(Bar *bar, BarArg *a)
|
2020-05-26 18:53:53 +00:00
|
|
|
{
|
2020-08-22 14:25:56 +00:00
|
|
|
int width;
|
2020-07-24 09:15:44 +00:00
|
|
|
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH
|
2020-08-22 14:25:56 +00:00
|
|
|
width = status2dtextlength(rawstext);
|
2020-07-24 09:15:44 +00:00
|
|
|
#else
|
2020-08-22 14:25:56 +00:00
|
|
|
width = status2dtextlength(stext);
|
2020-07-24 09:15:44 +00:00
|
|
|
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH
|
2020-08-22 14:25:56 +00:00
|
|
|
return width ? width + lrpad : 0;
|
2020-07-15 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-18 19:12:30 +00:00
|
|
|
#if BAR_EXTRASTATUS_PATCH
|
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
width_status2d_es(Bar *bar, BarArg *a)
|
2020-07-18 19:12:30 +00:00
|
|
|
{
|
2020-08-22 14:25:56 +00:00
|
|
|
int width;
|
2020-08-24 13:03:55 +00:00
|
|
|
#if BAR_STATUSCMD_PATCH
|
2020-08-22 14:25:56 +00:00
|
|
|
width = status2dtextlength(rawestext);
|
2020-07-24 09:15:44 +00:00
|
|
|
#else
|
2020-08-22 14:25:56 +00:00
|
|
|
width = status2dtextlength(estext);
|
2020-08-24 13:03:55 +00:00
|
|
|
#endif // BAR_STATUSCMD_PATCH
|
2020-08-22 14:25:56 +00:00
|
|
|
return width ? width + lrpad : 0;
|
2020-07-18 19:12:30 +00:00
|
|
|
}
|
|
|
|
#endif // BAR_EXTRASTATUS_PATCH
|
|
|
|
|
2020-07-15 06:57:30 +00:00
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
draw_status2d(Bar *bar, BarArg *a)
|
2020-07-15 06:57:30 +00:00
|
|
|
{
|
2020-07-24 09:15:44 +00:00
|
|
|
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH
|
2020-09-09 15:24:02 +00:00
|
|
|
return drawstatusbar(a, rawstext);
|
2020-07-24 09:15:44 +00:00
|
|
|
#else
|
2020-09-09 15:24:02 +00:00
|
|
|
return drawstatusbar(a, stext);
|
2020-07-24 09:15:44 +00:00
|
|
|
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH
|
2020-07-15 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-18 19:12:30 +00:00
|
|
|
#if BAR_EXTRASTATUS_PATCH
|
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
draw_status2d_es(Bar *bar, BarArg *a)
|
2020-07-18 19:12:30 +00:00
|
|
|
{
|
2020-08-24 13:03:55 +00:00
|
|
|
#if BAR_STATUSCMD_PATCH
|
2020-09-09 15:24:02 +00:00
|
|
|
return drawstatusbar(a, rawestext);
|
2020-07-24 09:15:44 +00:00
|
|
|
#else
|
2020-09-09 15:24:02 +00:00
|
|
|
return drawstatusbar(a, estext);
|
2020-08-24 13:03:55 +00:00
|
|
|
#endif // BAR_STATUSCMD_PATCH
|
2020-07-18 19:12:30 +00:00
|
|
|
}
|
|
|
|
#endif // BAR_EXTRASTATUS_PATCH
|
|
|
|
|
2020-07-18 11:03:30 +00:00
|
|
|
#if !BAR_STATUSCMD_PATCH
|
2020-07-15 06:57:30 +00:00
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
click_status2d(Bar *bar, Arg *arg, BarArg *a)
|
2020-07-15 06:57:30 +00:00
|
|
|
{
|
|
|
|
return ClkStatusText;
|
|
|
|
}
|
2020-07-18 11:03:30 +00:00
|
|
|
#endif // BAR_STATUSCMD_PATCH
|
2020-07-15 06:57:30 +00:00
|
|
|
|
|
|
|
int
|
2020-09-09 15:24:02 +00:00
|
|
|
drawstatusbar(BarArg *a, char* stext)
|
2020-07-15 06:57:30 +00:00
|
|
|
{
|
|
|
|
int i, w, len;
|
2020-09-09 15:24:02 +00:00
|
|
|
int x = a->x;
|
|
|
|
int y = a->y;
|
2020-05-26 18:53:53 +00:00
|
|
|
short isCode = 0;
|
|
|
|
char *text;
|
|
|
|
char *p;
|
2020-08-27 04:30:48 +00:00
|
|
|
Clr oldbg, oldfg;
|
2021-03-31 17:41:46 +00:00
|
|
|
len = strlen(stext);
|
|
|
|
if (!(text = (char*) malloc(sizeof(char)*(len + 1))))
|
2020-05-26 18:53:53 +00:00
|
|
|
die("malloc");
|
|
|
|
p = text;
|
2020-07-15 06:57:30 +00:00
|
|
|
#if BAR_STATUSCMD_PATCH
|
2020-05-27 19:04:22 +00:00
|
|
|
copyvalidchars(text, stext);
|
|
|
|
#else
|
2020-05-26 18:53:53 +00:00
|
|
|
memcpy(text, stext, len);
|
2020-07-15 06:57:30 +00:00
|
|
|
#endif // BAR_STATUSCMD_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
|
2020-07-18 11:03:30 +00:00
|
|
|
x += lrpad / 2;
|
2020-07-31 08:24:54 +00:00
|
|
|
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
|
|
|
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
|
|
|
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
2020-07-18 11:03:30 +00:00
|
|
|
|
2020-05-26 18:53:53 +00:00
|
|
|
/* process status text */
|
|
|
|
i = -1;
|
|
|
|
while (text[++i]) {
|
|
|
|
if (text[i] == '^' && !isCode) {
|
|
|
|
isCode = 1;
|
|
|
|
|
|
|
|
text[i] = '\0';
|
2020-06-11 17:42:00 +00:00
|
|
|
w = TEXTWM(text) - lrpad;
|
2020-09-09 15:24:02 +00:00
|
|
|
drw_text(drw, x, y, w, bh, 0, text, 0, True);
|
2020-05-26 18:53:53 +00:00
|
|
|
|
|
|
|
x += w;
|
|
|
|
|
|
|
|
/* process code */
|
|
|
|
while (text[++i] != '^') {
|
|
|
|
if (text[i] == 'c') {
|
|
|
|
char buf[8];
|
|
|
|
if (i + 7 > len) {
|
|
|
|
i += 7;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
memcpy(buf, (char*)text+i+1, 7);
|
|
|
|
buf[7] = '\0';
|
2020-07-15 06:57:30 +00:00
|
|
|
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
drw_clr_create(drw, &drw->scheme[ColFg], buf, 0xff);
|
2020-07-15 06:57:30 +00:00
|
|
|
#elif BAR_ALPHA_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
drw_clr_create(drw, &drw->scheme[ColFg], buf, alphas[SchemeNorm][ColFg]);
|
|
|
|
#else
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColFg], buf);
|
2020-07-15 06:57:30 +00:00
|
|
|
#endif // BAR_ALPHA_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
i += 7;
|
|
|
|
} else if (text[i] == 'b') {
|
|
|
|
char buf[8];
|
|
|
|
if (i + 7 > len) {
|
|
|
|
i += 7;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
memcpy(buf, (char*)text+i+1, 7);
|
|
|
|
buf[7] = '\0';
|
2020-07-15 06:57:30 +00:00
|
|
|
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
drw_clr_create(drw, &drw->scheme[ColBg], buf, 0xff);
|
2020-07-15 06:57:30 +00:00
|
|
|
#elif BAR_ALPHA_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
drw_clr_create(drw, &drw->scheme[ColBg], buf, alphas[SchemeNorm][ColBg]);
|
|
|
|
#else
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColBg], buf);
|
2020-07-15 06:57:30 +00:00
|
|
|
#endif // BAR_ALPHA_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
i += 7;
|
2020-08-28 05:17:52 +00:00
|
|
|
#if BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
|
|
|
} else if (text[i] == 'C') {
|
|
|
|
int c = atoi(text + ++i) % 16;
|
|
|
|
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c], 0xff);
|
|
|
|
#elif BAR_ALPHA_PATCH
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c], alphas[SchemeNorm][ColBg]);
|
|
|
|
#else
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]);
|
|
|
|
#endif // BAR_ALPHA_PATCH
|
|
|
|
} else if (text[i] == 'B') {
|
|
|
|
int c = atoi(text + ++i) % 16;
|
|
|
|
#if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c], 0xff);
|
|
|
|
#elif BAR_ALPHA_PATCH
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c], alphas[SchemeNorm][ColBg]);
|
|
|
|
#else
|
|
|
|
drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]);
|
|
|
|
#endif // BAR_ALPHA_PATCH
|
|
|
|
#endif // BAR_STATUS2D_XRDB_TERMCOLORS_PATCH
|
2020-05-26 18:53:53 +00:00
|
|
|
} else if (text[i] == 'd') {
|
|
|
|
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
|
|
|
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
2020-08-27 04:30:48 +00:00
|
|
|
} else if (text[i] == 'w') {
|
|
|
|
Clr swp;
|
|
|
|
swp = drw->scheme[ColFg];
|
|
|
|
drw->scheme[ColFg] = drw->scheme[ColBg];
|
|
|
|
drw->scheme[ColBg] = swp;
|
|
|
|
} else if (text[i] == 'v') {
|
|
|
|
oldfg = drw->scheme[ColFg];
|
|
|
|
oldbg = drw->scheme[ColBg];
|
|
|
|
} else if (text[i] == 't') {
|
|
|
|
drw->scheme[ColFg] = oldfg;
|
|
|
|
drw->scheme[ColBg] = oldbg;
|
2020-05-26 18:53:53 +00:00
|
|
|
} 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);
|
|
|
|
|
2020-05-31 13:14:07 +00:00
|
|
|
if (ry < 0)
|
|
|
|
ry = 0;
|
|
|
|
if (rx < 0)
|
|
|
|
rx = 0;
|
|
|
|
|
2020-09-09 15:24:02 +00:00
|
|
|
drw_rect(drw, rx + x, y + ry, rw, rh, 1, 0);
|
2020-05-26 18:53:53 +00:00
|
|
|
} else if (text[i] == 'f') {
|
|
|
|
x += atoi(text + ++i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
text = text + i + 1;
|
2021-03-31 17:41:46 +00:00
|
|
|
len -= i + 1;
|
2020-05-26 18:53:53 +00:00
|
|
|
i=-1;
|
|
|
|
isCode = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isCode) {
|
2020-06-11 17:42:00 +00:00
|
|
|
w = TEXTWM(text) - lrpad;
|
2020-09-09 15:24:02 +00:00
|
|
|
drw_text(drw, x, y, w, bh, 0, text, 0, True);
|
2020-07-15 06:57:30 +00:00
|
|
|
x += w;
|
2020-05-26 18:53:53 +00:00
|
|
|
}
|
2020-07-15 06:57:30 +00:00
|
|
|
free(p);
|
2020-05-26 18:53:53 +00:00
|
|
|
|
|
|
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
2020-08-22 07:26:56 +00:00
|
|
|
return len - 1;
|
2020-05-27 19:04:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
status2dtextlength(char* stext)
|
|
|
|
{
|
|
|
|
int i, w, len;
|
|
|
|
short isCode = 0;
|
|
|
|
char *text;
|
2020-07-15 06:57:30 +00:00
|
|
|
char *p;
|
2020-05-27 19:04:22 +00:00
|
|
|
|
|
|
|
len = strlen(stext) + 1;
|
|
|
|
if (!(text = (char*) malloc(sizeof(char)*len)))
|
|
|
|
die("malloc");
|
2020-07-15 06:57:30 +00:00
|
|
|
p = text;
|
|
|
|
#if BAR_STATUSCMD_PATCH
|
2020-05-27 19:04:22 +00:00
|
|
|
copyvalidchars(text, stext);
|
|
|
|
#else
|
|
|
|
memcpy(text, stext, len);
|
2020-07-15 06:57:30 +00:00
|
|
|
#endif // BAR_STATUSCMD_PATCH
|
2020-05-27 19:04:22 +00:00
|
|
|
|
|
|
|
/* compute width of the status text */
|
|
|
|
w = 0;
|
|
|
|
i = -1;
|
|
|
|
while (text[++i]) {
|
|
|
|
if (text[i] == '^') {
|
|
|
|
if (!isCode) {
|
|
|
|
isCode = 1;
|
|
|
|
text[i] = '\0';
|
2020-06-11 17:42:00 +00:00
|
|
|
w += TEXTWM(text) - lrpad;
|
2020-05-27 19:04:22 +00:00
|
|
|
text[i] = '^';
|
|
|
|
if (text[++i] == 'f')
|
|
|
|
w += atoi(text + ++i);
|
|
|
|
} else {
|
|
|
|
isCode = 0;
|
|
|
|
text = text + i + 1;
|
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isCode)
|
2020-06-11 17:42:00 +00:00
|
|
|
w += TEXTWM(text) - lrpad;
|
2020-07-15 06:57:30 +00:00
|
|
|
free(p);
|
2020-05-27 19:04:22 +00:00
|
|
|
return w;
|
2020-07-15 06:57:30 +00:00
|
|
|
}
|