Allows to configure which characters are used for tokenizing input string.
Passing empty string disables tokenizing.
---
This is the patch that adds configurable behaviour for this feature.
If maintainer feels like including it in upstream, fine.
Else, topicstarter may download this email and apply it with git am,
and I'll add it into wiki after a short time.
 dmenu.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dmenu.c b/dmenu.c
index a06ae15..05db5bf 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -40,6 +40,7 @@ static void run(void);
 static void setup(void);
 static void usage(void);
 
+static const char *delim = " ";
 static char text[BUFSIZ] = "";
 static int bh, mw, mh;
 static int inputw, promptw;
@@ -82,6 +83,8 @@ main(int argc, char *argv[]) {
                else if(i+1 == argc)
                        usage();
                /* these options take one argument */
+               else if(!strcmp(argv[i], "-d"))
+                       delim = argv[++i];
                else if(!strcmp(argv[i], "-l"))   /* number of lines in 
vertical list */
                        lines = atoi(argv[++i]);
                else if(!strcmp(argv[i], "-p"))   /* adds prompt to left of 
input field */
@@ -405,7 +408,7 @@ match(void) {
 
        strcpy(buf, text);
        /* separate input text into tokens to be matched individually */
-       for(s = strtok(buf, " "); s; tokv[tokc-1] = s, s = strtok(NULL, " "))
+       for(s = strtok(buf, delim); s; tokv[tokc-1] = s, s = strtok(NULL, 
delim))
                if(++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof 
*tokv)))
                        eprintf("cannot realloc %u bytes\n", tokn * sizeof 
*tokv);
        len = tokc ? strlen(tokv[0]) : 0;
@@ -612,7 +615,7 @@ setup(void) {
 
 void
 usage(void) {
-       fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font]\n"
+       fputs("usage: dmenu [-b] [-f] [-i] [-d delim] [-l lines] [-p prompt] 
[-fn font]\n"
              "             [-nb color] [-nf color] [-sb color] [-sf color] 
[-v]\n", stderr);
        exit(EXIT_FAILURE);
 }
-- 
1.7.10.4


Reply via email to