[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Sat, 7 Aug 2010 21:24:37 +0000 (UTC)

changeset: 605:d91b94a8ed1a
tag: tip
user: StephenB <mail4stb_AT_gmail.com>
date: Sat Aug 07 22:22:55 2010 +0100
files: tools.suckless.org/dmenu/patches/dmenu-4.1.1-xmms.diff tools.suckless.org/dmenu/patches/dmenu-tip-xmms.diff tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md
description:
added dmenu xmms patch for 4.1.1 and tip, and updated wiki page


diff -r 1b69b8cba0e0 -r d91b94a8ed1a tools.suckless.org/dmenu/patches/dmenu-4.1.1-xmms.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/dmenu/patches/dmenu-4.1.1-xmms.diff Sat Aug 07 22:22:55 2010 +0100
_AT_@ -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
+_AT_@ -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
+_AT_@ -12,6 +12,7 @@
+ .RB [ \-p " <prompt>"]
+ .RB [ \-sb " <color>"]
+ .RB [ \-sf " <color>"]
++.RB [ \-xs ]
+ .RB [ \-v ]
+ .SH DESCRIPTION
+ .SS Overview
+_AT_@ -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
+_AT_@ -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;
+_AT_@ -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 */
+_AT_@ -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;
+_AT_@ -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);
+ }
+_AT_@ -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 -r 1b69b8cba0e0 -r d91b94a8ed1a tools.suckless.org/dmenu/patches/dmenu-tip-xmms.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools.suckless.org/dmenu/patches/dmenu-tip-xmms.diff Sat Aug 07 22:22:55 2010 +0100
_AT_@ -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
+_AT_@ -19,6 +19,7 @@
+ .IR color ]
+ .RB [ \-sf
+ .IR color ]
++.RB [ \-xs ]
+ .RB [ \-v ]
+ .P
+ .BR dmenu_run " ..."
+_AT_@ -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
+_AT_@ -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;
+_AT_@ -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;
+_AT_@ -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);
+ }
+
+_AT_@ -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 -r 1b69b8cba0e0 -r d91b94a8ed1a tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md
--- a/tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md Fri Aug 06 14:36:20 2010 +0100
+++ b/tools.suckless.org/dmenu/patches/xmms-like_pattern_matching.md Sat Aug 07 22:22:55 2010 +0100
_AT_@ -14,13 +14,12 @@
 
 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_AT_orange.fr](mailto:julien.steinhauser_AT_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_AT_orange.fr](mailto:julien.steinhauser_AT_orange.fr)>, taken from [https://bbs.archlinux.org/viewtopic.php?pid=429090#p429090](fresch's patch))
+
Received on Sat Aug 07 2010 - 23:24:37 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:31:25 CEST