~ is a magic tag which needs to be separated by case, merging of different tags works with the '+' operator, ie xwrite /ctl select 1+2

This commit is contained in:
Anselm R. Garbe 2006-03-13 20:27:33 +01:00
parent 3eea13a29b
commit ae43c939d8
2 changed files with 11 additions and 12 deletions

View File

@ -153,21 +153,23 @@ get_tag(char *name)
char buf[256]; char buf[256];
char *tags[128]; char *tags[128];
fprintf(stderr, "get_tag %s\n", name);
for(i = 0; i < ntag; i++) { for(i = 0; i < ntag; i++) {
t = tag[i]; t = tag[i];
if(!strncmp(t->name, name, strlen(t->name))) if(!strncmp(t->name, name, strlen(name)))
return t; return t;
} }
cext_strlcpy(buf, name, sizeof(buf)); cext_strlcpy(buf, name, sizeof(buf));
nt = cext_tokenize(tags, 128, buf, ' '); nt = cext_tokenize(tags, 128, buf, '+');
fprintf(stderr, "get_tag nt=%d\n", nt);
for(i = 0; i < nclient; i++) for(i = 0; i < nclient; i++)
for(j = 0; j < nt; j++) for(j = 0; j < nt; j++)
if(strstr(client[i]->tags, tags[j])) if(strstr(client[i]->tags, tags[j]))
n++; n++;
fprintf(stderr, "get_tag %d\n", n); fprintf(stderr, "get_tag n=%d\n", n);
if(!n) if(!n)
return nil; return nil;
@ -186,6 +188,7 @@ select_tag(char *arg)
int i, j, n; int i, j, n;
Client *c; Client *c;
Tag *t = get_tag(arg); Tag *t = get_tag(arg);
if(!t) if(!t)
return; return;
focus_tag(t); focus_tag(t);
@ -221,7 +224,6 @@ update_tags()
unsigned int i, j, k; unsigned int i, j, k;
char buf[256]; char buf[256];
char *tags[128]; char *tags[128];
char *t;
char **newctag = nil; char **newctag = nil;
unsigned int newctagsz = 0; unsigned int newctagsz = 0;
@ -231,13 +233,10 @@ update_tags()
cext_strlcpy(buf, client[i]->tags, sizeof(buf)); cext_strlcpy(buf, client[i]->tags, sizeof(buf));
j = cext_tokenize(tags, 128, buf, ' '); j = cext_tokenize(tags, 128, buf, ' ');
for(k = 0; k < j; k++) { for(k = 0; k < j; k++) {
t = tags[k]; if(!strncmp(tags[k], "~", 2)) /* magic floating tag */
if(*t == '~')
t++;
if(!*t) /* should not happen, but some user might try */
continue; continue;
if(!istag(newctag, t, nnewctag)) { if(!istag(newctag, tags[k], nnewctag)) {
newctag = (char **)cext_array_attach((void **)newctag, strdup(t), newctag = (char **)cext_array_attach((void **)newctag, strdup(tags[k]),
sizeof(char *), &newctagsz); sizeof(char *), &newctagsz);
nnewctag++; nnewctag++;
} }

View File

@ -37,8 +37,8 @@ xwrite /ws/tag 1
# TAGGING RULES # TAGGING RULES
wmiir write /def/rules <<EOF wmiir write /def/rules <<EOF
/XMMS:.*/ -> ~0 /XMMS:.*/ -> ~
/Gimp.*:.*/ -> ~3 /Gimp.*:.*/ -> ~
EOF EOF
# BAR CONFIGURATION # BAR CONFIGURATION