dwm

Kris's build of dwm
git clone git clone https://git.krisyotam.com/krisyotam/dwm.git
Log | Files | Refs | README | LICENSE

bar_statuscolors.c (1712B)


      1 int
      2 width_statuscolors(Bar *bar, BarArg *a)
      3 {
      4 	#if BAR_STATUSCMD_PATCH
      5 	return textw_wosc(rawstext);
      6 	#else
      7 	return textw_wosc(stext);
      8 	#endif // BAR_STATUSCMD_PATCH
      9 }
     10 
     11 #if BAR_EXTRASTATUS_PATCH
     12 int
     13 width_statuscolors_es(Bar *bar, BarArg *a)
     14 {
     15 	#if BAR_STATUSCMD_PATCH
     16 	return textw_wosc(rawestext);
     17 	#else
     18 	return textw_wosc(estext);
     19 	#endif // BAR_STATUSCMD_PATCH
     20 }
     21 #endif // BAR_EXTRASTATUS_PATCH
     22 
     23 int
     24 draw_statuscolors(Bar *bar, BarArg *a)
     25 {
     26 	#if BAR_STATUSCMD_PATCH
     27 	return draw_wosc(bar, a, rawstext);
     28 	#else
     29 	return draw_wosc(bar, a, stext);
     30 	#endif // BAR_STATUSCMD_PATCH
     31 }
     32 
     33 #if BAR_EXTRASTATUS_PATCH
     34 int
     35 draw_statuscolors_es(Bar *bar, BarArg *a)
     36 {
     37 	#if BAR_STATUSCMD_PATCH
     38 	return draw_wosc(bar, a, rawestext);
     39 	#else
     40 	return draw_wosc(bar, a, estext);
     41 	#endif // BAR_STATUSCMD_PATCH
     42 }
     43 #endif // BAR_EXTRASTATUS_PATCH
     44 
     45 #if !BAR_STATUSCMD_PATCH
     46 int
     47 click_statuscolors(Bar *bar, Arg *arg, BarArg *a)
     48 {
     49 	return ClkStatusText;
     50 }
     51 #endif // BAR_STATUSCMD_PATCH
     52 
     53 int
     54 textw_wosc(char *s)
     55 {
     56 	char *ts = s;
     57 	char *tp = s;
     58 	int sw = 0;
     59 	char ctmp;
     60 	while (1) {
     61 		if ((unsigned int)*ts > LENGTH(colors)) {
     62 			ts++;
     63 			continue;
     64 		}
     65 		ctmp = *ts;
     66 		*ts = '\0';
     67 		sw += drw_fontset_getwidth(drw, tp, True);
     68 		*ts = ctmp;
     69 		if (ctmp == '\0')
     70 			break;
     71 		tp = ++ts;
     72 	}
     73 
     74 	return sw;
     75 }
     76 
     77 int
     78 draw_wosc(Bar *bar, BarArg *a, char *s)
     79 {
     80 	char *ts = s;
     81 	char *tp = s;
     82 	int tx = 0;
     83 	char ctmp;
     84 
     85 	while (1) {
     86 		if ((unsigned int)*ts > LENGTH(colors)) {
     87 			ts++;
     88 			continue;
     89 		}
     90 		ctmp = *ts;
     91 		*ts = '\0';
     92 		drw_text(drw, a->x + tx, a->y, a->w - tx, a->h, 0, tp, 0, True);
     93 		tx += TEXTW(tp) - lrpad;
     94 		if (ctmp == '\0')
     95 			break;
     96 		drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]);
     97 		*ts = ctmp;
     98 		tp = ++ts;
     99 	}
    100 
    101 	return 1;
    102 }