cleanup statuscmd/status2d

This commit is contained in:
speedie 2022-12-03 22:24:09 +01:00
parent 47c606ade1
commit c0c9540262
3 changed files with 17 additions and 20 deletions

2
bar.h
View file

@ -16,7 +16,7 @@ static const BarRule barrules[] = {
{ -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" }, { -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" },
{ 'A', 0, BAR_ALIGN_RIGHT, width_systray, draw_systray, click_systray, "systray" }, { 'A', 0, BAR_ALIGN_RIGHT, width_systray, draw_systray, click_systray, "systray" },
//{ 'A', 0, BAR_ALIGN_RIGHT, width_status_basic, draw_status_basic, click_status_basic, "basic status" }, //{ 'A', 0, BAR_ALIGN_RIGHT, width_status_basic, draw_status_basic, click_status_basic, "basic status" },
{ 'A', 0, BAR_ALIGN_RIGHT, width_status2d, draw_status2d, click_statuscmd, "status2d" }, { 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "clickable status" },
//{ -1, 0, BAR_ALIGN_NONE, width_title_basic, draw_title_basic, click_title_basic, "basic title" }, //{ -1, 0, BAR_ALIGN_NONE, width_title_basic, draw_title_basic, click_title_basic, "basic title" },
{ -1, 0, BAR_ALIGN_NONE, width_title, draw_title, click_title, "title" }, { -1, 0, BAR_ALIGN_NONE, width_title, draw_title, click_title, "title" },
}; };

View file

@ -2,19 +2,19 @@ static int clickstatusn;
static char lastbutton[] = "-"; static char lastbutton[] = "-";
int int
width_status2d(Bar *bar, BarWidthArg *a) width_status(Bar *bar, BarWidthArg *a)
{ {
return status2dtextlength(rawstext) + lrpad; return textlength(rawstext) + lrpad;
} }
int int
draw_status2d(Bar *bar, BarDrawArg *a) draw_status(Bar *bar, BarDrawArg *a)
{ {
return drawstatusbar(a->x, rawstext); return drawstatustext(a->x, rawstext);
} }
int int
drawstatusbar(int x, char* stext) drawstatustext(int x, char* stext)
{ {
int i, w, len; int i, w, len;
short isCode = 0; short isCode = 0;
@ -117,7 +117,7 @@ drawstatusbar(int x, char* stext)
} }
int int
status2dtextlength(char* stext) textlength(char* stext)
{ {
int i, w, len; int i, w, len;
short isCode = 0; short isCode = 0;
@ -156,13 +156,13 @@ status2dtextlength(char* stext)
} }
int int
click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a) click_status(Bar *bar, Arg *arg, BarClickArg *a)
{ {
return click_statuscmd_text(arg, a->rel_x, rawstext); return click_status_text(arg, a->rel_x, rawstext);
} }
int int
click_statuscmd_text(Arg *arg, int rel_x, char *text) click_status_text(Arg *arg, int rel_x, char *text)
{ {
int i = -1; int i = -1;
int x = 0; int x = 0;
@ -172,7 +172,7 @@ click_statuscmd_text(Arg *arg, int rel_x, char *text)
if ((unsigned char)text[i] < ' ') { if ((unsigned char)text[i] < ' ') {
ch = text[i]; ch = text[i];
text[i] = '\0'; text[i] = '\0';
x += status2dtextlength(text); x += textlength(text);
text[i] = ch; text[i] = ch;
text += i+1; text += i+1;
i = -1; i = -1;

View file

@ -1,10 +1,7 @@
static int width_status2d(Bar *bar, BarWidthArg *a); static int width_status(Bar *bar, BarWidthArg *a);
static int width_status2d_es(Bar *bar, BarWidthArg *a); static int draw_status(Bar *bar, BarDrawArg *a);
static int draw_status2d(Bar *bar, BarDrawArg *a); static int drawstatustext(int x, char *text);
static int draw_status2d_es(Bar *bar, BarDrawArg *a); static int textlength(char *stext);
static int drawstatusbar(int x, char *text); static int click_status(Bar *bar, Arg *arg, BarClickArg *a);
static int status2dtextlength(char *stext); static int click_status_text(Arg *arg, int rel_x, char *text);
static int click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a);
static int click_statuscmd_es(Bar *bar, Arg *arg, BarClickArg *a);
static int click_statuscmd_text(Arg *arg, int rel_x, char *text);
static void copyvalidchars(char *text, char *rawtext); static void copyvalidchars(char *text, char *rawtext);