tadd bigtags - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f8dea3c178590517e6f8833a2953c10c31ddbffc
 (DIR) parent 20ae0b0fc25448245b75e0bd7b30b2fd29525165
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 16 Dec 2005 15:14:14 +0000
       
       add bigtags
       
       Diffstat:
         M src/cmd/acme/acme.c                 |       6 +++++-
         M src/cmd/acme/cols.c                 |       3 +++
         M src/cmd/acme/rows.c                 |      11 +++++++++++
         M src/cmd/acme/text.c                 |      53 ++++++++++++++++++++++++++++++-
         M src/cmd/acme/wind.c                 |      25 +++++++++++++++++++++++++
       
       5 files changed, 96 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
       t@@ -591,7 +591,11 @@ mousethread(void *v)
                                        goto Continue;
                                }
                                /* scroll buttons, wheels, etc. */
       -                        if(t->what==Body && w != nil && (m.buttons & (8|16))){
       +/*
       + * TAG used to require t->what==Body but now allow
       + * scroll wheel in tag too.
       + */
       +                        if(w != nil && (m.buttons & (8|16))){
                                        if(m.buttons & 8)
                                                but = Kscrolloneup;
                                        else
 (DIR) diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
       t@@ -467,6 +467,9 @@ coldragwin(Column *c, Window *w, int but)
                error("can't find window");
        
          Found:
       +/* TAG - force recompute tag size (if in auto-expand mode) on mouse op. */
       +        w->taglines = 1;
       +/* END TAG */
                p = mouse->xy;
                if(abs(p.x-op.x)<5 && abs(p.y-op.y)<5){
                        colgrow(c, w, but);
 (DIR) diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
       t@@ -282,6 +282,17 @@ rowtype(Row *row, Rune r, Point p)
                        else{
                                winlock(w, 'K');
                                wintype(w, t, r);
       +/*
       + * 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){
       +                                t->w->tagsafe = FALSE;
       +                                if(r == '\n')
       +                                        t->w->tagexpand = TRUE;
       +                                winresize(w, w->r, TRUE, TRUE);
       +                        }
       +/* END TAG */
                                winunlock(w);
                        }
                }
 (DIR) diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
       t@@ -646,11 +646,21 @@ texttype(Text *t, Rune r)
                uint q0, q1;
                int nnb, nb, n, i;
                int nr;
       +        Point p;
                Rune *rp;
                Text *u;
        
       -        if(t->what!=Body && r=='\n')
       +/*
       + * 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')
                        return;
       +        if(t->what == Tag)
       +                t->w->tagsafe = FALSE;
       +/* END TAG */
       +
                nr = 1;
                rp = &r;
                switch(r){
       t@@ -667,9 +677,17 @@ texttype(Text *t, Rune r)
                        }
                        return;
                case Kdown:
       +/* TAG */
       +                if(t->what == Tag)
       +                        goto Tagdown;
       +/* END TAG */
                        n = t->fr.maxlines/3;
                        goto case_Down;
                case Kscrollonedown:
       +/* TAG */
       +                if(t->what == Tag)
       +                        goto Tagdown;
       +/* END TAG */
                        n = mousescrollsize(t->fr.maxlines);
                        if(n <= 0)
                                n = 1;
       t@@ -681,9 +699,17 @@ texttype(Text *t, Rune r)
                        textsetorigin(t, q0, TRUE);
                        return;
                case Kup:
       +/* TAG */
       +                if(t->what == Tag)
       +                        goto Tagup;
       +/* END TAG */
                        n = t->fr.maxlines/3;
                        goto case_Up;
                case Kscrolloneup:
       +/* TAG */
       +                if(t->what == Tag)
       +                        goto Tagup;
       +/* END TAG */
                        n = mousescrollsize(t->fr.maxlines);
                        goto case_Up;
                case Kpgup:
       t@@ -715,6 +741,31 @@ texttype(Text *t, Rune r)
                                q0++;
                        textshow(t, q0, q0, TRUE);
                        return;
       +/* TAG policy here */
       +        Tagdown:
       +                /* expand tag to show all text */
       +                if(!t->w->tagexpand){
       +                        t->w->tagexpand = TRUE;
       +                        winresize(t->w, t->w->r, FALSE, TRUE);
       +                }
       +                return;
       +        
       +        Tagup:
       +                /* shrink tag to single line */
       +                if(t->w->tagexpand){
       +                        t->w->tagexpand = FALSE;
       +                        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);
       +                }
       +                return;
       +/* END TAG */
                }
                if(t->what == Body){
                        seq++;
 (DIR) diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
       t@@ -100,17 +100,28 @@ wintaglines(Window *w, Rectangle r)
                int n;
                Rune rune;
        
       +/* TAG policy here */
       +
                if(!w->tagexpand)
                        return 1;
                w->tag.fr.noredraw = 1;
                textresize(&w->tag, r, TRUE);
                w->tag.fr.noredraw = 0;
       +        
       +        /* can't use more than we have */
                if(w->tag.fr.nlines >= w->tag.fr.maxlines)
                        return w->tag.fr.maxlines;
       +
       +        /* if tag ends with \n, include empty line at end for typing */
                n = w->tag.fr.nlines;
                bufread(&w->tag.file->b, w->tag.file->b.nc-1, &rune, 1);
                if(rune == '\n')
                        n++;
       +
       +        /* cannot magically shrink tag - would lose focus */
       +        if(n < w->taglines)
       +                n = w->taglines;
       +
                return n;
        }
        
       t@@ -125,6 +136,19 @@ if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\n", w->id, r, safe, keepex
                w->tagtop = r;
                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.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
       +        y = r1.max.y;
       +        if(1 || !safe || !w->tagsafe || !eqrect(w->tag.all, r1)){
       +                w->taglines = wintaglines(w, r);
       +                w->tagsafe = TRUE;
       +        }
       +/* END TAG */
       +
                r1 = r;
                r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
                y = r1.max.y;
       t@@ -141,6 +165,7 @@ if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr.r);
                        br.max.y = br.min.y + Dy(b->r);
                        draw(screen, br, b, nil, b->r.min);
                }
       +
                
                r1 = r;
                r1.min.y = y;