Annotation of researchv9/jerq/src/lib/mj/getrect.c, revision 1.1.1.1

1.1       root        1: #include       <jerq.h>
                      2: Texture boxcurs = {
                      3:        0x43FF, 0xE001, 0x7001, 0x3801, 0x1D01, 0x0F01, 0x8701, 0x8F01,
                      4:        0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0xFFFF,
                      5: };
                      6: Rectangle
                      7: canon(p1, p2)
                      8:        Point p1, p2;
                      9: {
                     10:        Rectangle r;
                     11:        r.origin.x = min(p1.x, p2.x);
                     12:        r.origin.y = min(p1.y, p2.y);
                     13:        r.corner.x = max(p1.x, p2.x);
                     14:        r.corner.y = max(p1.y, p2.y);
                     15:        return(r);
                     16: }
                     17: Rectangle
                     18: getrectb(n)
                     19:        int n;
                     20: {
                     21:        Rectangle r;
                     22:        Texture *t;
                     23:        Point p1, p2;
                     24:        t = cursswitch(&boxcurs);
                     25:        while(button123())nap(1);
                     26:        while(!button123()) nap(1);
                     27:        if(!(mouse.buttons&n)){
                     28:                r.origin.x=r.origin.y=r.corner.x=r.corner.y=0;
                     29:                while(button123()) nap(1);
                     30:                goto Return;
                     31:        }
                     32:        p1=mouse.xy;
                     33:        p2=p1;
                     34:        r=canon(p1, p2);
                     35:        outline(r);
                     36:        for(; mouse.buttons&n; nap(2)){
                     37:                outline(r);
                     38:                p2=mouse.xy;
                     39:                r=canon(p1, p2);
                     40:                outline(r);
                     41:        }
                     42:        outline(r);     /* undraw for the last time */
                     43:     Return:
                     44:        (void)cursswitch(t);
                     45:        return r;
                     46: }
                     47: Rectangle
                     48: getrect(n)
                     49: {
                     50:        return getrectb(8>>n);
                     51: }
                     52: outline(r)
                     53:        Rectangle r;
                     54: {
                     55:        segment(&display,r.origin,Pt(r.corner.x,r.origin.y),F_XOR);
                     56:        segment(&display,Pt(r.corner.x,r.origin.y),r.corner,F_XOR);
                     57:        segment(&display,r.corner,Pt(r.origin.x,r.corner.y),F_XOR);
                     58:        segment(&display,Pt(r.origin.x,r.corner.y),r.origin,F_XOR);
                     59: }

unix.superglobalmegacorp.com

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