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