commit cd1d0ab0b5ed07c03b066731328e9519cba5914c from: rsc date: Thu Jan 12 05:43:26 2006 UTC more tweaks commit - 77c5c852e499362b4fdf7a636e541bab6d496130 commit + cd1d0ab0b5ed07c03b066731328e9519cba5914c blob - 6df7374f52676ecca623c4a31d399df6ea6a7f1a blob + 9c3156e7c221572230764ca46bed64cd20c604ac --- src/cmd/acme/acme.c +++ src/cmd/acme/acme.c @@ -287,6 +287,7 @@ readfile(Column *c, char *s) w->body.file->mod = FALSE; w->dirty = FALSE; winsettag(w); + winresize(w, w->r, FALSE, TRUE); textscrdraw(&w->body); textsetselect(&w->tag, w->tag.file->b.nc, w->tag.file->b.nc); } blob - 8ac265c9fbdc71cd4db94265835b5c8e20229259 blob + d44388849d2281ab5a05cb220267f696279d9f77 --- src/cmd/acme/dat.h +++ src/cmd/acme/dat.h @@ -192,6 +192,7 @@ struct Text int ncachealloc; Rune *cache; int nofill; + int needundo; }; uint textbacknl(Text*, uint, uint); blob - adde0dd7f9de3b6b12ec92bbb02c7d6ce1bcf469 blob + 0e089105cd640a21bd48f3412762d7e8bbf9600c --- src/cmd/acme/text.c +++ src/cmd/acme/text.c @@ -859,6 +859,16 @@ texttype(Text *t, Rune r) u->cq0 = t->q0; else if(t->q0 != u->cq0+u->ncache) error("text.type cq1"); + /* + * Change the tag before we add to ncache, + * so that if the window body is resized the + * commit will not find anything in ncache. + */ + if(u->what==Body && u->ncache == 0){ + u->needundo = TRUE; + winsettag(t->w); + u->needundo = FALSE; + } textinsert(u, t->q0, rp, nr, FALSE); if(u != t) textsetselect(u, u->q0, u->q1); blob - 762fb9d04bac9500d1c08732c1c82d50a14b4d92 blob + 2b0369dd2b85e4c18a1b2594b57ebcdbe3cd5a2e --- src/cmd/acme/wind.c +++ src/cmd/acme/wind.c @@ -124,7 +124,7 @@ wintaglines(Window *w, Rectangle r) int winresize(Window *w, Rectangle r, int safe, int keepextra) { - int y, mouseintag; + int oy, y, mouseintag, tagresized; Image *b; Point p; Rectangle br, r1; @@ -141,7 +141,7 @@ if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\ 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); - if(1 || !safe || !w->tagsafe || !eqrect(w->tag.all, r1)){ + if(!safe || !w->tagsafe || !eqrect(w->tag.all, r1)){ w->taglines = wintaglines(w, r); w->tagsafe = TRUE; @@ -151,8 +151,10 @@ if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\ r1 = r; r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height); y = r1.max.y; + tagresized = 0; if(1 || !safe || !eqrect(w->tag.all, r1)){ -if(0) fprint(2, "resize tag %R => %R", w->tag.all, r1); + tagresized = 1; +if(0) fprint(2, "resize tag %R => %R\n", 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; @@ -175,7 +177,9 @@ if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr. r1 = r; r1.min.y = y; - if(1 || !safe || !eqrect(w->body.all, r1)){ + if(tagresized || !safe || !eqrect(w->body.all, r1)){ + 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 */ r1.min.y = y; r1.max.y = y+1; @@ -187,11 +191,12 @@ if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr. r1.min.y = y; r1.max.y = y; } -if(0) fprint(2, "resize body %R => %R", w->body.all, r1); +if(0) fprint(2, "resizing body; new r=%R; r1=%R\n", r, 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); +if(0) fprint(2, "after textresize: body.all=%R\n", w->body.all); textscrdraw(&w->body); + w->body.all.min.y = oy; } w->maxlines = min(w->body.fr.nlines, max(w->maxlines, w->body.fr.maxlines)); return w->r.max.y; @@ -446,7 +451,7 @@ winsettag1(Window *w) runemove(new+i, Ldelsnarf, 10); i += 10; if(w->filemenu){ - if(w->body.file->delta.nc>0 || w->body.ncache){ + if(w->body.needundo || w->body.file->delta.nc>0 || w->body.ncache){ runemove(new+i, Lundo, 5); i += 5; } @@ -523,8 +528,10 @@ winsettag1(Window *w) br.max.x = br.min.x + Dx(b->r); br.max.y = br.min.y + Dy(b->r); draw(screen, br, b, nil, b->r.min); - if(resize) + if(resize){ + w->tagsafe = 0; winresize(w, w->r, TRUE, TRUE); + } } void