acme: revise multiline tag code
This commit is contained in:
parent
cb1ac4c41d
commit
a2db69c8bd
5 changed files with 67 additions and 100 deletions
|
|
@ -53,7 +53,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
|
||||||
{
|
{
|
||||||
Rectangle r, r1;
|
Rectangle r, r1;
|
||||||
Window *v;
|
Window *v;
|
||||||
int i, j, minht, t;
|
int i, j, minht, ymax;
|
||||||
|
|
||||||
v = nil;
|
v = nil;
|
||||||
r = c->r;
|
r = c->r;
|
||||||
|
|
@ -72,31 +72,38 @@ coladd(Column *c, Window *w, Window *clone, int y)
|
||||||
if(i < c->nw)
|
if(i < c->nw)
|
||||||
i++; /* new window will go after v */
|
i++; /* new window will go after v */
|
||||||
/*
|
/*
|
||||||
* if v's too small, grow it first.
|
* if landing window (v) is too small, grow it first.
|
||||||
*/
|
*/
|
||||||
minht = v->tag.fr.font->height+Border+1;
|
minht = v->tag.fr.font->height+Border+1;
|
||||||
j = 0;
|
j = 0;
|
||||||
while(!c->safe || v->body.fr.maxlines<=3 || Dy(v->body.all) <= minht){
|
while(!c->safe || v->body.fr.maxlines<=3 || Dy(v->body.all) <= minht){
|
||||||
if(++j > 10){
|
if(++j > 10){
|
||||||
fprint(2, "oops: dy=%d\n", Dy(v->body.all));
|
fprint(2, "coladd: bug dy=%d\n", Dy(v->body.all));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
colgrow(c, v, 1);
|
colgrow(c, v, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* figure out where to split v to make room for w
|
||||||
|
*/
|
||||||
if(i == c->nw)
|
if(i == c->nw)
|
||||||
t = c->r.max.y;
|
ymax = c->r.max.y;
|
||||||
else
|
else
|
||||||
t = c->w[i]->r.min.y-Border;
|
ymax = c->w[i]->r.min.y-Border;
|
||||||
y = min(y, v->body.all.min.y+Dy(v->body.all)/2);
|
y = min(y, v->body.all.min.y+Dy(v->body.all)/2);
|
||||||
if(t - y < minht)
|
y = min(y, ymax - minht);
|
||||||
y = t - minht;
|
y = max(y, v->body.all.min.y);
|
||||||
if(y < v->body.all.min.y)
|
ymax = max(ymax, y+minht);
|
||||||
y = v->body.all.min.y;
|
|
||||||
r = v->r;
|
r = v->r;
|
||||||
r.max.y = t;
|
r.max.y = ymax;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* redraw w
|
||||||
|
*/
|
||||||
draw(screen, r, textcols[BACK], nil, ZP);
|
draw(screen, r, textcols[BACK], nil, ZP);
|
||||||
r1 = r;
|
r1 = r;
|
||||||
y = min(y, t-(v->tag.fr.font->height*v->taglines+v->body.fr.font->height+Border+1));
|
y = min(y, ymax-(v->tag.fr.font->height*v->taglines+v->body.fr.font->height+Border+1));
|
||||||
r1.max.y = min(y, v->body.fr.r.min.y+v->body.fr.nlines*v->body.fr.font->height);
|
r1.max.y = min(y, v->body.fr.r.min.y+v->body.fr.nlines*v->body.fr.font->height);
|
||||||
r1.min.y = winresize(v, r1, FALSE, FALSE);
|
r1.min.y = winresize(v, r1, FALSE, FALSE);
|
||||||
r1.max.y = r1.min.y+Border;
|
r1.max.y = r1.min.y+Border;
|
||||||
|
|
@ -151,8 +158,8 @@ colclose(Column *c, Window *w, int dofree)
|
||||||
windelete(w);
|
windelete(w);
|
||||||
winclose(w);
|
winclose(w);
|
||||||
}
|
}
|
||||||
memmove(c->w+i, c->w+i+1, (c->nw-i-1)*sizeof(Window*));
|
|
||||||
c->nw--;
|
c->nw--;
|
||||||
|
memmove(c->w+i, c->w+i+1, (c->nw-i)*sizeof(Window*));
|
||||||
c->w = realloc(c->w, c->nw*sizeof(Window*));
|
c->w = realloc(c->w, c->nw*sizeof(Window*));
|
||||||
if(c->nw == 0){
|
if(c->nw == 0){
|
||||||
draw(screen, r, display->white, nil, ZP);
|
draw(screen, r, display->white, nil, ZP);
|
||||||
|
|
@ -219,8 +226,7 @@ colresize(Column *c, Rectangle r)
|
||||||
r1.max.y = r.max.y;
|
r1.max.y = r.max.y;
|
||||||
else
|
else
|
||||||
r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
|
r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
|
||||||
if(Dy(r1) < Border+font->height)
|
r1.max.y = max(r1.max.y, r1.min.y + Border+font->height);
|
||||||
r1.max.y = r1.min.y + Border+font->height;
|
|
||||||
r2 = r1;
|
r2 = r1;
|
||||||
r2.max.y = r2.min.y+Border;
|
r2.max.y = r2.min.y+Border;
|
||||||
draw(screen, r2, display->black, nil, ZP);
|
draw(screen, r2, display->black, nil, ZP);
|
||||||
|
|
@ -307,7 +313,7 @@ colgrow(Column *c, Window *w, int but)
|
||||||
if(i==c->nw-1 || c->safe==FALSE)
|
if(i==c->nw-1 || c->safe==FALSE)
|
||||||
r.max.y = cr.max.y;
|
r.max.y = cr.max.y;
|
||||||
else
|
else
|
||||||
r.max.y = c->w[i+1]->r.min.y-Border;
|
r.max.y = c->w[i+1]->r.min.y - Border;
|
||||||
winresize(w, r, FALSE, TRUE);
|
winresize(w, r, FALSE, TRUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +348,7 @@ colgrow(Column *c, Window *w, int but)
|
||||||
}
|
}
|
||||||
nnl = min(onl + max(min(5, w->taglines-1+w->maxlines), onl/2), tot);
|
nnl = min(onl + max(min(5, w->taglines-1+w->maxlines), onl/2), tot);
|
||||||
if(nnl < w->taglines-1+w->maxlines)
|
if(nnl < w->taglines-1+w->maxlines)
|
||||||
nnl = (w->taglines-1+w->maxlines+nnl)/2;
|
nnl = (w->taglines-1+w->maxlines + nnl)/2;
|
||||||
if(nnl == 0)
|
if(nnl == 0)
|
||||||
nnl = 2;
|
nnl = 2;
|
||||||
dnl = nnl - onl;
|
dnl = nnl - onl;
|
||||||
|
|
@ -400,7 +406,7 @@ colgrow(Column *c, Window *w, int but)
|
||||||
if(Dy(r) < Dy(w->tagtop)+1+h+Border)
|
if(Dy(r) < Dy(w->tagtop)+1+h+Border)
|
||||||
r.max.y = r.min.y + Dy(w->tagtop)+1+h+Border;
|
r.max.y = r.min.y + Dy(w->tagtop)+1+h+Border;
|
||||||
/* draw window */
|
/* draw window */
|
||||||
winresize(w, r, c->safe, TRUE);
|
r.max.y = winresize(w, r, c->safe, i==c->nw-1);
|
||||||
if(i < c->nw-1){
|
if(i < c->nw-1){
|
||||||
r.min.y = r.max.y;
|
r.min.y = r.max.y;
|
||||||
r.max.y += Border;
|
r.max.y += Border;
|
||||||
|
|
@ -417,7 +423,7 @@ colgrow(Column *c, Window *w, int but)
|
||||||
r.max.y = y1+Dy(v->tagtop);
|
r.max.y = y1+Dy(v->tagtop);
|
||||||
if(nl[j])
|
if(nl[j])
|
||||||
r.max.y += 1 + nl[j]*v->body.fr.font->height;
|
r.max.y += 1 + nl[j]*v->body.fr.font->height;
|
||||||
y1 = winresize(v, r, c->safe, j+1==c->nw);
|
y1 = winresize(v, r, c->safe, j==c->nw-1);
|
||||||
if(j < c->nw-1){ /* no border on last window */
|
if(j < c->nw-1){ /* no border on last window */
|
||||||
r.min.y = y1;
|
r.min.y = y1;
|
||||||
r.max.y += Border;
|
r.max.y += Border;
|
||||||
|
|
@ -425,12 +431,6 @@ colgrow(Column *c, Window *w, int but)
|
||||||
y1 = r.max.y;
|
y1 = r.max.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
r = w->r;
|
|
||||||
r.min.y = y1;
|
|
||||||
r.max.y = c->r.max.y;
|
|
||||||
draw(screen, r, textcols[BACK], nil, ZP);
|
|
||||||
*/
|
|
||||||
free(nl);
|
free(nl);
|
||||||
free(ny);
|
free(ny);
|
||||||
c->safe = TRUE;
|
c->safe = TRUE;
|
||||||
|
|
@ -465,9 +465,8 @@ coldragwin(Column *c, Window *w, int but)
|
||||||
error("can't find window");
|
error("can't find window");
|
||||||
|
|
||||||
Found:
|
Found:
|
||||||
/* TAG - force recompute tag size (if in auto-expand mode) on mouse op. */
|
if(w->tagexpand) /* force recomputation of window tag size */
|
||||||
w->taglines = 1;
|
w->taglines = 1;
|
||||||
/* END TAG */
|
|
||||||
p = mouse->xy;
|
p = mouse->xy;
|
||||||
if(abs(p.x-op.x)<5 && abs(p.y-op.y)<5){
|
if(abs(p.x-op.x)<5 && abs(p.y-op.y)<5){
|
||||||
colgrow(c, w, but);
|
colgrow(c, w, but);
|
||||||
|
|
|
||||||
|
|
@ -33,3 +33,19 @@ HFILES=dat.h\
|
||||||
<$PLAN9/src/mkdirs
|
<$PLAN9/src/mkdirs
|
||||||
|
|
||||||
edit.$O ecmd.$O elog.$O: edit.h
|
edit.$O ecmd.$O elog.$O: edit.h
|
||||||
|
|
||||||
|
likeplan9:V:
|
||||||
|
mkdir -p likeplan9
|
||||||
|
rm -f likeplan9/*
|
||||||
|
for i in *.c
|
||||||
|
do
|
||||||
|
9 sed 's/->(fcall|lk|b|fr|ref|m|u|u1)\./->/g;
|
||||||
|
s/\.(fcall|lk|b|fr|ref|m|u|u1)([^a-zA-Z0-9_])/\2/g
|
||||||
|
s/&(([a-zA-Z0-9_]|->|\.)*)->(fcall|lk|b|fr|ref|m|u|u1)([^a-zA-Z0-9_])/\1\4/g
|
||||||
|
s/range\(([^,()]+), ([^,()]+)\)/(Range){\1, \2}/g
|
||||||
|
' $i >likeplan9/$i
|
||||||
|
done
|
||||||
|
|
||||||
|
diffplan9:V:
|
||||||
|
mk likeplan9
|
||||||
|
9 diff -n plan9 likeplan9 | sed 's;likeplan9/;;'
|
||||||
|
|
|
||||||
|
|
@ -217,8 +217,8 @@ rowclose(Row *row, Column *c, int dofree)
|
||||||
r = c->r;
|
r = c->r;
|
||||||
if(dofree)
|
if(dofree)
|
||||||
colcloseall(c);
|
colcloseall(c);
|
||||||
memmove(row->col+i, row->col+i+1, (row->ncol-i)*sizeof(Column*));
|
|
||||||
row->ncol--;
|
row->ncol--;
|
||||||
|
memmove(row->col+i, row->col+i+1, (row->ncol-i)*sizeof(Column*));
|
||||||
row->col = realloc(row->col, row->ncol*sizeof(Column*));
|
row->col = realloc(row->col, row->ncol*sizeof(Column*));
|
||||||
if(row->ncol == 0){
|
if(row->ncol == 0){
|
||||||
draw(screen, r, display->white, nil, ZP);
|
draw(screen, r, display->white, nil, ZP);
|
||||||
|
|
@ -282,17 +282,13 @@ rowtype(Row *row, Rune r, Point p)
|
||||||
else{
|
else{
|
||||||
winlock(w, 'K');
|
winlock(w, 'K');
|
||||||
wintype(w, t, r);
|
wintype(w, t, r);
|
||||||
/*
|
/* Expand tag if necessary */
|
||||||
* TAG If we typed in the tag, might need to make it
|
|
||||||
* bigger to show text. \n causes tag to expand.
|
|
||||||
*/
|
|
||||||
if(t->what == Tag){
|
if(t->what == Tag){
|
||||||
t->w->tagsafe = FALSE;
|
t->w->tagsafe = FALSE;
|
||||||
if(r == '\n')
|
if(r == '\n')
|
||||||
t->w->tagexpand = TRUE;
|
t->w->tagexpand = TRUE;
|
||||||
winresize(w, w->r, TRUE, TRUE);
|
winresize(w, w->r, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
/* END TAG */
|
|
||||||
winunlock(w);
|
winunlock(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -319,7 +315,7 @@ rowdump(Row *row, char *file)
|
||||||
uint q0, q1;
|
uint q0, q1;
|
||||||
Biobuf *b;
|
Biobuf *b;
|
||||||
char *buf, *a, *fontname;
|
char *buf, *a, *fontname;
|
||||||
Rune *r, *rp;
|
Rune *r;
|
||||||
Column *c;
|
Column *c;
|
||||||
Window *w, *w1;
|
Window *w, *w1;
|
||||||
Text *t;
|
Text *t;
|
||||||
|
|
@ -417,17 +413,10 @@ rowdump(Row *row, char *file)
|
||||||
Bwrite(b, buf, strlen(buf));
|
Bwrite(b, buf, strlen(buf));
|
||||||
m = min(RBUFSIZE, w->tag.file->b.nc);
|
m = min(RBUFSIZE, w->tag.file->b.nc);
|
||||||
bufread(&w->tag.file->b, 0, r, m);
|
bufread(&w->tag.file->b, 0, r, m);
|
||||||
if(dodollarsigns && r[0] == '$'){
|
|
||||||
rp = runestrdup(r);
|
|
||||||
expandenv(&rp, (uint*)&m);
|
|
||||||
}else
|
|
||||||
rp = r;
|
|
||||||
n = 0;
|
n = 0;
|
||||||
while(n<m && rp[n]!='\n')
|
while(n<m && r[n]!='\n')
|
||||||
n++;
|
n++;
|
||||||
Bprint(b, "%.*S\n", n, rp);
|
Bprint(b, "%.*S\n", n, r);
|
||||||
if(rp != r)
|
|
||||||
free(rp);
|
|
||||||
if(dumped){
|
if(dumped){
|
||||||
q0 = 0;
|
q0 = 0;
|
||||||
q1 = t->file->b.nc;
|
q1 = t->file->b.nc;
|
||||||
|
|
@ -705,6 +694,7 @@ rowload(Row *row, char *file, int initing)
|
||||||
Bterm(bout);
|
Bterm(bout);
|
||||||
free(bout);
|
free(bout);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
remove(buf);
|
||||||
goto Rescue2;
|
goto Rescue2;
|
||||||
}
|
}
|
||||||
Bputrune(bout, rune);
|
Bputrune(bout, rune);
|
||||||
|
|
@ -731,7 +721,6 @@ rowload(Row *row, char *file, int initing)
|
||||||
w->maxlines = min(w->body.fr.nlines, max(w->maxlines, w->body.fr.maxlines));
|
w->maxlines = min(w->body.fr.nlines, max(w->maxlines, w->body.fr.maxlines));
|
||||||
}
|
}
|
||||||
Bterm(b);
|
Bterm(b);
|
||||||
|
|
||||||
fbuffree(buf);
|
fbuffree(buf);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ textresize(Text *t, Rectangle r, int keepextra)
|
||||||
|
|
||||||
if(Dy(r) <= 0)
|
if(Dy(r) <= 0)
|
||||||
r.max.y = r.min.y;
|
r.max.y = r.min.y;
|
||||||
if(!keepextra)
|
else if(!keepextra)
|
||||||
r.max.y -= Dy(r)%t->fr.font->height;
|
r.max.y -= Dy(r)%t->fr.font->height;
|
||||||
odx = Dx(t->all);
|
odx = Dx(t->all);
|
||||||
t->all = r;
|
t->all = r;
|
||||||
|
|
@ -84,8 +84,9 @@ textresize(Text *t, Rectangle r, int keepextra)
|
||||||
t->lastsr = nullrect;
|
t->lastsr = nullrect;
|
||||||
r.min.x += Scrollwid+Scrollgap;
|
r.min.x += Scrollwid+Scrollgap;
|
||||||
frclear(&t->fr, 0);
|
frclear(&t->fr, 0);
|
||||||
textredraw(t, r, t->fr.font, screen, odx);
|
textredraw(t, r, t->fr.font, t->fr.b, odx);
|
||||||
if(keepextra && t->fr.r.max.y < t->all.max.y){
|
if(keepextra && t->fr.r.max.y < t->all.max.y){
|
||||||
|
/* draw background in bottom fringe of window */
|
||||||
r.min.x -= Scrollgap;
|
r.min.x -= Scrollgap;
|
||||||
r.min.y = t->fr.r.max.y;
|
r.min.y = t->fr.r.max.y;
|
||||||
r.max.y = t->all.max.y;
|
r.max.y = t->all.max.y;
|
||||||
|
|
@ -197,7 +198,7 @@ textload(Text *t, uint q0, char *file, int setqid)
|
||||||
char *tmp;
|
char *tmp;
|
||||||
Text *u;
|
Text *u;
|
||||||
|
|
||||||
if(t->ncache!=0 || t->file->b.nc || t->w==nil || t!=&t->w->body || (t->w->isdir && t->file->nname==0))
|
if(t->ncache!=0 || t->file->b.nc || t->w==nil || t!=&t->w->body)
|
||||||
error("text.load");
|
error("text.load");
|
||||||
if(t->w->isdir && t->file->nname==0){
|
if(t->w->isdir && t->file->nname==0){
|
||||||
warning(nil, "empty directory name");
|
warning(nil, "empty directory name");
|
||||||
|
|
@ -653,20 +654,13 @@ texttype(Text *t, Rune r)
|
||||||
uint q0, q1;
|
uint q0, q1;
|
||||||
int nnb, nb, n, i;
|
int nnb, nb, n, i;
|
||||||
int nr;
|
int nr;
|
||||||
Point p;
|
|
||||||
Rune *rp;
|
Rune *rp;
|
||||||
Text *u;
|
Text *u;
|
||||||
|
|
||||||
/*
|
|
||||||
* TAG
|
|
||||||
* Used to disallow \n in tag here.
|
|
||||||
* Also if typing in tag, mark that resize might be necessary.
|
|
||||||
*/
|
|
||||||
if(t->what!=Body && t->what!=Tag && r=='\n')
|
if(t->what!=Body && t->what!=Tag && r=='\n')
|
||||||
return;
|
return;
|
||||||
if(t->what == Tag)
|
if(t->what == Tag)
|
||||||
t->w->tagsafe = FALSE;
|
t->w->tagsafe = FALSE;
|
||||||
/* END TAG */
|
|
||||||
|
|
||||||
nr = 1;
|
nr = 1;
|
||||||
rp = &r;
|
rp = &r;
|
||||||
|
|
@ -684,17 +678,13 @@ texttype(Text *t, Rune r)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case Kdown:
|
case Kdown:
|
||||||
/* TAG */
|
|
||||||
if(t->what == Tag)
|
if(t->what == Tag)
|
||||||
goto Tagdown;
|
goto Tagdown;
|
||||||
/* END TAG */
|
|
||||||
n = t->fr.maxlines/3;
|
n = t->fr.maxlines/3;
|
||||||
goto case_Down;
|
goto case_Down;
|
||||||
case Kscrollonedown:
|
case Kscrollonedown:
|
||||||
/* TAG */
|
|
||||||
if(t->what == Tag)
|
if(t->what == Tag)
|
||||||
goto Tagdown;
|
goto Tagdown;
|
||||||
/* END TAG */
|
|
||||||
n = mousescrollsize(t->fr.maxlines);
|
n = mousescrollsize(t->fr.maxlines);
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
@ -706,17 +696,13 @@ texttype(Text *t, Rune r)
|
||||||
textsetorigin(t, q0, TRUE);
|
textsetorigin(t, q0, TRUE);
|
||||||
return;
|
return;
|
||||||
case Kup:
|
case Kup:
|
||||||
/* TAG */
|
|
||||||
if(t->what == Tag)
|
if(t->what == Tag)
|
||||||
goto Tagup;
|
goto Tagup;
|
||||||
/* END TAG */
|
|
||||||
n = t->fr.maxlines/3;
|
n = t->fr.maxlines/3;
|
||||||
goto case_Up;
|
goto case_Up;
|
||||||
case Kscrolloneup:
|
case Kscrolloneup:
|
||||||
/* TAG */
|
|
||||||
if(t->what == Tag)
|
if(t->what == Tag)
|
||||||
goto Tagup;
|
goto Tagup;
|
||||||
/* END TAG */
|
|
||||||
n = mousescrollsize(t->fr.maxlines);
|
n = mousescrollsize(t->fr.maxlines);
|
||||||
goto case_Up;
|
goto case_Up;
|
||||||
case Kpgup:
|
case Kpgup:
|
||||||
|
|
@ -748,7 +734,6 @@ texttype(Text *t, Rune r)
|
||||||
q0++;
|
q0++;
|
||||||
textshow(t, q0, q0, TRUE);
|
textshow(t, q0, q0, TRUE);
|
||||||
return;
|
return;
|
||||||
/* TAG policy here */
|
|
||||||
Tagdown:
|
Tagdown:
|
||||||
/* expand tag to show all text */
|
/* expand tag to show all text */
|
||||||
if(!t->w->tagexpand){
|
if(!t->w->tagexpand){
|
||||||
|
|
@ -762,17 +747,9 @@ texttype(Text *t, Rune r)
|
||||||
if(t->w->tagexpand){
|
if(t->w->tagexpand){
|
||||||
t->w->tagexpand = FALSE;
|
t->w->tagexpand = FALSE;
|
||||||
t->w->taglines = 1;
|
t->w->taglines = 1;
|
||||||
/* move mouse to stay in tag */
|
|
||||||
p = mouse->xy;
|
|
||||||
if(ptinrect(p, t->w->tag.all)
|
|
||||||
&& !ptinrect(p, t->w->tagtop)){
|
|
||||||
p.y = t->w->tagtop.min.y + Dy(t->w->tagtop)/2;
|
|
||||||
moveto(mousectl, p);
|
|
||||||
}
|
|
||||||
winresize(t->w, t->w->r, FALSE, TRUE);
|
winresize(t->w, t->w->r, FALSE, TRUE);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
/* END TAG */
|
|
||||||
}
|
}
|
||||||
if(t->what == Body){
|
if(t->what == Body){
|
||||||
seq++;
|
seq++;
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
|
|
||||||
w->tagtop = r;
|
w->tagtop = r;
|
||||||
w->tagtop.max.y = r.min.y + font->height;
|
w->tagtop.max.y = r.min.y + font->height;
|
||||||
|
|
||||||
r1.max.y = r1.min.y + w->taglines*font->height;
|
r1.max.y = r1.min.y + w->taglines*font->height;
|
||||||
|
|
||||||
incref(&reffont.ref);
|
incref(&reffont.ref);
|
||||||
f = fileaddtext(nil, &w->tag);
|
f = fileaddtext(nil, &w->tag);
|
||||||
textinit(&w->tag, f, r1, &reffont, tagcols);
|
textinit(&w->tag, f, r1, &reffont, tagcols);
|
||||||
|
|
@ -53,7 +53,6 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
filereset(w->tag.file);
|
filereset(w->tag.file);
|
||||||
textsetselect(&w->tag, nc, nc);
|
textsetselect(&w->tag, nc, nc);
|
||||||
}
|
}
|
||||||
/*assert(w->body.w == w); */
|
|
||||||
r1 = r;
|
r1 = r;
|
||||||
r1.min.y += w->taglines*font->height + 1;
|
r1.min.y += w->taglines*font->height + 1;
|
||||||
if(r1.max.y < r1.min.y)
|
if(r1.max.y < r1.min.y)
|
||||||
|
|
@ -66,7 +65,6 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
rf = rfget(FALSE, FALSE, FALSE, clone->body.reffont->f->name);
|
rf = rfget(FALSE, FALSE, FALSE, clone->body.reffont->f->name);
|
||||||
}else
|
}else
|
||||||
rf = rfget(FALSE, FALSE, FALSE, nil);
|
rf = rfget(FALSE, FALSE, FALSE, nil);
|
||||||
/*assert(w->body.w == w); */
|
|
||||||
f = fileaddtext(f, &w->body);
|
f = fileaddtext(f, &w->body);
|
||||||
w->body.what = Body;
|
w->body.what = Body;
|
||||||
textinit(&w->body, f, r1, rf, textcols);
|
textinit(&w->body, f, r1, rf, textcols);
|
||||||
|
|
@ -82,7 +80,6 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
w->filemenu = TRUE;
|
w->filemenu = TRUE;
|
||||||
w->maxlines = w->body.fr.maxlines;
|
w->maxlines = w->body.fr.maxlines;
|
||||||
w->autoindent = globalautoindent;
|
w->autoindent = globalautoindent;
|
||||||
/*assert(w->body.w == w); */
|
|
||||||
if(clone){
|
if(clone){
|
||||||
w->dirty = clone->dirty;
|
w->dirty = clone->dirty;
|
||||||
w->autoindent = clone->autoindent;
|
w->autoindent = clone->autoindent;
|
||||||
|
|
@ -119,8 +116,6 @@ wintaglines(Window *w, Rectangle r)
|
||||||
int n;
|
int n;
|
||||||
Rune rune;
|
Rune rune;
|
||||||
|
|
||||||
/* TAG policy here */
|
|
||||||
|
|
||||||
if(!w->tagexpand)
|
if(!w->tagexpand)
|
||||||
return 1;
|
return 1;
|
||||||
w->tag.fr.noredraw = 1;
|
w->tag.fr.noredraw = 1;
|
||||||
|
|
@ -151,57 +146,50 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
|
||||||
Point p;
|
Point p;
|
||||||
Rectangle r1;
|
Rectangle r1;
|
||||||
|
|
||||||
if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\n", w->id, r, safe, keepextra, font->height);
|
/* tagtop is first line of tag */
|
||||||
w->tagtop = r;
|
w->tagtop = r;
|
||||||
w->tagtop.max.y = r.min.y+font->height;
|
w->tagtop.max.y = r.min.y+font->height;
|
||||||
|
|
||||||
/*
|
|
||||||
* TAG If necessary, recompute the number of lines that should
|
|
||||||
* be in the tag.
|
|
||||||
*/
|
|
||||||
r1 = r;
|
r1 = r;
|
||||||
r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
|
r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
|
||||||
y = r1.max.y;
|
|
||||||
mouseintag = ptinrect(mouse->xy, w->tag.all);
|
mouseintag = ptinrect(mouse->xy, w->tag.all);
|
||||||
if(!safe || !w->tagsafe || !eqrect(w->tag.all, r1))
|
|
||||||
w->taglines = wintaglines(w, r);
|
|
||||||
/* END TAG */
|
|
||||||
|
|
||||||
r1 = r;
|
/* If needed, recompute number of lines in tag. */
|
||||||
r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
|
if(!safe || !w->tagsafe || !eqrect(w->tag.all, r1)){
|
||||||
|
w->taglines = wintaglines(w, r);
|
||||||
|
r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If needed, resize & redraw tag. */
|
||||||
y = r1.max.y;
|
y = r1.max.y;
|
||||||
tagresized = 0;
|
tagresized = 0;
|
||||||
if(0) fprint(2, "winresize tag %R %R\n", w->tag.all, r1);
|
|
||||||
if(!safe || !w->tagsafe || !eqrect(w->tag.all, r1)){
|
if(!safe || !w->tagsafe || !eqrect(w->tag.all, r1)){
|
||||||
tagresized = 1;
|
tagresized = 1;
|
||||||
if(0) fprint(2, "resize tag %R => %R\n", w->tag.all, r1);
|
|
||||||
textresize(&w->tag, r1, TRUE);
|
textresize(&w->tag, r1, TRUE);
|
||||||
if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr.r);
|
|
||||||
y = w->tag.fr.r.max.y;
|
y = w->tag.fr.r.max.y;
|
||||||
windrawbutton(w);
|
windrawbutton(w);
|
||||||
w->tagsafe = TRUE;
|
w->tagsafe = TRUE;
|
||||||
/* TAG */
|
|
||||||
/* If mouse is in tag, pull up as tag closes. */
|
/* If mouse is in tag, pull up as tag closes. */
|
||||||
if(mouseintag && !ptinrect(mouse->xy, w->tag.all)){
|
if(mouseintag && !ptinrect(mouse->xy, w->tag.all)){
|
||||||
p = mouse->xy;
|
p = mouse->xy;
|
||||||
p.y = w->tag.all.max.y-3;
|
p.y = w->tag.all.max.y-3;
|
||||||
moveto(mousectl, p);
|
moveto(mousectl, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If mouse is in body, push down as tag expands. */
|
/* If mouse is in body, push down as tag expands. */
|
||||||
if(!mouseintag && ptinrect(mouse->xy, w->tag.all)){
|
if(!mouseintag && ptinrect(mouse->xy, w->tag.all)){
|
||||||
p = mouse->xy;
|
p = mouse->xy;
|
||||||
p.y = w->tag.all.max.y+3;
|
p.y = w->tag.all.max.y+3;
|
||||||
moveto(mousectl, p);
|
moveto(mousectl, p);
|
||||||
}
|
}
|
||||||
/* END TAG */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* If needed, resize & redraw body. */
|
||||||
r1 = r;
|
r1 = r;
|
||||||
r1.min.y = y;
|
r1.min.y = y;
|
||||||
if(tagresized || !safe || !eqrect(w->body.all, r1)){
|
if(tagresized || !safe || !eqrect(w->body.all, r1)){
|
||||||
oy = y;
|
oy = y;
|
||||||
if(0) fprint(2, "resizing body; safe=%d all=%R r1=%R\n", safe, w->body.all, r1);
|
|
||||||
if(y+1+w->body.fr.font->height <= r.max.y){ /* room for one line */
|
if(y+1+w->body.fr.font->height <= r.max.y){ /* room for one line */
|
||||||
r1.min.y = y;
|
r1.min.y = y;
|
||||||
r1.max.y = y+1;
|
r1.max.y = y+1;
|
||||||
|
|
@ -213,10 +201,9 @@ if(0) fprint(2, "resizing body; safe=%d all=%R r1=%R\n", safe, w->body.all, r1);
|
||||||
r1.min.y = y;
|
r1.min.y = y;
|
||||||
r1.max.y = y;
|
r1.max.y = y;
|
||||||
}
|
}
|
||||||
if(0) fprint(2, "resizing body; new r=%R; r1=%R\n", r, r1);
|
y = textresize(&w->body, r1, keepextra);
|
||||||
w->r = r;
|
w->r = r;
|
||||||
w->r.max.y = textresize(&w->body, r1, keepextra);
|
w->r.max.y = y;
|
||||||
if(0) fprint(2, "after textresize: body.all=%R\n", w->body.all);
|
|
||||||
textscrdraw(&w->body);
|
textscrdraw(&w->body);
|
||||||
w->body.all.min.y = oy;
|
w->body.all.min.y = oy;
|
||||||
}
|
}
|
||||||
|
|
@ -354,6 +341,7 @@ winsetname(Window *w, Rune *name, int n)
|
||||||
int i;
|
int i;
|
||||||
static Rune Lslashguide[] = { '/', 'g', 'u', 'i', 'd', 'e', 0 };
|
static Rune Lslashguide[] = { '/', 'g', 'u', 'i', 'd', 'e', 0 };
|
||||||
static Rune Lpluserrors[] = { '+', 'E', 'r', 'r', 'o', 'r', 's', 0 };
|
static Rune Lpluserrors[] = { '+', 'E', 'r', 'r', 'o', 'r', 's', 0 };
|
||||||
|
|
||||||
t = &w->body;
|
t = &w->body;
|
||||||
if(runeeq(t->file->name, t->file->nname, name, n) == TRUE)
|
if(runeeq(t->file->name, t->file->nname, name, n) == TRUE)
|
||||||
return;
|
return;
|
||||||
|
|
@ -559,7 +547,6 @@ wincommit(Window *w, Text *t)
|
||||||
for(i=0; i<w->tag.file->b.nc; i++)
|
for(i=0; i<w->tag.file->b.nc; i++)
|
||||||
if(r[i]==' ' || r[i]=='\t')
|
if(r[i]==' ' || r[i]=='\t')
|
||||||
break;
|
break;
|
||||||
expandenv(&r, (uint*)&i);
|
|
||||||
if(runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE){
|
if(runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE){
|
||||||
seq++;
|
seq++;
|
||||||
filemark(w->body.file);
|
filemark(w->body.file);
|
||||||
|
|
@ -678,4 +665,3 @@ winevent(Window *w, char *fmt, ...)
|
||||||
sendp(x->c, nil);
|
sendp(x->c, nil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue