Annotation of coherent/g/usr/bin/me/ansi.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * The routines in this file
                      3:  * provide support for ANSI style terminals
                      4:  * over a serial line. The serial I/O services are
                      5:  * provided by routines in "termio.c". It compiles
                      6:  * into nothing if not an ANSI device.
                      7:  */
                      8: #include       <stdio.h>
                      9: #include       "ed.h"
                     10: 
                     11: #if    ANSI
                     12: 
                     13: #define        NROW    24                      /* Screen size.                 */
                     14: #define        NCOL    80                      /* Edit if you want to.         */
                     15: #define        BEL             0x07            /* BEL character.               */
                     16: #define        ESC             0x1B            /* ESC character.               */
                     17: 
                     18: extern int     ttopen();               /* Forward references.          */
                     19: extern int     ttgetc();
                     20: extern int     ttputc();
                     21: extern int     ttflush();
                     22: extern int     ttclose();
                     23: extern int     ansimove();
                     24: extern int     ansieeol();
                     25: extern int     ansieeop();
                     26: extern int     ansibeep();
                     27: extern int     ansiopen();
                     28: extern int     ansistand();
                     29: 
                     30: /*
                     31:  * Standard terminal interface
                     32:  * dispatch table. Most of the fields
                     33:  * point into "termio" code.
                     34:  */
                     35: TERM   term    = {
                     36:        NROW-1,
                     37:        NCOL,
                     38:        ansiopen,
                     39:        ttclose,
                     40:        ttgetc,
                     41:        ttputc,
                     42:        ttflush,
                     43:        ansimove,
                     44:        ansieeol,
                     45:        ansieeop,
                     46:        ansibeep,
                     47:        ansistand
                     48: };
                     49: 
                     50: ansimove(row, col)
                     51: {
                     52:        ttputc(ESC);
                     53:        ttputc('[');
                     54:        ansiparm(row+1);
                     55:        ttputc(';');
                     56:        ansiparm(col+1);
                     57:        ttputc('H');
                     58: }
                     59: 
                     60: ansieeol()
                     61: {
                     62:        ttputc(ESC);
                     63:        ttputc('[');
                     64:        ttputc('K');
                     65: }
                     66: 
                     67: ansieeop()
                     68: {
                     69:        ttputc(ESC);
                     70:        ttputc('[');
                     71:        ttputc('J');
                     72: }
                     73: 
                     74: ansibeep()
                     75: {
                     76:        ttputc(BEL);
                     77:        ttflush();
                     78: }
                     79: 
                     80: ansiparm(n)
                     81: register int   n;
                     82: {
                     83:        register int    q;
                     84: 
                     85:        q = n/10;
                     86:        if (q != 0)
                     87:                ansiparm(q);
                     88:        ttputc((n%10) + '0');
                     89: }
                     90: 
                     91: ansistand(f)
                     92: {
                     93:        ttputc(ESC);                    /* <ESC> [ Ps m -- Select graphics rendition */
                     94:        ttputc('[');                    /* (SGR)                                */
                     95:        ttputc(!f ? '0' : '7'); /* 7 = Reverse video */
                     96:        ttputc('m');
                     97: }
                     98: 
                     99: #endif
                    100: 
                    101: ansiopen()
                    102: {
                    103: #if    V7
                    104:        register uchar *cp;
                    105:        char *getenv();
                    106: 
                    107:        if ((cp = getenv("TERM")) == NULL) {
                    108:                puts("Shell variable TERM not defined!");
                    109:                exit(1);
                    110:        }
                    111:        if (strcmp(cp, "vt100") != 0) {
                    112:                puts("Terminal type not 'vt100'!");
                    113:                exit(1);
                    114:        }
                    115: #endif
                    116:        ttopen();
                    117: }

unix.superglobalmegacorp.com

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