bar_statuscmd.c (1571B)
1 #if !BAR_DWMBLOCKS_PATCH 2 static const char statusexport[] = "export BUTTON=-;"; 3 static int statuscmdn; 4 static char lastbutton[] = "-"; 5 #endif // BAR_DWMBLOCKS_PATCH 6 7 int 8 click_statuscmd(Bar *bar, Arg *arg, BarArg *a) 9 { 10 return click_statuscmd_text(arg, a->x, rawstext); 11 } 12 13 #if BAR_EXTRASTATUS_PATCH 14 int 15 click_statuscmd_es(Bar *bar, Arg *arg, BarArg *a) 16 { 17 return click_statuscmd_text(arg, a->x, rawestext); 18 } 19 #endif // BAR_EXTRASTATUS_PATCH 20 21 int 22 click_statuscmd_text(Arg *arg, int rel_x, char *text) 23 { 24 int i = -1; 25 int x = 0; 26 char ch; 27 #if BAR_DWMBLOCKS_PATCH 28 statussig = -1; 29 #else 30 statuscmdn = 0; 31 #endif // BAR_DWMBLOCKS_PATCH 32 while (text[++i]) { 33 if ((unsigned char)text[i] < ' ') { 34 #if BAR_STATUSCOLORS_PATCH 35 if (text[i] < 17) 36 continue; 37 #endif // BAR_STATUSCOLORS_PATCH 38 ch = text[i]; 39 text[i] = '\0'; 40 #if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH 41 x += status2dtextlength(text); 42 #else 43 x += TEXTWM(text) - lrpad; 44 #endif // BAR_STATUS2D_PATCH 45 text[i] = ch; 46 text += i+1; 47 i = -1; 48 #if BAR_DWMBLOCKS_PATCH 49 if (x >= rel_x && statussig != -1) 50 break; 51 statussig = ch; 52 #else 53 if (x >= rel_x) 54 break; 55 if (ch <= LENGTH(statuscmds)) 56 statuscmdn = ch; 57 #endif // BAR_DWMBLOCKS_PATCH 58 } 59 } 60 #if BAR_DWMBLOCKS_PATCH 61 if (statussig == -1) 62 statussig = 0; 63 #endif // BAR_DWMBLOCKS_PATCH 64 return ClkStatusText; 65 } 66 67 void 68 copyvalidchars(char *text, char *rawtext) 69 { 70 int i = -1, j = 0; 71 72 while (rawtext[++i]) { 73 if ((unsigned char)rawtext[i] >= ' ') { 74 text[j++] = rawtext[i]; 75 } 76 } 77 text[j] = '\0'; 78 } 79