home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / newemacs / ed.h < prev    next >
C/C++ Source or Header  |  1986-03-04  |  7KB  |  163 lines

  1. /*
  2.  * This file is the general header file for
  3.  * all parts of the MicroEMACS display editor. It contains
  4.  * definitions used by everyone, and it contains the stuff
  5.  * you have to edit to create a version of the editor for
  6.  * a specific operating system and terminal.
  7.  */
  8.  
  9. #define    NROW    24            /* Screen size.            */
  10. #define    NCOL    80            /* Edit if you want to.        */
  11. #define    BEL    0x07            /* BEL character.        */
  12.  
  13. #define    CVMVAS    1            /* C-V, M-V arg. in screens.    */
  14.  
  15. #define    NFILEN    80            /* # of bytes, file name    */
  16. #define    NBUFN    16            /* # of bytes, buffer name    */
  17. #define    NLINE    256            /* # of bytes, line        */
  18. #define    NKBDM    256            /* # of strokes, keyboard macro    */
  19. #define    NPAT    80            /* # of bytes, pattern        */
  20. #define    HUGE    1000            /* Huge number            */
  21.  
  22. #define    METACH    0x1B            /* M- prefix,   Control-[, ESC    */
  23. #define    CTMECH    0x1C            /* C-M- prefix, Control-\    */
  24. #define    EXITCH    0x1D            /* Exit level,  Control-]    */
  25. #define    CTRLCH    0x1E            /* C- prefix,    Control-^    */
  26. #define    HELPCH    0x1F            /* Help key,    Control-_    */
  27.  
  28. #define    CTRL    0x0100            /* Control flag, or'ed in    */
  29. #define    META    0x0200            /* Meta flag, or'ed in        */
  30. #define    CTLX    0x0400            /* ^X flag, or'ed in        */
  31. #define EXTKY   0x0800                  /* extended key flad or'ed in   */
  32.                                         /* for IBM PC's and clones      */
  33.  
  34.  
  35. #define    FALSE    0            /* False, no, bad, etc.        */
  36. #define    TRUE    1            /* True, yes, good, etc.    */
  37. #define    ABORT    2            /* Death, ^G, abort, etc.    */
  38.  
  39. #define    FIOSUC    0            /* File I/O, success.        */
  40. #define    FIOFNF    1            /* File I/O, file not found.    */
  41. #define    FIOEOF    2            /* File I/O, end of file.    */
  42. #define    FIOERR    3            /* File I/O, error.        */
  43.  
  44. #define    CFCPCN    0x0001            /* Last command was C-P, C-N    */
  45. #define    CFKILL    0x0002            /* Last command was a kill    */
  46.  
  47. /*
  48.  * There is a window structure allocated for
  49.  * every active display window. The windows are kept in a
  50.  * big list, in top to bottom screen order, with the listhead at
  51.  * "wheadp". Each window contains its own values of dot and mark.
  52.  * The flag field contains some bits that are set by commands
  53.  * to guide redisplay; although this is a bit of a compromise in
  54.  * terms of decoupling, the full blown redisplay is just too
  55.  * expensive to run for every input character. 
  56.  */
  57. typedef    struct    WINDOW {
  58.     struct    WINDOW *w_wndp;        /* Next window            */
  59.     struct    BUFFER *w_bufp;        /* Buffer displayed in window    */
  60.     struct    LINE *w_linep;        /* Top line in the window    */
  61.     struct    LINE *w_dotp;        /* Line containing "."        */
  62.     short    w_doto;            /* Byte offset for "."        */
  63.     struct    LINE *w_markp;        /* Line containing "mark"    */
  64.     short    w_marko;        /* Byte offset for "mark"    */
  65.     char    w_toprow;        /* Origin 0 top row of window    */
  66.     char    w_ntrows;        /* # of rows of text in window    */
  67.     char    w_force;        /* If NZ, forcing row.        */
  68.     char    w_flag;            /* Flags.            */
  69. }    WINDOW;
  70.  
  71. #define    WFFORCE    0x01            /* Window needs forced reframe    */
  72. #define    WFMOVE    0x02            /* Movement from line to line    */
  73. #define    WFEDIT    0x04            /* Editing within a line    */
  74. #define    WFHARD    0x08            /* Better to a full display    */
  75. #define    WFMODE    0x10            /* Update mode line.        */
  76.  
  77. /*
  78.  * Text is kept in buffers. A buffer header, described
  79.  * below, exists for every buffer in the system. The buffers are
  80.  * kept in a big list, so that commands that search for a buffer by
  81.  * name can find the buffer header. There is a safe store for the
  82.  * dot and mark in the header, but this is only valid if the buffer
  83.  * is not being displayed (that is, if "b_nwnd" is 0). The text for
  84.  * the buffer is kept in a circularly linked list of lines, with
  85.  * a pointer to the header line in "b_linep".
  86.  */
  87. typedef    struct    BUFFER {
  88.     struct    BUFFER *b_bufp;        /* Link to next BUFFER        */
  89.     struct    LINE *b_dotp;        /* Link to "." LINE structure    */
  90.     short    b_doto;            /* Offset of "." in above LINE    */
  91.     struct    LINE *b_markp;        /* The same as the above two,    */
  92.     short    b_marko;        /* but for the "mark"        */
  93.     struct    LINE *b_linep;        /* Link to the header LINE    */
  94.     char    b_nwnd;            /* Count of windows on buffer    */
  95.     char    b_flag;            /* Flags            */
  96.     char    b_fname[NFILEN];    /* File name            */
  97.     char    b_bname[NBUFN];        /* Buffer name            */
  98. }    BUFFER;
  99.  
  100. #define    BFTEMP    0x01            /* Internal temporary buffer    */
  101. #define    BFCHG    0x02            /* Changed since last write    */
  102. #define BFOVRWRITE 0x10                 /* in overwrite mode            */
  103.  
  104. /*
  105.  * The starting position of a
  106.  * region, and the size of the region in
  107.  * characters, is kept in a region structure.
  108.  * Used by the region commands.
  109.  */
  110. typedef    struct    {
  111.     struct    LINE *r_linep;        /* Origin LINE address.        */
  112.     short    r_offset;        /* Origin LINE offset.        */
  113.     short    r_size;            /* Length in characters.    */
  114. }    REGION;
  115.  
  116. /*
  117.  * All text is kept in circularly linked
  118.  * lists of "LINE" structures. These begin at the
  119.  * header line (which is the blank line beyond the
  120.  * end of the buffer). This line is pointed to by
  121.  * the "BUFFER". Each line contains a the number of
  122.  * bytes in the line (the "used" size), the size
  123.  * of the text array, and the text. The end of line
  124.  * is not stored as a byte; it's implied. Future
  125.  * additions will include update hints, and a
  126.  * list of marks into the line.
  127.  */
  128. typedef    struct    LINE {
  129.     struct    LINE *l_fp;        /* Link to the next line    */
  130.     struct    LINE *l_bp;        /* Link to the previous line    */
  131.     short    l_size;            /* Allocated size        */
  132.     short    l_used;            /* Used size            */
  133.     char    l_text[1];        /* A bunch of characters.    */
  134. }    LINE;
  135.  
  136. #define    lforw(lp)    ((lp)->l_fp)
  137. #define    lback(lp)    ((lp)->l_bp)
  138. #define    lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  139. #define    lputc(lp, n, c)    ((lp)->l_text[(n)]=(c))
  140. #define    llength(lp)    ((lp)->l_used)
  141.  
  142. extern    int    fillcol;        /* Fill column            */
  143. extern    int    currow;            /* Cursor row            */
  144. extern    int    curcol;            /* Cursor column        */
  145. extern    int    thisflag;        /* Flags, this command        */
  146. extern    int    lastflag;        /* Flags, last command        */
  147. extern    int    curgoal;        /* Goal for C-P, C-N        */
  148. extern    int    mpresf;            /* Stuff in message line    */
  149. extern    int    sgarbf;            /* State of screen unknown    */
  150. extern    WINDOW    *curwp;            /* Current window        */
  151. extern    BUFFER    *curbp;            /* Current buffer        */
  152. extern    WINDOW    *wheadp;        /* Head of list of windows    */
  153. extern    BUFFER    *bheadp;        /* Head of list of buffers    */
  154. extern    BUFFER    *blistp;        /* Buffer for C-X C-B        */
  155. extern    short    kbdm[];            /* Holds kayboard macro data    */
  156. extern    short    *kbdmip;        /* Input pointer for above    */
  157. extern    short    *kbdmop;        /* Output pointer for above    */
  158. extern    char    pat[];            /* Search pattern        */
  159.  
  160. extern    BUFFER    *bfind();        /* Lookup a buffer by name    */
  161. extern    WINDOW    *wpopup();        /* Pop up window creation    */
  162. extern    LINE    *lalloc();        /* Allocate a line        */
  163.