@@ 23,3 23,8 @@ static unsigned int lines = 0;
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";
+
+/* tsv-alt: reverse the order of tab separation.
+ * 0 = display<TAB>output. 1 = output<TAB>display
+ * can be reversed with -r as well */
+static int revtab = 0;
@@ 3,7 3,7 @@
dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
.RB [ \-bcfiv ]
.RB [ \-bcfirv ]
.RB [ \-l
.IR lines ]
.RB [ \-m
@@ 83,6 83,10 @@ prints version information to stdout, then exits.
.TP
.BI \-w " windowid"
embed into windowid.
.TP
.B \-r
tsv-alt: reverse the behavior of tab separation.
.TP
.SH USAGE
dmenu is completely controlled by the keyboard. Items are selected using the
arrow keys, page up, page down, home, and end.
@@ 29,6 29,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
struct item {
char *text;
char *otext;
struct item *left, *right;
int out;
};
@@ 113,7 114,7 @@ cleanup(void)
for (i = 0; i < SchemeLast; i++)
free(scheme[i]);
for (i = 0; items && items[i].text; ++i)
free(items[i].text);
free(revtab ? items[i].otext : items[i].text);
free(items);
drw_free(drw);
XSync(dpy, False);
@@ 498,7 499,7 @@ insert:
break;
case XK_Return:
case XK_KP_Enter:
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
puts((sel && !(ev->state & ShiftMask)) ? sel->otext : text);
if (!(ev->state & ControlMask)) {
cleanup();
exit(0);
@@ 557,7 558,7 @@ paste(void)
static void
readstdin(void)
{
char *line = NULL;
char *line = NULL, *tmp;
size_t i, itemsiz = 0, linesiz = 0;
ssize_t len;
@@ 570,14 571,18 @@ readstdin(void)
}
if (line[len - 1] == '\n')
line[len - 1] = '\0';
if (!(items[i].text = strdup(line)))
if (!(items[i].text = items[i].otext = strdup(line)))
die("strdup:");
if ((tmp = strchr(items[i].text, '\t'))) {
*tmp++ = '\0';
revtab ? (items[i].text = tmp) : (items[i].otext = tmp);
}
items[i].out = 0;
}
free(line);
if (items)
items[i].text = NULL;
items[i].text = items[i].otext = NULL;
lines = MIN(lines, i);
}
@@ 739,7 744,7 @@ setup(void)
static void
usage(void)
{
die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
die("usage: dmenu [-bfirv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
}
@@ 763,7 768,9 @@ main(int argc, char *argv[])
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;
} else if (i + 1 == argc)
} else if (!strcmp(argv[i], "-r")) /* reverse the tab separation */
revtab = (!revtab);
else if (i + 1 == argc)
usage();
/* these options take one argument */
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */