[hackers] [wmii] Add 'continue' key to /rules. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Fri, 4 Jun 2010 20:59:20 +0000 (UTC)

changeset: 2702:0f9b8782e1bf
user: Kris Maglione <kris_AT_suckless.org>
date: Fri Jun 04 16:46:25 2010 -0400
files: cmd/wmii/client.c cmd/wmii/fns.h cmd/wmii/rule.c include/stuff/util.h lib/libstuff/Makefile lib/libstuff/util/trim.c man/wmii.man1
description:
Add 'continue' key to /rules.

diff -r 1006e2f6027a -r 0f9b8782e1bf cmd/wmii/client.c
--- a/cmd/wmii/client.c Fri Jun 04 16:16:36 2010 -0400
+++ b/cmd/wmii/client.c Fri Jun 04 16:46:25 2010 -0400
@@ -202,13 +202,18 @@
         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 @@
                                         }
                                 }
                         }
- return ret;
+ if(!more)
+ return ret;
                 }
         return ret;
 }
diff -r 1006e2f6027a -r 0f9b8782e1bf cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Fri Jun 04 16:16:36 2010 -0400
+++ b/cmd/wmii/fns.h Fri Jun 04 16:46:25 2010 -0400
@@ -251,7 +251,6 @@
 int ownerscreen(Rectangle);
 
 /* rule.c */
-void trim(char *str, const char *chars);
 void update_rules(Rule**, char*);
 
 /* view.c */
diff -r 1006e2f6027a -r 0f9b8782e1bf cmd/wmii/rule.c
--- a/cmd/wmii/rule.c Fri Jun 04 16:16:36 2010 -0400
+++ b/cmd/wmii/rule.c Fri Jun 04 16:46:25 2010 -0400
@@ -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 -r 1006e2f6027a -r 0f9b8782e1bf include/stuff/util.h
--- a/include/stuff/util.h Fri Jun 04 16:16:36 2010 -0400
+++ b/include/stuff/util.h Fri Jun 04 16:46:25 2010 -0400
@@ -35,6 +35,7 @@
 #define strlcat stuff_strlcat
 #define strcasestr stuff_strcasestr
 
+
 void _die(char*, int, char*, ...);
 void backtrace(char*);
 void closeexec(int);
@@ -68,11 +69,11 @@
 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 -r 1006e2f6027a -r 0f9b8782e1bf lib/libstuff/Makefile
--- a/lib/libstuff/Makefile Fri Jun 04 16:16:36 2010 -0400
+++ b/lib/libstuff/Makefile Fri Jun 04 16:46:25 2010 -0400
@@ -76,6 +76,7 @@
         util/strlcatprint \
         util/sxprint \
         util/tokenize \
+ util/trim \
         util/uniq \
         util/unquote \
         util/utflcpy \
diff -r 1006e2f6027a -r 0f9b8782e1bf lib/libstuff/util/trim.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libstuff/util/trim.c Fri Jun 04 16:46:25 2010 -0400
@@ -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 -r 1006e2f6027a -r 0f9b8782e1bf man/wmii.man1
--- a/man/wmii.man1 Fri Jun 04 16:16:36 2010 -0400
+++ b/man/wmii.man1 Fri Jun 04 16:46:25 2010 -0400
@@ -271,7 +271,12 @@
         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
Received on Fri Jun 04 2010 - 20:59:20 UTC

This archive was generated by hypermail 2.2.0 : Fri Jun 04 2010 - 21:00:08 UTC