commit 21f180b4ea657d2ec506a26704d8d5f6e54483d2
parent eb54fce1b519768c5b9a2741141ae62d21901c49
Author: Kris Maglione <kris@suckless.org>
Date: Fri, 4 Jun 2010 16:46:25 -0400
Add 'continue' key to /rules.
Diffstat:
7 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c
@@ -202,13 +202,18 @@ apply_rules(Client *c) {
IxpMsg m;
Rule *r;
Ruleval *rv;
- bool ret;
+ bool ret, more;
ret = false;
for(r=def.rules.rule; r; r=r->next)
if(regexec(r->regex, c->props, nil, 0)) {
+ more = false;
for(rv=r->values; rv; rv=rv->next) {
- if(!strcmp(rv->key, "default-tags")) {
+ if(!strcmp(rv->key, "continue"))
+ more = true;
+ else if(!strcmp(rv->key, "tags"))
+ utflcpy(c->tags, rv->value, sizeof c->tags);
+ else if(!strcmp(rv->key, "default-tags")) {
utflcpy(c->tags, rv->value, sizeof c->tags);
ret = true;
}else {
@@ -221,7 +226,8 @@ apply_rules(Client *c) {
}
}
}
- return ret;
+ if(!more)
+ return ret;
}
return ret;
}
diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h
@@ -251,7 +251,6 @@ void* findthing(Rectangle, int, Vector_ptr*, Rectangle(*)(void*), bool);
int ownerscreen(Rectangle);
/* rule.c */
-void trim(char *str, const char *chars);
void update_rules(Rule**, char*);
/* view.c */
diff --git a/cmd/wmii/rule.c b/cmd/wmii/rule.c
@@ -1,4 +1,4 @@
-/* Copyright ©2006 Anselm R. Garbe <garbeam at gmail dot com>
+/* Copyright ©2010 Kris Maglione <maglione.k at Gmail>
* See LICENSE file for license details.
*/
@@ -6,23 +6,6 @@
#include "fns.h"
void
-trim(char *str, const char *chars) {
- const char *cp;
- char *p, *q;
- char c;
-
- q = str;
- for(p=str; *p; p++) {
- for(cp=chars; (c = *cp); cp++)
- if(*p == c)
- break;
- if(c == '\0')
- *q++ = *p;
- }
- *q = '\0';
-}
-
-void
update_rules(Rule **rule, char *data) {
#define putc(m, c) BLOCK(if((m)->pos < (m)->end) *(m)->pos++ = c;)
#define getc(m) ((m)->pos < (m)->end ? *(m)->pos++ : 0)
diff --git a/include/stuff/util.h b/include/stuff/util.h
@@ -35,6 +35,7 @@ enum {
#define strlcat stuff_strlcat
#define strcasestr stuff_strcasestr
+
void _die(char*, int, char*, ...);
void backtrace(char*);
void closeexec(int);
@@ -68,11 +69,11 @@ uint strlcat(char*, const char*, uint);
int strlcatprint(char*, int, const char*, ...);
char* sxprint(const char*, ...);
uint tokenize(char**, uint, char*, char);
+void trim(char *str, const char *chars);
void uniq(char**);
int unquote(char*, char*[], int);
int utflcpy(char*, const char*, int);
char* vsxprint(const char*, va_list);
-
extern char buffer[8092];
extern char* _buffer;
extern char* const _buf_end;
diff --git a/lib/libstuff/Makefile b/lib/libstuff/Makefile
@@ -76,6 +76,7 @@ OBJ=\
util/strlcatprint \
util/sxprint \
util/tokenize \
+ util/trim \
util/uniq \
util/unquote \
util/utflcpy \
diff --git a/lib/libstuff/util/trim.c b/lib/libstuff/util/trim.c
@@ -0,0 +1,19 @@
+/* Written by Kris Maglione <maglione.k at Gmail> */
+/* Public domain */
+#include "util.h"
+
+void
+trim(char *str, const char *chars) {
+ const char *r;
+ char *p, *q;
+
+ for(p=str, q=str; *p; p++) {
+ for(r=chars; *r; r++)
+ if(*p == *r)
+ break;
+ if(!*r)
+ *q++ = *p;
+ }
+ *q = '\0';
+}
+
diff --git a/man/wmii.man1 b/man/wmii.man1
@@ -271,7 +271,12 @@ follows.
special meaning:
>>
- : default-tags <tags>
+ : continue
+ Normally, when a matching rule is encountered, rule
+ matching stops. When the continue key is provided
+ (with any value), matching continues at the next
+ rule.
+ : default-tags=<tags>
Like _tags_, but only sets the tags if they can't be
obtained from the client's group or from the
\_WMII_TAGS window property. This key should be