home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / EDITOR / TDE120.ZIP / TDESTR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-05  |  11.1 KB  |  287 lines

  1. /*
  2.  * New editor name:  tde, the Thomson-Davis Editor.
  3.  * Author:           Frank Davis
  4.  * Date:             June 5, 1991
  5.  *
  6.  * This modification of Douglas Thomson's code is released into the
  7.  * public domain, Frank Davis.  You may distribute it freely.
  8.  *
  9.  * This file contains all the structure declarations and defines common
  10.  *  to all the editor modules.
  11.  */
  12.  
  13. #define MAX_KEYS           206
  14.  
  15. #define MAX_COLS            80  /* widest screen ever used */
  16. #define MAX_LINES           24  /* highest screen ever used */
  17. #define BUFF_SIZE          256  /* buffer size for lines */
  18. #define MAX_LINE_LENGTH    255  /* longest line allowed in file */
  19. #define UNDO_MAX            12  /* maximum number of lines in undo buffer */
  20.  
  21. #define ERROR           (-1)          /* abnormal termination */
  22. #define OK              0             /* normal termination */
  23. #define TRUE            1             /* logical true */
  24. #define FALSE           0             /* logical false */
  25.  
  26. #define RTURN           262           /* Return key = 262 */
  27. #define CONTROL_Z       26            /* Control z  = 26 or DOS eof character */
  28. #define ESC             258           /* Escape key = 258 */
  29.  
  30. /*
  31.  * The following defines are used by the "error" function, to indicate
  32.  *  how serious the error is.
  33.  */
  34. #define WARNING 1               /* user must acknowledge, editor continues */
  35. #define FATAL   2               /* editor aborts - very rare! */
  36.  
  37. /*
  38.  * define the type of block marked by user
  39.  */
  40. #define NOTMARKED  0            /* block type undefined */
  41. #define BOX        1            /* block marked by row and column */
  42. #define LINE       2            /* block marked by begin and end lines */
  43.  
  44. #define MOVE       1
  45. #define DELETE     2
  46. #define COPY       3
  47. #define KOPY       4
  48. #define FILL       5
  49. #define OVERLAY    6
  50.  
  51. #define LOCAL      1
  52. #define NOT_LOCAL  2
  53. #define GLOBAL     3
  54.  
  55. #define IGNORE     1
  56. #define MATCH      2
  57.  
  58. #define PROMPT     1
  59. #define NOPROMPT   2
  60.  
  61. #define FORWARD    1
  62. #define BACKWARD   2
  63.  
  64. #define BEGIN      1
  65. #define END        2
  66.  
  67. #define EXIST       0
  68. #define WRITE       2
  69. #define READ        4
  70. #define READ_WRITE  6
  71.  
  72. /*
  73.  * possible answers to various questions - see get_yn, get_ynaq and get_oa
  74.  */
  75. #define A_YES       1
  76. #define A_NO        2
  77. #define A_ALWAYS    3
  78. #define A_QUIT      4
  79. #define A_ABORT     5
  80. #define A_OVERWRITE 6
  81. #define A_APPEND    7
  82.  
  83. /*
  84.  * The following defines specify which video attributes give desired
  85.  *  effects on different display devices.
  86.  * REVERSE is supposed to be reverse video - a different background color,
  87.  *  so that even a blank space can be identified.
  88.  * HIGH is supposed to quickly draw the user's eye to the relevant part of
  89.  *  the screen, either for a message or for matched text in find/replace.
  90.  * NORMAL is supposed to be something pleasant to look at for the main
  91.  *  body of the text.
  92.  * These defines may not be optimal for all types of display. Eventually
  93.  *  the user should be allowed to select which attribute is used where.
  94.  */
  95. #define VIDEO_INT      0x10
  96.  
  97. #define HERC_REVERSE   0x70
  98. #define HERC_UNDER     0x01
  99. #define HERC_NORMAL    0x07
  100. #define HERC_HIGH      0x0F
  101.  
  102. #define COLOR_HEAD     0x4b
  103. #define COLOR_TEXT     0x07
  104. #define COLOR_MODE     0x17
  105. #define COLOR_BLOCK    0x7f
  106. #define COLOR_MESSAGE  0x0f
  107. #define COLOR_HELP     0x1A
  108. #define COLOR_DIAG     0x1A
  109. #define COLOR_EOF      0x09
  110.  
  111. #define COLOR_80       3
  112. #define MONO_80        7
  113.  
  114. #define VGA             3
  115. #define EGA             2
  116. #define CGA             1
  117. #define MDA             0
  118.  
  119. /*
  120.  * Some systems (like the PC) require a special kind of pointer for
  121.  *  arrays or structures larger than 64K.  For Microsoft C compilers, I handle
  122.  *  the special pointer arithmetic internally.  See the functions in tdeasm.c
  123.  *  for those special pointer routines.
  124.  */
  125. #ifdef __TURBOC__
  126.    typedef char huge *text_ptr;
  127. #elif __MSC__
  128.    typedef char far * text_ptr;
  129. #else
  130.    typedef char *text_ptr;
  131. #endif
  132.  
  133. struct vcfg {
  134.    int color;
  135.    int rescan;
  136.    int mode;
  137.    int far *videomem;
  138. };
  139.  
  140.  
  141. typedef struct {
  142.    int  pattern_length;
  143.    int  search_case;
  144.    int  search_defined;
  145.    unsigned char pattern[MAX_COLS];
  146.    char skip_forward[256];
  147.    char skip_backward[256];
  148. } boyer_moore_type;
  149.  
  150.  
  151. /*
  152.  * "mode_infos" contain the editor mode variables.  The configuration
  153.  *  utility modifies this structure to custimize the start-up tde
  154.  *  configuration
  155.  */
  156. typedef struct {
  157.    int color_scheme;            /* color to start out with */
  158.    int insert;                  /* in insert mode? */
  159.    int indent;                  /* in auto-indent mode? */
  160.    int tab_size;                /* characters between tab stops */
  161.    int backup;                  /* copy file to .bak? */
  162.    int sdel;                    /* stream delete mode */
  163.    int enh_kbd;                 /* type of keyboard */
  164.    char *eof;                   /* message to display at end of file */
  165. } mode_infos;
  166.  
  167.  
  168. /*
  169.  * "displays" contain all the status information about what attributes are
  170.  *  used for what purposes, which attribute is currently set, and so on.
  171.  * The editor only knows about one physical screen.
  172.  */
  173. typedef struct {
  174.     int line;                   /* actual line cursor currently on */
  175.     int col;                    /* actual column cursor currently in */
  176.     int nlines;                 /* lines on display device */
  177.     int ncols;                  /* columns on display device */
  178.     int line_length;            /* length of longest line */
  179.     int mode_line;              /* line to display editor modes - fmd */
  180.     int head_color;             /* file header color */
  181.     int text_color;             /* text area color */
  182.     int mode_color;             /* mode line color - footer */
  183.     int block_color;            /* hilited area of blocked region */
  184.     int message_color;          /* color of editor messages */
  185.     int help_color;             /* color of help screen */
  186.     int diag_color;             /* color for diagnostics in mode line */
  187.     int eof_color;              /* color for end of file line */
  188.     int adapter;                /* VGA, EGA, CGA, or MDA? */
  189.     unsigned int overw_cursor;  /* hi part = top scan line, lo part = bottom */
  190.     unsigned int insert_cursor; /* hi part = top scan line, lo part = bottom */
  191.     char far *display_address;  /* address of display memory */
  192. } displays;
  193.  
  194. /*
  195.  * "status_infos" contain all the editor status information that is
  196.  *  global to the entire editor (i.e. not dependent on the file or
  197.  *  window)
  198.  */
  199. typedef struct {
  200.     struct s_windows *current_window;  /* current active window */
  201.     struct s_file_infos *current_file; /* current active file */
  202.     struct s_file_infos *file_list; /* all active files */
  203.     struct s_windows *window_list; /* all active windows */
  204.     int  window_count;           /* number of windows - displayed and hidden */
  205.     int  file_count;             /* number of files currently open */
  206.     int  next_file_number;      /* number to assign next open file */
  207.     text_ptr start_mem;         /* first char in main text buffer */
  208.     text_ptr end_mem;           /* last char in main text buffer used+1 */
  209.     text_ptr temp_end;          /* temporary end_mem marker */
  210.     text_ptr max_mem;           /* last char available for storage (+1) */
  211.     int  marked;                 /* has block been marked? */
  212.     int  prompt_line;            /* line to display cursor */
  213.     int  prompt_col;             /* column to display cursor */
  214.     struct s_windows *marked_window;   /* pointer to window with marked block */
  215.     struct s_file_infos *marked_file;  /* pointer to file w/ marked block */
  216.     char rw_name[MAX_COLS];      /* name of last file read or written */
  217.     char pattern[MAX_COLS];      /* last search pattern */
  218.     char subst[MAX_COLS];        /* last substitute text */
  219.     int  replace_flag;           /* prompt or noprompt b4 replacing */
  220.     int  overlap;                /* overlap between pages for page up etc */
  221.     text_ptr buff_line;          /* address of line in line_buff */
  222.     int  copied;                 /* has line been copied to file? */
  223.     char line_buff[BUFF_SIZE+2]; /* for currently edited line */
  224.     int  command;                /* function of key just entered */
  225.     int  key_pressed;
  226.     int  stop;                   /* stop indicator */
  227.     int  undo_head;                        /* pointer to last line in buffer */
  228.     char undo_buffer[UNDO_MAX][BUFF_SIZE]; /* room for last 12 changed lines */
  229. } status_infos;
  230.  
  231. /*
  232.  * "file_infos" contain all the information unique to a given file
  233.  */
  234. typedef struct s_file_infos {
  235.     text_ptr start_text;        /* first char in file */
  236.     text_ptr end_text;          /* last char in file (+1) */
  237.     long length;                /* number of lines in file */
  238.     int modified;               /* file has been modified since save? */
  239.     int dirty;                  /* file in window modified? */
  240.     int new_file;               /* is current file new? */
  241.     char file_name[MAX_COLS];   /* name of current file being edited */
  242.     int block_type;             /* block type - line or box */
  243.     text_ptr block_start;       /* beginning block position */
  244.     text_ptr block_end;         /* ending block position */
  245.     int  block_bc;              /* beginning column */
  246.     long block_br;              /* beginning row */
  247.     int  block_ec;              /* ending column */
  248.     long block_er;              /* ending row */
  249.     int  file_no;               /* file number */
  250.     int  ref_count;             /* no. of windows referring to file */
  251.     int  next_window_letter;    /* letter to assign to next window */
  252.     int  file_attrib;           /* file attributes (rwx etc) */
  253.     struct s_file_infos *next;  /* next file in doubly linked list */
  254.     struct s_file_infos *prev;  /* previous file in doubly linked list */
  255. } file_infos;
  256.  
  257. /*
  258.  * "windows" contain all the information that is unique to a given
  259.  *  window.
  260.  */
  261. typedef struct s_windows {
  262.     file_infos *file_info;      /* file in window */
  263.     text_ptr cursor;            /* start of line containing cursor */
  264.     int ccol;                   /* column cursor logically in */
  265.     int rcol;                   /* column cursor actually in */
  266.     int bcol;                   /* base column to start display */
  267.     int cline;                  /* line cursor logically in */
  268.     long rline;                 /* real line cursor in */
  269.     int top_line;               /* top line in window */
  270.     int bottom_line;            /* bottom line in window */
  271.     int page;                   /* no. of lines to scroll for one page */
  272.     int visible;                /* window hidden or visible */
  273.     int letter;                 /* window letter */
  274.     struct s_windows *next;     /* next window in doubly linked list */
  275.     struct s_windows *prev;     /* previous window in doubly linked list */
  276. } windows;
  277.  
  278. /*
  279.  *  Use a dispatch array-structure to determine function of key pressed
  280.  *  by user.  Initialize it in "default.h".  Read in a configuration
  281.  *  file to change the key functions as desired by user, coming soon. ;*)
  282.  */
  283.  
  284. typedef struct {
  285.    unsigned char func;
  286. } DISPATCH_TABLE;
  287.