sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit c51ebe46e057297b6a7fd4e45c16df2a7d35735a
parent 8309dc5da7af56eb5bd955c6816402e4d08e66df
Author: StephenB <mail4stb@gmail.com>
Date:   Sat,  7 Aug 2010 22:22:55 +0100

added dmenu xmms patch for 4.1.1 and tip, and updated wiki page
Diffstat:
Atools.suckless.org/dmenu/patches/dmenu-4.1.1-xmms.diff | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools.suckless.org/dmenu/patches/dmenu-tip-xmms.diff | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md | 13++++++-------
3 files changed, 257 insertions(+), 7 deletions(-)

diff --git a/tools.suckless.org/dmenu/patches/dmenu-4.1.1-xmms.diff b/tools.suckless.org/dmenu/patches/dmenu-4.1.1-xmms.diff @@ -0,0 +1,130 @@ +--- dmenu-4.1.1/config.def.h 2010-08-04 14:21:27.468630995 +0100 ++++ dmenu-4.1.1/config.def.h 2010-08-04 15:33:31.475940022 +0100 +@@ -7,3 +7,4 @@ + static const char *selbgcolor = "#0066ff"; + static const char *selfgcolor = "#ffffff"; + static unsigned int spaceitem = 30; /* px between menu items */ ++static unsigned int maxtokens = 16; /* max. tokens for pattern matching */ +--- dmenu-4.1.1/dmenu.1 2010-08-04 14:21:27.468630995 +0100 ++++ dmenu-4.1.1/dmenu.1 2010-08-04 15:18:35.557920858 +0100 +@@ -12,6 +12,7 @@ + .RB [ \-p " <prompt>"] + .RB [ \-sb " <color>"] + .RB [ \-sf " <color>"] ++.RB [ \-xs ] + .RB [ \-v ] + .SH DESCRIPTION + .SS Overview +@@ -49,6 +50,9 @@ + .B \-sf <color> + defines the selected foreground color (#RGB, #RRGGBB, and color names are supported). + .TP ++.B \-xs ++xmms-like pattern matching. ++.TP + .B \-v + prints version information to standard output, then exits. + .SH USAGE +--- dmenu-4.1.1/dmenu.c 2010-08-04 14:21:27.468630995 +0100 ++++ dmenu-4.1.1/dmenu.c 2010-08-04 15:18:35.557920858 +0100 +@@ -75,6 +75,7 @@ + /* variables */ + static char *maxname = NULL; + static char *prompt = NULL; ++static char **tokens = NULL; + static char text[4096]; + static int cmdw = 0; + static int promptw = 0; +@@ -84,6 +85,7 @@ + static unsigned int mw, mh; + static unsigned int numlockmask = 0; + static Bool running = True; ++static Bool xmms = False; + static Display *dpy; + static DC dc; + static Item *allitems = NULL; /* first of all items */ +@@ -578,22 +580,55 @@ + drawmenu(); + } + ++unsigned int tokenize(char *pat, char **tok) ++{ ++ unsigned int i = 0; ++ char tmp[4096] = {0}; ++ ++ strncpy(tmp, pat, strlen(pat)); ++ tok[0] = strtok(tmp, " "); ++ ++ while(tok[i] && i < maxtokens) ++ tok[++i] = strtok(NULL, " "); ++ return i; ++} ++ + void + match(char *pattern) { +- unsigned int plen; ++ unsigned int plen, tokencnt = 0; ++ char append = 0; + Item *i, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; + + if(!pattern) + return; +- plen = strlen(pattern); ++ ++ if(!xmms) ++ tokens[(tokencnt = 1)-1] = pattern; ++ else ++ if(!(tokencnt = tokenize(pattern, tokens))) ++ tokens[(tokencnt = 1)-1] = ""; + item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL; +- for(i = allitems; i; i = i->next) +- if(!fstrncmp(pattern, i->text, plen + 1)) ++ for(i = allitems; i; i = i->next) { ++ for(int j = 0; j < tokencnt; ++j) { ++ plen = strlen(tokens[j]); ++ if(!fstrncmp(tokens[j], i->text, plen + 1)) ++ append = !append || append > 1 ? 1 : append; ++ else if(!fstrncmp(tokens[j], i->text, plen )) ++ append = !append || append > 2 ? 2 : append; ++ else if(fstrstr(i->text, tokens[j])) ++ append = append > 0 && append < 3 ? append : 3; ++ else { ++ append = 0; ++ break; ++ } ++ } ++ if(append == 1) + appenditem(i, &lexact, &exactend); +- else if(!fstrncmp(pattern, i->text, plen)) ++ else if(append == 2) + appenditem(i, &lprefix, &prefixend); +- else if(fstrstr(i->text, pattern)) ++ else if(append == 3) + appenditem(i, &lsubstr, &substrend); ++ } + if(lexact) { + item = lexact; + itemend = exactend; +@@ -748,6 +783,7 @@ + if(prompt) + promptw = MIN(textw(prompt), mw / 5); + text[0] = '\0'; ++ tokens = malloc((xmms?maxtokens:1)*sizeof(char*)); + match(text); + XMapRaised(dpy, win); + } +@@ -806,11 +842,13 @@ + else if(!strcmp(argv[i], "-sf")) { + if(++i < argc) selfgcolor = argv[i]; + } ++ else if(!strcmp(argv[i], "-xs")) ++ xmms = True; + else if(!strcmp(argv[i], "-v")) + eprint("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n"); + else + eprint("usage: dmenu [-i] [-b] [-e <xid>] [-l <lines>] [-fn <font>] [-nb <color>]\n" +- " [-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n"); ++ " [-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-xs] [-v]\n"); + if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + fprintf(stderr, "warning: no locale support\n"); + if(!(dpy = XOpenDisplay(NULL))) diff --git a/tools.suckless.org/dmenu/patches/dmenu-tip-xmms.diff b/tools.suckless.org/dmenu/patches/dmenu-tip-xmms.diff @@ -0,0 +1,121 @@ +diff -r de7ad128a8b9 dmenu.1 +--- a/dmenu.1 Fri Aug 06 14:16:08 2010 +0100 ++++ b/dmenu.1 Sat Aug 07 21:28:03 2010 +0100 +@@ -19,6 +19,7 @@ + .IR color ] + .RB [ \-sf + .IR color ] ++.RB [ \-xs ] + .RB [ \-v ] + .P + .BR dmenu_run " ..." +@@ -72,6 +73,9 @@ + .BI \-sf " color" + defines the selected foreground color. + .TP ++.B \-xs ++xmms-like pattern matching. ++.TP + .B \-v + prints version information to standard output, then exits. + .SH USAGE +diff -r de7ad128a8b9 dmenu.c +--- a/dmenu.c Fri Aug 06 14:16:08 2010 +0100 ++++ b/dmenu.c Sat Aug 07 21:28:03 2010 +0100 +@@ -45,6 +45,9 @@ + static const char *normfgcolor = "#000000"; + static const char *selbgcolor = "#0066ff"; + static const char *selfgcolor = "#ffffff"; ++static const unsigned int maxtokens = 16; /* max. tokens for pattern matching */ ++static char **tokens = NULL; ++static Bool xmms = False; + static unsigned int inputw = 0; + static unsigned int lines = 0; + static unsigned int mw, mh; +@@ -339,20 +342,53 @@ + drawmenu(); + } + ++unsigned int ++tokenize(char **tok) { ++ unsigned int i = 0; ++ char tmp[sizeof text] = {0}; ++ ++ strcpy(tmp, text); ++ tok[0] = strtok(tmp, " "); ++ ++ while(tok[i] && i < maxtokens) ++ tok[++i] = strtok(NULL, " "); ++ return i; ++} ++ + void + match(void) { + size_t len; ++ unsigned int tokencnt = 0; ++ char append = 0; + Item *item, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; + +- len = strlen(text); ++ if(!xmms) ++ tokens[(tokencnt = 1)-1] = text; ++ else ++ if(!(tokencnt = tokenize(tokens))) ++ tokens[(tokencnt = 1)-1] = ""; + matches = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL; +- for(item = allitems; item; item = item->next) +- if(!fstrncmp(text, item->text, len + 1)) +- appenditem(item, &lexact, &exactend); +- else if(!fstrncmp(text, item->text, len)) +- appenditem(item, &lprefix, &prefixend); +- else if(fstrstr(item->text, text)) +- appenditem(item, &lsubstr, &substrend); ++ for(item = allitems; item; item = item->next) { ++ for(int j = 0; j < tokencnt; ++j) { ++ len = strlen(tokens[j]); ++ if(!fstrncmp(tokens[j], item->text, len + 1)) ++ append = !append || append > 1 ? 1 : append; ++ else if(!fstrncmp(tokens[j], item->text, len )) ++ append = !append || append > 2 ? 2 : append; ++ else if(fstrstr(item->text, tokens[j])) ++ append = append > 0 && append < 3 ? append : 3; ++ else { ++ append = 0; ++ break; ++ } ++ } ++ if(append == 1) ++ appenditem(item, &lexact, &exactend); ++ else if(append == 2) ++ appenditem(item, &lprefix, &prefixend); ++ else if(append == 3) ++ appenditem(item, &lsubstr, &substrend); ++ } + if(lexact) { + matches = lexact; + itemend = exactend; +@@ -495,13 +531,14 @@ + promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0; + XMapRaised(dc->dpy, win); + text[0] = '\0'; ++ tokens = malloc((xmms?maxtokens:1)*sizeof(char*)); + match(); + } + + void + usage(void) { + fputs("usage: dmenu [-b] [-i] [-l lines] [-p prompt] [-fn font] [-nb color]\n" +- " [-nf color] [-sb color] [-sf color] [-v]\n", stderr); ++ " [-nf color] [-sb color] [-sf color] [-xs] [-v]\n", stderr); + exit(EXIT_FAILURE); + } + +@@ -541,6 +578,8 @@ + selbgcolor = argv[++i]; + else if(!strcmp(argv[i], "-sf")) + selfgcolor = argv[++i]; ++ else if(!strcmp(argv[i], "-xs")) ++ xmms = True; + else + usage(); + diff --git a/tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md b/tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md @@ -14,13 +14,12 @@ could match This feature is enabled by -xs command line flag, it can be useful to ease the matching on huge strings. -The code comes from a vertical patch for dmenu_3.9 wrote by Fresch, the original patch has a lot of options, I just cutted out the ones I use on top of Meillo's dmenu vertical patch. (multiselect, newline and this one) - -Cutter ------- -- Julien Steinhauser <[julien.steinhauser@orange.fr](mailto:julien.steinhauser@orange.fr)> - Download -------- -* [dmenu_xmms.diff](dmenu_xmms.diff) +* [dmenu-tip-xmms.diff](dmenu-tip-xmms.diff) (for hg tip - **use at your own risk**) + +* [dmenu-4.1.1-xmms.diff](dmenu-4.1.1-xmms.diff) (latest dmenu release at time of writing) + +* [dmenu_xmms.diff](dmenu_xmms.diff) (for **dmenu_3.9** - the original patch submitted by Julien Steinhauser <[julien.steinhauser@orange.fr](mailto:julien.steinhauser@orange.fr)>, taken from [https://bbs.archlinux.org/viewtopic.php?pid=429090#p429090](fresch's patch)) +