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