[wiki] [sites] dmenu: fix instant and non-blocking-stdin patch to name style || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 02 Jul 2016 12:54:07 +0200

commit b72759de5f1924d77ff247c2495b24a0501f70f0
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat Jul 2 12:52:37 2016 +0200

    dmenu: fix instant and non-blocking-stdin patch to name style

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
deleted file mode 100644
index 8bae1e6..0000000
--- a/tools.suckless.org/dmenu/patches/dmenu-git-non-blocking-stdin.diff
+++ /dev/null
_AT_@ -1,247 +0,0 @@
-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 Sat Jul 02 2016 - 12:54:07 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 02 2016 - 13:00:15 CEST