dmenu-printinputtext-20190822-bbc464d.diff - sites - public wiki contents of su… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dmenu-printinputtext-20190822-bbc464d.diff (2502B) | |
--- | |
1 From fb5db7880838c7691fb789b7f204906a1539e833 Mon Sep 17 00:00:00 2001 | |
2 From: efe <[email protected]> | |
3 Date: Wed, 22 Aug 2018 20:22:04 -0400 | |
4 Subject: [PATCH] print input text patch for dmenu | |
5 | |
6 --- | |
7 dmenu.1 | 8 ++++++-- | |
8 dmenu.c | 10 ++++++++-- | |
9 2 files changed, 14 insertions(+), 4 deletions(-) | |
10 | |
11 diff --git a/dmenu.1 b/dmenu.1 | |
12 index c065087..8d6f155 100644 | |
13 --- a/dmenu.1 | |
14 +++ b/dmenu.1 | |
15 @@ -3,7 +3,7 @@ | |
16 dmenu \- dynamic menu | |
17 .SH SYNOPSIS | |
18 .B dmenu | |
19 -.RB [ \-bfiv ] | |
20 +.RB [ \-bfitv ] | |
21 .RB [ \-l | |
22 .IR lines ] | |
23 .RB [ \-m | |
24 @@ -75,6 +75,9 @@ defines the selected background color. | |
25 .BI \-sf " color" | |
26 defines the selected foreground color. | |
27 .TP | |
28 +.B \-t | |
29 +Return key prints input text instead of selection. | |
30 +.TP | |
31 .B \-v | |
32 prints version information to stdout, then exits. | |
33 .TP | |
34 @@ -89,13 +92,14 @@ Copy the selected item to the input field. | |
35 .TP | |
36 .B Return | |
37 Confirm selection. Prints the selected item to stdout and exits, retur… | |
38 -success. | |
39 +success. If \-t option is given it confirms input instead of selection. | |
40 .TP | |
41 .B Ctrl-Return | |
42 Confirm selection. Prints the selected item to stdout and continues. | |
43 .TP | |
44 .B Shift\-Return | |
45 Confirm input. Prints the input text to stdout and exits, returning su… | |
46 +If \-t option is given it confirms selection instead of input. | |
47 .TP | |
48 .B Escape | |
49 Exit without selecting an item, returning failure. | |
50 diff --git a/dmenu.c b/dmenu.c | |
51 index 5c835dd..9abb7ce 100644 | |
52 --- a/dmenu.c | |
53 +++ b/dmenu.c | |
54 @@ -46,6 +46,7 @@ static struct item *items = NULL; | |
55 static struct item *matches, *matchend; | |
56 static struct item *prev, *curr, *next, *sel; | |
57 static int mon = -1, screen; | |
58 +static int use_text_input = 0; | |
59 | |
60 static Atom clip, utf8; | |
61 static Display *dpy; | |
62 @@ -466,7 +467,10 @@ insert: | |
63 break; | |
64 case XK_Return: | |
65 case XK_KP_Enter: | |
66 - puts((sel && !(ev->state & ShiftMask)) ? sel->text : te… | |
67 + if (use_text_input) | |
68 + puts((sel && (ev->state & ShiftMask)) ? sel->te… | |
69 + else | |
70 + puts((sel && !(ev->state & ShiftMask)) ? sel->t… | |
71 if (!(ev->state & ControlMask)) { | |
72 cleanup(); | |
73 exit(0); | |
74 @@ -707,7 +711,9 @@ main(int argc, char *argv[]) | |
75 else if (!strcmp(argv[i], "-i")) { /* case-insensitive … | |
76 fstrncmp = strncasecmp; | |
77 fstrstr = cistrstr; | |
78 - } else if (i + 1 == argc) | |
79 + } else if (!strcmp(argv[i], "-t")) /* favors text input… | |
80 + use_text_input = 1; | |
81 + else if (i + 1 == argc) | |
82 usage(); | |
83 /* these options take one argument */ | |
84 else if (!strcmp(argv[i], "-l")) /* number of lines i… | |
85 -- | |
86 2.11.0 | |
87 |