commit 4bf559b548fafe3943c5b49f0448c90667ed0bb3
parent 9aae09409411ec31ee564e69b411d247b5a89294
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Thu, 20 Aug 2020 15:05:11 -0500
nodoc fix added for a VERY common conflict type
Diffstat:
12 files changed, 454 insertions(+), 11 deletions(-)
diff --git a/patches/center/USAGE b/patches/center/USAGE
@@ -45,6 +45,9 @@ Description from source:
== PATCH MODIFICATIONS ==
(1). Removed lines relating to config.def.h
(2). Modified for loop in 'max_textw' to conform to pre-C99 syntax, since apparently that is needed.
+(3). Added a 'nodoc' patch version which strips out added documentation
== INCOMPATIBILITIES ==
-No known specific incompatibilities.
+THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES!
+If you encounter such conflicts, try emerging with the 'centeroption-nodoc.patch' file instead. It is the
+same as the 'centeroption.patch' file except it makes no changes to the documentation.
diff --git a/patches/center/centeroption-nodoc.patch b/patches/center/centeroption-nodoc.patch
@@ -0,0 +1,83 @@
+diff --git a/dmenu.c b/dmenu.c
+index 65f25ce..041c7f8 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -89,6 +89,16 @@ calcoffsets(void)
+ break;
+ }
+
++static int
++max_textw(void)
++{
++ int len = 0;
++ struct item *item = items;
++ for (item = items; item && item->text; item++)
++ len = MAX(TEXTW(item->text), len);
++ return len;
++}
++
+ static void
+ cleanup(void)
+ {
+@@ -611,6 +620,7 @@ setup(void)
+ bh = drw->fonts->h + 2;
+ lines = MAX(lines, 0);
+ mh = (lines + 1) * bh;
++ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ #ifdef XINERAMA
+ i = 0;
+ if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
+@@ -637,9 +647,16 @@ setup(void)
+ if (INTERSECT(x, y, 1, 1, info[i]))
+ break;
+
+- x = info[i].x_org;
+- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
+- mw = info[i].width;
++ if (centered) {
++ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
++ x = info[i].x_org + ((info[i].width - mw) / 2);
++ y = info[i].y_org + ((info[i].height - mh) / 2);
++ } else {
++ x = info[i].x_org;
++ y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
++ mw = info[i].width;
++ }
++
+ XFree(info);
+ } else
+ #endif
+@@ -647,11 +664,17 @@ setup(void)
+ if (!XGetWindowAttributes(dpy, parentwin, &wa))
+ die("could not get embedding window attributes: 0x%lx",
+ parentwin);
+- x = 0;
+- y = topbar ? 0 : wa.height - mh;
+- mw = wa.width;
++
++ if (centered) {
++ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
++ x = (wa.width - mw) / 2;
++ y = (wa.height - mh) / 2;
++ } else {
++ x = 0;
++ y = topbar ? 0 : wa.height - mh;
++ mw = wa.width;
++ }
+ }
+- promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
+ inputw = MIN(inputw, mw/3);
+ match();
+
+@@ -709,6 +732,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], "-c")) /* centers dmenu on screen */
++ centered = 1;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+--
+2.24.1
+
diff --git a/patches/dynamicoptions/USAGE b/patches/dynamicoptions/USAGE
@@ -28,6 +28,9 @@ Description from source:
== PATCH MODIFICATIONS ==
(1). Removed lines relating to config.def.h
+(2). Added a 'nodoc' patch version which strips out added documentation
== INCOMPATIBILITIES ==
-No known specific incompatibilities.
+THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES!
+If you encounter such conflicts, try emerging with the 'dynamicoptions-nodoc.patch' file instead. It is the
+same as the 'dynamicoptions.patch' file except it makes no changes to the documentation.
diff --git a/patches/dynamicoptions/dynamicoptions-nodoc.patch b/patches/dynamicoptions/dynamicoptions-nodoc.patch
@@ -0,0 +1,109 @@
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b5..356d4cc9 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -210,9 +210,33 @@ grabkeyboard(void)
+ die("cannot grab keyboard");
+ }
+
++static void readstdin(FILE* stream);
++
++static void
++refreshoptions(){
++ int dynlen = strlen(dynamic);
++ char* cmd= malloc(dynlen + strlen(text)+2);
++ if(cmd == NULL)
++ die("malloc:");
++ sprintf(cmd,"%s %s",dynamic, text);
++ FILE *stream = popen(cmd, "r");
++ if(!stream)
++ die("popen(%s):",cmd);
++ readstdin(stream);
++ int pc = pclose(stream);
++ if(pc == -1)
++ die("pclose:");
++ free(cmd);
++ curr = sel = items;
++}
++
+ static void
+ match(void)
+ {
++ if(dynamic && *dynamic){
++ refreshoptions();
++ }
++
+ static char **tokv = NULL;
+ static int tokn = 0;
+
+@@ -234,7 +258,7 @@ match(void)
+ for (i = 0; i < tokc; i++)
+ if (!fstrstr(item->text, tokv[i]))
+ break;
+- if (i != tokc) /* not all tokens match */
++ if (i != tokc && !(dynamic && *dynamic)) /* not all tokens match */
+ continue;
+ /* exact matches go first, then prefixes, then substrings */
+ if (!tokc || !fstrncmp(text, item->text, textsize))
+@@ -519,14 +543,14 @@ paste(void)
+ }
+
+ static void
+-readstdin(void)
++readstdin(FILE* stream)
+ {
+ char buf[sizeof text], *p;
+ size_t i, imax = 0, size = 0;
+ unsigned int tmpmax = 0;
+
+ /* read each line from stdin and add it to the item list */
+- for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
++ for (i = 0; fgets(buf, sizeof buf, stream); i++) {
+ if (i + 1 >= size / sizeof *items)
+ if (!(items = realloc(items, (size += BUFSIZ))))
+ die("cannot realloc %u bytes:", size);
+@@ -544,7 +568,8 @@ readstdin(void)
+ if (items)
+ items[i].text = NULL;
+ inputw = items ? TEXTW(items[imax].text) : 0;
+- lines = MIN(lines, i);
++ if (!dynamic || !*dynamic)
++ lines = MIN(lines, i);
+ }
+
+ static void
+@@ -683,7 +708,7 @@ static void
+ usage(void)
+ {
+ fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+- " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
++ " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n" "[-dy command]\n", stderr);
+ exit(1);
+ }
+
+@@ -726,6 +751,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], "-dy")) /* dynamic command to run */
++ dynamic = argv[++i];
+ else
+ usage();
+
+@@ -754,9 +781,11 @@ main(int argc, char *argv[])
+
+ if (fast && !isatty(0)) {
+ grabkeyboard();
+- readstdin();
++ if(!(dynamic && *dynamic))
++ readstdin(stdin);
+ } else {
+- readstdin();
++ if(!(dynamic && *dynamic))
++ readstdin(stdin);
+ grabkeyboard();
+ }
+ setup();
+--
+2.26.2
+
diff --git a/patches/grid/USAGE b/patches/grid/USAGE
@@ -26,6 +26,9 @@ Description from source:
== PATCH MODIFICATIONS ==
(1). Removed lines relating to config.def.h
+(2). Added a 'nodoc' patch version which strips out added documentation
== INCOMPATIBILITIES ==
-No known specific incompatibilities.
+THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES!
+If you encounter such conflicts, try emerging with the 'grid-nodoc.patch' file instead. It is the
+same as the 'grid.patch' file except it makes no changes to the documentation.
diff --git a/patches/grid/grid-nodoc.patch b/patches/grid/grid-nodoc.patch
@@ -0,0 +1,51 @@
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..d79b6bb 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -77,7 +77,7 @@ calcoffsets(void)
+ int i, n;
+
+ if (lines > 0)
+- n = lines * bh;
++ n = lines * columns * bh;
+ else
+ n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
+ /* calculate which items will begin the next page and previous page */
+@@ -152,9 +152,15 @@ drawmenu(void)
+ }
+
+ if (lines > 0) {
+- /* draw vertical list */
+- for (item = curr; item != next; item = item->right)
+- drawitem(item, x, y += bh, mw - x);
++ /* draw grid */
++ int i = 0;
++ for (item = curr; item != next; item = item->right, i++)
++ drawitem(
++ item,
++ x + ((i / lines) * ((mw - x) / columns)),
++ y + (((i % lines) + 1) * bh),
++ (mw - x) / columns
++ );
+ } else if (matches) {
+ /* draw horizontal list */
+ x += inputw;
+@@ -708,9 +714,13 @@ main(int argc, char *argv[])
+ } else if (i + 1 == argc)
+ usage();
+ /* these options take one argument */
+- else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
++ else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
++ columns = atoi(argv[++i]);
++ if (lines == 0) lines = 1;
++ } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
+ lines = atoi(argv[++i]);
+- else if (!strcmp(argv[i], "-m"))
++ if (columns == 0) columns = 1;
++ } else if (!strcmp(argv[i], "-m"))
+ mon = atoi(argv[++i]);
+ else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
+ prompt = argv[++i];
+--
+2.23.1
+
diff --git a/patches/highpriority/USAGE b/patches/highpriority/USAGE
@@ -21,18 +21,21 @@ Description from source:
[SchemeHp] = { "#bbbbbb", "#333333" },
- Set the scheme colors to be whatever you want.
+ Set the scheme colors to be whatever you want
(3). Run 'emerge dmenu'
== YOU PROBABLY SHOULD ==
(1). Run dmenu with the '-hb' or '-hf' options to set the high-priority item background and foreground
- respectively.
+ respectively
(2). Run dmenu with the '-hp X,Y,Z' option, where 'X,Y,Z' is a comma seperated list of one or more
- strings to be considered high-priority options.
+ strings to be considered high-priority options
== PATCH MODIFICATIONS ==
(1). Removed lines relating to config.def.h
-(2). Modified for loop in 'max_textw' to conform to pre-C99 syntax, since apparently that is needed.
+(2). Modified for loop in 'max_textw' to conform to pre-C99 syntax, since apparently that is needed
+(3). Added a 'nodoc' patch version which strips out added documentation
== INCOMPATIBILITIES ==
-No known specific incompatibilities.
+THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES!
+If you encounter such conflicts, try emerging with the 'highpriority-nodoc.patch' file instead. It is the
+same as the 'highpriority.patch' file except it makes no changes to the documentation.
diff --git a/patches/highpriority/highpriority-nodoc.patch b/patches/highpriority/highpriority-nodoc.patch
@@ -0,0 +1,140 @@
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..7bf4099 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -26,14 +26,16 @@
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+ /* enums */
+-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeHp, SchemeOut, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
+ struct item *left, *right;
+- int out;
++ int out, hp;
+ };
+
++static char **hpitems = NULL;
++static int hplength = 0;
+ static char text[BUFSIZ] = "";
+ static char *embed;
+ static int bh, mw, mh;
+@@ -58,6 +60,37 @@ static Clr *scheme[SchemeLast];
+ static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
+ static char *(*fstrstr)(const char *, const char *) = strstr;
+
++static char**
++tokenize(char *source, const char *delim, int *llen) {
++ int listlength = 0;
++ char **list = malloc(1 * sizeof(char*));
++ char *token = strtok(source, delim);
++
++ while (token) {
++ if (!(list = realloc(list, sizeof(char*) * (listlength + 1))))
++ die("Unable to realloc %d bytes\n", sizeof(char*) * (listlength + 1));
++ if (!(list[listlength] = strdup(token)))
++ die("Unable to strdup %d bytes\n", strlen(token) + 1);
++ token = strtok(NULL, delim);
++ listlength++;
++ }
++
++ *llen = listlength;
++ return list;
++}
++
++static int
++arrayhas(char **list, int length, char *item) {
++ int i = 0;
++ for (i; i < length; i++) {
++ int len1 = strlen(list[i]);
++ int len2 = strlen(item);
++ if (fstrncmp(list[i], item, len1 > len2 ? len2 : len1) == 0)
++ return 1;
++ }
++ return 0;
++}
++
+ static void
+ appenditem(struct item *item, struct item **list, struct item **last)
+ {
+@@ -118,6 +150,8 @@ drawitem(struct item *item, int x, int y, int w)
+ {
+ if (item == sel)
+ drw_setscheme(drw, scheme[SchemeSel]);
++ else if (item->hp)
++ drw_setscheme(drw, scheme[SchemeHp]);
+ else if (item->out)
+ drw_setscheme(drw, scheme[SchemeOut]);
+ else
+@@ -219,7 +253,7 @@ match(void)
+ char buf[sizeof text], *s;
+ int i, tokc = 0;
+ size_t len, textsize;
+- struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
++ struct item *item, *lhpprefix, *lprefix, *lsubstr, *hpprefixend, *prefixend, *substrend;
+
+ strcpy(buf, text);
+ /* separate input text into tokens to be matched individually */
+@@ -228,7 +262,7 @@ match(void)
+ die("cannot realloc %u bytes:", tokn * sizeof *tokv);
+ len = tokc ? strlen(tokv[0]) : 0;
+
+- matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
++ matches = lhpprefix = lprefix = lsubstr = matchend = hpprefixend = prefixend = substrend = NULL;
+ textsize = strlen(text) + 1;
+ for (item = items; item && item->text; item++) {
+ for (i = 0; i < tokc; i++)
+@@ -236,14 +270,24 @@ match(void)
+ break;
+ if (i != tokc) /* not all tokens match */
+ continue;
+- /* exact matches go first, then prefixes, then substrings */
++ /* exact matches go first, then prefixes with high priority, then prefixes, then substrings */
+ if (!tokc || !fstrncmp(text, item->text, textsize))
+ appenditem(item, &matches, &matchend);
++ else if (item->hp && !fstrncmp(tokv[0], item->text, len))
++ appenditem(item, &lhpprefix, &hpprefixend);
+ else if (!fstrncmp(tokv[0], item->text, len))
+ appenditem(item, &lprefix, &prefixend);
+ else
+ appenditem(item, &lsubstr, &substrend);
+ }
++ if (lhpprefix) {
++ if (matches) {
++ matchend->right = lhpprefix;
++ lhpprefix->left = matchend;
++ } else
++ matches = lhpprefix;
++ matchend = hpprefixend;
++ }
+ if (lprefix) {
+ if (matches) {
+ matchend->right = lprefix;
+@@ -535,6 +579,7 @@ readstdin(void)
+ if (!(items[i].text = strdup(buf)))
+ die("cannot strdup %u bytes:", strlen(buf) + 1);
+ items[i].out = 0;
++ items[i].hp = arrayhas(hpitems, hplength, items[i].text);
+ drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
+ if (tmpmax > inputw) {
+ inputw = tmpmax;
+@@ -724,8 +770,14 @@ main(int argc, char *argv[])
+ colors[SchemeSel][ColBg] = argv[++i];
+ else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
+ colors[SchemeSel][ColFg] = argv[++i];
++ else if (!strcmp(argv[i], "-hb")) /* high priority background color */
++ colors[SchemeHp][ColBg] = argv[++i];
++ else if (!strcmp(argv[i], "-hf")) /* low priority background color */
++ colors[SchemeHp][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
++ else if (!strcmp(argv[i], "-hp"))
++ hpitems = tokenize(argv[++i], ",", &hplength);
+ else
+ usage();
+
+--
+2.26.2
+
diff --git a/patches/incremental/USAGE b/patches/incremental/USAGE
@@ -25,6 +25,9 @@ Description from source:
== PATCH MODIFICATIONS ==
(1). Removed lines relating to config.def.h
(2). Changed chunk 2 in the dwm.c diff to be compatible with the current version of the 'usage' function
+(3). Added a 'nodoc' patch version which strips out added documentation
== INCOMPATIBILITIES ==
-No known specific incompatibilities.
+THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES!
+If you encounter such conflicts, try emerging with the 'incremental-nodoc.patch' file instead. It is the
+same as the 'incremental.patch' file except it makes no changes to the documentation.
diff --git a/patches/incremental/incremental-nodoc.patch b/patches/incremental/incremental-nodoc.patch
@@ -0,0 +1,27 @@
+diff --git a/dmenu.c b/dmenu.c
+index e0c2f80..7f1be56 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -447,6 +447,10 @@ keypress(XKeyEvent *ev)
+ match();
+ break;
+ }
++ if (incremental) {
++ puts(text);
++ fflush(stdout);
++ }
+ drawmenu();
+ }
+
+@@ -629,6 +633,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], "-r")) /* incremental */
++ incremental = 1;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+--
+2.8.3
+
diff --git a/patches/initialtext/USAGE b/patches/initialtext/USAGE
@@ -14,7 +14,9 @@ Description from source:
(1). Run dmenu with the '-it X' option, where 'X' is the text you want dmenu to start with
== PATCH MODIFICATIONS ==
-No modifications were made to this patch.
+(1). Added a 'nodoc' patch version which strips out added documentation
== INCOMPATIBILITIES ==
-No known specific incompatibilities.
+THIS PATCH MAKES CHANGES TO DMENU'S BUILT-IN DOCUMENTATION, WHICH CAN CAUSE CONFLICTS WITH OTHER PATCHES!
+If you encounter such conflicts, try emerging with the 'initialtext-nodoc.patch' file instead. It is the
+same as the 'initialtext.patch' file except it makes no changes to the documentation.
diff --git a/patches/initialtext/initialtext-nodoc.patch b/patches/initialtext/initialtext-nodoc.patch
@@ -0,0 +1,16 @@
+diff --git a/dmenu.c b/dmenu.c
+index d605ab4..0564dfe 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -680,7 +681,10 @@ main(int argc, char *argv[])
+ colors[SchemeSel][ColFg] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
+- else
++ else if (!strcmp(argv[i], "-it")) { /* embedding window id */
++ const char * text = argv[++i];
++ insert(text, strlen(text));
++ } else
+ usage();
+
+ if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())