commit - aaf0ca63c20c9b2aa596628a0ca82a162eb95e85
commit + b74734beb3bcc4e916680531dcc46a6dfb0da2ea
blob - bed6f3e1da40eaac4a9cf7cb546b847fe2d5f8ca
blob + a686ad70b4b102547f75d9b931a392a4c1ca3172
--- dmenu/dmenu.1
+++ dmenu/dmenu.1
.BI \-d " delimiter"
when used in a line, the value after the delimiter will be displayed. When selected, the value before the delimiter will be output. Only uses a single char as the delimiter.
.TP
+.B \-S
+dmenu does not sort menu items after matching.
+.TP
.BI \-l " lines"
dmenu lists items vertically, with the given number of lines.
.TP
blob - c55b1c10e3f2568ab338cb887e353dee1e465a00
blob + 0fc063bc7dbeb142ba339c208cb3695b6a11d796
--- dmenu/dmenu.c
+++ dmenu/dmenu.c
static struct item *matches, *matchend;
static struct item *prev, *curr, *next, *sel;
static int mon = -1, screen;
+static int sortmatches = 1;
static Atom clip, utf8;
static Display *dpy;
break;
if (i != tokc) /* not all tokens match */
continue;
- /* exact matches go first, then prefixes, then substrings */
- if (!tokc || !fstrncmp(text, item->text, textsize))
+
+ if (!sortmatches)
appenditem(item, &matches, &matchend);
- else if (!fstrncmp(tokv[0], item->text, len))
- appenditem(item, &lprefix, &prefixend);
- else
- appenditem(item, &lsubstr, &substrend);
+ else {
+ /* exact matches go first, then prefixes, then substrings */
+ if (!tokc || !fstrncmp(text, item->text, textsize))
+ appenditem(item, &matches, &matchend);
+ else if (!fstrncmp(tokv[0], item->text, len))
+ appenditem(item, &lprefix, &prefixend);
+ else
+ appenditem(item, &lsubstr, &substrend);
+ }
}
if (lprefix) {
if (matches) {
static void
usage(void)
{
- die("usage: dmenu [-bfivP] [-d delim] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ die("usage: dmenu [-bfivPS] [-d delim] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
}
topbar = 0;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
- else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */
+ else if (!strcmp(argv[i], "-F")) /* disable fuzzy matching */
fuzzy = 0;
+ else if (!strcmp(argv[i], "-S")) /* do not sort matches */
+ sortmatches = 0;
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;