fast grab patch (thanks Rob) e0e6b071
Connor Lane Smith · 2011-05-08 15:15 2 file(s) · +27 −13
dmenu.1 +13 −9
4 4
.SH SYNOPSIS
5 5
.B dmenu
6 6
.RB [ \-b ]
7 +
.RB [ \-f ]
7 8
.RB [ \-i ]
8 9
.RB [ \-l
9 10
.IR lines ]
32 33
.BR dwm (1).
33 34
It manages huge numbers of user-defined menu items efficiently.
34 35
.P
35 -
dmenu reads a list of newline-separated items from standard input and creates a
36 -
menu.  When the user selects an item or enters any text and presses Return,
37 -
their choice is printed to standard output and dmenu terminates.
36 +
dmenu reads a list of newline-separated items from stdin and creates a menu.
37 +
When the user selects an item or enters any text and presses Return, their
38 +
choice is printed to stdout and dmenu terminates.
38 39
.P
39 40
.B dmenu_run
40 41
is a dmenu script used by dwm which lists programs in the user's PATH and
46 47
.TP
47 48
.B \-b
48 49
dmenu appears at the bottom of the screen.
50 +
.TP
51 +
.B \-f
52 +
dmenu grabs the keyboard before reading stdin.  This is faster, but may lock up
53 +
X if stdin is from a terminal.
49 54
.TP
50 55
.B \-i
51 56
dmenu matches menu items case insensitively.
66 71
defines the normal background color.
67 72
.IR #RGB ,
68 73
.IR #RRGGBB ,
69 -
and color names are supported.
74 +
and X color names are supported.
70 75
.TP
71 76
.BI \-nf " color"
72 77
defines the normal foreground color.
78 83
defines the selected foreground color.
79 84
.TP
80 85
.B \-v
81 -
prints version information to standard output, then exits.
86 +
prints version information to stdout, then exits.
82 87
.SH USAGE
83 88
dmenu is completely controlled by the keyboard.  Besides standard Unix line
84 89
editing and item selection (Up/Down/Left/Right, PageUp/PageDown, Home/End), the
88 93
Copy the selected item to the input field.
89 94
.TP
90 95
.B Return (Control\-j)
91 -
Confirm selection.  Prints the selected item to standard output and exits,
92 -
returning success.
96 +
Confirm selection.  Prints the selected item to stdout and exits, returning
97 +
success.
93 98
.TP
94 99
.B Shift\-Return (Control\-Shift\-j)
95 -
Confirm input.  Prints the input text to standard output and exits, returning
96 -
success.
100 +
Confirm input.  Prints the input text to stdout and exits, returning success.
97 101
.TP
98 102
.B Escape (Control\-c)
99 103
Exit without selecting an item, returning failure.
dmenu.c +14 −4
64 64
65 65
int
66 66
main(int argc, char *argv[]) {
67 +
	Bool fast = False;
67 68
	int i;
68 69
69 70
	progname = "dmenu";
77 78
			topbar = False;
78 79
		else if(!strcmp(argv[i], "-i"))
79 80
			fstrncmp = strncasecmp;
81 +
		else if(!strcmp(argv[i], "-f"))
82 +
			fast = True;
80 83
		else if(i == argc-1)
81 84
			goto usage;
82 85
		/* double flags */
101 104
102 105
	dc = initdc();
103 106
	initfont(dc, font);
104 -
	readstdin();
105 -
	setup();
107 +
108 +
	if(fast) {
109 +
		setup();
110 +
		readstdin();
111 +
	}
112 +
	else {
113 +
		readstdin();
114 +
		setup();
115 +
	}
116 +
	match();
106 117
	run();
107 118
	return EXIT_FAILURE;
108 119
109 120
usage:
110 -
	fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
121 +
	fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
111 122
	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
112 123
	return EXIT_FAILURE;
113 124
}
530 541
	inputw = MIN(inputw, mw/3);
531 542
	promptw = prompt ? textw(dc, prompt) : 0;
532 543
	XMapRaised(dc->dpy, win);
533 -
	match();
534 544
}