Adding restrict return patch

This commit is contained in:
bakkeby 2021-05-17 10:59:48 +02:00
parent 976d6bc04c
commit d6894046f1
4 changed files with 26 additions and 0 deletions

View File

@ -26,6 +26,8 @@ dmenu, how to install it and how it works.
### Changelog: ### Changelog:
2021-05-17 - Added the restrict return patch
2021-05-15 - Added the tsv and printindex patches 2021-05-15 - Added the tsv and printindex patches
2020-08-08 - Added the json, symbols, managed, morecolor, multi-selection and preselect patches 2020-08-08 - Added the json, symbols, managed, morecolor, multi-selection and preselect patches
@ -179,6 +181,10 @@ dmenu, how to install it and how it works.
- adds a new flag to dmenu with which text input will be rejected if it would result in no - adds a new flag to dmenu with which text input will be rejected if it would result in no
matching item matching item
- [restrict-return](https://tools.suckless.org/dmenu/patches/restrict-return/)
- adds a '-1' option which disables Shift-Return and Ctrl-Return
- this guarantees that dmenu will only output one item, and that item was read from stdin
- [scroll](https://tools.suckless.org/dmenu/patches/scroll/) - [scroll](https://tools.suckless.org/dmenu/patches/scroll/)
- this patch adds support for text scrolling - this patch adds support for text scrolling
- it doesn't append '...' for long input anymore as it can handle long text - it doesn't append '...' for long input anymore as it can handle long text

View File

@ -18,6 +18,9 @@ static int instant = 0; /* -n option; if 1, selects matchin
static int center = 1; /* -c option; if 0, dmenu won't be centered on the screen */ static int center = 1; /* -c option; if 0, dmenu won't be centered on the screen */
static int min_width = 500; /* minimum width when centered */ static int min_width = 500; /* minimum width when centered */
#endif // CENTER_PATCH #endif // CENTER_PATCH
#if RESTRICT_RETURN_PATCH
static int restrict_return = 0; /* -1 option; if 1, disables shift-return and ctrl-return */
#endif // RESTRICT_RETURN_PATCH
/* -fn option overrides fonts[0]; default X11 font or font set */ /* -fn option overrides fonts[0]; default X11 font or font set */
#if PANGO_PATCH #if PANGO_PATCH
static char font[] = "monospace 10"; static char font[] = "monospace 10";

11
dmenu.c
View File

@ -925,6 +925,10 @@ insert:
break; break;
case XK_Return: case XK_Return:
case XK_KP_Enter: case XK_KP_Enter:
#if RESTRICT_RETURN_PATCH
if (restrict_return && (!sel || ev->state & (ShiftMask | ControlMask)))
break;
#endif // RESTRICT_RETURN_PATCH
#if !MULTI_SELECTION_PATCH #if !MULTI_SELECTION_PATCH
#if JSON_PATCH #if JSON_PATCH
if (!printjsonssel(ev->state)) if (!printjsonssel(ev->state))
@ -1512,6 +1516,9 @@ usage(void)
#if REJECTNOMATCH_PATCH #if REJECTNOMATCH_PATCH
"R" // (changed from r to R due to conflict with INCREMENTAL_PATCH) "R" // (changed from r to R due to conflict with INCREMENTAL_PATCH)
#endif // REJECTNOMATCH_PATCH #endif // REJECTNOMATCH_PATCH
#if RESTRICT_RETURN_PATCH
"1"
#endif // RESTRICT_RETURN_PATCH
"] " "] "
#if MANAGED_PATCH #if MANAGED_PATCH
"[-wm] " "[-wm] "
@ -1630,6 +1637,10 @@ main(int argc, char *argv[])
} else if (!strcmp(argv[i], "-ix")) { /* adds ability to return index in list */ } else if (!strcmp(argv[i], "-ix")) { /* adds ability to return index in list */
print_index = 1; print_index = 1;
#endif // PRINTINDEX_PATCH #endif // PRINTINDEX_PATCH
#if RESTRICT_RETURN_PATCH
} else if (!strcmp(argv[i], "-1")) {
restrict_return = 1;
#endif // RESTRICT_RETURN_PATCH
} else if (i + 1 == argc) } else if (i + 1 == argc)
usage(); usage();
/* these options take one argument */ /* these options take one argument */

View File

@ -233,6 +233,12 @@
*/ */
#define REJECTNOMATCH_PATCH 0 #define REJECTNOMATCH_PATCH 0
/* 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.
* https://tools.suckless.org/dmenu/patches/restrict-return/
*/
#define RESTRICT_RETURN_PATCH 0
/* This patch adds support for text scrolling and no longer appends '...' for long input as /* This patch adds support for text scrolling and no longer appends '...' for long input as
* it can handle long text. * it can handle long text.
* https://tools.suckless.org/dmenu/patches/scroll/ * https://tools.suckless.org/dmenu/patches/scroll/