Introduction
Introduction Statistics Contact Development Disclaimer Help
dmenu-tsv-alt-20220919-fce06f4.diff - sites - public wiki contents of suckless.…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dmenu-tsv-alt-20220919-fce06f4.diff (3005B)
---
1 diff --git a/config.def.h b/config.def.h
2 index 1edb647..bd0fcef 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -21,3 +21,8 @@ static unsigned int lines = 0;
6 * for example: " /?\"&[]"
7 */
8 static const char worddelimiters[] = " ";
9 +
10 +/* tsv-alt: reverse the order of tab separation.
11 + * 0 = display<TAB>output. 1 = output<TAB>display
12 + * can be reversed with -r as well */
13 +static int revtab = 0;
14 diff --git a/dmenu.1 b/dmenu.1
15 index 323f93c..39c3492 100644
16 --- a/dmenu.1
17 +++ b/dmenu.1
18 @@ -3,7 +3,7 @@
19 dmenu \- dynamic menu
20 .SH SYNOPSIS
21 .B dmenu
22 -.RB [ \-bfiv ]
23 +.RB [ \-bfivr ]
24 .RB [ \-l
25 .IR lines ]
26 .RB [ \-m
27 @@ -80,6 +80,10 @@ prints version information to stdout, then exits.
28 .TP
29 .BI \-w " windowid"
30 embed into windowid.
31 +.TP
32 +.B \-r
33 +tsv-alt: reverse the behavior of tab separation.
34 +.TP
35 .SH USAGE
36 dmenu is completely controlled by the keyboard. Items are selected usi…
37 arrow keys, page up, page down, home, and end.
38 diff --git a/dmenu.c b/dmenu.c
39 index 818313a..9783fc4 100644
40 --- a/dmenu.c
41 +++ b/dmenu.c
42 @@ -30,6 +30,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast };…
43
44 struct item {
45 char *text;
46 + char *otext;
47 struct item *left, *right;
48 int out;
49 };
50 @@ -105,7 +106,7 @@ cleanup(void)
51 for (i = 0; i < SchemeLast; i++)
52 free(scheme[i]);
53 for (i = 0; items && items[i].text; ++i)
54 - free(items[i].text);
55 + free(revtab ? items[i].otext : items[i].text);
56 free(items);
57 drw_free(drw);
58 XSync(dpy, False);
59 @@ -490,7 +491,7 @@ insert:
60 break;
61 case XK_Return:
62 case XK_KP_Enter:
63 - puts((sel && !(ev->state & ShiftMask)) ? sel->text : te…
64 + puts((sel && !(ev->state & ShiftMask)) ? sel->otext : t…
65 if (!(ev->state & ControlMask)) {
66 cleanup();
67 exit(0);
68 @@ -560,11 +561,15 @@ readstdin(void)
69 die("cannot realloc %zu bytes:", size);
70 if (line[len - 1] == '\n')
71 line[len - 1] = '\0';
72 - items[i].text = line;
73 + items[i].text = items[i].otext = line;
74 + if ((line = strchr(line, '\t'))) {
75 + *line++ = '\0';
76 + revtab ? (items[i].text = line) : (items[i].ote…
77 + }
78 items[i].out = 0;
79 }
80 if (items)
81 - items[i].text = NULL;
82 + items[i].text = items[i].otext = NULL;
83 lines = MIN(lines, i);
84 }
85
86 @@ -710,7 +715,7 @@ setup(void)
87 static void
88 usage(void)
89 {
90 - fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] […
91 + fputs("usage: dmenu [-bfivr] [-l lines] [-p prompt] [-fn font] …
92 " [-nb color] [-nf color] [-sb color] [-sf co…
93 exit(1);
94 }
95 @@ -733,7 +738,9 @@ main(int argc, char *argv[])
96 else if (!strcmp(argv[i], "-i")) { /* case-insensitive …
97 fstrncmp = strncasecmp;
98 fstrstr = cistrstr;
99 - } else if (i + 1 == argc)
100 + } else if (!strcmp(argv[i], "-r")) /* reverse the tab s…
101 + revtab = (!revtab);
102 + else if (i + 1 == argc)
103 usage();
104 /* these options take one argument */
105 else if (!strcmp(argv[i], "-l")) /* number of lines i…
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.