Annotation of researchv9/jtools/src/pads/x11/buttons.c, revision 1.1

1.1     ! root        1: #include "univ.h"
        !             2: 
        !             3: extern Script ObjScript;
        !             4: Script Generic;
        !             5: Index CIndex;
        !             6: Entry *CarteEntry();
        !             7: 
        !             8: Entry *ObjectEntry(i)
        !             9: {
        !            10:        return CIndex ? CarteEntry(CIndex,i): (Entry*)0;
        !            11: }
        !            12: 
        !            13: ObjectLimits(s)
        !            14: Script *s;
        !            15: {
        !            16:        register Carte *c;
        !            17: 
        !            18:        if( !CIndex ) return;
        !            19:        assert( MJR(CIndex)&CARTE );
        !            20:        c = IndexToCarte(CIndex);
        !            21:        s->items = c->size;
        !            22:        s->width = c->width;
        !            23: }
        !            24: 
        !            25: Entry *CarteEntry(ix, i)
        !            26: Index ix;
        !            27: register short i;
        !            28: {
        !            29:        static Entry e;
        !            30:        static Script subscript[4];
        !            31:        extern int MenuNest;
        !            32: 
        !            33:        register Carte *nest, *c;
        !            34:        register int j;
        !            35:        register Script *s;
        !            36:        Index nix;
        !            37: 
        !            38:        assert( MJR(ix)&CARTE );
        !            39:        c = IndexToCarte(ix);
        !            40:        if( i >= c->size ) return 0;
        !            41:        e.script = 0;
        !            42:        if( c->attrib&NUMERIC ){
        !            43:                e.action = HostNumeric;
        !            44:                e.text = itoa( (int) (e.opand = i + (short) c->bin[1]) );
        !            45:                return &e;
        !            46:        }
        !            47:        for( j = 1; ; ++j ){
        !            48:                assert( i>=0 && j<=c->size );
        !            49:                if( nix=c->bin[j], MJR(nix)&CARTE ){
        !            50:                        nest = IndexToCarte(nix);
        !            51:                        if( nest->bin[0] ){
        !            52:                                if( i == 0 ){
        !            53:                                        e.action = HostAction;
        !            54:                                        e.opand = (long) &nest->bin[0];
        !            55:                                        e.text = IndexToStr(nest->bin[0]);
        !            56:                                        e.script = s = &subscript[MenuNest];
        !            57:                                        s->cindex = nix;
        !            58:                                        s->generator = ObjectEntry;
        !            59:                                        s->limits = ObjectLimits;
        !            60:                                        return &e;
        !            61:                                }
        !            62:                                --i;
        !            63:                        } else {
        !            64:                                if( i < nest->size )
        !            65:                                        return CarteEntry(nix,i);
        !            66:                                i -=  nest->size;
        !            67:                        }
        !            68:                } else {
        !            69:                        if( i == 0 ){
        !            70:                                e.action = HostAction;
        !            71:                                e.opand = (long) &c->bin[j];
        !            72:                                e.text = IndexToStr(c->bin[j]);
        !            73:                                return &e;
        !            74:                        }
        !            75:                        --i;
        !            76:                }
        !            77:        }
        !            78: }
        !            79: 
        !            80: Entry *SubEntry(i)
        !            81: register i;
        !            82: {
        !            83:        int MakeCurrent(); extern Pad Sentinel;
        !            84:        register Pad *p;
        !            85:        static Entry e  = { 0, MakeCurrent, 0 };
        !            86: 
        !            87:        for( p = Sentinel.back; p != &Sentinel && i-- > 0; p = p->back ){}
        !            88:        if( p == &Sentinel ) return (Entry *) 0;
        !            89:        e.text = p->name;
        !            90:        e.opand = (long) p;
        !            91:        return &e;
        !            92: }
        !            93: 
        !            94: SubLimits(s)
        !            95: register Script *s;
        !            96: {
        !            97:        extern Pad Sentinel;
        !            98:        register Pad *p;
        !            99:        register l;
        !           100: 
        !           101:        s->items = 0;
        !           102:        s->width = 1;
        !           103:        for( p = Sentinel.back; p != &Sentinel ; p = p->back ){
        !           104:                ++s->items;
        !           105:                l = strlen(p->name);
        !           106:                if( l > s->width ) s->width = l;
        !           107:        }
        !           108: }
        !           109: 
        !           110: Script SubScript = { SubEntry, SubLimits };
        !           111: 
        !           112: Entry *PadEntry(i)
        !           113: register i;
        !           114: {
        !           115:        static Entry e[] = {
        !           116:                { "\376",       0,              0 },
        !           117:                { "reshape",    Reshape,        0 },
        !           118:                { "move",       Move,           0 },
        !           119:                { "close",      DeletePick,     0 },
        !           120:                { "(fold)",     0,              0 },
        !           121:                { "top",        0,              0,      &SubScript}
        !           122:        };
        !           123: 
        !           124:        if( i > 5 ) return (Entry *) 0;
        !           125:        if( i == 4 && Current ) return FoldEntry(&Current->attributes);
        !           126:        return e+i;
        !           127: }
        !           128: 
        !           129: Entry *LineEntry(i)
        !           130: {
        !           131:        static Entry e [] = {   { "\376",       0,              0 },
        !           132:                                { "cut",        CutLine,        0 },
        !           133:                                { "sever",      Sever,          0 },    };
        !           134: 
        !           135:        if( i<3 ) return e+i;
        !           136:        if( i==3 && Selected.line)
        !           137:                return FoldEntry(&Selected.line->attributes);
        !           138:        return 0;
        !           139: }
        !           140:        
        !           141: Script ObjScript = { ObjectEntry, ObjectLimits, &Generic };
        !           142: 
        !           143: MOUSEServe()
        !           144: {
        !           145:        register int but;
        !           146:        register Line *lop;     /* Line or Pad! */
        !           147:        register Pad *p;
        !           148:        register Entry *e = 0;
        !           149:        register Script *s;
        !           150:        register char *confirm = "confirm: ";
        !           151: 
        !           152:        if( !ptinrect(mouse.xy,Drect) ) return;
        !           153: Again:
        !           154:        switch( butts ){
        !           155:        case BUTT1:
        !           156:                Pointing();
        !           157:                if( !button23() ) goto AllDone;
        !           158:                while( button1() ) jnap(2);
        !           159:                goto Again;
        !           160:        case BUTT2:
        !           161:                but = 2;
        !           162:                Generic.generator = LineEntry;
        !           163:                if( lop = Selected.line )
        !           164:                        MakeCurrent(Selected.pad);
        !           165:                break;
        !           166:        case BUTT3:
        !           167:                if( (p = PickPad(mouse.xy)) && (p != Current) ){
        !           168:                        MakeCurrent(p);
        !           169:                        goto Again;
        !           170:                }
        !           171:                Generic.generator = PadEntry;
        !           172:                lop = (Line*) Current;
        !           173:        }
        !           174:        switch( butts ){
        !           175:        case BUTT3:
        !           176:                but = 3;
        !           177:        case BUTT2:
        !           178:                ObjScript.cindex = 0;
        !           179:                if( lop ){
        !           180:                        if( lop->ptop != 255 ){
        !           181:                                ObjScript.prevtop = lop->ptop;
        !           182:                                ObjScript.prevhit = lop->phit;
        !           183:                        }
        !           184:                        ObjScript.cindex = lop->carte;
        !           185:                        HostObject = lop->object;
        !           186:                        HostParent = Current ? Current->object : (long)0;
        !           187:                }
        !           188:                if( e = ScriptHit(&ObjScript, but, (RectList*)0) ){
        !           189:                        if( lop ){
        !           190:                                lop->ptop = ObjScript.prevtop;
        !           191:                                lop->phit = ObjScript.prevhit;
        !           192:                        }
        !           193:                        if( e->text[strlen(e->text)-1] == '?' ){
        !           194:                                cursswitch(&Danger);
        !           195:                                if( Configuration&NOVICEUSER )
        !           196:                                        InvertKBDrect( confirm, e->text );
        !           197:                                while( !butts ) waitMOUSE();
        !           198:                                if( !button(but) ) e = 0;
        !           199:                                while( butts ) waitMOUSE();
        !           200:                                if( Configuration&NOVICEUSER )
        !           201:                                        PaintKBD();
        !           202:                                cursswitch( Pcursor );
        !           203:                        }
        !           204:                }
        !           205:                if( e && e->action ){
        !           206:                        if( but == 3 && lop) FlashBorder(lop);
        !           207:                        (e->action)(e->opand);
        !           208:                        if( but == 2 ) Select((Line*)0, (Pad*) 0);
        !           209:                }
        !           210:        }
        !           211: AllDone:
        !           212:        while( butts ) waitMOUSE();
        !           213: }
        !           214: 
        !           215: FlashBorder(p)
        !           216: Pad *p;
        !           217: {
        !           218:        HeavyBorder(p);
        !           219:        wait(CPU);
        !           220:        HeavyBorder(p);
        !           221:        wait(CPU);
        !           222: }

unix.superglobalmegacorp.com

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