bar now displays tags perfectly ;)

This commit is contained in:
Anselm R. Garbe 2006-03-09 02:43:20 +01:00
parent 407ed38930
commit 03a80ed0d5
5 changed files with 24 additions and 31 deletions

View File

@ -11,9 +11,9 @@
static int
comp_label(const void *l1, const void *l2)
{
Label *ll1 = (Label *)l1;
Label *ll2 = (Label *)l2;
return strcmp((const char *)ll1->name, (const char *)ll2->name);
Label *ll1 = *(Label **)l1;
Label *ll2 = *(Label **)l2;
return strcmp(ll1->name, ll2->name);
}
Label *
@ -31,8 +31,8 @@ get_label(char *name)
l->color = def.sel;
label = (Label **)cext_array_attach((void **)label, l, sizeof(Label *), &labelsz);
nlabel++;
qsort(label, nlabel, sizeof(Label *), comp_label);
return l;
}
@ -72,10 +72,14 @@ update_bar_geometry()
void
draw_bar()
{
unsigned int i;
unsigned int i, iexp = 0;
unsigned int w = 0;
Label *exp = name2label(expand);
Draw d = { 0 };
if(exp)
iexp = label2index(exp);
d.align = WEST;
d.gc = gcbar;
d.drawable = pmapbar;
@ -92,7 +96,7 @@ draw_bar()
Label *l = label[i];
l->rect.x = l->rect.y = 0;
l->rect.height = brect.height;
if(i == iexpand)
if(i == iexp)
continue;
l->rect.width = brect.height;
if(strlen(l->data)) {
@ -115,7 +119,7 @@ draw_bar()
label[i]->rect.width = brect.width - label[i]->rect.x;
}
else {
label[iexpand]->rect.width = brect.width - w;
label[iexp]->rect.width = brect.width - w;
for(i = 1; i < nlabel; i++)
label[i]->rect.x = label[i - 1]->rect.x + label[i - 1]->rect.width;
}

View File

@ -597,8 +597,7 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, 0, DMWRITE);
break;
case FsFexpand:
snprintf(buf, sizeof(buf), "%s", iexpand >= nlabel ? "nil" : label[iexpand]->name);
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
return mkstat(stat, dir, wname, strlen(expand), DMREAD | DMWRITE);
break;
case FsFdata:
return mkstat(stat, dir, wname, (dir_i1 == nlabel) ? 0 : strlen(label[dir_i1]->data), DMREAD | DMWRITE);
@ -759,8 +758,6 @@ xremove(IXPConn *c, Fcall *fcall)
/* now detach the label */
destroy_label(l);
free(l);
if(iexpand >= nlabel)
iexpand = 0;
draw_bar();
}
break;
@ -1165,8 +1162,8 @@ xread(IXPConn *c, Fcall *fcall)
}
break;
case FsFexpand:
fcall->count = strlen(iexpand >= nlabel ? "nil" : label[iexpand]->name);
memcpy(p, iexpand >= nlabel ? "nil" : label[iexpand]->name, fcall->count);
fcall->count = strlen(expand);
memcpy(p, expand, fcall->count);
break;
case FsFdata:
if(i1 >= nlabel)
@ -1347,19 +1344,9 @@ xwrite(IXPConn *c, Fcall *fcall)
}
break;
case FsFexpand:
{
Label *l;
if(fcall->count && fcall->count < 16) {
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
if((l = name2label(buf))) {
iexpand = label2index(l);
draw_bar();
break;
}
}
}
return Enofile;
memcpy(expand, fcall->data, fcall->count);
expand[fcall->count] = 0;
draw_bar();
break;
case FsFdata:
{

View File

@ -308,10 +308,11 @@ main(int argc, char *argv[])
ctag = nil;
client = nil;
expand[0] = 0;
key = nil;
keysz = nkey = 0;
label = nil;
nlabel = labelsz = iexpand = 0;
nlabel = labelsz = 0;
class = nil;
nclass = classsz = 0;

View File

@ -188,7 +188,7 @@ unsigned int nkey;
Label **label;
unsigned int nlabel;
unsigned int labelsz;
unsigned int iexpand;
char expand[256];
char **ctag;
unsigned int nctag;
unsigned int ctagsz;

View File

@ -99,7 +99,7 @@ do
case "$type" in
NT)
wmiir create /bar/$1
xwrite /bar/$1/colors $WMII_NORMCOLORS
xwrite /bar/$1/colors $WMII_SELCOLORS
xwrite /bar/$1/data $1;;
RT)
wmiir remove /bar/$1;;
@ -108,9 +108,10 @@ do
then
: # no old tag label
else
xwrite /bar/$old/data $old
xwrite /bar/$old/colors $WMII_SELCOLORS
fi
xwrite /bar/$1/data '*'$1
xwrite /bar/$1/data $1
xwrite /bar/$1/colors $WMII_NORMCOLORS
old=$1;;
LB)
if wmiir read /tags | awk "\$NF == $1 {exit 1}"