Unified · Split
| @@ -13,7 +13,7 @@ enum { · 12 unmodified lines | ||
| 13 | 13 | Off = 3, |
| 14 | 14 | }; |
| 15 | 15 | |
| 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; | |
| 17 | 17 | static char sep[16], bats[16], *aux; |
| 18 | 18 | static char *pos = "rb", *dfmt = "YYYY/MM/DD WW hh:mm:ss", *items[64]; |
| 19 | 19 | static int itemw[64], nitems; |
| @@ -127,6 +127,7 @@ redraw(void) · 107 unmodified lines | ||
| 127 | 127 | Tmfmt tf; |
| 128 | 128 | Point p; |
| 129 | 129 | Tm tm; |
| 130 | + int i; | |
| 130 | 131 | |
| 131 | 132 | r = screen->r; |
| 132 | 133 | |
| @@ -142,6 +143,14 @@ redraw(void) · 9 unmodified lines | ||
| 142 | 143 | } |
| 143 | 144 | draw(screen, r, cback, nil, ZP); |
| 144 | 145 | 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 | + } | |
| 145 | 154 | split(s); |
| 146 | 155 | |
| 147 | 156 | flushimage(display, 1); |
| @@ -209,10 +218,16 @@ clicked(int x, int buttons) · 61 unmodified lines | ||
| 209 | 218 | { |
| 210 | 219 | int i, ix; |
| 211 | 220 | |
| 221 | + if(hlitem >= 0){ | |
| 222 | + hlitem = -1; | |
| 223 | + return; | |
| 224 | + } | |
| 225 | + | |
| 212 | 226 | for(i = ix = 0; i < nitems; i++){ |
| 213 | 227 | ix += itemw[i]; |
| 214 | 228 | if(x <= ix){ |
| 215 | 229 | fprint(1, "%d\t%s\n", buttons, items[i]); |
| 230 | + hlitem = i; | |
| 216 | 231 | break; |
| 217 | 232 | } |
| 218 | 233 | } |
| @@ -307,6 +322,7 @@ threadmain(int argc, char **argv) · 88 unmodified lines | ||
| 307 | 322 | a[Eaux].c = chancreate(sizeof(s), 0); |
| 308 | 323 | a[Etimer].c = chancreate(sizeof(ulong), 0); |
| 309 | 324 | |
| 325 | + hlitem = -1; | |
| 310 | 326 | aux = strdup(""); |
| 311 | 327 | readbattery(); |
| 312 | 328 | redraw(); |
| @@ -326,8 +342,8 @@ threadmain(int argc, char **argv) · 13 unmodified lines | ||
| 326 | 342 | } |
| 327 | 343 | break; |
| 328 | 344 | |
| 329 | − case Emouse: | |
| 330 | − if(m.buttons == 0 || m.buttons == oldbuttons) | |
| 345 | + case Emouse: | |
| 346 | + if(m.buttons == oldbuttons) | |
| 331 | 347 | break; |
| 332 | 348 | clicked(m.xy.x-screen->r.min.x, m.buttons); |
| 333 | 349 | /* wet floor */ |