mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
Better window size management.
This commit is contained in:
parent
9881c00260
commit
20ae0b0fc2
4 changed files with 34 additions and 11 deletions
|
@ -53,7 +53,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
|
|||
{
|
||||
Rectangle r, r1;
|
||||
Window *v;
|
||||
int i, t;
|
||||
int i, j, minht, t;
|
||||
|
||||
v = nil;
|
||||
r = c->r;
|
||||
|
@ -74,15 +74,27 @@ coladd(Column *c, Window *w, Window *clone, int y)
|
|||
/*
|
||||
* if v's too small, grow it first.
|
||||
*/
|
||||
if(!c->safe || v->body.fr.maxlines<=3){
|
||||
minht = v->tag.fr.font->height+Border+1;
|
||||
j = 0;
|
||||
while(!c->safe || v->body.fr.maxlines<=3 || Dy(v->body.all) <= minht){
|
||||
if(++j > 10){
|
||||
fprint(2, "oops: dy=%d\n", Dy(v->body.all));
|
||||
break;
|
||||
}
|
||||
if(j > 1)
|
||||
fprint(2, "regrow\n");
|
||||
colgrow(c, v, 1);
|
||||
y = v->body.fr.r.min.y+Dy(v->body.fr.r)/2;
|
||||
}
|
||||
r = v->r;
|
||||
if(i == c->nw)
|
||||
t = c->r.max.y;
|
||||
else
|
||||
t = c->w[i]->r.min.y-Border;
|
||||
y = v->body.all.min.y+Dy(v->body.all)/2;
|
||||
if(t - y < minht)
|
||||
y = t - minht;
|
||||
if(y < v->body.all.min.y)
|
||||
y = v->body.all.min.y;
|
||||
r = v->r;
|
||||
r.max.y = t;
|
||||
draw(screen, r, textcols[BACK], nil, ZP);
|
||||
r1 = r;
|
||||
|
@ -209,6 +221,8 @@ colresize(Column *c, Rectangle r)
|
|||
r1.max.y = r.max.y;
|
||||
else
|
||||
r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
|
||||
if(Dy(r1) < Border+font->height)
|
||||
r1.max.y = r1.min.y + Border+font->height;
|
||||
r2 = r1;
|
||||
r2.max.y = r2.min.y+Border;
|
||||
draw(screen, r2, display->black, nil, ZP);
|
||||
|
|
|
@ -9,7 +9,7 @@ void warningew(Window*, Mntdir*, char*, ...);
|
|||
#define fbufalloc() emalloc(BUFSIZE)
|
||||
#define fbuffree(x) free(x)
|
||||
|
||||
void plumblook(Plumbmsg*m);
|
||||
void plumblook(Plumbmsg *m);
|
||||
void plumbshow(Plumbmsg*m);
|
||||
void acmeputsnarf(void);
|
||||
void acmegetsnarf(void);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
CFid *plumbsendfid;
|
||||
CFid *plumbeditfid;
|
||||
|
||||
Window* openfile(Text*, Expand*);
|
||||
Window* openfile(Text*, Expand*, int);
|
||||
|
||||
int nuntitled;
|
||||
|
||||
|
@ -167,7 +167,7 @@ look3(Text *t, uint q0, uint q1, int external)
|
|||
if(expanded == FALSE)
|
||||
return;
|
||||
if(e.name || e.u.at)
|
||||
openfile(t, &e);
|
||||
openfile(t, &e, FALSE);
|
||||
else{
|
||||
if(t->w == nil)
|
||||
return;
|
||||
|
@ -207,6 +207,7 @@ plumblook(Plumbmsg *m)
|
|||
{
|
||||
Expand e;
|
||||
char *addr;
|
||||
int newwindow;
|
||||
|
||||
if(m->ndata >= BUFSIZE){
|
||||
warning(nil, "insanely long file name (%d bytes) in plumb message (%.32s...)\n", m->ndata, m->data);
|
||||
|
@ -227,7 +228,8 @@ plumblook(Plumbmsg *m)
|
|||
e.u.ar = bytetorune(addr, &e.a1);
|
||||
e.agetc = plumbgetc;
|
||||
}
|
||||
openfile(nil, &e);
|
||||
newwindow = plumblookup(m->attr, "newwindow") != nil;
|
||||
openfile(nil, &e, newwindow);
|
||||
free(e.name);
|
||||
free(e.u.at);
|
||||
drawtopwindow();
|
||||
|
@ -688,7 +690,7 @@ lookid(int id, int dump)
|
|||
|
||||
|
||||
Window*
|
||||
openfile(Text *t, Expand *e)
|
||||
openfile(Text *t, Expand *e, int newwindow)
|
||||
{
|
||||
Range r;
|
||||
Window *w, *ow;
|
||||
|
@ -705,6 +707,8 @@ openfile(Text *t, Expand *e)
|
|||
}else
|
||||
w = lookfile(e->name, e->nname);
|
||||
if(w){
|
||||
if(newwindow==TRUE && !w->isdir)
|
||||
w = coladd(w->col, nil, w, -1);
|
||||
t = &w->body;
|
||||
if(!t->col->safe && t->fr.maxlines==0) /* window is obscured by full-column window */
|
||||
colgrow(t->col, t->col->w[0], 1);
|
||||
|
@ -785,7 +789,7 @@ new(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
|
|||
e.nname = nf;
|
||||
e.bname = runetobyte(f, nf);
|
||||
e.jump = TRUE;
|
||||
openfile(et, &e);
|
||||
openfile(et, &e, FALSE);
|
||||
free(f);
|
||||
free(e.bname);
|
||||
arg = skipbl(a, na, &narg);
|
||||
|
|
|
@ -121,6 +121,7 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
|
|||
Image *b;
|
||||
Rectangle br, r1;
|
||||
|
||||
if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\n", w->id, r, safe, keepextra, font->height);
|
||||
w->tagtop = r;
|
||||
w->tagtop.max.y = r.min.y+font->height;
|
||||
|
||||
|
@ -128,7 +129,9 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
|
|||
r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
|
||||
y = r1.max.y;
|
||||
if(1 || !safe || !eqrect(w->tag.all, r1)){
|
||||
if(0) fprint(2, "resize tag %R => %R", w->tag.all, r1);
|
||||
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;
|
||||
b = button;
|
||||
if(w->body.file->mod && !w->isdir && !w->isscratch)
|
||||
|
@ -141,7 +144,7 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
|
|||
|
||||
r1 = r;
|
||||
r1.min.y = y;
|
||||
if(!safe || !eqrect(w->body.all, r1)){
|
||||
if(1 || !safe || !eqrect(w->body.all, r1)){
|
||||
if(y+1+w->body.fr.font->height <= r.max.y){ /* room for one line */
|
||||
r1.min.y = y;
|
||||
r1.max.y = y+1;
|
||||
|
@ -153,8 +156,10 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
|
|||
r1.min.y = y;
|
||||
r1.max.y = y;
|
||||
}
|
||||
if(0) fprint(2, "resize body %R => %R", w->body.all, r1);
|
||||
w->r = r;
|
||||
w->r.max.y = textresize(&w->body, r1, keepextra);
|
||||
if(0) fprint(2, " => %R (%R; %R)\n", w->body.all, w->body.fr.r, w->r);
|
||||
textscrdraw(&w->body);
|
||||
}
|
||||
w->maxlines = min(w->body.fr.nlines, max(w->maxlines, w->body.fr.maxlines));
|
||||
|
|
Loading…
Reference in a new issue