[wiki] [sites] [dmenu][preselect]: port to v5.2 || NRK

From: <git_AT_suckless.org>
Date: Sat, 10 Dec 2022 04:56:19 +0100

commit adc927374407ee9a73430425353e3a61b312f72e
Author: NRK <nrk_AT_disroot.org>
Date: Sat Dec 10 09:54:29 2022 +0600

    [dmenu][preselect]: port to v5.2

diff --git a/tools.suckless.org/dmenu/patches/preselect/dmenu-preselect-5.2.diff b/tools.suckless.org/dmenu/patches/preselect/dmenu-preselect-5.2.diff
new file mode 100644
index 00000000..940a489a
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/preselect/dmenu-preselect-5.2.diff
_AT_@ -0,0 +1,60 @@
+diff --git a/config.def.h b/config.def.h
+index 1edb647..95bee59 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -21,3 +21,6 @@ static unsigned int lines = 0;
+ * for example: " /?\"&[]"
+ */
+ static const char worddelimiters[] = " ";
++
++/* -n option; preselected item starting from 0 */
++static unsigned int preselected = 0;
+diff --git a/dmenu.1 b/dmenu.1
+index 323f93c..6e1ee7f 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -22,6 +22,8 @@ dmenu \- dynamic menu
+ .IR color ]
+ .RB [ \-w
+ .IR windowid ]
++.RB [ \-n
++.IR number ]
+ .P
+ .BR dmenu_run " ..."
+ .SH DESCRIPTION
+_AT_@ -80,6 +82,9 @@ prints version information to stdout, then exits.
+ .TP
+ .BI \-w " windowid"
+ embed into windowid.
++.TP
++.BI \-n " number"
++preseslected item starting from 0.
+ .SH USAGE
+ dmenu is completely controlled by the keyboard. Items are selected using the
+ arrow keys, page up, page down, home, and end.
+diff --git a/dmenu.c b/dmenu.c
+index 27b7a30..e2e79b3 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -679,6 +679,12 @@ setup(void)
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ inputw = mw / 3; /* input width: ~33% of monitor width */
+ match();
++ for (i = 0; i < preselected; i++) {
++ if (sel && sel->right && (sel = sel->right) == next) {
++ curr = next;
++ calcoffsets();
++ }
++ }
+
+ /* create menu window */
+ swa.override_redirect = True;
+_AT_@ -757,6 +763,8 @@ main(int argc, char *argv[])
+ colors[SchemeSel][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
++ else if (!strcmp(argv[i], "-n")) /* preselected item */
++ preselected = atoi(argv[++i]);
+ else
+ usage();
+
diff --git a/tools.suckless.org/dmenu/patches/preselect/index.md b/tools.suckless.org/dmenu/patches/preselect/index.md
index 30066459..70d4d94d 100644
--- a/tools.suckless.org/dmenu/patches/preselect/index.md
+++ b/tools.suckless.org/dmenu/patches/preselect/index.md
_AT_@ -15,8 +15,10 @@ Create menu with the second item preselected:
 
 Download
 --------
+* [dmenu-preselect-5.2](dmenu-preselect-5.2.diff) (2022-12-10)
 * [dmenu-preselect-20200513-db6093f](dmenu-preselect-20200513-db6093f.diff) (2020-05-13)
 
 Authors
 -------
 * Mathieu Moneyron <mathieu.moneyron_AT_gmail.com>
+* NRK <nrk_AT_disroot.org> (v5.2 port)
Received on Sat Dec 10 2022 - 04:56:19 CET

This archive was generated by hypermail 2.3.0 : Sat Dec 10 2022 - 05:00:47 CET