[wiki] [sites] dmenu patch «print input text» || efe

From: <git_AT_suckless.org>
Date: Thu, 23 Aug 2018 19:19:55 +0200

commit bcddb0aa6d004844e07af8ae46efce41d4d4a039
Author: efe <efe_AT_efe.kim>
Date: Thu Aug 23 13:09:56 2018 -0400

    dmenu patch «print input text»
    
    Just a simple dmenu patch and the corresponding wiki page for it.
    It basically swaps Return and Shift+Return functions. I use it
    for surf's url bar.
    
     Commiter: efe <efe_AT_efe.kim>
    
     Changes to be committed:
            new file: dmenu-printinputtext-20190822-bbc464d.diff
            new file: printinputtext.md

diff --git a/tools.suckless.org/dmenu/patches/dmenu-printinputtext-20190822-bbc464d.diff b/tools.suckless.org/dmenu/patches/dmenu-printinputtext-20190822-bbc464d.diff
new file mode 100644
index 00000000..f1ae0149
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/dmenu-printinputtext-20190822-bbc464d.diff
_AT_@ -0,0 +1,87 @@
+From fb5db7880838c7691fb789b7f204906a1539e833 Mon Sep 17 00:00:00 2001
+From: efe <efe_AT_efe.kim>
+Date: Wed, 22 Aug 2018 20:22:04 -0400
+Subject: [PATCH] print input text patch for dmenu
+
+---
+ dmenu.1 | 8 ++++++--
+ dmenu.c | 10 ++++++++--
+ 2 files changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/dmenu.1 b/dmenu.1
+index c065087..8d6f155 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -3,7 +3,7 @@
+ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+-.RB [ \-bfiv ]
++.RB [ \-bfitv ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-m
+_AT_@ -75,6 +75,9 @@ defines the selected background color.
+ .BI \-sf " color"
+ defines the selected foreground color.
+ .TP
++.B \-t
++Return key prints input text instead of selection.
++.TP
+ .B \-v
+ prints version information to stdout, then exits.
+ .TP
+_AT_@ -89,13 +92,14 @@ Copy the selected item to the input field.
+ .TP
+ .B Return
+ Confirm selection. Prints the selected item to stdout and exits, returning
+-success.
++success. If \-t option is given it confirms input instead of selection.
+ .TP
+ .B Ctrl-Return
+ Confirm selection. Prints the selected item to stdout and continues.
+ .TP
+ .B Shift\-Return
+ Confirm input. Prints the input text to stdout and exits, returning success.
++If \-t option is given it confirms selection instead of input.
+ .TP
+ .B Escape
+ Exit without selecting an item, returning failure.
+diff --git a/dmenu.c b/dmenu.c
+index 5c835dd..9abb7ce 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -46,6 +46,7 @@ static struct item *items = NULL;
+ static struct item *matches, *matchend;
+ static struct item *prev, *curr, *next, *sel;
+ static int mon = -1, screen;
++static int use_text_input = 0;
+
+ static Atom clip, utf8;
+ static Display *dpy;
+_AT_@ -466,7 +467,10 @@ insert:
+ break;
+ case XK_Return:
+ case XK_KP_Enter:
+- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
++ if (use_text_input)
++ puts((sel && (ev->state & ShiftMask)) ? sel->text : text);
++ else
++ puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
+ if (!(ev->state & ControlMask)) {
+ cleanup();
+ exit(0);
+_AT_@ -707,7 +711,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], "-t")) /* favors text input over selection */
++ use_text_input = 1;
++ else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+--
+2.11.0
+
diff --git a/tools.suckless.org/dmenu/patches/printinputtext.md b/tools.suckless.org/dmenu/patches/printinputtext.md
new file mode 100644
index 00000000..b9a27495
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/printinputtext.md
_AT_@ -0,0 +1,29 @@
+print input text
+================
+
+Description
+-----------
+
+This patch adds a flag (`-t`) which makes Return key to ignore selection
+and print the input text to stdout. The flag basically swaps the functions
+of Return and Shift+Return hotkeys.
+
+The default behaviour of dmenu makes sense when selecting from given options
+(i.e. as a program launcher) but it is annoying when you might be entering
+text that is different than the given options (i.e. as surf's url bar).
+
+Usage in Surf
+-------------
+
+Just add the `-t` flag to the dmenu in the SETPROP function of surf's
+config.def.h. Now the url bar should behave just like in all other browsers.
+
+Download
+--------
+
+* [dmenu-printinputtext-20190822-bbc464d.diff](dmenu-printinputtext-20190822-bbc464d.diff)
+
+Author
+------
+
+* efe - efe_AT_efe.kim
Received on Thu Aug 23 2018 - 19:19:55 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 23 2018 - 19:24:27 CEST