|
@@ -124,14 +124,14 @@ textmouse(Control *c, Mouse *m)
|
|
|
int sel;
|
|
|
|
|
|
t = (Text*)c;
|
|
|
- if (debug) fprint(2, "textmouse %s t->lastbut %d; m->buttons %d\n", t->name, t->lastbut, m->buttons);
|
|
|
+ if (debug) fprint(2, "textmouse %s t->lastbut %d; m->buttons %d\n", t->Control.name, t->lastbut, m->buttons);
|
|
|
if (t->warp >= 0)
|
|
|
return;
|
|
|
if ((t->selectstyle == Selup) && (m->buttons&7)) {
|
|
|
sel = textline(t, m->xy);
|
|
|
if (t->sel >= 0) {
|
|
|
// if (debug) fprint(2, "textmouse Selup %q sel=%d t->sel=%d t->but=%d\n",
|
|
|
-// t->name, sel, t->sel, t->but);
|
|
|
+// t->Control.name, sel, t->sel, t->but);
|
|
|
t->offsel = (sel == t->sel) ? 0 : 1;
|
|
|
if ((sel == t->sel &&
|
|
|
((t->selected[t->sel] && !t->but) ||
|
|
@@ -148,13 +148,13 @@ textmouse(Control *c, Mouse *m)
|
|
|
sel = texttoggle(t, m->xy);
|
|
|
if(sel >= 0) {
|
|
|
if (t->selectstyle == Seldown) {
|
|
|
- chanprint(t->event, "%q: select %d %d",
|
|
|
- t->name, sel, t->selected[sel] ? (m->buttons & 7) : 0);
|
|
|
+ chanprint(t->Control.event, "%q: select %d %d",
|
|
|
+ t->Control.name, sel, t->selected[sel] ? (m->buttons & 7) : 0);
|
|
|
if (debug) fprint(2, "textmouse Seldown event %q: select %d %d\n",
|
|
|
- t->name, sel, t->selected[sel] ? (m->buttons & 7) : 0);
|
|
|
+ t->Control.name, sel, t->selected[sel] ? (m->buttons & 7) : 0);
|
|
|
} else {
|
|
|
if (debug) fprint(2, "textmouse Selup no event yet %q: select %d %d\n",
|
|
|
- t->name, sel, t->selected[sel] ? (m->buttons & 7) : 0);
|
|
|
+ t->Control.name, sel, t->selected[sel] ? (m->buttons & 7) : 0);
|
|
|
t->sel = sel;
|
|
|
t->but = t->selected[sel] ? (m->buttons & 7) : 0;
|
|
|
}
|
|
@@ -163,10 +163,10 @@ textmouse(Control *c, Mouse *m)
|
|
|
sel = textline(t, m->xy);
|
|
|
t->offsel = 0;
|
|
|
if ((sel >= 0) && (sel == t->sel)) {
|
|
|
- chanprint(t->event, "%q: select %d %d",
|
|
|
- t->name, sel, t->but);
|
|
|
+ chanprint(t->Control.event, "%q: select %d %d",
|
|
|
+ t->Control.name, sel, t->but);
|
|
|
if (debug) fprint(2, "textmouse Selup event %q: select %d %d\n",
|
|
|
- t->name, sel, t->but);
|
|
|
+ t->Control.name, sel, t->but);
|
|
|
} else if (sel != t->sel) {
|
|
|
if ((t->selected[t->sel] && t->but) ||
|
|
|
((!t->selected[t->sel]) && (!t->but))) {
|
|
@@ -175,7 +175,7 @@ textmouse(Control *c, Mouse *m)
|
|
|
textshow(t);
|
|
|
}
|
|
|
if (debug) fprint(2, "textmouse Selup cancel %q: select %d %d\n",
|
|
|
- t->name, sel, t->but);
|
|
|
+ t->Control.name, sel, t->but);
|
|
|
}
|
|
|
t->sel = -1;
|
|
|
t->but = 0;
|
|
@@ -212,13 +212,13 @@ textshow(Text *t)
|
|
|
Font *f;
|
|
|
Rune *text;
|
|
|
|
|
|
- if (t->hidden)
|
|
|
+ if (t->Control.hidden)
|
|
|
return;
|
|
|
- r = t->rect;
|
|
|
+ r = t->Control.rect;
|
|
|
f = t->font->font;
|
|
|
- draw(t->screen, r, t->image->image, nil, t->image->image->r.min);
|
|
|
+ draw(t->Control.screen, r, t->image->image, nil, t->image->image->r.min);
|
|
|
if(t->border > 0){
|
|
|
- border(t->screen, r, t->border, t->bordercolor->image, t->bordercolor->image->r.min);
|
|
|
+ border(t->Control.screen, r, t->border, t->bordercolor->image, t->bordercolor->image->r.min);
|
|
|
r = insetrect(r, t->border);
|
|
|
}
|
|
|
tr = r;
|
|
@@ -228,9 +228,9 @@ textshow(Text *t)
|
|
|
ntext = runestrlen(text);
|
|
|
r.max.y = r.min.y+f->height;
|
|
|
if(t->sel == i && t->offsel)
|
|
|
- draw(t->screen, r, t->selectingcolor->image, nil, ZP);
|
|
|
+ draw(t->Control.screen, r, t->selectingcolor->image, nil, ZP);
|
|
|
else if(t->selected[i])
|
|
|
- draw(t->screen, r, t->selectcolor->image, nil, ZP);
|
|
|
+ draw(t->Control.screen, r, t->selectcolor->image, nil, ZP);
|
|
|
p = _ctlalignpoint(r,
|
|
|
runestringnwidth(f, text, ntext),
|
|
|
f->height, t->align);
|
|
@@ -241,7 +241,7 @@ textshow(Text *t)
|
|
|
moveto(t->controlset->mousectl, p2);
|
|
|
t->warp = -1;
|
|
|
}
|
|
|
- _string(t->screen, p, t->textcolor->image,
|
|
|
+ _string(t->Control.screen, p, t->textcolor->image,
|
|
|
ZP, f, nil, text, ntext, tr,
|
|
|
nil, ZP, SoverD);
|
|
|
r.min.y += f->height;
|
|
@@ -261,24 +261,24 @@ textctl(Control *c, CParse *cp)
|
|
|
cmd = _ctllookup(cp->args[0], cmds, nelem(cmds));
|
|
|
switch(cmd){
|
|
|
default:
|
|
|
- ctlerror("%q: unrecognized message '%s'", t->name, cp->str);
|
|
|
+ ctlerror("%q: unrecognized message '%s'", t->Control.name, cp->str);
|
|
|
break;
|
|
|
case EAlign:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
t->align = _ctlalignment(cp->args[1]);
|
|
|
break;
|
|
|
case EBorder:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
if(cp->iargs[1] < 0)
|
|
|
- ctlerror("%q: bad border: %c", t->name, cp->str);
|
|
|
+ ctlerror("%q: bad border: %c", t->Control.name, cp->str);
|
|
|
t->border = cp->iargs[1];
|
|
|
break;
|
|
|
case EBordercolor:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
- _setctlimage(t, &t->bordercolor, cp->args[1]);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
+ _setctlimage(&t->Control, &t->bordercolor, cp->args[1]);
|
|
|
break;
|
|
|
case EClear:
|
|
|
- _ctlargcount(t, cp, 1);
|
|
|
+ _ctlargcount(&t->Control, cp, 1);
|
|
|
for(i=0; i<t->nline; i++)
|
|
|
free(t->line[i]);
|
|
|
free(t->line);
|
|
@@ -289,10 +289,10 @@ textctl(Control *c, CParse *cp)
|
|
|
textshow(t);
|
|
|
break;
|
|
|
case EDelete:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
i = cp->iargs[1];
|
|
|
if(i<0 || i>=t->nline)
|
|
|
- ctlerror("%q: line number out of range: %s", t->name, cp->str);
|
|
|
+ ctlerror("%q: line number out of range: %s", t->Control.name, cp->str);
|
|
|
free(t->line[i]);
|
|
|
memmove(t->line+i, t->line+i+1, (t->nline-(i+1))*sizeof(Rune*));
|
|
|
memmove(t->selected+i, t->selected+i+1, t->nline-(i+1));
|
|
@@ -302,50 +302,50 @@ textctl(Control *c, CParse *cp)
|
|
|
case EFocus:
|
|
|
break;
|
|
|
case EFont:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
_setctlfont(t, &t->font, cp->args[1]);
|
|
|
break;
|
|
|
case EHide:
|
|
|
- _ctlargcount(t, cp, 1);
|
|
|
- t->hidden = 1;
|
|
|
+ _ctlargcount(&t->Control, cp, 1);
|
|
|
+ t->Control.hidden = 1;
|
|
|
break;
|
|
|
case EImage:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
- _setctlimage(t, &t->image, cp->args[1]);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
+ _setctlimage(&t->Control, &t->image, cp->args[1]);
|
|
|
break;
|
|
|
case ERect:
|
|
|
- _ctlargcount(t, cp, 5);
|
|
|
+ _ctlargcount(&t->Control, cp, 5);
|
|
|
r.min.x = cp->iargs[1];
|
|
|
r.min.y = cp->iargs[2];
|
|
|
r.max.x = cp->iargs[3];
|
|
|
r.max.y = cp->iargs[4];
|
|
|
if(Dx(r)<=0 || Dy(r)<=0)
|
|
|
- ctlerror("%q: bad rectangle: %s", t->name, cp->str);
|
|
|
- t->rect = r;
|
|
|
+ ctlerror("%q: bad rectangle: %s", t->Control.name, cp->str);
|
|
|
+ t->Control.rect = r;
|
|
|
t->nvis = (Dy(r)-2*t->border)/t->font->font->height;
|
|
|
break;
|
|
|
case EReplace:
|
|
|
- _ctlargcount(t, cp, 3);
|
|
|
+ _ctlargcount(&t->Control, cp, 3);
|
|
|
i = cp->iargs[1];
|
|
|
if(i<0 || i>=t->nline)
|
|
|
- ctlerror("%q: line number out of range: %s", t->name, cp->str);
|
|
|
+ ctlerror("%q: line number out of range: %s", t->Control.name, cp->str);
|
|
|
free(t->line[i]);
|
|
|
t->line[i] = _ctlrunestr(cp->args[2]);
|
|
|
textshow(t);
|
|
|
break;
|
|
|
case EReveal:
|
|
|
- _ctlargcount(t, cp, 1);
|
|
|
- t->hidden = 0;
|
|
|
+ _ctlargcount(&t->Control, cp, 1);
|
|
|
+ t->Control.hidden = 0;
|
|
|
textshow(t);
|
|
|
break;
|
|
|
case EScroll:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
t->scroll = cp->iargs[1];
|
|
|
break;
|
|
|
case ESelect:
|
|
|
if(cp->nargs!=2 && cp->nargs!=3)
|
|
|
badselect:
|
|
|
- ctlerror("%q: bad select message: %s", t->name, cp->str);
|
|
|
+ ctlerror("%q: bad select message: %s", t->Control.name, cp->str);
|
|
|
if(cp->nargs == 2){
|
|
|
if(strcmp(cp->args[1], "all") == 0){
|
|
|
memset(t->selected, 1, t->nline);
|
|
@@ -361,53 +361,53 @@ textctl(Control *c, CParse *cp)
|
|
|
break;
|
|
|
}
|
|
|
if(cp->iargs[1]<0 || cp->iargs[1]>=t->nline)
|
|
|
- ctlerror("%q: selection index out of range (nline %d): %s", t->name, t->nline, cp->str);
|
|
|
+ ctlerror("%q: selection index out of range (nline %d): %s", t->Control.name, t->nline, cp->str);
|
|
|
if(t->selected[cp->iargs[1]] != (cp->iargs[2]!=0))
|
|
|
texttogglei(t, cp->iargs[1]);
|
|
|
break;
|
|
|
case ESelectcolor:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
- _setctlimage(t, &t->selectcolor, cp->args[1]);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
+ _setctlimage(&t->Control, &t->selectcolor, cp->args[1]);
|
|
|
break;
|
|
|
case ESelectmode:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
if(strcmp(cp->args[1], "single") == 0)
|
|
|
t->selectmode = Selsingle;
|
|
|
else if(strncmp(cp->args[1], "multi", 5) == 0)
|
|
|
t->selectmode = Selmulti;
|
|
|
break;
|
|
|
case ESelectstyle:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
if(strcmp(cp->args[1], "down") == 0)
|
|
|
t->selectstyle = Seldown;
|
|
|
else if(strcmp(cp->args[1], "up") == 0)
|
|
|
t->selectstyle = Selup;
|
|
|
break;
|
|
|
case EShow:
|
|
|
- _ctlargcount(t, cp, 1);
|
|
|
+ _ctlargcount(&t->Control, cp, 1);
|
|
|
textshow(t);
|
|
|
break;
|
|
|
case ESize:
|
|
|
if (cp->nargs == 3)
|
|
|
r.max = Pt(10000, 10000);
|
|
|
else{
|
|
|
- _ctlargcount(t, cp, 5);
|
|
|
+ _ctlargcount(&t->Control, cp, 5);
|
|
|
r.max.x = cp->iargs[3];
|
|
|
r.max.y = cp->iargs[4];
|
|
|
}
|
|
|
r.min.x = cp->iargs[1];
|
|
|
r.min.y = cp->iargs[2];
|
|
|
if(r.min.x<=0 || r.min.y<=0 || r.max.x<=0 || r.max.y<=0 || r.max.x < r.min.x || r.max.y < r.min.y)
|
|
|
- ctlerror("%q: bad sizes: %s", t->name, cp->str);
|
|
|
- t->size.min = r.min;
|
|
|
- t->size.max = r.max;
|
|
|
+ ctlerror("%q: bad sizes: %s", t->Control.name, cp->str);
|
|
|
+ t->Control.size.min = r.min;
|
|
|
+ t->Control.size.max = r.max;
|
|
|
break;
|
|
|
case ETextcolor:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
- _setctlimage(t, &t->textcolor, cp->args[1]);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
+ _setctlimage(&t->Control, &t->textcolor, cp->args[1]);
|
|
|
break;
|
|
|
case ETopline:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
i = cp->iargs[1];
|
|
|
if(i < 0)
|
|
|
i = 0;
|
|
@@ -432,14 +432,14 @@ textctl(Control *c, CParse *cp)
|
|
|
case EAdd:
|
|
|
switch (cp->nargs) {
|
|
|
default:
|
|
|
- ctlerror("%q: wrong argument count in '%s'", t->name, cp->str);
|
|
|
+ ctlerror("%q: wrong argument count in '%s'", t->Control.name, cp->str);
|
|
|
case 2:
|
|
|
n = t->nline;
|
|
|
break;
|
|
|
case 3:
|
|
|
n = cp->iargs[1];
|
|
|
if(n<0 || n>t->nline)
|
|
|
- ctlerror("%q: line number out of range: %s", t->name, cp->str);
|
|
|
+ ctlerror("%q: line number out of range: %s", t->Control.name, cp->str);
|
|
|
break;
|
|
|
}
|
|
|
rp = _ctlrunestr(cp->args[cp->nargs-1]);
|
|
@@ -464,10 +464,10 @@ textctl(Control *c, CParse *cp)
|
|
|
textshow(t);
|
|
|
break;
|
|
|
case EWarp:
|
|
|
- _ctlargcount(t, cp, 2);
|
|
|
+ _ctlargcount(&t->Control, cp, 2);
|
|
|
i = cp->iargs[1];
|
|
|
if(i <0 || i>=t->nline)
|
|
|
- ctlerror("%q: selection index out of range (nline %d): %s", t->name, t->nline, cp->str);
|
|
|
+ ctlerror("%q: selection index out of range (nline %d): %s", t->Control.name, t->nline, cp->str);
|
|
|
if(i < t->topline || i >= t->topline+t->nvis){
|
|
|
t->topline = i;
|
|
|
}
|
|
@@ -499,7 +499,7 @@ textline(Text *t, Point p)
|
|
|
Rectangle r;
|
|
|
int i;
|
|
|
|
|
|
- r = t->rect;
|
|
|
+ r = t->Control.rect;
|
|
|
if(t->border > 0)
|
|
|
r = insetrect(r, t->border);
|
|
|
if(!ptinrect(p, r))
|
|
@@ -540,9 +540,9 @@ createtext(Controlset *cs, char *name)
|
|
|
t->selectmode = Selsingle;
|
|
|
t->selectstyle = Selup; // Seldown;
|
|
|
t->lastbut = 0;
|
|
|
- t->mouse = textmouse;
|
|
|
- t->ctl = textctl;
|
|
|
- t->exit = textfree;
|
|
|
+ t->Control.mouse = textmouse;
|
|
|
+ t->Control.ctl = textctl;
|
|
|
+ t->Control.exit = textfree;
|
|
|
t->warp = -1;
|
|
|
t->sel = -1;
|
|
|
t->offsel = 0;
|