History

highlight clicked item

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit a256cd71 parent 041131c1 file · +19 −3Browse files

Unified · Split

bar.c+19−3
@@ -13,7 +13,7 @@ enum { · 12 unmodified lines
1313 Off = 3,
1414 };
1515
16−static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw;
16+static int wctl, owidth, width, twidth, bottom, bat, minheight, seplen, sepw, hlitem;
1717 static char sep[16], bats[16], *aux;
1818 static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64];
1919 static int itemw[64], nitems;
@@ -127,6 +127,7 @@ redraw(void) · 107 unmodified lines
127127 Tmfmt tf;
128128 Point p;
129129 Tm tm;
130+ int i;
130131
131132 r = screen->r;
132133
@@ -142,6 +143,14 @@ redraw(void) · 9 unmodified lines
142143 }
143144 draw(screen, r, cback, nil, ZP);
144145 string(screen, p, ctext, ZP, f, s);
146+ if(hlitem >= 0){
147+ for(i = 0; i < hlitem; i++)
148+ r.min.x += itemw[i];
149+ r.max.x = r.min.x + itemw[i];
150+ replclipr(screen, 0, r);
151+ stringbg(screen, p, cback, ZP, f, s, ctext, ZP);
152+ replclipr(screen, 0, screen->r);
153+ }
145154 split(s);
146155
147156 flushimage(display, 1);
@@ -209,10 +218,16 @@ clicked(int x, int buttons) · 61 unmodified lines
209218 {
210219 int i, ix;
211220
221+ if(hlitem >= 0){
222+ hlitem = -1;
223+ return;
224+ }
225+
212226 for(i = ix = 0; i < nitems; i++){
213227 ix += itemw[i];
214228 if(x <= ix){
215229 fprint(1, "%d\t%s\n", buttons, items[i]);
230+ hlitem = i;
216231 break;
217232 }
218233 }
@@ -307,6 +322,7 @@ threadmain(int argc, char **argv) · 88 unmodified lines
307322 a[Eaux].c = chancreate(sizeof(s), 0);
308323 a[Etimer].c = chancreate(sizeof(ulong), 0);
309324
325+ hlitem = -1;
310326 aux = strdup("");
311327 readbattery();
312328 redraw();
@@ -326,8 +342,8 @@ threadmain(int argc, char **argv) · 13 unmodified lines
326342 }
327343 break;
328344
329− case Emouse:
330− if(m.buttons == 0 || m.buttons == oldbuttons)
345+ case Emouse:
346+ if(m.buttons == oldbuttons)
331347 break;
332348 clicked(m.xy.x-screen->r.min.x, m.buttons);
333349 /* wet floor */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t