commit 79547e9d63b7d94ded96c2027cccd6aba12f6008
Author: ozpv <dev_AT_haemolacriaa.com>
Date: Sun Mar 3 15:30:13 2024 -0600
add no input box patch for dmenu
diff --git a/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-5.2.diff b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-5.2.diff
new file mode 100644
index 00000000..139ec3a3
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-5.2.diff
_AT_@ -0,0 +1,147 @@
+diff -up dmenu/config.def.h dmenu-noinput/config.def.h
+--- dmenu/config.def.h 2024-03-03 12:59:00.545293913 -0600
++++ dmenu-noinput/config.def.h 2024-03-03 10:00:59.974900500 -0600
+_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 draw_input = 1; /* -noi option; if 0, the input will not be drawn by default */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+diff -up dmenu/dmenu.c dmenu-noinput/dmenu.c
+--- dmenu/dmenu.c 2024-03-03 12:59:00.545293913 -0600
++++ dmenu-noinput/dmenu.c 2024-03-03 12:15:44.416277776 -0600
+_AT_@ -147,7 +147,7 @@ drawmenu(void)
+ {
+ unsigned int curpos;
+ struct item *item;
+- int x = 0, y = 0, w;
++ int x = 0, y = 0, w = 0;
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, 0, 0, mw, mh, 1, 1);
+_AT_@ -156,15 +156,17 @@ drawmenu(void)
+ drw_setscheme(drw, scheme[SchemeSel]);
+ x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
+ }
+- /* draw input field */
+- w = (lines > 0 || !matches) ? mw - x : inputw;
+- drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
+
+- curpos = TEXTW(text) - TEXTW(&text[cursor]);
+- if ((curpos += lrpad / 2 - 1) < w) {
++ if (draw_input) {
++ w = (lines > 0 || !matches) ? mw - x : inputw;
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
++ drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
++
++ curpos = TEXTW(text) - TEXTW(&text[cursor]);
++ if ((curpos += lrpad / 2 - 1) < w) {
++ drw_setscheme(drw, scheme[SchemeNorm]);
++ drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
++ }
+ }
+
+ if (lines > 0) {
+_AT_@ -178,8 +180,8 @@ drawmenu(void)
+ if (curr->left) {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
++ x += w;
+ }
+- x += w;
+ for (item = curr; item != next; item = item->right)
+ x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">")));
+ if (next) {
+_AT_@ -358,16 +360,19 @@ keypress(XKeyEvent *ev)
+ case XK_p: ksym = XK_Up; break;
+
+ case XK_k: /* delete right */
+- text[cursor] = '+- match();
++ if (draw_input) {
++ text[cursor] = '++ match();
++ }
+ break;
+ case XK_u: /* delete left */
+- insert(NULL, 0 - cursor);
++ if (draw_input)
++ insert(NULL, 0 - cursor);
+ break;
+ case XK_w: /* delete word */
+- while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
++ while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]) && draw_input)
+ insert(NULL, nextrune(-1) - cursor);
+- while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
++ while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]) && draw_input)
+ insert(NULL, nextrune(-1) - cursor);
+ break;
+ case XK_y: /* paste selection */
+_AT_@ -414,23 +419,23 @@ keypress(XKeyEvent *ev)
+ switch(ksym) {
+ default:
+ insert:
+- if (!iscntrl((unsigned char)*buf))
++ if (!iscntrl((unsigned char)*buf) && draw_input)
+ insert(buf, len);
+ break;
+ case XK_Delete:
+ case XK_KP_Delete:
+- if (text[cursor] == '++ if (text[cursor] == '+ return;
+ cursor = nextrune(+1);
+ /* fallthrough */
+ case XK_BackSpace:
+- if (cursor == 0)
++ if (cursor == 0 || !draw_input)
+ return;
+ insert(NULL, nextrune(-1) - cursor);
+ break;
+ case XK_End:
+ case XK_KP_End:
+- if (text[cursor] != '++ if (text[cursor] != '+ cursor = strlen(text);
+ break;
+ }
+_AT_@ -514,7 +519,7 @@ insert:
+ }
+ break;
+ case XK_Tab:
+- if (!sel)
++ if (!sel || !draw_input)
+ return;
+ cursor = strnlen(sel->text, sizeof text - 1);
+ memcpy(text, sel->text, cursor);
+_AT_@ -677,7 +682,7 @@ setup(void)
+ mw = wa.width;
+ }
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+- inputw = mw / 3; /* input width: ~33% of monitor width */
++ inputw = !draw_input ? 0 : mw / 3; /* input width: ~33% of monitor width */
+ match();
+
+ /* create menu window */
+_AT_@ -715,7 +720,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ die("usage: dmenu [-bfiv] [-noi] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+_AT_@ -734,6 +739,8 @@ main(int argc, char *argv[])
+ topbar = 0;
+ else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
+ fast = 1;
++ else if (!strcmp(argv[i], "-noi")) /* no input field. intended to be used with a prompt */
++ draw_input = 0;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
diff --git a/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-with.png b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-with.png
new file mode 100644
index 00000000..f040df18
Binary files /dev/null and b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-with.png differ
diff --git a/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-without.png b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-without.png
new file mode 100644
index 00000000..42111f8c
Binary files /dev/null and b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinput-without.png differ
diff --git a/tools.suckless.org/dmenu/patches/no-input/dmenu-noinputlinesbelowpromptfullwidth-5.2.diff b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinputlinesbelowpromptfullwidth-5.2.diff
new file mode 100644
index 00000000..38839a7c
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/no-input/dmenu-noinputlinesbelowpromptfullwidth-5.2.diff
_AT_@ -0,0 +1,156 @@
+diff -up dmenu/config.def.h dmenu-noinputlinesbelowpromptfullwidth/config.def.h
+--- dmenu/config.def.h 2024-03-03 12:59:00.545293913 -0600
++++ dmenu-noinputlinesbelowpromptfullwidth/config.def.h 2024-03-03 12:50:07.883388742 -0600
+_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 draw_input = 1; /* -noi option; if 0, the input will not be drawn by default */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+diff -up dmenu/dmenu.c dmenu-noinputlinesbelowpromptfullwidth/dmenu.c
+--- dmenu/dmenu.c 2024-03-03 12:59:00.545293913 -0600
++++ dmenu-noinputlinesbelowpromptfullwidth/dmenu.c 2024-03-03 15:06:12.469545907 -0600
+_AT_@ -147,30 +147,32 @@ drawmenu(void)
+ {
+ unsigned int curpos;
+ struct item *item;
+- int x = 0, y = 0, w;
++ int x = 0, y = 0, w = 0;
+
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, 0, 0, mw, mh, 1, 1);
+
+ if (prompt && *prompt) {
+ drw_setscheme(drw, scheme[SchemeSel]);
+- x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
++ x = drw_text(drw, x, 0, !draw_input ? mw : promptw, bh, lrpad / 2, prompt, 0);
+ }
+- /* draw input field */
+- w = (lines > 0 || !matches) ? mw - x : inputw;
+- drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
+
+- curpos = TEXTW(text) - TEXTW(&text[cursor]);
+- if ((curpos += lrpad / 2 - 1) < w) {
++ if (draw_input) {
++ w = (lines > 0 || !matches) ? mw - x : inputw;
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
++ drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
++
++ curpos = TEXTW(text) - TEXTW(&text[cursor]);
++ if ((curpos += lrpad / 2 - 1) < w) {
++ drw_setscheme(drw, scheme[SchemeNorm]);
++ drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
++ }
+ }
+
+ if (lines > 0) {
+ /* draw vertical list */
+ for (item = curr; item != next; item = item->right)
+- drawitem(item, x, y += bh, mw - x);
++ drawitem(item, (!draw_input && prompt && *prompt) ? x - mw : x - promptw, y += bh, mw);
+ } else if (matches) {
+ /* draw horizontal list */
+ x += inputw;
+_AT_@ -178,8 +180,8 @@ drawmenu(void)
+ if (curr->left) {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
++ x += w;
+ }
+- x += w;
+ for (item = curr; item != next; item = item->right)
+ x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">")));
+ if (next) {
+_AT_@ -358,16 +360,19 @@ keypress(XKeyEvent *ev)
+ case XK_p: ksym = XK_Up; break;
+
+ case XK_k: /* delete right */
+- text[cursor] = '+- match();
++ if (draw_input) {
++ text[cursor] = '++ match();
++ }
+ break;
+ case XK_u: /* delete left */
+- insert(NULL, 0 - cursor);
++ if (draw_input)
++ insert(NULL, 0 - cursor);
+ break;
+ case XK_w: /* delete word */
+- while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
++ while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]) && draw_input)
+ insert(NULL, nextrune(-1) - cursor);
+- while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
++ while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]) && draw_input)
+ insert(NULL, nextrune(-1) - cursor);
+ break;
+ case XK_y: /* paste selection */
+_AT_@ -414,23 +419,23 @@ keypress(XKeyEvent *ev)
+ switch(ksym) {
+ default:
+ insert:
+- if (!iscntrl((unsigned char)*buf))
++ if (!iscntrl((unsigned char)*buf) && draw_input)
+ insert(buf, len);
+ break;
+ case XK_Delete:
+ case XK_KP_Delete:
+- if (text[cursor] == '++ if (text[cursor] == '+ return;
+ cursor = nextrune(+1);
+ /* fallthrough */
+ case XK_BackSpace:
+- if (cursor == 0)
++ if (cursor == 0 || !draw_input)
+ return;
+ insert(NULL, nextrune(-1) - cursor);
+ break;
+ case XK_End:
+ case XK_KP_End:
+- if (text[cursor] != '++ if (text[cursor] != '+ cursor = strlen(text);
+ break;
+ }
+_AT_@ -514,7 +519,7 @@ insert:
+ }
+ break;
+ case XK_Tab:
+- if (!sel)
++ if (!sel || !draw_input)
+ return;
+ cursor = strnlen(sel->text, sizeof text - 1);
+ memcpy(text, sel->text, cursor);
+_AT_@ -677,7 +682,7 @@ setup(void)
+ mw = wa.width;
+ }
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+- inputw = mw / 3; /* input width: ~33% of monitor width */
++ inputw = !draw_input ? 0 : mw / 3; /* input width: ~33% of monitor width */
+ match();
+
+ /* create menu window */
+_AT_@ -715,7 +720,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ die("usage: dmenu [-bfiv] [-noi] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
+ }
+
+_AT_@ -734,6 +739,8 @@ main(int argc, char *argv[])
+ topbar = 0;
+ else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
+ fast = 1;
++ else if (!strcmp(argv[i], "-noi")) /* no input field. intended to be used with a prompt */
++ draw_input = 0;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
diff --git a/tools.suckless.org/dmenu/patches/no-input/index.md b/tools.suckless.org/dmenu/patches/no-input/index.md
new file mode 100644
index 00000000..c159ecc8
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/no-input/index.md
_AT_@ -0,0 +1,29 @@
+no input
+======
+
+Description
+-----------
+This patch removes the input box to create more aesthetic script menus.
+Only intended to be used with a prompt, otherwise there will be an empty box.
+There are two different patches, one with a modified [lines below prompt](
https://tools.suckless.org/dmenu/patches/lines-below-prompt/) patch that fixes it with this patch.
+
+Usage
+-----
+Pass along '-noi' with dmenu's arguments in your script to activate, or configure inside of config.def.h / config.h.
+
+Example
+-------
+with patch:
+![dmenu noinput with](dmenu-noinput-with.png)
+
+without patch:
+![dmenu noinput without](dmenu-noinput-without.png)
+
+Download
+--------
+* [dmenu-noinput-5.2.diff](dmenu-noinput-5.2.diff) (2024-03-03)
+* [dmenu-noinputlinesbelowpromptfullwidth-5.2.diff](dmenu-noinputlinesbelowpromptfullwidth-5.2.diff) (2024-03-03)
+
+Author
+-------
+* [ozpv](
https://github.com/ozpv)
Received on Sun Mar 03 2024 - 22:33:42 CET