commit 3eea13a29bbb5c7f2ee6da6453320666cf97fe69
parent ae9064ab0901c6beb50b6a65270bf9d18fc399c7
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Mon, 13 Mar 2006 19:49:06 +0100
I recently worked on allowing 'select tag(s)', but not finished yet
Diffstat:
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -148,27 +148,35 @@ istag(char **tags, char *tag, unsigned int ntags)
Tag *
get_tag(char *name)
{
- unsigned int i, n = 0;
+ unsigned int i, n = 0, j, nt;
Tag *t;
+ char buf[256];
+ char *tags[128];
- if(!istag(ctag, name, nctag))
- return nil;
for(i = 0; i < ntag; i++) {
t = tag[i];
if(!strncmp(t->name, name, strlen(t->name)))
return t;
}
+ cext_strlcpy(buf, name, sizeof(buf));
+ nt = cext_tokenize(tags, 128, buf, ' ');
+
for(i = 0; i < nclient; i++)
- if(strstr(client[i]->tags, name))
- n++;
+ for(j = 0; j < nt; j++)
+ if(strstr(client[i]->tags, tags[j]))
+ n++;
+
+ fprintf(stderr, "get_tag %d\n", n);
if(!n)
return nil;
t = alloc_tag(name);
for(i = 0; i < nclient; i++)
- if(strstr(client[i]->tags, name))
- attach_totag(t, client[i]);
+ for(j = 0; j < nt; j++)
+ if(strstr(client[i]->tags, tags[j]))
+ if(!clientoftag(t, client[i]))
+ attach_totag(t, client[i]);
return t;
}
diff --git a/libcext/tokenize.c b/libcext/tokenize.c
@@ -28,7 +28,7 @@ cext_tokenize(char **result, unsigned int reslen, char *str, char delim)
} else
n++;
}
- if(strlen(p))
+ if((i < reslen) && (p < n) && strlen(p))
result[i++] = p;
return i; /* number of tokens */
}