diff options
author | Saumit Dinesan <79687674+justsaumit@users.noreply.github.com> | 2022-01-27 23:01:59 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 23:01:59 +0530 |
commit | d8d069da8e68a1feb65a27b88cd9e8ac87fb09a7 (patch) | |
tree | f379afae0e6e21e049635b31672e367c52fb2be2 | |
parent | a4cd52a47d182c46e967f022c42d3a9aa89dc205 (diff) |
Add files via upload
-rw-r--r-- | patches/1.dmenu-xresources-4.9.diff | 126 | ||||
-rw-r--r-- | patches/2.dmenu-password-5.0.diff | 103 | ||||
-rw-r--r-- | patches/3.dmenu-numbers-4.9.diff | 81 | ||||
-rw-r--r-- | patches/4.dmenu-lineheight-5.0.diff | 106 | ||||
-rw-r--r-- | patches/5.dmenu-highpriority-4.9.diff | 178 | ||||
-rw-r--r-- | patches/9.dmenu-highlight-20201211-fcdc159.diff | 97 | ||||
-rw-r--r-- | patches/9.dmenu-instant-4.7.diff | 73 |
7 files changed, 764 insertions, 0 deletions
diff --git a/patches/1.dmenu-xresources-4.9.diff b/patches/1.dmenu-xresources-4.9.diff new file mode 100644 index 0000000..267fb0a --- /dev/null +++ b/patches/1.dmenu-xresources-4.9.diff @@ -0,0 +1,126 @@ +diff '--color=auto' -up ../dmenu-4.9/dmenu.c ./dmenu.c +--- ../dmenu-4.9/dmenu.c 2019-02-02 13:55:02.000000000 +0100 ++++ ./dmenu.c 2020-05-24 00:27:58.038586112 +0200 +@@ -15,6 +15,7 @@ + #include <X11/extensions/Xinerama.h> + #endif + #include <X11/Xft/Xft.h> ++#include <X11/Xresource.h> + + #include "drw.h" + #include "util.h" +@@ -53,6 +54,10 @@ static XIC xic; + static Drw *drw; + static Clr *scheme[SchemeLast]; + ++/* Temporary arrays to allow overriding xresources values */ ++static char *colortemp[4]; ++static char *tempfonts; ++ + #include "config.h" + + static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; +@@ -596,8 +601,13 @@ setup(void) + int a, di, n, area = 0; + #endif + /* init appearance */ +- for (j = 0; j < SchemeLast; j++) +- scheme[j] = drw_scm_create(drw, colors[j], 2); ++ for (j = 0; j < SchemeLast; j++) { ++ scheme[j] = drw_scm_create(drw, (const char**)colors[j], 2); ++ } ++ for (j = 0; j < SchemeOut; ++j) { ++ for (i = 0; i < 2; ++i) ++ free(colors[j][i]); ++ } + + clip = XInternAtom(dpy, "CLIPBOARD", False); + utf8 = XInternAtom(dpy, "UTF8_STRING", False); +@@ -687,6 +697,41 @@ usage(void) + exit(1); + } + ++void ++readxresources(void) { ++ XrmInitialize(); ++ ++ char* xrm; ++ if ((xrm = XResourceManagerString(drw->dpy))) { ++ char *type; ++ XrmDatabase xdb = XrmGetStringDatabase(xrm); ++ XrmValue xval; ++ ++ if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval)) ++ fonts[0] = strdup(xval.addr); ++ else ++ fonts[0] = strdup(fonts[0]); ++ if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval)) ++ colors[SchemeNorm][ColBg] = strdup(xval.addr); ++ else ++ colors[SchemeNorm][ColBg] = strdup(colors[SchemeNorm][ColBg]); ++ if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval)) ++ colors[SchemeNorm][ColFg] = strdup(xval.addr); ++ else ++ colors[SchemeNorm][ColFg] = strdup(colors[SchemeNorm][ColFg]); ++ if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval)) ++ colors[SchemeSel][ColBg] = strdup(xval.addr); ++ else ++ colors[SchemeSel][ColBg] = strdup(colors[SchemeSel][ColBg]); ++ if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval)) ++ colors[SchemeSel][ColFg] = strdup(xval.addr); ++ else ++ colors[SchemeSel][ColFg] = strdup(colors[SchemeSel][ColFg]); ++ ++ XrmDestroyDatabase(xdb); ++ } ++} ++ + int + main(int argc, char *argv[]) + { +@@ -715,15 +760,15 @@ main(int argc, char *argv[]) + else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ + prompt = argv[++i]; + else if (!strcmp(argv[i], "-fn")) /* font or font set */ +- fonts[0] = argv[++i]; ++ tempfonts = argv[++i]; + else if (!strcmp(argv[i], "-nb")) /* normal background color */ +- colors[SchemeNorm][ColBg] = argv[++i]; ++ colortemp[0] = argv[++i]; + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ +- colors[SchemeNorm][ColFg] = argv[++i]; ++ colortemp[1] = argv[++i]; + else if (!strcmp(argv[i], "-sb")) /* selected background color */ +- colors[SchemeSel][ColBg] = argv[++i]; ++ colortemp[2] = argv[++i]; + else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ +- colors[SchemeSel][ColFg] = argv[++i]; ++ colortemp[3] = argv[++i]; + else if (!strcmp(argv[i], "-w")) /* embedding window id */ + embed = argv[++i]; + else +@@ -743,8 +788,23 @@ main(int argc, char *argv[]) + die("could not get embedding window attributes: 0x%lx", + parentwin); + drw = drw_create(dpy, screen, root, wa.width, wa.height); +- if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) ++ readxresources(); ++ /* Now we check whether to override xresources with commandline parameters */ ++ if ( tempfonts ) ++ fonts[0] = strdup(tempfonts); ++ if ( colortemp[0]) ++ colors[SchemeNorm][ColBg] = strdup(colortemp[0]); ++ if ( colortemp[1]) ++ colors[SchemeNorm][ColFg] = strdup(colortemp[1]); ++ if ( colortemp[2]) ++ colors[SchemeSel][ColBg] = strdup(colortemp[2]); ++ if ( colortemp[3]) ++ colors[SchemeSel][ColFg] = strdup(colortemp[3]); ++ ++ if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts))) + die("no fonts could be loaded."); ++ ++ free(fonts[0]); + lrpad = drw->fonts->h; + + #ifdef __OpenBSD__ diff --git a/patches/2.dmenu-password-5.0.diff b/patches/2.dmenu-password-5.0.diff new file mode 100644 index 0000000..7a187b9 --- /dev/null +++ b/patches/2.dmenu-password-5.0.diff @@ -0,0 +1,103 @@ +From c4de1032bd4c247bc20b6ab92a10a8d778966679 Mon Sep 17 00:00:00 2001 +From: Mehrad Mahmoudian <m.mahmoudian@gmail.com> +Date: Tue, 4 May 2021 12:05:09 +0300 +Subject: [PATCH] patched with password patch + +--- + dmenu.1 | 5 ++++- + dmenu.c | 21 +++++++++++++++++---- + 2 files changed, 21 insertions(+), 5 deletions(-) + +diff --git a/dmenu.1 b/dmenu.1 +index 323f93c..762f707 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -3,7 +3,7 @@ + dmenu \- dynamic menu + .SH SYNOPSIS + .B dmenu +-.RB [ \-bfiv ] ++.RB [ \-bfivP ] + .RB [ \-l + .IR lines ] + .RB [ \-m +@@ -47,6 +47,9 @@ is faster, but will lock up X until stdin reaches end\-of\-file. + .B \-i + dmenu matches menu items case insensitively. + .TP ++.B \-P ++dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored. ++.TP + .BI \-l " lines" + dmenu lists items vertically, with the given number of lines. + .TP +diff --git a/dmenu.c b/dmenu.c +index 65f25ce..ad8f63b 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -37,7 +37,7 @@ struct item { + static char text[BUFSIZ] = ""; + static char *embed; + static int bh, mw, mh; +-static int inputw = 0, promptw; ++static int inputw = 0, promptw, passwd = 0; + static int lrpad; /* sum of left and right padding */ + static size_t cursor; + static struct item *items = NULL; +@@ -132,6 +132,7 @@ drawmenu(void) + unsigned int curpos; + struct item *item; + int x = 0, y = 0, w; ++ char *censort; + + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, mw, mh, 1, 1); +@@ -143,7 +144,12 @@ drawmenu(void) + /* 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); ++ if (passwd) { ++ censort = ecalloc(1, sizeof(text)); ++ memset(censort, '.', strlen(text)); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0); ++ free(censort); ++ } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + + curpos = TEXTW(text) - TEXTW(&text[cursor]); + if ((curpos += lrpad / 2 - 1) < w) { +@@ -524,6 +530,11 @@ readstdin(void) + char buf[sizeof text], *p; + size_t i, imax = 0, size = 0; + unsigned int tmpmax = 0; ++ if(passwd){ ++ inputw = lines = 0; ++ return; ++ } ++ + + /* read each line from stdin and add it to the item list */ + for (i = 0; fgets(buf, sizeof buf, stdin); i++) { +@@ -689,7 +700,7 @@ setup(void) + static void + usage(void) + { +- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ fputs("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); + } +@@ -712,7 +723,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], "-P")) /* is the input a password */ ++ passwd = 1; ++ else if (i + 1 == argc) + usage(); + /* these options take one argument */ + else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ +-- +2.31.1 + diff --git a/patches/3.dmenu-numbers-4.9.diff b/patches/3.dmenu-numbers-4.9.diff new file mode 100644 index 0000000..113be80 --- /dev/null +++ b/patches/3.dmenu-numbers-4.9.diff @@ -0,0 +1,81 @@ +From 61abc60dbfaa8ec63fcd176307308aee88a19e32 Mon Sep 17 00:00:00 2001 +From: Miles Alan <m@milesalan.com> +Date: Sat, 10 Aug 2019 17:20:08 -0500 +Subject: [PATCH] Display number of matched and total items in top right corner + +--- + dmenu.c | 25 +++++++++++++++++++++++-- + 1 file changed, 23 insertions(+), 2 deletions(-) + +diff --git a/dmenu.c b/dmenu.c +index 6b8f51b..98c5810 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -24,6 +24,8 @@ + * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) + #define LENGTH(X) (sizeof X / sizeof X[0]) + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) ++#define NUMBERSMAXDIGITS 100 ++#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1 + + /* enums */ + enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ +@@ -34,6 +36,7 @@ struct item { + int out; + }; + ++static char numbers[NUMBERSBUFSIZE] = ""; + static char text[BUFSIZ] = ""; + static char *embed; + static int bh, mw, mh; +@@ -126,6 +129,21 @@ drawitem(struct item *item, int x, int y, int w) + return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); + } + ++static void ++recalculatenumbers() ++{ ++ unsigned int numer = 0, denom = 0; ++ struct item *item; ++ if (matchend) { ++ numer++; ++ for (item = matchend; item && item->left; item = item->left) ++ numer++; ++ } ++ for (item = items; item && item->text; item++) ++ denom++; ++ snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom); ++} ++ + static void + drawmenu(void) + { +@@ -151,6 +169,7 @@ drawmenu(void) + drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + } + ++ recalculatenumbers(); + if (lines > 0) { + /* draw vertical list */ + for (item = curr; item != next; item = item->right) +@@ -165,13 +184,15 @@ drawmenu(void) + } + x += w; + for (item = curr; item != next; item = item->right) +- x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">"))); ++ x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">") - TEXTW(numbers))); + if (next) { + w = TEXTW(">"); + drw_setscheme(drw, scheme[SchemeNorm]); +- drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0); ++ drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0); + } + } ++ drw_setscheme(drw, scheme[SchemeNorm]); ++ drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0); + drw_map(drw, win, 0, 0, mw, mh); + } + +-- +2.19.2 + diff --git a/patches/4.dmenu-lineheight-5.0.diff b/patches/4.dmenu-lineheight-5.0.diff new file mode 100644 index 0000000..3b0df3d --- /dev/null +++ b/patches/4.dmenu-lineheight-5.0.diff @@ -0,0 +1,106 @@ +From ba103e38ea4ab07f9a3ee90627714b9bea17c329 Mon Sep 17 00:00:00 2001 +From: pskry <peter@skrypalle.dk> +Date: Sun, 8 Nov 2020 22:04:22 +0100 +Subject: [PATCH] Add an option which defines the lineheight + +Despite both the panel and dmenu using the same font (a Terminus 12), +dmenu is shorter and the panel is visible from under the dmenu bar. +The appearance can be even more distracting when using similar colors +for background and selections. With the option added by this patch, +dmenu can be launched with a '-h 24', thus completely covering the panel. +--- + config.def.h | 3 +++ + dmenu.1 | 5 +++++ + dmenu.c | 11 ++++++++--- + 3 files changed, 16 insertions(+), 3 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1edb647..4394dec 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -15,6 +15,9 @@ static const char *colors[SchemeLast][2] = { + }; + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; ++/* -h option; minimum height of a menu line */ ++static unsigned int lineheight = 0; ++static unsigned int min_lineheight = 8; + + /* + * Characters not considered part of a word while deleting words +diff --git a/dmenu.1 b/dmenu.1 +index 323f93c..f2a82b4 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -6,6 +6,8 @@ dmenu \- dynamic menu + .RB [ \-bfiv ] + .RB [ \-l + .IR lines ] ++.RB [ \-h ++.IR height ] + .RB [ \-m + .IR monitor ] + .RB [ \-p +@@ -50,6 +52,9 @@ dmenu matches menu items case insensitively. + .BI \-l " lines" + dmenu lists items vertically, with the given number of lines. + .TP ++.BI \-h " height" ++dmenu uses a menu line of at least 'height' pixels tall, but no less than 8. ++.TP + .BI \-m " monitor" + dmenu is displayed on the monitor number supplied. Monitor numbers are starting + from 0. +diff --git a/dmenu.c b/dmenu.c +index 65f25ce..f2a4047 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -131,7 +131,7 @@ drawmenu(void) + { + unsigned int curpos; + struct item *item; +- int x = 0, y = 0, w; ++ int x = 0, y = 0, fh = drw->fonts->h, w; + + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, mw, mh, 1, 1); +@@ -148,7 +148,7 @@ drawmenu(void) + 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); ++ drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0); + } + + if (lines > 0) { +@@ -609,6 +609,7 @@ setup(void) + + /* calculate menu geometry */ + bh = drw->fonts->h + 2; ++ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */ + lines = MAX(lines, 0); + mh = (lines + 1) * bh; + #ifdef XINERAMA +@@ -689,7 +690,7 @@ setup(void) + static void + usage(void) + { +- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ fputs("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); + } +@@ -717,6 +718,10 @@ main(int argc, char *argv[]) + /* these options take one argument */ + else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ + lines = atoi(argv[++i]); ++ else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ ++ lineheight = atoi(argv[++i]); ++ lineheight = MAX(lineheight, min_lineheight); ++ } + else if (!strcmp(argv[i], "-m")) + mon = atoi(argv[++i]); + else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ +-- +2.29.2 + diff --git a/patches/5.dmenu-highpriority-4.9.diff b/patches/5.dmenu-highpriority-4.9.diff new file mode 100644 index 0000000..03e106a --- /dev/null +++ b/patches/5.dmenu-highpriority-4.9.diff @@ -0,0 +1,178 @@ +From e9e1691a9b4ffa2db45cd5108b76b9a68610ba37 Mon Sep 17 00:00:00 2001 +From: takase1121 <takase1121@outlook.com> +Date: Sun, 17 May 2020 07:05:32 +0800 +Subject: [PATCH] Adds high-priority items. + +This allows users to specify a list of high priority commands that should be +displayed before other matches with the following arrangement: + +match -> prefix && high priority -> prefix -> substring + +As you can see, high priority for substring matches is not implemented or will not +be implemented depending on needs. +--- + config.def.h | 1 + + dmenu.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++----- + 2 files changed, 59 insertions(+), 6 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1edb647..65e03fb 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -12,6 +12,7 @@ static const char *colors[SchemeLast][2] = { + [SchemeNorm] = { "#bbbbbb", "#222222" }, + [SchemeSel] = { "#eeeeee", "#005577" }, + [SchemeOut] = { "#000000", "#00ffff" }, ++ [SchemeHp] = { "#bbbbbb", "#333333" } + }; + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; +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,36 @@ 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) { ++ for (int i = 0; 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; +@@ -683,7 +728,8 @@ 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" ++ " [-hb color] [-hf color] [-hp items]\n", stderr); + exit(1); + } + +@@ -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/9.dmenu-highlight-20201211-fcdc159.diff b/patches/9.dmenu-highlight-20201211-fcdc159.diff new file mode 100644 index 0000000..c3ac5c1 --- /dev/null +++ b/patches/9.dmenu-highlight-20201211-fcdc159.diff @@ -0,0 +1,97 @@ +From fcdc1593ed418166f20b7e691a49b1e6eefc116e Mon Sep 17 00:00:00 2001 +From: Nathaniel Evan <nathanielevan@zohomail.com> +Date: Fri, 11 Dec 2020 11:08:12 +0700 +Subject: [PATCH] Highlight matched text in a different color scheme + +--- + config.def.h | 3 +++ + dmenu.c | 44 +++++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 44 insertions(+), 3 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1edb647..79be73a 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -11,7 +11,10 @@ static const char *colors[SchemeLast][2] = { + /* fg bg */ + [SchemeNorm] = { "#bbbbbb", "#222222" }, + [SchemeSel] = { "#eeeeee", "#005577" }, ++ [SchemeSelHighlight] = { "#ffc978", "#005577" }, ++ [SchemeNormHighlight] = { "#ffc978", "#222222" }, + [SchemeOut] = { "#000000", "#00ffff" }, ++ [SchemeOutHighlight] = { "#ffc978", "#00ffff" }, + }; + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; +diff --git a/dmenu.c b/dmenu.c +index 65f25ce..cce1ad1 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -26,8 +26,7 @@ + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) + + /* enums */ +-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ +- ++enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeOutHighlight, SchemeLast }; /* color schemes */ + struct item { + char *text; + struct item *left, *right; +@@ -113,6 +112,43 @@ cistrstr(const char *s, const char *sub) + return NULL; + } + ++static void ++drawhighlights(struct item *item, int x, int y, int maxw) ++{ ++ char restorechar, tokens[sizeof text], *highlight, *token; ++ int indentx, highlightlen; ++ ++ drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : item->out ? SchemeOutHighlight : SchemeNormHighlight]); ++ strcpy(tokens, text); ++ for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) { ++ highlight = fstrstr(item->text, token); ++ while (highlight) { ++ // Move item str end, calc width for highlight indent, & restore ++ highlightlen = highlight - item->text; ++ restorechar = *highlight; ++ item->text[highlightlen] = '\0'; ++ indentx = TEXTW(item->text); ++ item->text[highlightlen] = restorechar; ++ ++ // Move highlight str end, draw highlight, & restore ++ restorechar = highlight[strlen(token)]; ++ highlight[strlen(token)] = '\0'; ++ if (indentx - (lrpad / 2) - 1 < maxw) ++ drw_text( ++ drw, ++ x + indentx - (lrpad / 2) - 1, ++ y, ++ MIN(maxw - indentx, TEXTW(highlight) - lrpad), ++ bh, 0, highlight, 0 ++ ); ++ highlight[strlen(token)] = restorechar; ++ ++ if (strlen(highlight) - strlen(token) < strlen(token)) break; ++ highlight = fstrstr(highlight + strlen(token), token); ++ } ++ } ++} ++ + static int + drawitem(struct item *item, int x, int y, int w) + { +@@ -123,7 +159,9 @@ drawitem(struct item *item, int x, int y, int w) + else + drw_setscheme(drw, scheme[SchemeNorm]); + +- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); ++ int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); ++ drawhighlights(item, x, y, w); ++ return r; + } + + static void +-- +2.29.2 + diff --git a/patches/9.dmenu-instant-4.7.diff b/patches/9.dmenu-instant-4.7.diff new file mode 100644 index 0000000..a78276f --- /dev/null +++ b/patches/9.dmenu-instant-4.7.diff @@ -0,0 +1,73 @@ +diff --git a/config.def.h b/config.def.h +index 1edb647..37f43d5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -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 9eab758..98d3725 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -3,7 +3,7 @@ + dmenu \- dynamic menu + .SH SYNOPSIS + .B dmenu +-.RB [ \-bfiv ] ++.RB [ \-bfinv ] + .RB [ \-l + .IR lines ] + .RB [ \-m +@@ -47,6 +47,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 d605ab4..2c2f03e 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -260,6 +260,13 @@ match(void) + matchend = substrend; + } + curr = sel = matches; ++ ++ if(instant && matches && matches==matchend && !lsubstr) { ++ puts(matches->text); ++ cleanup(); ++ exit(0); ++ } ++ + calcoffsets(); + } + +@@ -636,7 +643,7 @@ setup(void) + static void + usage(void) + { +- fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" ++ fputs("usage: dmenu [-bfinv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); + } +@@ -659,7 +666,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 */ |