/def/colrule now uses 30+40+20+10 syntax (num of + + 1 means num of columns, the sum must be 100, which is used for new columns), renamed /def/rules into /def/tagrules, renamed /def/ncol into /def/colrules

This commit is contained in:
Anselm R. Garbe 2006-05-31 19:48:44 +02:00
parent ee0dda3606
commit 25a7fc9216
9 changed files with 80 additions and 78 deletions

View File

@ -251,7 +251,7 @@ attach_to_area(Area *a, Client *c, Bool send)
}
if(!send && aidx) { /* column */
unsigned int w = ncol_of_view(v);
unsigned int w = newcolw_of_view(v);
if(v->area.data[1]->frame.size && w) {
a = new_column(v, v->area.size, w);
arrange_view(v);

View File

@ -868,8 +868,8 @@ match_tags(Client *c, const char *prop)
unsigned int i;
regmatch_t tmpregm;
for(i = 0; i < crule.size; i++) {
Rule *r = crule.data[i];
for(i = 0; i < trule.size; i++) {
Rule *r = trule.data[i];
if(!regexec(&r->regex, prop, 1, &tmpregm, 0))
if(!strlen(c->tags) || !strncmp(c->tags, "nil", 4))
apply_tags(c, r->value);
@ -879,7 +879,7 @@ match_tags(Client *c, const char *prop)
void
apply_rules(Client *c)
{
if(!def.rules)
if(!def.colrules)
goto Fallback;
match_tags(c, c->props);

View File

@ -38,10 +38,10 @@ enum { WMII_IOUNIT = 2048 };
* /def/font FsFfont xlib font name
* /def/selcolors FsFselcolors selected colors
* /def/normcolors FsFnormcolors normal colors
* /def/rules FsFrules rules
* /def/tagrules FsFtagrules tagging rules
* /def/keys FsFkeys keys
* /def/grabmod FsFgrabmod grab modifier
* /def/ncol FsFncol column number
* /def/colrules FsFcolrules column rules
* /bar/ FsDbars
* /bar/lab/ FsDbar
* /bar/lab/data FsFdata <arbitrary data which gets displayed>
@ -199,9 +199,9 @@ name_of_qid(Qid wqid[IXP_MAX_WELEM], unsigned short qsel)
case FsFselcolors: return "selcolors"; break;
case FsFnormcolors: return "normcolors"; break;
case FsFfont: return "font"; break;
case FsFncol: return "ncol"; break;
case FsFcolrules: return "colrules"; break;
case FsFgrabmod: return "grabmod"; break;
case FsFrules: return "rules"; break;
case FsFtagrules: return "tagrules"; break;
case FsFkeys: return "keys"; break;
case FsFcolors: return "colors"; break;
case FsFdata:
@ -302,14 +302,14 @@ type_of_name(Qid wqid[IXP_MAX_WELEM], unsigned short qsel, char *name)
return FsFnormcolors;
if(!strncmp(name, "font", 5))
return FsFfont;
if(!strncmp(name, "ncol", 5))
return FsFncol;
if(!strncmp(name, "colrules", 9))
return FsFcolrules;
if(!strncmp(name, "grabmod", 8))
return FsFgrabmod;
if(!strncmp(name, "keys", 5))
return FsFkeys;
if(!strncmp(name, "rules", 6))
return FsFrules;
if(!strncmp(name, "tagrules", 9))
return FsFtagrules;
if(!strncmp(name, "data", 5))
return FsFdata;
if(!strncmp(name, "mode", 5))
@ -457,8 +457,8 @@ qid_of_name(Qid wqid[IXP_MAX_WELEM], unsigned short qsel, char *name)
case FsFborder:
case FsFgrabmod:
case FsFfont:
case FsFncol:
case FsFrules:
case FsFcolrules:
case FsFtagrules:
case FsFselcolors:
case FsFnormcolors:
case FsFkeys:
@ -611,11 +611,11 @@ stat_of_name(Stat *stat, char *name, Qid wqid[IXP_MAX_WELEM], unsigned short qse
case FsFkeys:
return pack_stat(stat, wqid, qsel, name, def.keys ? strlen(def.keys) : 0, IXP_DMREAD | IXP_DMWRITE);
break;
case FsFrules:
return pack_stat(stat, wqid, qsel, name, def.rules ? strlen(def.rules) : 0, IXP_DMREAD | IXP_DMWRITE);
case FsFtagrules:
return pack_stat(stat, wqid, qsel, name, def.tagrules ? strlen(def.tagrules) : 0, IXP_DMREAD | IXP_DMWRITE);
break;
case FsFncol:
return pack_stat(stat, wqid, qsel, name, def.ncol ? strlen(def.ncol) : 0, IXP_DMREAD | IXP_DMWRITE);
case FsFcolrules:
return pack_stat(stat, wqid, qsel, name, def.colrules ? strlen(def.colrules) : 0, IXP_DMREAD | IXP_DMWRITE);
case FsFfont:
return pack_stat(stat, wqid, qsel, name, strlen(def.font), IXP_DMREAD | IXP_DMWRITE);
case FsFgrabmod:
@ -940,33 +940,33 @@ xread(IXPConn *c, Fcall *fcall)
else if(fcall->count)
memcpy(p, def.keys + fcall->offset, fcall->count);
break;
case FsFrules:
len = def.rules ? strlen(def.rules) : 0;
case FsFtagrules:
len = def.tagrules ? strlen(def.tagrules) : 0;
if(len <= fcall->offset) {
fcall->count = 0;
break;
}
fcall->count = len - fcall->offset;
if(fcall->count > fcall->iounit) {
memcpy(p, def.rules + fcall->offset, fcall->iounit);
memcpy(p, def.tagrules + fcall->offset, fcall->iounit);
fcall->count = fcall->iounit;
}
else if(fcall->count)
memcpy(p, def.rules + fcall->offset, fcall->count);
memcpy(p, def.tagrules + fcall->offset, fcall->count);
break;
case FsFncol:
len = def.ncol ? strlen(def.ncol) : 0;
case FsFcolrules:
len = def.colrules ? strlen(def.colrules) : 0;
if(len <= fcall->offset) {
fcall->count = 0;
break;
}
fcall->count = len - fcall->offset;
if(fcall->count > fcall->iounit) {
memcpy(p, def.ncol + fcall->offset, fcall->iounit);
memcpy(p, def.colrules + fcall->offset, fcall->iounit);
fcall->count = fcall->iounit;
}
else if(fcall->count)
memcpy(p, def.ncol + fcall->offset, fcall->count);
memcpy(p, def.colrules + fcall->offset, fcall->count);
break;
default:
break;
@ -1043,11 +1043,11 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_pack_stat(p, &stat);
fcall->count += stat_of_name(&stat, "keys", m->wqid, m->sel);
p = ixp_pack_stat(p, &stat);
fcall->count += stat_of_name(&stat, "rules", m->wqid, m->sel);
fcall->count += stat_of_name(&stat, "tagrules", m->wqid, m->sel);
p = ixp_pack_stat(p, &stat);
fcall->count += stat_of_name(&stat, "grabmod", m->wqid, m->sel);
p = ixp_pack_stat(p, &stat);
fcall->count += stat_of_name(&stat, "ncol", m->wqid, m->sel);
fcall->count += stat_of_name(&stat, "colrules", m->wqid, m->sel);
p = ixp_pack_stat(p, &stat);
break;
case FsDview:
@ -1217,27 +1217,27 @@ xread(IXPConn *c, Fcall *fcall)
else if(fcall->count)
memcpy(p, def.keys, fcall->count);
break;
case FsFrules:
fcall->count = def.rules ? strlen(def.rules) : 0;
case FsFtagrules:
fcall->count = def.tagrules ? strlen(def.tagrules) : 0;
if(fcall->count > fcall->iounit) {
memcpy(p, def.rules, fcall->iounit);
memcpy(p, def.tagrules, fcall->iounit);
fcall->count = fcall->iounit;
}
else if(fcall->count)
memcpy(p, def.rules, fcall->count);
memcpy(p, def.tagrules, fcall->count);
break;
case FsFgrabmod:
if((fcall->count = strlen(def.grabmod)))
memcpy(p, def.grabmod, fcall->count);
break;
case FsFncol:
fcall->count = def.ncol ? strlen(def.ncol) : 0;
case FsFcolrules:
fcall->count = def.colrules ? strlen(def.colrules) : 0;
if(fcall->count > fcall->iounit) {
memcpy(p, def.ncol, fcall->iounit);
memcpy(p, def.colrules, fcall->iounit);
fcall->count = fcall->iounit;
}
else if(fcall->count)
memcpy(p, def.ncol, fcall->count);
memcpy(p, def.colrules, fcall->count);
break;
case FsFfont:
if((fcall->count = strlen(def.font)))
@ -1427,33 +1427,33 @@ xwrite(IXPConn *c, Fcall *fcall)
memcpy(def.keys + fcall->offset, fcall->data, fcall->count);
def.keys[fcall->offset + fcall->count] = 0;
break;
case FsFrules:
if(def.rulessz < fcall->offset + fcall->count + 1) {
def.rulessz = fcall->offset + fcall->count + 1;
tmp = cext_emallocz(def.rulessz);
len = def.rules ? strlen(def.rules) : 0;
case FsFtagrules:
if(def.tagrulessz < fcall->offset + fcall->count + 1) {
def.tagrulessz = fcall->offset + fcall->count + 1;
tmp = cext_emallocz(def.tagrulessz);
len = def.tagrules ? strlen(def.tagrules) : 0;
if(len) {
memcpy(tmp, def.rules, len);
free(def.rules);
memcpy(tmp, def.tagrules, len);
free(def.tagrules);
}
def.rules = tmp;
def.tagrules = tmp;
}
memcpy(def.rules + fcall->offset, fcall->data, fcall->count);
def.rules[fcall->offset + fcall->count] = 0;
memcpy(def.tagrules + fcall->offset, fcall->data, fcall->count);
def.tagrules[fcall->offset + fcall->count] = 0;
break;
case FsFncol:
if(def.ncolsz < fcall->offset + fcall->count + 1) {
def.ncolsz = fcall->offset + fcall->count + 1;
tmp = cext_emallocz(def.ncolsz);
len = def.ncol ? strlen(def.ncol) : 0;
case FsFcolrules:
if(def.colrulessz < fcall->offset + fcall->count + 1) {
def.colrulessz = fcall->offset + fcall->count + 1;
tmp = cext_emallocz(def.colrulessz);
len = def.colrules ? strlen(def.colrules) : 0;
if(len) {
memcpy(tmp, def.ncol, len);
free(def.ncol);
memcpy(tmp, def.colrules, len);
free(def.colrules);
}
def.ncol = tmp;
def.colrules = tmp;
}
memcpy(def.ncol + fcall->offset, fcall->data, fcall->count);
def.ncol[fcall->offset + fcall->count] = 0;
memcpy(def.colrules + fcall->offset, fcall->data, fcall->count);
def.colrules[fcall->offset + fcall->count] = 0;
break;
case FsFgeom:
if(fcall->count >= sizeof(buf))
@ -1543,15 +1543,15 @@ xclunk(IXPConn *c, Fcall *fcall)
type = unpack_type(m->wqid[m->sel].path);
if(type == FsFkeys)
update_keys();
else if(type == FsFrules) {
else if(type == FsFtagrules) {
unsigned int i;
update_rules(&crule, def.rules);
update_rules(&trule, def.tagrules);
for(i = 0; i < client.size; i++)
apply_rules(client.data[i]);
update_views();
}
else if(type == FsFncol) {
update_rules(&vrule, def.ncol);
else if(type == FsFcolrules) {
update_rules(&vrule, def.colrules);
}
cext_vdetach(ixp_vector_of_maps(&c->map), m);
free(m);

View File

@ -148,11 +148,11 @@ draw_xor_border(XRectangle *r)
void
do_mouse_resize(Client *c, BlitzAlign align)
{
int px, py, ox, oy, i, di;
int px, py, ox, oy, i;
float rx, ry;
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;

View File

@ -390,7 +390,7 @@ update_views()
}
unsigned int
ncol_of_view(View *v)
newcolw_of_view(View *v)
{
unsigned int i, n;
regmatch_t tmpregm;

View File

@ -295,10 +295,10 @@ main(int argc, char *argv[])
key.size = 0;
bar.data = nil;
bar.size = 0;
def.ncol = nil;
def.ncolsz = 0;
def.rules = nil;
def.rulessz = 0;
def.colrules = nil;
def.colrulessz = 0;
def.tagrules = nil;
def.tagrulessz = 0;
def.keys = nil;
def.keyssz = 0;
def.font = strdup(BLITZ_FONT);

View File

@ -66,12 +66,12 @@ enum {
FsFevent,
FsFctl,
FsFname,
FsFrules,
FsFtagrules,
FsFcolrules,
FsFprops,
FsFmode,
FsFtags,
FsFindex,
FsFncol,
FsLast
};
@ -161,13 +161,13 @@ typedef struct {
unsigned int snap;
char *keys;
unsigned int keyssz;
char *rules;
unsigned int rulessz;
char *tagrules;
unsigned int tagrulessz;
char *colrules;
unsigned int colrulessz;
char grabmod[5];
unsigned long mod;
int colmode;
char *ncol;
unsigned int ncolsz;
} Default;
/* global variables */
@ -206,7 +206,7 @@ Cursor cursor[CurLast];
unsigned int valid_mask;
unsigned int num_lock_mask;
void (*handler[LASTEvent]) (XEvent *);
RuleVector crule;
RuleVector trule;
RuleVector vrule;
@ -321,7 +321,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);
unsigned int newcolw_of_view(View *v);
/* wm.c */
void scan_wins();

View File

@ -1,7 +1,7 @@
# Customize to fit your system
# paths
PREFIX = /usr/home/kris/wmii-dev/inst/
PREFIX = /usr/local
CONFPREFIX = ${PREFIX}/etc
MANPREFIX = ${PREFIX}/share/man

View File

@ -36,12 +36,14 @@ xwrite /def/border 2
xwrite /def/font $WMII_FONT
xwrite /def/selcolors $WMII_SELCOLORS
xwrite /def/normcolors $WMII_NORMCOLORS
wmiir write /def/ncol <<EOF
# COLUMN RULES
wmiir write /def/colrules <<EOF
/1/ -> 60+40
EOF
# TAGGING RULES
wmiir write /def/rules <<EOF
wmiir write /def/tagrules <<EOF
/XMMS.*/ -> ~
/Gimp.*/ -> ~
/MPlayer.*/ -> ~