author | Anselm R. Garbe <arg@suckless.org> |
Tue, 29 May 2007 11:47:55 +0200 | |
changeset 905 | ca352bd2f8f7 |
parent 858 | b797071ebbd4 |
child 906 | e04a79845936 |
permissions | -rw-r--r-- |
858
b797071ebbd4
yet another fix of copyright compactisition
Anselm R. Garbe <arg@suckless.org>
parents:
857
diff
changeset
|
1 |
/* © 2006-2007 Anselm R. Garbe <garbeam at gmail dot com> |
b797071ebbd4
yet another fix of copyright compactisition
Anselm R. Garbe <arg@suckless.org>
parents:
857
diff
changeset
|
2 |
* © 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com> |
905
ca352bd2f8f7
added anydot to Copyright holders, because he contributed a lot recently
Anselm R. Garbe <arg@suckless.org>
parents:
858
diff
changeset
|
3 |
* © 2007 Premysl Hruby <dfenze at gmail dot com> |
857
453788ae925c
making Copyright notices more compact
Anselm R. Garbe <arg@suckless.org>
parents:
837
diff
changeset
|
4 |
* See LICENSE file for license details. */ |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
5 |
#include "dwm.h" |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
6 |
#include <regex.h> |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
7 |
#include <stdio.h> |
791 | 8 |
#include <stdlib.h> |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
9 |
#include <X11/Xutil.h> |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
10 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
11 |
/* static */ |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
12 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
13 |
typedef struct { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
14 |
const char *prop; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
15 |
const char *tags; |
837
123231b9eb87
renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents:
830
diff
changeset
|
16 |
Bool isfloating; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
17 |
} Rule; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
18 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
19 |
typedef struct { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
20 |
regex_t *propregex; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
21 |
regex_t *tagregex; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
22 |
} Regs; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
23 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
24 |
TAGS |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
25 |
RULES |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
26 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
27 |
static Regs *regs = NULL; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
28 |
static unsigned int nrules = 0; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
29 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
30 |
/* extern */ |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
31 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
32 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
33 |
compileregs(void) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
34 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
35 |
regex_t *reg; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
36 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
37 |
if(regs) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
38 |
return; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
39 |
nrules = sizeof rule / sizeof rule[0]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
40 |
regs = emallocz(nrules * sizeof(Regs)); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
41 |
for(i = 0; i < nrules; i++) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
42 |
if(rule[i].prop) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
43 |
reg = emallocz(sizeof(regex_t)); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
44 |
if(regcomp(reg, rule[i].prop, REG_EXTENDED)) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
45 |
free(reg); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
46 |
else |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
47 |
regs[i].propregex = reg; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
48 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
49 |
if(rule[i].tags) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
50 |
reg = emallocz(sizeof(regex_t)); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
51 |
if(regcomp(reg, rule[i].tags, REG_EXTENDED)) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
52 |
free(reg); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
53 |
else |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
54 |
regs[i].tagregex = reg; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
55 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
56 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
57 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
58 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
59 |
Bool |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
60 |
isvisible(Client *c) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
61 |
unsigned int i; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
62 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
63 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
64 |
if(c->tags[i] && seltag[i]) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
65 |
return True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
66 |
return False; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
67 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
68 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
69 |
void |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
70 |
settags(Client *c, Client *trans) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
71 |
char prop[512]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
72 |
unsigned int i, j; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
73 |
regmatch_t tmp; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
74 |
Bool matched = trans != NULL; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
75 |
XClassHint ch = { 0 }; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
76 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
77 |
if(matched) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
78 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
79 |
c->tags[i] = trans->tags[i]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
80 |
else { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
81 |
XGetClassHint(dpy, c->win, &ch); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
82 |
snprintf(prop, sizeof prop, "%s:%s:%s", |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
83 |
ch.res_class ? ch.res_class : "", |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
84 |
ch.res_name ? ch.res_name : "", c->name); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
85 |
for(i = 0; i < nrules; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
86 |
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
837
123231b9eb87
renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents:
830
diff
changeset
|
87 |
c->isfloating = rule[i].isfloating; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
88 |
for(j = 0; regs[i].tagregex && j < ntags; j++) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
89 |
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
90 |
matched = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
91 |
c->tags[j] = True; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
92 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
93 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
94 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
95 |
if(ch.res_class) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
96 |
XFree(ch.res_class); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
97 |
if(ch.res_name) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
98 |
XFree(ch.res_name); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
99 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
100 |
if(!matched) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
101 |
for(i = 0; i < ntags; i++) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
102 |
c->tags[i] = seltag[i]; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
103 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
104 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
105 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
106 |
tag(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
107 |
int i; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
108 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
109 |
if(!sel) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
110 |
return; |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
111 |
for(i = 0; i < ntags; i++) |
827 | 112 |
sel->tags[i] = arg == NULL; |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
113 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
114 |
if(i >= 0 && i < ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
115 |
sel->tags[i] = True; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
116 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
117 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
118 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
119 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
120 |
toggletag(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
121 |
int i, j; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
122 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
123 |
if(!sel) |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
124 |
return; |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
125 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
126 |
sel->tags[i] = !sel->tags[i]; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
127 |
for(j = 0; j < ntags && !sel->tags[j]; j++); |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
128 |
if(j == ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
129 |
sel->tags[i] = True; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
130 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
131 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
132 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
133 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
134 |
toggleview(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
135 |
int i, j; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
136 |
|
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
137 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
138 |
seltag[i] = !seltag[i]; |
826 | 139 |
for(j = 0; j < ntags && !seltag[j]; j++); |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
140 |
if(j == ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
141 |
seltag[i] = True; /* cannot toggle last view */ |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
142 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
143 |
} |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
144 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
145 |
void |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
146 |
view(const char *arg) { |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
147 |
int i; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
148 |
|
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
149 |
for(i = 0; i < ntags; i++) |
827 | 150 |
seltag[i] = arg == NULL; |
823
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
151 |
i = arg ? atoi(arg) : 0; |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
152 |
if(i >= 0 && i < ntags) |
fb5cbf0bd923
replaced Arg union with const char *arg, seems cleaner to me, even if we need atoi() in some places
Anselm R. Garbe <arg@suckless.org>
parents:
813
diff
changeset
|
153 |
seltag[i] = True; |
790
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
154 |
lt->arrange(); |
48e7c3b45250
split screen.c into layout.c and tag.c (because the view is an implicit mixture of both)
Anselm R. Garbe <arg@suckless.org>
parents:
diff
changeset
|
155 |
} |