[wiki] [sites] [dmenu][patch][restrict-return] new patch that adds the option '-r' that disables Ctrl-Return and Shift-Return || Nathan Sketch

From: <git_AT_suckless.org>
Date: Thu, 17 Dec 2020 22:27:42 +0100

commit 11e047cb257675fc5c1b289242da394db7ad9648
Author: Nathan Sketch <sketchn98_AT_gmail.com>
Date: Thu Dec 17 16:26:57 2020 -0500

    [dmenu][patch][restrict-return] new patch that adds the option '-r' that disables Ctrl-Return and Shift-Return

diff --git a/tools.suckless.org/dmenu/patches/restrict-return/dmenu-restrictreturn-5.0.diff b/tools.suckless.org/dmenu/patches/restrict-return/dmenu-restrictreturn-5.0.diff
new file mode 100644
index 00000000..6d3553e1
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/restrict-return/dmenu-restrictreturn-5.0.diff
_AT_@ -0,0 +1,65 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..47c2f76 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -2,6 +2,7 @@
+ /* Default settings; can be overriden by command line. */
+
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
++static int restrict_return = 0; /* -r option; if 1, disables shift-return and ctrl-return */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..0dcafce 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -3,7 +3,7 @@
+ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+-.RB [ \-bfiv ]
++.RB [ \-bfirv ]
+ .RB [ \-l
+ .IR lines ]
+ .RB [ \-m
+_AT_@ -47,6 +47,10 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
++.B \-r
++disables ctr-return and shift-return. this guarantees that dmenu prints to
++stdout only once, and it only prints an item read from stdin.
++.TP
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index 65f25ce..a278680 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -464,6 +464,13 @@ insert:
+ break;
+ case XK_Return:
+ case XK_KP_Enter:
++ if (restrict_return) {
++ if (!sel || ev->state & (ShiftMask | ControlMask))
++ break;
++ puts(sel->text);
++ cleanup();
++ exit(0);
++ }
+ puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
+ if (!(ev->state & ControlMask)) {
+ cleanup();
+_AT_@ -712,7 +719,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"))
++ restrict_return = 1;
++ else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
diff --git a/tools.suckless.org/dmenu/patches/restrict-return/index.md b/tools.suckless.org/dmenu/patches/restrict-return/index.md
new file mode 100644
index 00000000..683aaef7
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/restrict-return/index.md
_AT_@ -0,0 +1,13 @@
+Restrict Return
+===============
+This patch adds a '-r' option which disables Shift-Return and Ctrl-Return. This
+guarantees that dmenu will only output one item, and that item was read from
+stdin.
+
+Download
+--------
+* [dmenu-restrictreturn-5.0.diff](dmenu-restrictreturn-5.0.diff)
+
+Author
+------
+* Nathan Sketch <sketchn98_AT_gmail.com>
Received on Thu Dec 17 2020 - 22:27:42 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 17 2020 - 22:36:44 CET