[wiki] [sites] Adding the page introducing my noescape patch. The patch allows the user to pass the -no-escape flag to dmenu in order to prevent the escape key from killing dmenu. || AzureOrange404

From: <git_AT_suckless.org>
Date: Tue, 28 Mar 2023 18:26:45 +0200

commit cbe28d5d74172579e10698d95eecf3267c477826
Author: AzureOrange404 <azureorange404_AT_protonmail.com>
Date: Tue Mar 28 18:24:44 2023 +0200

    Adding the page introducing my noescape patch.
    The patch allows the user to pass the -no-escape flag to dmenu in order to prevent the escape key from killing dmenu.

diff --git a/tools.suckless.org/dmenu/patches/noescape/dmenu-noescape-20230328-dfbbf7f.diff b/tools.suckless.org/dmenu/patches/noescape/dmenu-noescape-20230328-dfbbf7f.diff
new file mode 100644
index 00000000..6efde4cf
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/noescape/dmenu-noescape-20230328-dfbbf7f.diff
_AT_@ -0,0 +1,66 @@
+From 5622f9497f5dca83035443a0a00e89c63862b15b Mon Sep 17 00:00:00 2001
+From: Aaron Züger <contact_AT_azureorange.xyz>
+Date: Tue, 28 Mar 2023 18:05:36 +0200
+Subject: [PATCH] Added the -no-escape flag which will stop the escape key from
+ exiting dmenu.
+
+---
+ dmenu.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index 4e7df12..203d9bf 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -1,6 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+ #include <ctype.h>
+ #include <locale.h>
++#include <stdbool.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+_AT_@ -53,6 +54,8 @@ static XIC xic;
+ static Drw *drw;
+ static Clr *scheme[SchemeLast];
+
++static bool no_escape = false;
++
+ #include "config.h"
+
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+_AT_@ -447,8 +450,10 @@ insert:
+ sel = matchend;
+ break;
+ case XK_Escape:
+- cleanup();
+- exit(1);
++ if (no_escape == false) {
++ cleanup();
++ exit(1);
++ }
+ case XK_Home:
+ case XK_KP_Home:
+ if (sel == matches) {
+_AT_@ -716,6 +721,7 @@ static void
+ usage(void)
+ {
+ die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ " [-no-escape]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+_AT_@ -737,7 +743,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], "-no-escape")) /* disable escape */
++ no_escape = !no_escape;
++ else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+--
+2.40.0
+
diff --git a/tools.suckless.org/dmenu/patches/noescape/index.md b/tools.suckless.org/dmenu/patches/noescape/index.md
new file mode 100644
index 00000000..5c6984c5
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/noescape/index.md
_AT_@ -0,0 +1,17 @@
+noescape
+======
+
+Currently dmenu will be killed if pressing the escape key.
+And this is probably what everybody wants.
+But if anyone wanted to run something through dmenu and does not want dmenu to be killed, this is the patch for you.
+
+This patch introduces the `-no-escape` flag, which will block the escape key from killing dmenu.
+
+Download
+--------
+
+* [dmenu-noescape-20230328-dfbbf7f.diff](dmenu-noescape-20230328-dfbbf7f.diff)
+
+Author
+------
+* Aaron Züger <contact_AT_azureorange.xyz>
Received on Tue Mar 28 2023 - 18:26:45 CEST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2023 - 18:36:54 CEST