Annotation of researchv9/cmd/emacs/ttest.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: 
                      3: /* EMACS_MODES: c, !fill */
                      4: 
                      5: /* terminal type tester.  exercises terminal capabilities to dest
                      6:  * their definition and use. */
                      7: 
                      8: extern char *UP;                                       /* cursor up line */
                      9: extern char *DOWN;
                     10: extern char *BACK;
                     11: extern char *FORWARD;
                     12: extern char *HOME;
                     13: extern char *CLEAR;
                     14: extern char *CLREST;
                     15: extern char *CLINE;
                     16: extern char *BELL;
                     17: extern char *CURAD;
                     18: extern char *TMAP;
                     19: extern char *NOP;
                     20: extern char *LOPEN;
                     21: extern char *LDEL;
                     22: extern char *INSERTC;
                     23: extern char *INSERTM;
                     24: extern char *OSERTC;
                     25: extern char *INSERTP;
                     26: extern char *DELC;
                     27: extern char *SSCROLL;
                     28: extern char *RSCROLL;
                     29: extern char *CR;
                     30: extern char *SCREG;
                     31: extern char *ULINE;
                     32: extern int EOVER;
                     33: extern char *SCINIT;
                     34: extern char *VEXIT;
                     35: extern int XBASE;
                     36: extern int YBASE;
                     37: extern int SCRWID;
                     38: extern int SCRNLIN;
                     39: extern int SCRWRAP;
                     40: extern int VCOST;
                     41: extern int SRCADD;
                     42: extern int MI;
                     43: extern int IN;
                     44: extern int DELMODE;
                     45: extern char *RELUP;
                     46: extern char *RELDOWN;
                     47: extern char *RELFORW;
                     48: extern char *RELBACK;
                     49: 
                     50: extern int scrlin,scrcol;
                     51: 
                     52: pause()
                     53: {
                     54:        mgetchar();
                     55: }
                     56: 
                     57: main()
                     58: {
                     59:        int i;
                     60:        
                     61:        ttystart();                     /* start terminal processing */
                     62:        
                     63: /* Clear screen test */
                     64:        
                     65:        xprintf ("\n\n       Clear Screen Test");
                     66:        pause();
                     67:        clear();
                     68:        xprintf (
                     69:                "*\n Screen was cleared, astrick @ upper left of screen");
                     70:        pause();
                     71:        
                     72: /* Cursor addressing: */
                     73: 
                     74:        clear();
                     75: 
                     76:        if (CURAD) {
                     77:                for (i = 0; i <= SCRWID;  i++) {
                     78:                        scrlin = -100;          /* make sure we do cursor movement */
                     79:                        mgo(10,i);
                     80:                        putchar((i&07)+'0');
                     81:                }
                     82:                mgo(12,10);
                     83:                xprintf ("Above line should count accross the screen 0-7");
                     84:                pause();
                     85:                clear();
                     86:                for (i = 0; i < SCRNLIN; i++) {
                     87:                        scrlin = -100;
                     88:                        mgo(i,SCRWID/2);
                     89:                        xprintf ("%d",i);
                     90:                }
                     91:                mgo(0,0);
                     92:                xprintf ("Screen should");
                     93:                mgo(1,0);
                     94:                xprintf ("have a line");
                     95:                mgo(2,0);
                     96:                xprintf ("counting down");
                     97:                mgo(3,0);
                     98:                xprintf ("the middle");
                     99:                pause();
                    100:                clear();
                    101:        }
                    102:        if (!CURAD) {
                    103:                switch ((RELUP!=0)+
                    104:                        (RELDOWN!=0)+
                    105:                        (RELFORW!=0)+
                    106:                        (RELBACK!=0)) {
                    107:                                
                    108:                default:
                    109:                        xprintf("ru, rd, rr and rl must all be defined");
                    110:                        pause();
                    111:                        clear();
                    112:                        die(0);
                    113: 
                    114:                case 4 : ;
                    115:                /* Need some relative addressing tests here */
                    116: 
                    117:                case 0: ;
                    118:                }
                    119:        }
                    120:        if ((!CURAD)&&(!RELUP)&&((!UP)||(!DOWN)||((!CR)&&(!BACK)))) {
                    121:                xprintf(
                    122:                "Must have cursor addressing, or up, do & (cr or bc)");
                    123:                pause();
                    124:                clear();
                    125:                die(0);
                    126:        }
                    127: /* RELATIVE SCREEN MOTION */
                    128:        
                    129:        if (BACK) {
                    130:                mgo(5,0);
                    131:                xprintf ("Drawing backwards from 10,20 to 10,0");
                    132:                mgo(10,20);
                    133:                for (i = 0; i < 20; i++) {
                    134:                        putchar('x');
                    135:                        eprintf(BACK);
                    136:                        eprintf(BACK);
                    137:                }
                    138:                putchar('x');
                    139:                eprintf(BACK);
                    140:                pause();
                    141:                clear();
                    142:        }
                    143:        if (FORWARD) {
                    144:                mgo(5,0);
                    145:                xprintf ("Drawing Forwards from 10,0 to 10,20");
                    146:                if (BACK==0) {
                    147:                        mgo(6,0);
                    148:                        xprintf("Skipping everyother character");
                    149:                }
                    150:                mgo(10,0);
                    151:                for (i = 0; i < 20; i++) {
                    152:                        putchar('x');
                    153:                        if (BACK) eprintf(BACK);
                    154:                        else i++;
                    155:                        eprintf(FORWARD);
                    156:                }
                    157:                putchar('x');
                    158:                eprintf(BACK);
                    159:                pause();
                    160:                clear();
                    161:        }
                    162:        if (DOWN) {
                    163:                mgo(0,5);
                    164:                if (BACK) xprintf ("Drawing down from 1,20 to 21,20");
                    165:                else xprintf("Drawing down diagonal from 1,20 to 21,40");
                    166:                mgo(1,20);
                    167:                for (i = 0; i < 20; i++) {
                    168:                        putchar('x');
                    169:                        eprintf(BACK);
                    170:                        eprintf(DOWN);
                    171:                }
                    172:                putchar('x');
                    173:                eprintf(BACK);
                    174:                pause();
                    175:                clear();
                    176:        }
                    177:        if (UP) {
                    178:                mgo(0,5);
                    179:                if (BACK) xprintf ("Drawing UP from 21,20 to 1,20");
                    180:                else xprintf("Drawing up diagonal from 21,20 to 1,40");
                    181:                mgo(21,20);
                    182:                for (i = 0; i < 20; i++) {
                    183:                        putchar('x');
                    184:                        eprintf(BACK);
                    185:                        eprintf(UP);
                    186:                }
                    187:                putchar('x');
                    188:                eprintf(BACK);
                    189:                pause();
                    190:                clear();
                    191:        }
                    192: /* Carriage Return  */
                    193:        
                    194:        if (CR) {
                    195:                mgo(10,25);
                    196:                xprintf ("Carriage");
                    197:                mgo(10,0);
                    198:                xprintf ("Return");
                    199:                pause();
                    200:                clear();
                    201:        }
                    202:        
                    203: /* HOME */
                    204:        
                    205:        if (HOME) {
                    206:                mgo(10,25);
                    207:                xprintf ("Going");
                    208:                eprintf (HOME);
                    209:                printf("Home");
                    210:                pause();
                    211:                clear();
                    212:        }
                    213:        
                    214: /* Wrapping */
                    215:        
                    216:        if (SCRWRAP) {
                    217:                mgo(5,SCRWID-6);
                    218:                printf("cursor wraps");
                    219:                if (CURAD) {
                    220:                        scrlin = -100;
                    221:                        mgo(7,0);
                    222:                } else {
                    223:                        printf("\r\n"); /* PUNT for terminal with no CM */
                    224:                }
                    225:                printf("wraps under wraps");
                    226:                pause();
                    227:                clear();
                    228:        }
                    229:        
                    230:        if (CLINE) {
                    231:                mgo(10,0);
                    232:                xprintf ("clearing everything after clear");
                    233:                mgo(11,0);
                    234:                xprintf ("clearing everything after clear");
                    235:                mgo(10,5);
                    236:                clrl();
                    237:                pause();
                    238:                clear();
                    239:        }
                    240: /* BELL */
                    241:        
                    242:        if (BELL) {
                    243:                xprintf ("beep beep beep");
                    244:                beep();
                    245:                sdelay(1000);
                    246:                beep();
                    247:                sdelay(1000);
                    248:                beep();
                    249:                clear();
                    250:        }
                    251:        if (SSCROLL){
                    252:                mgo(SCRNLIN-1,0);
                    253:                printf ("scrolling");
                    254:                eprintf(SSCROLL);
                    255:                mgo(SCRNLIN-1,0);
                    256:                printf("up");
                    257:                eprintf(SSCROLL);
                    258:                mgo(SCRNLIN-1,0);
                    259:                printf("the");
                    260:                eprintf(SSCROLL);
                    261:                mgo(SCRNLIN-1,0);
                    262:                printf("screen");
                    263:                pause();
                    264:                clear();
                    265:        }
                    266:        if (INSERTC||INSERTM) { 
                    267:                
                    268:                mgo(10,0);
                    269:                xprintf("Testing insert character.");
                    270:                if (IN) {
                    271:                        xprintf ("              These won't move unless pushed\n");
                    272:                        xprintf("These move when you push them\n");
                    273:                }
                    274:                else xprintf ("         These move too\n");
                    275:                xprintf("  all characters except ^G insert after test");
                    276:                mgo(10,4);
                    277:                if (INSERTM) {
                    278:                        eprintf(INSERTM);
                    279:                }
                    280:                while ((i = mgetchar()) != '') {
                    281:                        if (INSERTC) eprintf(INSERTC);
                    282:                        putchar(i);
                    283:                        if (INSERTP) eprintf(INSERTP);
                    284:                }
                    285:                if (OSERTC) eprintf(OSERTC);
                    286:                clear();
                    287:        }
                    288:        if (DELC) { 
                    289:                mgo(10,0);
                    290:                xprintf("Testing delete character.");
                    291:                if (IN) {
                    292:                        xprintf(" All of these characters, including the wrap to the new line, should move");
                    293:                        xprintf ("              These won't move\n");
                    294:                }
                    295:                else xprintf ("         These move too\n");
                    296:                xprintf("  all characters except ^G delete after test");
                    297:                mgo(10,4);
                    298:                if (DELMODE) {
                    299:                        eprintf(INSERTM);
                    300:                }
                    301:                while ((i = mgetchar()) != '') {
                    302:                        eprintf(DELC);
                    303:                }
                    304:                if (DELMODE) eprintf(OSERTC);
                    305:                clear();
                    306:        }
                    307:        if ((SCREG)&&((!SSCROLL)||(!RSCROLL)||(!CURAD))) {
                    308:                mgo(1,1);
                    309:                xprintf("Region scrolling requires sf, sr and cm");
                    310:                pause();
                    311:                clear();
                    312:                goto skipscroll;
                    313:        }
                    314:        if (LOPEN) {
                    315:                for (i = 0; i < SCRNLIN; i++) {
                    316:                        mgo(i,0);
                    317:                        xprintf ("Line %d",i);
                    318:                }
                    319:                mgo(0,10);
                    320:                xprintf("u to scroll lines %d through %d up",2,SCRNLIN-2);
                    321:                mgo(1,10);
                    322:                xprintf("d to scroll down");
                    323: again:         i = mgetchar();
                    324:                if (i == 'u') {
                    325:                        vadjust(2,SCRNLIN-2,-1);
                    326:                        goto again;
                    327:                }
                    328:                if (i == 'd') {
                    329:                        vadjust(2,SCRNLIN-2,1);
                    330:                        goto again;
                    331:                }
                    332:                clear();
                    333:        }
                    334: skipscroll:
                    335:        if (ULINE) {
                    336:                
                    337:                if (EOVER) {
                    338:                        mgo(4,0);
                    339:                        uprint("Underlined_Characters");
                    340:                        mgo(6,0);
                    341:                        uprint("These won't wind up underlined");
                    342:                        mgo(6,0);
                    343:                        xprintf("These won't wind up underlined");
                    344:                } else {
                    345:                        mgo(6,0);
                    346:                        EOVER = 1;
                    347:                        uprint("...............................");
                    348:                        EOVER = 0;
                    349:                        mgo(6,0);
                    350:                        xprintf("These characters are underlined");
                    351:                }
                    352:                pause();
                    353:                clear();
                    354:        }
                    355:        die(0);
                    356:                
                    357: }
                    358: 
                    359: uprint(sp)
                    360: register char *sp;
                    361: {
                    362:        int lie = 0;
                    363:        if (!EOVER) {
                    364:                /* terminal does not overwrite underscores! */
                    365:                /* What a mess, tell handler it will */
                    366:                lie = 1;
                    367:                EOVER = 0;
                    368:        }
                    369:        while (*sp) {
                    370:                        xputc('_');
                    371:                        xputc('\b');
                    372:                        xputc(*sp++);
                    373:        }
                    374:        if (lie) EOVER=1;
                    375: }

unix.superglobalmegacorp.com

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