Annotation of researchv9/jerq/src/sam/term/frdelete.c, revision 1.1.1.1

1.1       root        1: #include "frame.h"
                      2: 
                      3: frdelete(f, p0, p1)
                      4:        register Frame *f;
                      5:        Posn p0, p1;
                      6: {
                      7:        Point pt0, pt1, ppt0;
                      8:        register Box *b;
                      9:        register n0, n1, n;
                     10:        Rectangle r;
                     11:        int nn0;
                     12:        if(p0>=f->nchars || p0==p1 || f->b==0)
                     13:                return 0;
                     14:        if(p1>f->nchars)
                     15:                p1=f->nchars;
                     16:        n0=findbox(f, 0, 0, p0);
                     17:        n1=findbox(f, n0, p0, p1);
                     18:        pt0=ptofcharnb(f, p0, n0);
                     19:        pt1=ptofchar(f, p1);
                     20:        if(f->p0!=p0 || f->p1!=p1)      /* likely they ARE equal */
                     21:                selectp(f, F_XOR);      /* can do better some day */
                     22:        selectf(f, pt0, pt1, F_CLR);
                     23:        if(n0==f->nbox)
                     24:                panic("off end in frdelete");
                     25:        nn0=n0;
                     26:        ppt0=pt0;
                     27:        freebox(f, n0, n1-1);
                     28:        /*
                     29:         * Invariants:
                     30:         *  pt0 points to beginning, pt1 points to end
                     31:         *  n0 is box containing beginning of stuff being deleted
                     32:         *  n1, b are box containing beginning of stuff to be kept after deletion
                     33:         *  region between pt0 and pt1 is clear
                     34:         */
                     35:        b=&f->box[n1];
                     36:        while(pt1.x!=pt0.x && n1<f->nbox){
                     37:                cklinewrap0(f, &pt0, b);
                     38:                cklinewrap(f, &pt1, b);
                     39:                if(b->len>0){
                     40:                        n=canfit(f, pt0, b);
                     41:                        if(n==0)
                     42:                                        panic("canfit==0");
                     43:                        if(n!=b->len){
                     44:                                splitbox(f, n1, n);
                     45:                                b=&f->box[n1];
                     46:                        }
                     47:                        r.origin=r.corner=pt1;
                     48:                        r.corner.x+=b->wid, r.corner.y+=f->font->height;
                     49:                        bitblt(B, r, B, pt0, F_STORE);
                     50:                        if(pt0.y==pt1.y)
                     51:                                r.origin.x=r.corner.x-(pt1.x-pt0.x);
                     52:                        rectf(B, r, F_CLR);
                     53:                }
                     54:                advance(f, &pt1, b);
                     55:                pt0.x+=newwid(f, pt0, b);
                     56:                f->box[n0++]=f->box[n1++];
                     57:                b++;
                     58:        }
                     59:        if(pt1.y!=pt0.y){
                     60:                Point pt2;
                     61:                pt2=ptofcharptb(f, 32767, pt1, n1);
                     62:                if(pt2.y>f->r.corner.y)
                     63:                        panic("ptofchar in frdelete");
                     64:                if(n1<f->nbox){
                     65:                        int q0, q1, q2;
                     66:                        q0=pt0.y+f->font->height, q1=pt1.y+f->font->height;
                     67:                        q2=pt2.y+f->font->height;
                     68:                        bitblt(B, Rect(pt1.x, pt1.y, f->r.corner.x, q1),
                     69:                               B, pt0, F_STORE);
                     70:                        bitblt(B, Rect(f->r.origin.x, q1, f->r.corner.x, q2),
                     71:                               B, Pt(f->r.origin.x, q0), F_STORE);
                     72:                        selectf(f, Pt(pt2.x, pt2.y-(pt1.y-pt0.y)), pt2, F_CLR);
                     73:                }else
                     74:                        selectf(f, pt0, pt2, F_CLR);
                     75:        }
                     76:        closebox(f, n0, n1-1);
                     77:        if(nn0>0 && f->box[nn0-1].len>=0 && ppt0.x-f->box[nn0-1].wid>=(int)f->left){
                     78:                --nn0;
                     79:                ppt0.x-=f->box[nn0].wid;
                     80:        }
                     81:        clean(f, ppt0, nn0, n0<f->nbox-1? n0+1 : n0);
                     82:        if(f->p1>p1)
                     83:                f->p1-=p1-p0;
                     84:        else if(f->p1>p0)
                     85:                f->p1=p0;
                     86:        if(f->p0>p1)
                     87:                f->p0-=p1-p0;
                     88:        else if(f->p0>p0)
                     89:                f->p0=p0;
                     90:        selectp(f, F_XOR);
                     91:        f->nchars-=p1-p0;
                     92:        if(pt0.x!=pt1.x)
                     93:                f->lastlinefull=pt0.x==f->left;
                     94:        pt0=ptofchar(f, f->nchars);
                     95:        n=f->nlines;
                     96:        f->nlines=(pt0.y-f->r.origin.y)/f->font->height+(pt0.x>f->left);
                     97:        return n-f->nlines;
                     98: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.