Annotation of coherent/g/usr/bin/me/ed.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * This file is the general header file for all parts of the MicroEMACS
                      3:  * display editor.  It contains definitions used by everyone, and it
                      4:  * contains the stuff you have to edit to create a version of the editor for
                      5:  * a specific operating system and terminal.
                      6:  */
                      7: #ifdef COHERENT
                      8: #define        V7      1                       /* V7 UN*X or Coherent          */
                      9: #define        VMS     0                       /* VAX/VMS                      */
                     10: #define        CPM     0                       /* CP/M-86                      */
                     11: #define        MSDOS   0                       /* MS-DOS                       */
                     12: #define        GEM     0                       /* GEMDOS                       */
                     13: #define        PROMPT  " Coherent MicroEMACS -- "
                     14: #define ANSI   0
                     15: #define VT52   0                       /* VT52 terminal (Zenith).      */
                     16: #define        VT100   1                       /* Handle VT100 style keypad.   */
                     17: #define        LK201   0                       /* Handle LK201 style keypad.   */
                     18: #define        RAINBOW 0                       /* Use Rainbow fast video.      */
                     19: #define TERMCAP 0                      /* Use TERMCAP                  */
                     20: #define TERMNFO 1                      /* Use TERMINFO                 */
                     21: #define        NATIVE  0                       /* Native ATARI ST screen       */
                     22: #define        EXKEYS  0                       /* Extended keys                */
                     23: #endif
                     24: 
                     25: #ifdef GEMDOS
                     26: #define        V7      0                       /* V7 UN*X or Coherent          */
                     27: #define        VMS     0                       /* VAX/VMS                      */
                     28: #define        CPM     0                       /* CP/M-86                      */
                     29: #define        GEM     1                       /* GEMDOS                       */
                     30: #define        MSDOS   0                       /* MS-DOS                       */
                     31: #define        UPPERNM 0                       /* if 0 names in all lower case */
                     32: #define        PROMPT  " ST MicroEMACS 1.8 -- "
                     33: #define ANSI   0
                     34: #define VT52   0                       /* VT52 terminal (Zenith).      */
                     35: #define        VT100   0                       /* Handle VT100 style keypad.   */
                     36: #define        LK201   0                       /* Handle LK201 style keypad.   */
                     37: #define        RAINBOW 0                       /* Use Rainbow fast video.      */
                     38: #define TERMCAP 0                      /* Use TERMCAP                  */
                     39: #define TERMNFO 0                      /* Use TERMINFO                 */
                     40: #define        NATIVE  1                       /* Native ATARI ST screen       */
                     41: #define        EXKEYS  1                       /* Extended keys                */
                     42: #endif
                     43: 
                     44: #if    MSDOS
                     45: #define        V7      0                       /* V7 UN*X or Coherent          */
                     46: #define        VMS     0                       /* VAX/VMS                      */
                     47: #define        CPM     0                       /* CP/M-86                      */
                     48: #define        GEM     0                       /* GEMDOS                       */
                     49: #define        PROMPT  " DOS MicroEMACS V4.0.16 -- "
                     50: #ifndef        IBM
                     51: #define        ANSI    1                       /* Use ANSI.SYS                 */
                     52: #else
                     53: #define ANSI   0                       /* don't use ANSI.SYS           */
                     54: #endif
                     55: #define VT52   0                       /* VT52 terminal (Zenith).      */
                     56: #define        VT100   0                       /* Handle VT100 style keypad.   */
                     57: #define        LK201   0                       /* Handle LK201 style keypad.   */
                     58: #define        RAINBOW 0                       /* Use Rainbow fast video.      */
                     59: #define TERMCAP 0                      /* Use TERMCAP                  */
                     60: #define TERMNFO 0                      /* Use TERMINFO                 */
                     61: #define        NATIVE  0                       /* Native ATARI ST screen       */
                     62: #define        EXKEYS  1                       /* Extended keys                */
                     63: #endif
                     64: 
                     65: #ifndef        PROMPT
                     66: #define        PROMPT  " MicroEMACS -- "
                     67: #endif
                     68: 
                     69: /* 
                     70:  * NORMAL_CHARS will be 1 when the ctype.h problems are solved
                     71:  * for internationalization or when international characters are
                     72:  * not required.
                     73:  */
                     74: #define NORMAL_CHARS 0
                     75: 
                     76: #define        CVMVAS  1                       /* C-V, M-V arg. in screens.    */
                     77: #define        LIBHELP 1                       /* Use help stuff               */
                     78: 
                     79: #define  MAXMAC 10                     /* Max # of macros bound to keybindings */
                     80: #define  MAXREB 50                     /* Size of rebind table */
                     81: #define  HASHP  41                     /* Prime for hashing main table */
                     82: #define         BINDID ((MAXREB << 8) ^ (HASHP << 4) ^ MAXMAC)
                     83: #define        NCFILES 5                       /* Max # of files on command line */
                     84: #define        NFILEN  80                      /* # of bytes, file name        */
                     85: #define        NBUFN   16                      /* # of bytes, buffer name      */
                     86: #define        NLINE   256                     /* # of bytes, line             */
                     87: #define        NKBDM   256                     /* # of strokes, keyboard macro */
                     88: #define        NPAT    80                      /* # of bytes, pattern          */
                     89: #define        HUGE    1000                    /* Huge number                  */
                     90: #define        NSRCH   128                     /* undoable search command len  */
                     91: #define        ERRLINES 3                      /* error window lines displayed */
                     92: 
                     93: #define        AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
                     94: #define        METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
                     95: #define        CTMECH  0x1C                    /* C-M- prefix, Control-\       */
                     96: #define        EXITCH  0x1D                    /* Exit level,  Control-]       */
                     97: #define        CTRLCH  0x1E                    /* C- prefix,   Control-^       */
                     98: #define        HELPCH  0x1F                    /* Help key,    Control-_       */
                     99: 
                    100: #define        FALSE   0                       /* False, no, bad, etc.         */
                    101: #define        TRUE    1                       /* True, yes, good, etc.        */
                    102: #define        ABORT   2                       /* Death, ^G, abort, etc.       */
                    103: 
                    104: #define        FIOSUC  0                       /* File I/O, success.           */
                    105: #define        FIOFNF  1                       /* File I/O, file not found.    */
                    106: #define        FIOEOF  2                       /* File I/O, end of file.       */
                    107: #define        FIOERR  3                       /* File I/O, error.             */
                    108: 
                    109: #define        CFCPCN  0x0001                  /* Last command was C-P, C-N    */
                    110: #define        CFKILL  0x0002                  /* Last command was a kill      */
                    111: 
                    112: 
                    113: #if    EXKEYS
                    114: /*
                    115:  * The following codes should be bound to the function keys in the system
                    116:  * specific keyboard handling (mostly in termio.c).
                    117:  *
                    118:  * When used in the key table in main.c, the same functions should be
                    119:  * available through other key sequences.
                    120:  */
                    121: #define        FN0     0x80                    /* Function key 0       */
                    122: #define        FN1     0x81                    /* Function key 1       */
                    123: #define        FN2     0x82                    /* Function key 2       */
                    124: #define        FN3     0x83                    /* Function key 3       */
                    125: #define        FN4     0x84                    /* Function key 4       */
                    126: #define        FN5     0x85                    /* Function key 5       */
                    127: #define        FN6     0x86                    /* Function key 6       */
                    128: #define        FN7     0x87                    /* Function key 7       */
                    129: #define        FN8     0x88                    /* Function key 8       */
                    130: #define        FN9     0x89                    /* Function key 9       */
                    131: #define        FNA     0x8A                    /* Function key 10      */
                    132: #define        FNB     0x8B                    /* Function key 11      */
                    133: #define        FNC     0x8C                    /* Function key 12      */
                    134: #define        FND     0x8D                    /* Function key 13      */
                    135: #define        FNE     0x8E                    /* Function key 14      */
                    136: #define        FNF     0x8F                    /* Function key 15      */
                    137: #define        FN10    0x90                    /* Function key 16      */
                    138: #define        FN11    0x91                    /* Function key 17      */
                    139: #define        FN12    0x92                    /* Function key 18      */
                    140: #define        FN13    0x93                    /* Function key 19      */
                    141: #define        FN14    0x94                    /* Function key 20      */
                    142: #define        FN15    0x95                    /* Function key 21      */
                    143: #define        FN16    0x96                    /* Function key 22      */
                    144: #define        FN17    0x97                    /* Function key 23      */
                    145: #define        FN18    0x98                    /* Function key 24      */
                    146: #define        FN19    0x99                    /* Function key 25      */
                    147: #define        FN1A    0x9A                    /* Function key 26      */
                    148: #define        FN1B    0x9B                    /* Function key 27      */
                    149: #define        FN1C    0x9C                    /* Function key 28      */
                    150: #define        FN1D    0x9D                    /* Function key 29      */
                    151: #define        FN1E    0x9E                    /* Function key 30      */
                    152: #define        FN1F    0x9F                    /* Function key 31      */
                    153: #endif
                    154: 
                    155: #define        CTRL    0x0100                  /* Control flag, or'ed in       */
                    156: #define        META    0x0200                  /* Meta flag, or'ed in          */
                    157: #define        PFX1    0x0400                  /* prefix 1 flag, or'ed in      */
                    158: #define        PFX2    0x0800                  /* prefix 2 flag, or'ed in      */
                    159: #define        PFX3    0x1000                  /* prefix 3 flag, or'ed in      */
                    160: #define OBND   0x2000                  /* original binding only        */
                    161: 
                    162: typedef unsigned char uchar;
                    163: 
                    164: /*
                    165:  * Key bindings point into a function table which
                    166:  * contains function names.
                    167:  */
                    168: typedef struct KEYTAB KEYTAB;
                    169: struct KEYTAB {
                    170:        short   k_code;                 /* Key code                     */
                    171:        char    k_fun;          /* Function number */
                    172:        char    k_synonym;      /* Next at this hash value */
                    173: };
                    174: 
                    175: typedef struct FUNTAB FUNTAB;
                    176: struct FUNTAB {
                    177:        int     (*f_fp)();              /* Routine to handle it */
                    178: };
                    179: 
                    180: /*
                    181:  * flexable bindings data.
                    182:  */
                    183: typedef struct BIND {
                    184:        KEYTAB  table[MAXREB];          /* overlay keybind table        */
                    185:        uchar   *macs[MAXMAC + 2];      /* list of kbd macros           */
                    186:        short   maclen[MAXMAC + 2];     /* lengths of kbd macros        */
                    187:        short   pfx1;                   /* prefix 1 char                */
                    188:        short   pfx2;                   /* prefix 2 char                */
                    189:        short   pfx3;                   /* prefix 3 char                */
                    190:        short   repeat;                 /* repeat argument char         */
                    191:        int     ffold;                  /* Fold Flag                    */
                    192:        int     fillcol;                /* Current fill column          */
                    193:        int     bracket;                /* Bracket Mode switch          */
                    194:        int     tabsiz;                 /* tabsize                      */
                    195:        int     tabsize;                /* Tab size (0: use real tabs)  */
                    196:        int     autoindent;             /* Autoindent                   */
                    197:        int     dispmode;               /* display char < ' ' directly  */
                    198: } BIND;
                    199: extern BIND bind;
                    200: 
                    201: /*
                    202:  * There is a window structure allocated for every active display window.
                    203:  * The windows are kept in a big list, in top to bottom screen order, with
                    204:  * the listhead at "wheadp".  Each window contains its own values of dot and
                    205:  * mark.  The flag field contains some bits that are set by commands to guide
                    206:  * redisplay; although this is a bit of a compromise in terms of decoupling,
                    207:  * the full blown redisplay is just too expensive to run for every input
                    208:  * character. 
                    209:  */
                    210: typedef        struct  WINDOW {
                    211:        struct  WINDOW *w_wndp;         /* Next window                  */
                    212:        struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
                    213:        struct  LINE *w_linep;          /* Top line in the window       */
                    214:        struct  LINE *w_dotp;           /* Line containing "."          */
                    215:        short   w_doto;                 /* Byte offset for "."          */
                    216:        struct  LINE *w_markp;          /* Line containing "mark"       */
                    217:        short   w_marko;                /* Byte offset for "mark"       */
                    218:        char    w_toprow;               /* Origin 0 top row of window   */
                    219:        char    w_ntrows;               /* # of rows of text in window  */
                    220:        char    w_force;                /* If NZ, forcing row.          */
                    221:        char    w_flag;                 /* Flags.                       */
                    222: }      WINDOW;
                    223: 
                    224: #define        WFFORCE 0x01                    /* Window needs forced reframe  */
                    225: #define        WFMOVE  0x02                    /* Movement from line to line   */
                    226: #define        WFEDIT  0x04                    /* Editing within a line        */
                    227: #define        WFHARD  0x08                    /* Better to a full display     */
                    228: #define        WFMODE  0x10                    /* Update mode line.            */
                    229: 
                    230: /*
                    231:  * Text is kept in buffers. A buffer header, described
                    232:  * below, exists for every buffer in the system. The buffers are
                    233:  * kept in a big list, so that commands that search for a buffer by
                    234:  * name can find the buffer header. There is a safe store for the
                    235:  * dot and mark in the header, but this is only valid if the buffer
                    236:  * is not being displayed (that is, if "b_nwnd" is 0). The text for
                    237:  * the buffer is kept in a circularly linked list of lines, with
                    238:  * a pointer to the header line in "b_linep".
                    239:  */
                    240: typedef        struct  BUFFER {
                    241:        struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
                    242:        struct  LINE *b_dotp;           /* Link to "." LINE structure   */
                    243:        short   b_doto;                 /* Offset of "." in above LINE  */
                    244:        struct  LINE *b_markp;          /* The same as the above two,   */
                    245:        short   b_marko;                /* but for the "mark"           */
                    246:        struct  LINE *b_linep;          /* Link to the header LINE      */
                    247:        char    b_nwnd;                 /* Count of windows on buffer   */
                    248:        char    b_flag;                 /* Flags                        */
                    249:        uchar   b_fname[NFILEN];        /* File name                    */
                    250:        uchar   b_bname[NBUFN];         /* Buffer name                  */
                    251: }      BUFFER;
                    252: 
                    253: #define        BFTEMP  0x01                    /* Internal temporary buffer    */
                    254: #define        BFCHG   0x02                    /* Changed since last write     */
                    255: #define        BFERROR 0x04                    /* Error file buffer            */
                    256: #define        BFNOWRT 0x08                    /* Don't write this buffer      */
                    257: #define        BFBACKP 0x10                    /* Rename file before write     */
                    258: #define        BFWRITE 0x20                    /* Written since read           */
                    259: #define        BFTRUNC 0x40                    /* File truncated               */
                    260: #define        BFHELP  0x80                    /* Buffer is a help buffer      */
                    261: 
                    262: /*
                    263:  * The starting position of a
                    264:  * region, and the size of the region in
                    265:  * characters, is kept in a region structure.
                    266:  * Used by the region commands.
                    267:  */
                    268: typedef        struct  {
                    269:        struct  LINE *r_linep;          /* Origin LINE address.         */
                    270:        short   r_offset;               /* Origin LINE offset.          */
                    271:        short   r_size;                 /* Length in characters.        */
                    272: }      REGION;
                    273: 
                    274: /*
                    275:  * All text is kept in circularly linked
                    276:  * lists of "LINE" structures. These begin at the
                    277:  * header line (which is the blank line beyond the
                    278:  * end of the buffer). This line is pointed to by
                    279:  * the "BUFFER". Each line contains a the number of
                    280:  * bytes in the line (the "used" size), the size
                    281:  * of the text array, and the text. The end of line
                    282:  * is not stored as a byte; its implied. Future
                    283:  * additions will include update hints, and a
                    284:  * list of marks into the line.
                    285:  */
                    286: typedef        struct  LINE {
                    287:        struct  LINE *l_fp;             /* Link to the next line        */
                    288:        struct  LINE *l_bp;             /* Link to the previous line    */
                    289:        short   l_size;                 /* Allocated size               */
                    290:        short   l_used;                 /* Used size                    */
                    291:        long    l_lnumber;              /* Line number in original file */
                    292:        uchar   l_text[];               /* A bunch of characters.       */
                    293: }      LINE;
                    294: 
                    295: #define        lforw(lp)       ((lp)->l_fp)
                    296: #define        lback(lp)       ((lp)->l_bp)
                    297: #define        lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
                    298: #define        lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
                    299: #define        llength(lp)     ((lp)->l_used)
                    300: #define        l_number(lp)    ((lp)->l_lnumber)
                    301: /*
                    302:  * The editor communicates with the display
                    303:  * using a high level interface. A "TERM" structure
                    304:  * holds useful variables, and indirect pointers to
                    305:  * routines that do useful operations. The low level get
                    306:  * and put routines are here too. This lets a terminal,
                    307:  * in addition to having non standard commands, have
                    308:  * funny get and put character code too. The calls
                    309:  * might get changed to "termp->t_field" style in
                    310:  * the future, to make it possible to run more than
                    311:  * one terminal type.
                    312:  */  
                    313: typedef        struct  {
                    314:        short   t_nrow;                 /* Number of rows.              */
                    315:        short   t_ncol;                 /* Number of columns.           */
                    316:        int     (*t_open)();            /* Open terminal at the start.  */
                    317:        int     (*t_close)();           /* Close terminal at end.       */
                    318:        int     (*t_getchar)();         /* Get character from keyboard. */
                    319:        int     (*t_putchar)();         /* Put character to display.    */
                    320:        int     (*t_flush)();           /* Flush output buffers.        */
                    321:        int     (*t_move)();            /* Move the cursor, origin 0.   */
                    322:        int     (*t_eeol)();            /* Erase to end of line.        */
                    323:        int     (*t_eeop)();            /* Clear screen                 */
                    324:        int     (*t_beep)();            /* Beep.                        */
                    325:        int     (*t_stand)();           /* Standout mode.               */
                    326: }      TERM;
                    327: 
                    328: /* Shorthand for terminal routines...  */
                    329: #define        tputc(X)        (*term.t_putchar)(X)    /* Put a character      */
                    330: #define        tgetc           (*term.t_getchar)       /* Get a character      */
                    331: #define        tbeep           (*term.t_beep)          /* Beep the bell        */
                    332: #define        tstand(X)       (*term.t_stand)(X)      /* Standout mode        */
                    333: #define        topen           (*term.t_open)          /* Open the terminal    */
                    334: #define        tclose          (*term.t_close)         /* Close the terminal   */
                    335: #define        tmove(X,Y)      (*term.t_move)((X),(Y)) /* Move cursor          */
                    336: #define        teeol           (*term.t_eeol)          /* Erase to end of line */
                    337: #define        teeop           (*term.t_eeop)          /* Clear screen         */
                    338: #define        tflush          (*term.t_flush)         /* Flush output buff    */
                    339: 
                    340: /* Command line switch flags -- set in runswitch       */
                    341: #define        CF_ERROR        (0x0001)        /* Error edit switch specified  */
                    342: #define        CF_WARN         (0x0004)        /* Warn user before overwrite   */
                    343: #define CF_GRABMEM     (0x0008)        /* GEM grab memory              */
                    344: #define        CF_VLONG        (0x2000)        /* Very long screen flag        */
                    345: #define        CF_LONGSCR      (0x4000)        /* Long screen flag             */
                    346: #define        CF_DEBUG        (0x8000)        /* Debugging flag               */
                    347: 
                    348: #define taber(c) ((c) += ((bind.tabsiz - (c % bind.tabsiz)) - 1))
                    349: 
                    350: extern unsigned int runswitch;         /* Switch flags                 */
                    351: 
                    352: extern int     currow;                 /* Cursor row                   */
                    353: extern int     curcol;                 /* Cursor column                */
                    354: extern int     thisflag;               /* Flags, this command          */
                    355: extern int     lastflag;               /* Flags, last command          */
                    356: extern int     curgoal;                /* Goal for C-P, C-N            */
                    357: extern int     mpresf;                 /* Stuff in message line        */
                    358: extern int     sgarbf;                 /* State of screen unknown      */
                    359: extern WINDOW  *curwp;                 /* Current window               */
                    360: extern BUFFER  *curbp;                 /* Current buffer               */
                    361: extern WINDOW  *wheadp;                /* Head of list of windows      */
                    362: extern BUFFER  *bheadp;                /* Head of list of buffers      */
                    363: extern BUFFER  *blistp;                /* Buffer for C-X C-B           */
                    364: #if    LIBHELP
                    365: extern BUFFER  *helpbp;                /* Buffer for help              */
                    366: #endif
                    367: extern BUFFER  *errbp;                 /* Error file buffer            */
                    368: extern short   *kbdm;                  /* Holds kayboard macro data    */
                    369: extern short   *kbdmip;                /* Input pointer for above      */
                    370: extern short   *kbdmop;                /* Output pointer for above     */
                    371: extern uchar   pat[];                  /* Search pattern               */
                    372: extern TERM    term;                   /* Terminal information.        */
                    373: extern uchar   *ufiles[];              /* command-line specified files */
                    374: extern uchar   errfile[];              /* error file name              */
                    375: #if    LIBHELP
                    376: extern uchar   hfname[];               /* Help file name buffer        */
                    377: extern uchar   hiname[];               /* Help index name buffer       */
                    378: extern uchar   *helpfile;              /* Help file name               */
                    379: extern uchar   *helpindex;             /* Help index file name         */
                    380: #endif
                    381: extern BUFFER  *bfind();               /* Lookup a buffer by name      */
                    382: extern WINDOW  *wpopup();              /* Pop up window creation       */
                    383: extern LINE    *lalloc();              /* Allocate a line              */
                    384: 
                    385: extern KEYTAB keytab[];
                    386: extern FUNTAB funtab[];
                    387: 
                    388: /* A major optimization for native GEMDOS situations...        */
                    389: #if    GEM && NATIVE
                    390: #undef tputc
                    391: extern long    bios();
                    392: #define        tputc(X)        bios(3, 2, (X)) /* Faster output                */
                    393: #endif

unix.superglobalmegacorp.com

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