applied multisel patch to mainline 0d12a474
Anselm R Garbe · 2013-04-17 20:56 2 file(s) · +21 −3
dmenu.1 +3 −0
83 83
Confirm selection.  Prints the selected item to stdout and exits, returning
84 84
success.
85 85
.TP
86 +
.B Ctrl-Return
87 +
Confirm selection.  Prints the selected item to stdout and continues.
88 +
.TP
86 89
.B Shift\-Return
87 90
Confirm input.  Prints the input text to stdout and exits, returning success.
88 91
.TP
dmenu.c +18 −3
22 22
struct Item {
23 23
	char *text;
24 24
	Item *left, *right;
25 +
	Bool out;
25 26
};
26 27
27 28
static void appenditem(Item *item, Item **list, Item **last);
49 50
static const char *normfgcolor = "#bbbbbb";
50 51
static const char *selbgcolor  = "#005577";
51 52
static const char *selfgcolor  = "#eeeeee";
53 +
static const char *outbgcolor  = "#00ffff";
54 +
static const char *outfgcolor  = "#000000";
52 55
static unsigned int lines = 0;
53 56
static unsigned long normcol[ColLast];
54 57
static unsigned long selcol[ColLast];
58 +
static unsigned long outcol[ColLast];
55 59
static Atom clip, utf8;
56 60
static Bool topbar = True;
57 61
static DC *dc;
185 189
		dc->w = mw - dc->x;
186 190
		for(item = curr; item != next; item = item->right) {
187 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 196
	else if(matches) {
197 202
		for(item = curr; item != next; item = item->right) {
198 203
			dc->x += dc->w;
199 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 208
		dc->w = textw(dc, ">");
203 209
		dc->x = mw - dc->w;
278 284
			XConvertSelection(dc->dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
279 285
			                  utf8, utf8, win, CurrentTime);
280 286
			return;
287 +
		case XK_Return:
288 +
		case XK_KP_Enter:
289 +
			break;
281 290
		default:
282 291
			return;
283 292
		}
362 371
	case XK_Return:
363 372
	case XK_KP_Enter:
364 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 378
	case XK_Right:
367 379
		if(text[cursor] != '\0') {
368 380
			cursor = nextrune(+1);
480 492
			*p = '\0';
481 493
		if(!(items[i].text = strdup(buf)))
482 494
			eprintf("cannot strdup %u bytes:", strlen(buf)+1);
495 +
		items[i].out = False;
483 496
		if(strlen(items[i].text) > max)
484 497
			max = strlen(maxstr = items[i].text);
485 498
	}
531 544
	normcol[ColFG] = getcolor(dc, normfgcolor);
532 545
	selcol[ColBG]  = getcolor(dc, selbgcolor);
533 546
	selcol[ColFG]  = getcolor(dc, selfgcolor);
547 +
	outcol[ColBG]  = getcolor(dc, outbgcolor);
548 +
	outcol[ColFG]  = getcolor(dc, outfgcolor);
534 549
535 550
	clip = XInternAtom(dc->dpy, "CLIPBOARD",   False);
536 551
	utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);