added /def/ncol stuff, see wmiirc for an initial syntax proposal

This commit is contained in:
Anselm R. Garbe 2006-05-31 09:51:40 +02:00
parent d2a9e3a860
commit 4904a19aae
7 changed files with 41 additions and 35 deletions

View File

@ -234,25 +234,6 @@ place_client(Area *a, Client *c)
free(rects);
}
static unsigned int
ncol_of_view(View *v)
{
unsigned int i, n;
regmatch_t tmpregm;
for(i = 0; i < vrule.size; i++) {
Rule *r = vrule.data[i];
if(!regexec(&r->regex, v->name, 1, &tmpregm, 0)) {
if(sscanf(r->values, "%u", &n) == 1) {
fprintf(stderr, "r->values=%s n=%d\n", r->values, n);
return n;
}
fprintf(stderr, "r->values=%s n=%d\n", r->values, n);
}
}
return 0;
}
void
attach_to_area(Area *a, Client *c)
{
@ -269,9 +250,10 @@ attach_to_area(Area *a, Client *c)
if(aidx) { /* column */
unsigned int nc = ncol_of_view(v);
fprintf(stderr, "nc=%d v->area.size=%d\n", nc, v->area.size);
if(nc && nc > v->area.size - 1)
a = create_area(v, v->sel);
if(v->area.data[1]->frame.size && nc && nc > v->area.size - 1) {
a = create_area(v, ++v->sel);
arrange_view(v);
}
}
f = create_frame(a, c);

View File

@ -872,7 +872,7 @@ match_tags(Client *c, const char *prop)
Rule *r = crule.data[i];
if(!regexec(&r->regex, prop, 1, &tmpregm, 0))
if(!strlen(c->tags) || !strncmp(c->tags, "nil", 4))
apply_tags(c, r->values);
apply_tags(c, r->value);
}
}

View File

@ -127,7 +127,7 @@ do_mouse_resize(Client *c, BlitzAlign align)
int px = 0, py = 0, i, ox, oy;
Window dummy;
XEvent ev;
unsigned int num = 0;
unsigned int num = 0, di;
Frame *f = c->frame.data[c->sel];
int aidx = idx_of_area(f->area);
int snap = aidx ? 0 : rect.height / 66;
@ -136,7 +136,7 @@ do_mouse_resize(Client *c, BlitzAlign align)
XRectangle origin = frect;
XPoint pt;
XQueryPointer(dpy, c->framewin, &dummy, &dummy, &ox, &oy, &i, &i, &i);
XQueryPointer(dpy, c->framewin, &dummy, &dummy, &ox, &oy, &i, &i, &di);
pt.x = ox; pt.y = oy;
XSync(dpy, False);

View File

@ -13,7 +13,7 @@
enum {
IGNORE,
REGEX,
TAGS
VALUE
};
static Vector *
@ -26,7 +26,7 @@ void
update_rules(RuleVector *rule, const char *data)
{
int mode = IGNORE;
char *p, *r = nil, *v = nil, regex[256], values[256];
char *p, *r = nil, *v = nil, regex[256], value[256];
if(!data || !strlen(data))
return;
@ -46,9 +46,9 @@ update_rules(RuleVector *rule, const char *data)
r = regex;
}
else if(*p == '>') {
mode = TAGS;
values[0] = 0;
v = values;
mode = VALUE;
value[0] = 0;
v = value;
}
break;
case REGEX:
@ -61,13 +61,13 @@ update_rules(RuleVector *rule, const char *data)
r++;
}
break;
case TAGS:
if(*p == '\n' || *(p + 1) == 0) {
case VALUE:
if(*p == '\n' || *p == 0) {
Rule *rul = cext_emallocz(sizeof(Rule));
*v = 0;
cext_trim(values, " \t/");
cext_trim(value, " \t/");
if(!regcomp(&rul->regex, regex, 0)) {
cext_strlcpy(rul->values, values, sizeof(rul->values));
cext_strlcpy(rul->value, value, sizeof(rul->value));
cext_vattach(vector_of_rules(rule), rul);
}
else

View File

@ -387,3 +387,23 @@ update_views()
else
update_view_bars();
}
unsigned int
ncol_of_view(View *v)
{
unsigned int i, n;
regmatch_t tmpregm;
for(i = 0; i < vrule.size; i++) {
Rule *r = vrule.data[i];
if(!regexec(&r->regex, v->name, 1, &tmpregm, 0)) {
if(sscanf(r->value, "%u", &n) == 1) {
fprintf(stderr, "r->value=%s n=%d\n", r->value, n);
return n;
}
fprintf(stderr, "r->value=%s n=%d\n", r->value, n);
}
}
return 0;
}

View File

@ -177,7 +177,7 @@ VECTOR(BarVector, Bar *);
typedef struct {
regex_t regex;
char values[256];
char value[256];
} Rule;
VECTOR(RuleVector, Rule *);
@ -322,6 +322,7 @@ void restack_view(View *v);
View *view_of_name(const char *name);
void destroy_view(View *v);
void update_views();
unsigned int ncol_of_view(View *v);
/* wm.c */
void scan_wins();

View File

@ -36,6 +36,9 @@ xwrite /def/border 2
xwrite /def/font $WMII_FONT
xwrite /def/selcolors $WMII_SELCOLORS
xwrite /def/normcolors $WMII_NORMCOLORS
wmiir write /def/ncol <<EOF
/.*/ -> 2
EOF
# TAGGING RULES
wmiir write /def/rules <<EOF