URI: 
       tacme: multiline tag fixes - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 41636940514d72e2a941f55f28dc07685e74b3b4
   DIR parent a2db69c8bda889f30ea38dae5473689cde108458
  HTML Author: Russ Cox <rsc@swtch.com>
       Date:   Fri,  7 Mar 2008 12:51:41 -0500
       
       acme: multiline tag fixes
       
       Diffstat:
         M src/cmd/acme/cols.c                 |      46 +++++++++++++++++++++----------
         M src/cmd/acme/wind.c                 |       8 +++++---
       
       2 files changed, 37 insertions(+), 17 deletions(-)
       ---
   DIR diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
       t@@ -53,7 +53,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
        {
                Rectangle r, r1;
                Window *v;
       -        int i, j, minht, ymax;
       +        int i, j, minht, ymax, buggered;
        
                v = nil;
                r = c->r;
       t@@ -68,6 +68,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
                        if(y < v->r.max.y)
                                break;
                }
       +        buggered = 0;
                if(c->nw > 0){
                        if(i < c->nw)
                                i++;        /* new window will go after v */
       t@@ -78,7 +79,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
                        j = 0;
                        while(!c->safe || v->body.fr.maxlines<=3 || Dy(v->body.all) <= minht){
                                if(++j > 10){
       -                                fprint(2, "coladd: bug dy=%d\n", Dy(v->body.all));
       +                                buggered = 1;        /* too many windows in column */
                                        break;
                                }
                                colgrow(c, v, 1);
       t@@ -87,20 +88,28 @@ coladd(Column *c, Window *w, Window *clone, int y)
                        /*
                         * figure out where to split v to make room for w
                         */
       -                if(i == c->nw)
       -                        ymax = c->r.max.y;
       -                else
       +                
       +                /* new window stops where next window begins */
       +                if(i < c->nw)
                                ymax = c->w[i]->r.min.y-Border;
       -                y = min(y, v->body.all.min.y+Dy(v->body.all)/2);
       +                else
       +                        ymax = c->r.max.y;
       +                
       +                /* new window must start after v's tag ends */
       +                y = max(y, v->tagtop.max.y+Border);
       +                
       +                /* new window must start early enough to end before ymax */
                        y = min(y, ymax - minht);
       -                y = max(y, v->body.all.min.y);
       -                ymax = max(ymax, y+minht);
       -                r = v->r;
       -                r.max.y = ymax;
       +                
       +                /* if y is too small, too many windows in column */
       +                if(y < v->tagtop.max.y+Border)
       +                        buggered = 1;
        
                        /*
       -                 * redraw w
       +                 * resize & redraw v
                         */
       +                r = v->r;
       +                r.max.y = ymax;
                        draw(screen, r, textcols[BACK], nil, ZP);
                        r1 = r;
                        y = min(y, ymax-(v->tag.fr.font->height*v->taglines+v->body.fr.font->height+Border+1));
       t@@ -108,6 +117,10 @@ coladd(Column *c, Window *w, Window *clone, int y)
                        r1.min.y = winresize(v, r1, FALSE, FALSE);
                        r1.max.y = r1.min.y+Border;
                        draw(screen, r1, display->black, nil, ZP);
       +                
       +                /*
       +                 * leave r with w's coordinates
       +                 */
                        r.min.y = r1.max.y;
                }
                if(w == nil){
       t@@ -127,11 +140,16 @@ coladd(Column *c, Window *w, Window *clone, int y)
                memmove(c->w+i+1, c->w+i, (c->nw-i)*sizeof(Window*));
                c->nw++;
                c->w[i] = w;
       +        c->safe = TRUE;
       +        
       +        /* if there were too many windows, redraw the whole column */
       +        if(buggered)
       +                colresize(c, c->r);
       +
                savemouse(w);
       -        /* near but not on the button */
       +        /* near the button, but in the body */
                moveto(mousectl, addpt(w->tag.scrollr.max, Pt(3, 3)));
                barttext = &w->body;
       -        c->safe = TRUE;
                return w;
        }
        
       t@@ -406,7 +424,7 @@ colgrow(Column *c, Window *w, int but)
                if(Dy(r) < Dy(w->tagtop)+1+h+Border)
                        r.max.y = r.min.y + Dy(w->tagtop)+1+h+Border;
                /* draw window */
       -        r.max.y = winresize(w, r, c->safe, i==c->nw-1);
       +        r.max.y = winresize(w, r, c->safe, TRUE);
                if(i < c->nw-1){
                        r.min.y = r.max.y;
                        r.max.y += Border;
   DIR diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
       t@@ -142,17 +142,19 @@ wintaglines(Window *w, Rectangle r)
        int
        winresize(Window *w, Rectangle r, int safe, int keepextra)
        {
       -        int oy, y, mouseintag, tagresized;
       +        int oy, y, mouseintag, mouseinbody, tagresized;
                Point p;
                Rectangle r1;
        
       +        mouseintag = ptinrect(mouse->xy, w->tag.all);
       +        mouseinbody = ptinrect(mouse->xy, w->body.all);
       +
                /* tagtop is first line of tag */
                w->tagtop = r;
                w->tagtop.max.y = r.min.y+font->height;
        
                r1 = r;
                r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
       -        mouseintag = ptinrect(mouse->xy, w->tag.all);
        
                /* If needed, recompute number of lines in tag. */
                if(!safe || !w->tagsafe || !eqrect(w->tag.all, r1)){
       t@@ -178,7 +180,7 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
                        }
        
                        /* If mouse is in body, push down as tag expands. */
       -                if(!mouseintag && ptinrect(mouse->xy, w->tag.all)){
       +                if(mouseinbody && ptinrect(mouse->xy, w->tag.all)){
                                p = mouse->xy;
                                p.y = w->tag.all.max.y+3;
                                moveto(mousectl, p);