diff options
| author | Anselm R Garbe <anselm@garbe.us> | 2013-04-17 20:56:54 +0200 |
|---|---|---|
| committer | Anselm R Garbe <anselm@garbe.us> | 2013-04-17 20:56:54 +0200 |
| commit | 0d12a47415edba5db73f56dba76f123394581387 (patch) | |
| tree | 0754a8f3dc6bfb12f5fd1f64678f6545f3a9225c | |
| parent | dec9a28863f388072be105e0950deb72ac719d48 (diff) | |
applied multisel patch to mainline
| -rw-r--r-- | dmenu.1 | 3 | ||||
| -rw-r--r-- | dmenu.c | 21 |
2 files changed, 21 insertions, 3 deletions
| @@ -83,6 +83,9 @@ Copy the selected item to the input field. | |||
| 83 | Confirm selection. Prints the selected item to stdout and exits, returning | 83 | Confirm selection. Prints the selected item to stdout and exits, returning |
| 84 | success. | 84 | success. |
| 85 | .TP | 85 | .TP |
| 86 | .B Ctrl-Return | ||
| 87 | Confirm selection. Prints the selected item to stdout and continues. | ||
| 88 | .TP | ||
| 86 | .B Shift\-Return | 89 | .B Shift\-Return |
| 87 | Confirm input. Prints the input text to stdout and exits, returning success. | 90 | Confirm input. Prints the input text to stdout and exits, returning success. |
| 88 | .TP | 91 | .TP |
| @@ -22,6 +22,7 @@ typedef struct Item Item; | |||
| 22 | struct Item { | 22 | struct Item { |
| 23 | char *text; | 23 | char *text; |
| 24 | Item *left, *right; | 24 | Item *left, *right; |
| 25 | Bool out; | ||
| 25 | }; | 26 | }; |
| 26 | 27 | ||
| 27 | static void appenditem(Item *item, Item **list, Item **last); | 28 | static void appenditem(Item *item, Item **list, Item **last); |
| @@ -49,9 +50,12 @@ static const char *normbgcolor = "#222222"; | |||
| 49 | static const char *normfgcolor = "#bbbbbb"; | 50 | static const char *normfgcolor = "#bbbbbb"; |
| 50 | static const char *selbgcolor = "#005577"; | 51 | static const char *selbgcolor = "#005577"; |
| 51 | static const char *selfgcolor = "#eeeeee"; | 52 | static const char *selfgcolor = "#eeeeee"; |
| 53 | static const char *outbgcolor = "#00ffff"; | ||
| 54 | static const char *outfgcolor = "#000000"; | ||
| 52 | static unsigned int lines = 0; | 55 | static unsigned int lines = 0; |
| 53 | static unsigned long normcol[ColLast]; | 56 | static unsigned long normcol[ColLast]; |
| 54 | static unsigned long selcol[ColLast]; | 57 | static unsigned long selcol[ColLast]; |
| 58 | static unsigned long outcol[ColLast]; | ||
| 55 | static Atom clip, utf8; | 59 | static Atom clip, utf8; |
| 56 | static Bool topbar = True; | 60 | static Bool topbar = True; |
| 57 | static DC *dc; | 61 | static DC *dc; |
| @@ -185,7 +189,8 @@ drawmenu(void) { | |||
| 185 | dc->w = mw - dc->x; | 189 | dc->w = mw - dc->x; |
| 186 | for(item = curr; item != next; item = item->right) { | 190 | for(item = curr; item != next; item = item->right) { |
| 187 | dc->y += dc->h; | 191 | dc->y += dc->h; |
| 188 | drawtext(dc, item->text, (item == sel) ? selcol : normcol); | 192 | drawtext(dc, item->text, (item == sel) ? selcol : |
| 193 | (item->out) ? outcol : normcol); | ||
| 189 | } | 194 | } |
| 190 | } | 195 | } |
| 191 | else if(matches) { | 196 | else if(matches) { |
| @@ -197,7 +202,8 @@ drawmenu(void) { | |||
| 197 | for(item = curr; item != next; item = item->right) { | 202 | for(item = curr; item != next; item = item->right) { |
| 198 | dc->x += dc->w; | 203 | dc->x += dc->w; |
| 199 | dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">")); | 204 | dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">")); |
| 200 | drawtext(dc, item->text, (item == sel) ? selcol : normcol); | 205 | drawtext(dc, item->text, (item == sel) ? selcol : |
| 206 | (item->out) ? outcol : normcol); | ||
| 201 | } | 207 | } |
| 202 | dc->w = textw(dc, ">"); | 208 | dc->w = textw(dc, ">"); |
| 203 | dc->x = mw - dc->w; | 209 | dc->x = mw - dc->w; |
| @@ -278,6 +284,9 @@ keypress(XKeyEvent *ev) { | |||
| 278 | XConvertSelection(dc->dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, | 284 | XConvertSelection(dc->dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, |
| 279 | utf8, utf8, win, CurrentTime); | 285 | utf8, utf8, win, CurrentTime); |
| 280 | return; | 286 | return; |
| 287 | case XK_Return: | ||
| 288 | case XK_KP_Enter: | ||
| 289 | break; | ||
| 281 | default: | 290 | default: |
| 282 | return; | 291 | return; |
| 283 | } | 292 | } |
| @@ -362,7 +371,10 @@ keypress(XKeyEvent *ev) { | |||
| 362 | case XK_Return: | 371 | case XK_Return: |
| 363 | case XK_KP_Enter: | 372 | case XK_KP_Enter: |
| 364 | puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); | 373 | puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); |
| 365 | exit(EXIT_SUCCESS); | 374 | if(!(ev->state & ControlMask)) |
| 375 | exit(EXIT_SUCCESS); | ||
| 376 | sel->out = True; | ||
| 377 | break; | ||
| 366 | case XK_Right: | 378 | case XK_Right: |
| 367 | if(text[cursor] != '\0') { | 379 | if(text[cursor] != '\0') { |
| 368 | cursor = nextrune(+1); | 380 | cursor = nextrune(+1); |
| @@ -480,6 +492,7 @@ readstdin(void) { | |||
| 480 | *p = '\0'; | 492 | *p = '\0'; |
| 481 | if(!(items[i].text = strdup(buf))) | 493 | if(!(items[i].text = strdup(buf))) |
| 482 | eprintf("cannot strdup %u bytes:", strlen(buf)+1); | 494 | eprintf("cannot strdup %u bytes:", strlen(buf)+1); |
| 495 | items[i].out = False; | ||
| 483 | if(strlen(items[i].text) > max) | 496 | if(strlen(items[i].text) > max) |
| 484 | max = strlen(maxstr = items[i].text); | 497 | max = strlen(maxstr = items[i].text); |
| 485 | } | 498 | } |
| @@ -531,6 +544,8 @@ setup(void) { | |||
| 531 | normcol[ColFG] = getcolor(dc, normfgcolor); | 544 | normcol[ColFG] = getcolor(dc, normfgcolor); |
| 532 | selcol[ColBG] = getcolor(dc, selbgcolor); | 545 | selcol[ColBG] = getcolor(dc, selbgcolor); |
| 533 | selcol[ColFG] = getcolor(dc, selfgcolor); | 546 | selcol[ColFG] = getcolor(dc, selfgcolor); |
| 547 | outcol[ColBG] = getcolor(dc, outbgcolor); | ||
| 548 | outcol[ColFG] = getcolor(dc, outfgcolor); | ||
| 534 | 549 | ||
| 535 | clip = XInternAtom(dc->dpy, "CLIPBOARD", False); | 550 | clip = XInternAtom(dc->dpy, "CLIPBOARD", False); |
| 536 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); | 551 | utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False); |
