[wiki] [sites] [tools/dmenu] update several patches to git master || koniu

From: <git_AT_suckless.org>
Date: Wed, 15 Jun 2016 14:08:03 +0200

commit 193f2148224a1be13cf5ad5f6ed8b7efb259e600
Author: koniu <koniu_AT_riseup.net>
Date: Wed Jun 15 13:06:31 2016 +0100

    [tools/dmenu] update several patches to git master

diff --git a/tools.suckless.org/dmenu/patches/dmenu-git-incremental.diff b/tools.suckless.org/dmenu/patches/dmenu-git-incremental.diff
new file mode 100644
index 0000000..a5de38b
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/dmenu-git-incremental.diff
_AT_@ -0,0 +1,70 @@
+diff --git a/config.def.h b/config.def.h
+index dcffd38..b879e9f 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 incremental = 0; /* -r option; if 1, dmenu outputs during input */
+ /* -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 d3ab805..044f955 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -6,6 +6,7 @@ dmenu \- dynamic menu
+ .RB [ \-b ]
+ .RB [ \-f ]
+ .RB [ \-i ]
++.RB [ \-r ]
+ .RB [ \-l
+ .RB [ \-m
+ .IR monitor ]
+_AT_@ -48,6 +49,9 @@ X until stdin reaches end\-of\-file.
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
++.B \-r
++dmenu outputs text each time a key is pressed.
++.TP
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index e0c2f80..100ab10 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -447,6 +447,11 @@ keypress(XKeyEvent *ev)
+ match();
+ break;
+ }
++ if(incremental) {
++ fprintf(stdout, "%s
", text);
++ fflush(stdout);
++ }
++
+ drawmenu();
+ }
+
+_AT_@ -610,7 +615,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ fputs("usage: dmenu [-b] [-f] [-i] [-r] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-v]
", stderr);
+ exit(1);
+ }
+_AT_@ -632,7 +637,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")) /* outputs during input */
++ incremental = 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/dmenu-git-instant.diff b/tools.suckless.org/dmenu/patches/dmenu-git-instant.diff
new file mode 100644
index 0000000..ee48c64
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/dmenu-git-instant.diff
_AT_@ -0,0 +1,72 @@
+diff --git a/config.def.h b/config.def.h
+index dcffd38..a42d28b 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -1,6 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+ /* Default settings; can be overriden by command line. */
+
++static int instant = 0;
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+diff --git a/dmenu.1 b/dmenu.1
+index d3ab805..8806d4d 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -6,6 +6,7 @@ dmenu \- dynamic menu
+ .RB [ \-b ]
+ .RB [ \-f ]
+ .RB [ \-i ]
++.RB [ \-n ]
+ .RB [ \-l
+ .RB [ \-m
+ .IR monitor ]
+_AT_@ -48,6 +49,9 @@ X until stdin reaches end\-of\-file.
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
++.B \-n
++dmenu instantly selects if only one match.
++.TP
+ .BI \-l " lines"
+ dmenu lists items vertically, with the given number of lines.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index e0c2f80..f079479 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -250,6 +250,13 @@ match(void)
+ matchend = substrend;
+ }
+ curr = sel = matches;
++
++ if(instant && matches && matches==matchend && !lsubstr) {
++ puts(matches->text);
++ cleanup();
++ exit(0);
++ }
++
+ calcoffsets();
+ }
+
+_AT_@ -610,7 +617,7 @@ setup(void)
+ static void
+ usage(void)
+ {
+- fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
++ fputs("usage: dmenu [-b] [-f] [-i] [-n] [-l lines] [-p prompt] [-fn font] [-m monitor]
"
+ " [-nb color] [-nf color] [-sb color] [-sf color] [-v]
", stderr);
+ exit(1);
+ }
+_AT_@ -632,7 +639,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], "-n")) /* instant select only match */
++ instant = 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/dmenu-git-non-blocking-stdin.diff b/tools.suckless.org/dmenu/patches/dmenu-git-non-blocking-stdin.diff
new file mode 100644
index 0000000..8bae1e6
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/dmenu-git-non-blocking-stdin.diff
_AT_@ -0,0 +1,247 @@
+diff --git a/dmenu.1 b/dmenu.1
+index d3ab805..00958cf 100644
+--- a/dmenu.1
++++ b/dmenu.1
+_AT_@ -4,7 +4,6 @@ dmenu \- dynamic menu
+ .SH SYNOPSIS
+ .B dmenu
+ .RB [ \-b ]
+-.RB [ \-f ]
+ .RB [ \-i ]
+ .RB [ \-l
+ .RB [ \-m
+_AT_@ -41,10 +40,6 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
+ .B \-b
+ dmenu appears at the bottom of the screen.
+ .TP
+-.B \-f
+-dmenu grabs the keyboard before reading stdin. This is faster, but will lock up
+-X until stdin reaches end\-of\-file.
+-.TP
+ .B \-i
+ dmenu matches menu items case insensitively.
+ .TP
+diff --git a/dmenu.c b/dmenu.c
+index e0c2f80..f819d67 100644
+--- a/dmenu.c
++++ b/dmenu.c
+_AT_@ -1,12 +1,15 @@
+ /* See LICENSE file for copyright and license details. */
+ #include <ctype.h>
++#include <fcntl.h>
+ #include <locale.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <strings.h>
+ #include <time.h>
++#include <unistd.h>
+
++#include <sys/select.h>
+ #include <X11/Xlib.h>
+ #include <X11/Xatom.h>
+ #include <X11/Xutil.h>
+_AT_@ -31,6 +34,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
+ struct item {
+ char *text;
+ struct item *left, *right;
++ struct item *next;
+ int out;
+ };
+
+_AT_@ -181,6 +185,7 @@ drawmenu(void)
+ }
+ }
+ drw_map(drw, win, 0, 0, mw, mh);
++ XFlush(dpy);
+ }
+
+ static void
+_AT_@ -209,6 +214,7 @@ match(void)
+ int i, tokc = 0;
+ size_t len, textsize;
+ struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
++ int preserve = 0;
+
+ strcpy(buf, text);
+ /* separate input text into tokens to be matched individually */
+_AT_@ -219,19 +225,24 @@ match(void)
+
+ matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
+ textsize = strlen(text);
+- for (item = items; item && item->text; item++) {
++
++ for (item = items; item; item = item->next) {
+ for (i = 0; i < tokc; i++)
+ if (!fstrstr(item->text, tokv[i]))
+ break;
+ if (i != tokc) /* not all tokens match */
+ continue;
+ /* exact matches go first, then prefixes, then substrings */
+- if (!tokc || !fstrncmp(text, item->text, textsize))
++ if (!tokc || !fstrncmp(text, item->text, textsize)) {
+ appenditem(item, &matches, &matchend);
+- else if (!fstrncmp(tokv[0], item->text, len))
++ if (sel == item) preserve = 1;
++ } else if (!fstrncmp(tokv[0], item->text, len)) {
+ appenditem(item, &lprefix, &prefixend);
+- else
++ if (sel == item) preserve = 1;
++ } else {
+ appenditem(item, &lsubstr, &substrend);
++ if (sel == item) preserve = 1;
++ }
+ }
+ if (lprefix) {
+ if (matches) {
+_AT_@ -249,7 +260,9 @@ match(void)
+ matches = lsubstr;
+ matchend = substrend;
+ }
+- curr = sel = matches;
++ if (!preserve)
++ curr = sel = matches;
++
+ calcoffsets();
+ }
+
+_AT_@ -467,36 +480,11 @@ paste(void)
+ }
+
+ static void
+-readstdin(void)
+-{
+- char buf[sizeof text], *p, *maxstr = NULL;
+- size_t i, max = 0, size = 0;
+-
+- /* read each line from stdin and add it to the item list */
+- for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
+- if (i + 1 >= size / sizeof *items)
+- if (!(items = realloc(items, (size += BUFSIZ))))
+- die("cannot realloc %u bytes:", size);
+- if ((p = strchr(buf, '
')))
+- *p = '
Received on Wed Jun 15 2016 - 14:08:03 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 15 2016 - 14:12:15 CEST