summaryrefslogtreecommitdiffstats
path: root/tag.c
diff options
context:
space:
mode:
authorarg@10ksloc.org <unknown>2006-08-03 12:12:26 +0200
committerarg@10ksloc.org <unknown>2006-08-03 12:12:26 +0200
commitb35575574be53a1b3be42d7037d2f432a19a3890 (patch)
tree6be2344c68ec6590fa816bbd578e0f36fe21c0b8 /tag.c
parenthotfix of settags (diff)
downloaddwm-b35575574be53a1b3be42d7037d2f432a19a3890.tar.gz
dwm-b35575574be53a1b3be42d7037d2f432a19a3890.zip
removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
Diffstat (limited to '')
-rw-r--r--tag.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/tag.c b/tag.c
index 9022371..b20e71e 100644
--- a/tag.c
+++ b/tag.c
@@ -13,7 +13,7 @@
13 13
14typedef struct { 14typedef struct {
15 const char *pattern; 15 const char *pattern;
16 Bool tags[TLast]; 16 const unsigned int *tags;
17 Bool isfloat; 17 Bool isfloat;
18} Rule; 18} Rule;
19 19
@@ -145,7 +145,7 @@ replacetag(Arg *arg)
145 if(!sel) 145 if(!sel)
146 return; 146 return;
147 147
148 for(i = 0; i < TLast; i++) 148 for(i = 0; i < ntags; i++)
149 sel->tags[i] = False; 149 sel->tags[i] = False;
150 appendtag(arg); 150 appendtag(arg);
151} 151}
@@ -155,7 +155,7 @@ settags(Client *c)
155{ 155{
156 char classinst[256]; 156 char classinst[256];
157 static unsigned int len = sizeof(rule) / sizeof(rule[0]); 157 static unsigned int len = sizeof(rule) / sizeof(rule[0]);
158 unsigned int i, j; 158 unsigned int i, j, n;
159 regex_t regex; 159 regex_t regex;
160 regmatch_t tmp; 160 regmatch_t tmp;
161 Bool matched = False; 161 Bool matched = False;
@@ -168,10 +168,11 @@ settags(Client *c)
168 for(i = 0; !matched && i < len; i++) { 168 for(i = 0; !matched && i < len; i++) {
169 if(!regcomp(&regex, rule[i].pattern, 0)) { 169 if(!regcomp(&regex, rule[i].pattern, 0)) {
170 if(!regexec(&regex, classinst, 1, &tmp, 0)) { 170 if(!regexec(&regex, classinst, 1, &tmp, 0)) {
171 for(j = 0; j < TLast; j++) { 171 n = rule[i].tags ?
172 if((c->tags[j] = rule[i].tags[j])) 172 sizeof(rule[i].tags) / sizeof(rule[i].tags[0]) : 0;
173 matched = True; 173 matched = n != 0;
174 } 174 for(j = 0; j < n; j++)
175 c->tags[rule[i].tags[j]] = True;
175 c->isfloat = rule[i].isfloat; 176 c->isfloat = rule[i].isfloat;
176 } 177 }
177 regfree(&regex); 178 regfree(&regex);
@@ -204,13 +205,13 @@ view(Arg *arg)
204void 205void
205viewnext(Arg *arg) 206viewnext(Arg *arg)
206{ 207{
207 arg->i = (tsel < TLast-1) ? tsel+1 : 0; 208 arg->i = (tsel < ntags-1) ? tsel+1 : 0;
208 view(arg); 209 view(arg);
209} 210}
210 211
211void 212void
212viewprev(Arg *arg) 213viewprev(Arg *arg)
213{ 214{
214 arg->i = (tsel > 0) ? tsel-1 : TLast-1; 215 arg->i = (tsel > 0) ? tsel-1 : ntags-1;
215 view(arg); 216 view(arg);
216} 217}