Mercurial > dwm-meillo
annotate tag.c @ 750:3d957a703ce2 default tip
added absolute path to halt
author | meillo@marmaro.de |
---|---|
date | Thu, 05 Jul 2007 22:05:11 +0200 |
parents | 6692d7e7e156 |
children |
rev | line source |
---|---|
644 | 1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> |
75 | 2 * See LICENSE file for license details. |
3 */ | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
4 #include "dwm.h" |
114 | 5 #include <regex.h> |
6 #include <stdio.h> | |
191 | 7 #include <stdlib.h> |
75 | 8 #include <string.h> |
114 | 9 #include <sys/types.h> |
75 | 10 #include <X11/Xutil.h> |
11 | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
12 |
114 | 13 typedef struct { |
191 | 14 const char *clpattern; |
15 const char *tpattern; | |
114 | 16 Bool isfloat; |
17 } Rule; | |
18 | |
191 | 19 typedef struct { |
20 regex_t *clregex; | |
21 regex_t *tregex; | |
22 } RReg; | |
23 | |
24 /* static */ | |
25 | |
146
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
144
diff
changeset
|
26 TAGS |
f328ce9c558c
centralized/externalized configuration to config.h
arg@10ksloc.org
parents:
144
diff
changeset
|
27 RULES |
84
052fe7498930
ordered variables in structs and source files alphabetically
Anselm R. Garbe <garbeam@wmii.de>
parents:
80
diff
changeset
|
28 |
191 | 29 static RReg *rreg = NULL; |
30 static unsigned int len = 0; | |
31 | |
125 | 32 /* extern */ |
33 | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
34 Client * |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
441
diff
changeset
|
35 getnext(Client *c) { |
261
d6fd632d861c
implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents:
240
diff
changeset
|
36 for(; c && !isvisible(c); c = c->next); |
93
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
37 return c; |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
38 } |
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
39 |
127
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
40 Client * |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
441
diff
changeset
|
41 getprev(Client *c) { |
261
d6fd632d861c
implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents:
240
diff
changeset
|
42 for(; c && !isvisible(c); c = c->prev); |
127
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
43 return c; |
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
44 } |
1480e19f6377
using double-linked list in order to get correct prev focus handling
arg@10ksloc.org
parents:
125
diff
changeset
|
45 |
93
c498da7520c7
added heretag command which allows to tag a client of a foreign tag with current tag
Anselm R. Garbe <garbeam@wmii.de>
parents:
84
diff
changeset
|
46 void |
487 | 47 initrregs(void) { |
191 | 48 unsigned int i; |
49 regex_t *reg; | |
50 | |
51 if(rreg) | |
52 return; | |
581
601842ee4484
applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents:
573
diff
changeset
|
53 len = sizeof rule / sizeof rule[0]; |
191 | 54 rreg = emallocz(len * sizeof(RReg)); |
55 for(i = 0; i < len; i++) { | |
56 if(rule[i].clpattern) { | |
57 reg = emallocz(sizeof(regex_t)); | |
609 | 58 if(regcomp(reg, rule[i].clpattern, REG_EXTENDED)) |
191 | 59 free(reg); |
60 else | |
61 rreg[i].clregex = reg; | |
62 } | |
63 if(rule[i].tpattern) { | |
64 reg = emallocz(sizeof(regex_t)); | |
609 | 65 if(regcomp(reg, rule[i].tpattern, REG_EXTENDED)) |
191 | 66 free(reg); |
67 else | |
68 rreg[i].tregex = reg; | |
69 } | |
70 } | |
71 } | |
72 | |
270
dacd3f3c5823
implemented restack behavior (floats are on top in tiled mode)
Anselm R.Garbe <arg@10ksloc.org>
parents:
267
diff
changeset
|
73 void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
441
diff
changeset
|
74 settags(Client *c, Client *trans) { |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
75 char prop[512]; |
191 | 76 unsigned int i, j; |
114 | 77 regmatch_t tmp; |
431
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
78 Bool matched = trans != NULL; |
742
39b941868ce3
adapting John Grahor's patch to dwm-3.5
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
79 XClassHint ch = { 0 }; |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
80 |
431
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
81 if(matched) { |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
82 for(i = 0; i < ntags; i++) |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
83 c->tags[i] = trans->tags[i]; |
a230e4432bb7
moved transient_for tag inheritance to settags
Anselm R. Garbe <arg@10kloc.org>
parents:
430
diff
changeset
|
84 } |
742
39b941868ce3
adapting John Grahor's patch to dwm-3.5
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
85 else { |
39b941868ce3
adapting John Grahor's patch to dwm-3.5
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
86 XGetClassHint(dpy, c->win, &ch); |
581
601842ee4484
applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29
parents:
573
diff
changeset
|
87 snprintf(prop, sizeof prop, "%s:%s:%s", |
114 | 88 ch.res_class ? ch.res_class : "", |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
89 ch.res_name ? ch.res_name : "", c->name); |
609 | 90 for(i = 0; i < len; i++) |
336
2a65e8b3d21a
implemented class:inst:title matching
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
91 if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) { |
191 | 92 c->isfloat = rule[i].isfloat; |
93 for(j = 0; rreg[i].tregex && j < ntags; j++) { | |
94 if(!regexec(rreg[i].tregex, tags[j], 1, &tmp, 0)) { | |
95 matched = True; | |
96 c->tags[j] = True; | |
97 } | |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
98 } |
747
f0e6c8860014
now clients perform only the first rule matching from config
meillo@marmaro.de
parents:
745
diff
changeset
|
99 break; /* perform only the first rule matching */ |
114 | 100 } |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
101 if(ch.res_class) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
102 XFree(ch.res_class); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
103 if(ch.res_name) |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
104 XFree(ch.res_name); |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
105 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
106 if(!matched) |
261
d6fd632d861c
implement multi-tag selection through button3 click on the specific tag
Anselm R.Garbe <arg@10ksloc.org>
parents:
240
diff
changeset
|
107 for(i = 0; i < ntags; i++) |
262
d659a2dce2b5
implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature
Anselm R.Garbe <arg@10ksloc.org>
parents:
261
diff
changeset
|
108 c->tags[i] = seltag[i]; |
76
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
109 } |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
110 |
4bd49f404f10
proceeded with cleaning up, sorting functions, etc
Anselm R. Garbe <garbeam@wmii.de>
parents:
75
diff
changeset
|
111 void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
441
diff
changeset
|
112 tag(Arg *arg) { |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
113 unsigned int i; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
114 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
115 if(!sel) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
116 return; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
117 for(i = 0; i < ntags; i++) |
594
f7dcd3ac8d6f
removed viewall(), replaced with view(-1); added tag(-1) to tag a client with all tags (new key combo MODKEY-Shift-0)
arg@mig29
parents:
581
diff
changeset
|
118 sel->tags[i] = (arg->i == -1) ? True : False; |
611 | 119 if(arg->i >= 0 && arg->i < ntags) |
120 sel->tags[arg->i] = True; | |
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
121 arrange(); |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
122 } |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
123 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
124 void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
441
diff
changeset
|
125 toggletag(Arg *arg) { |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
126 unsigned int i; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
127 |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
128 if(!sel) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
129 return; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
130 sel->tags[arg->i] = !sel->tags[arg->i]; |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
131 for(i = 0; i < ntags && !sel->tags[i]; i++); |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
132 if(i == ntags) |
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
133 sel->tags[arg->i] = True; |
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
134 arrange(); |
284
5f5c56e104de
changed replacetag into toggletag
Anselm R.Garbe <arg@10ksloc.org>
parents:
277
diff
changeset
|
135 } |
745 | 136 |
749
6692d7e7e156
added maxlayout by mitch, moved config.h to config.meillo.h, some smaller modifications
meillo@marmaro.de
parents:
747
diff
changeset
|
137 /* begin code by jukka */ |
745 | 138 void |
139 viewnext(Arg *arg) { | |
140 unsigned int i; | |
141 Bool last = seltag[ntags-1]; | |
142 | |
143 for (i=ntags-1; i>0; --i) | |
144 seltag[i] = seltag[i-1]; | |
145 seltag[0] = last; | |
146 arrange(); | |
147 } | |
749
6692d7e7e156
added maxlayout by mitch, moved config.h to config.meillo.h, some smaller modifications
meillo@marmaro.de
parents:
747
diff
changeset
|
148 /* end code by jukka */ |