home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / editors / tde150.arj / TDESTR.H < prev    next >
C/C++ Source or Header  |  1992-04-01  |  19KB  |  485 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 define's and structure declarations common to all
  10.  * editor modules.  It should be included in every source code module.
  11.  */
  12.  
  13. #define MAX_KEYS           256
  14. #define STROKE_LIMIT      1024  /* number of key strokes in playback buffer */
  15.  
  16. #define MAX_COLS            80  /* widest screen ever used */
  17. #define MAX_LINES           24  /* highest screen ever used */
  18. #define BUFF_SIZE          256  /* buffer size for lines */
  19. #define MAX_LINE_LENGTH    255  /* longest line allowed in file */
  20. #define UNDO_MAX            20  /* maximum number of lines in undo buffer */
  21. #define FNAME_LENGTH        45  /* maximum file name length */
  22. #define NO_MARKERS           3  /* maximum no. of markers */
  23.  
  24. /*
  25.  * general defines.
  26.  */
  27. #define ERROR           (-1)          /* abnormal termination */
  28. #define OK              0             /* normal termination */
  29. #define TRUE            1             /* logical true */
  30. #define FALSE           0             /* logical false */
  31.  
  32. /*
  33.  * special cases for keyboard mapping -  see bottom of main.c
  34.  */
  35. #define RTURN           262           /* Return key = 262 */
  36. #define CONTROL_Z       26            /* Control z  = 26 or DOS eof character */
  37. #define ESC             258           /* Escape key = 258 */
  38.  
  39. /*
  40.  * The following defines are used by the "error" function, to indicate
  41.  *  how serious the error is.
  42.  */
  43. #define WARNING         1    /* user must acknowledge, editor continues */
  44. #define FATAL           2    /* editor aborts - very rare! */
  45. #define INFO            3    /* display message, acknowledge, continue */
  46.  
  47. /*
  48.  * define the type of block marked by user
  49.  */
  50. #define NOTMARKED       0    /* block type undefined */
  51. #define BOX             1    /* block marked by row and column */
  52. #define LINE            2    /* block marked by begin and end lines */
  53. #define STREAM          3    /* block marked by begin and end characters */
  54.  
  55. #define MOVE            1
  56. #define DELETE          2
  57. #define COPY            3
  58. #define KOPY            4
  59. #define FILL            5
  60. #define OVERLAY         6
  61. #define NUMBER          7
  62.  
  63. #define LEFT            1
  64. #define RIGHT           2
  65.  
  66.  
  67. /*
  68.  * three types of ways to update windows
  69.  */
  70. #define LOCAL           1
  71. #define NOT_LOCAL       2
  72. #define GLOBAL          3
  73.  
  74. #define CURLINE         1
  75. #define NOTCURLINE      2
  76.  
  77. /*
  78.  * search/replace flags.
  79.  */
  80. #define CLR_SEARCH      0
  81. #define WRAPPED         1
  82. #define SEARCHING       2
  83.  
  84. #define IGNORE          1
  85. #define MATCH           2
  86.  
  87. #define PROMPT          1
  88. #define NOPROMPT        2
  89.  
  90. #define FORWARD         1
  91. #define BACKWARD        2
  92.  
  93. #define BEGIN           1
  94. #define END             2
  95.  
  96. /*
  97.  * used in interrupt 0x21 function xx for checking file status
  98.  */
  99. #define EXIST           0
  100. #define WRITE           2
  101. #define READ            4
  102. #define READ_WRITE      6
  103.  
  104. #define NORMAL          0x00
  105. #define READ_ONLY       0x01
  106. #define HIDDEN          0x02
  107. #define SYSTEM          0x04
  108. #define VOLUME_LABEL    0x08
  109. #define SUBDIRECTORY    0x10
  110. #define ARCHIVE         0x20
  111.  
  112. /*
  113.  * critical error def's
  114.  */
  115. #define RETRY           1
  116. #define FAIL            3
  117.  
  118.  
  119. /*
  120.  * flags used for opening files to write either in binary or text mode.
  121.  * crlf is for opening files in text mode - Operating System converts
  122.  * lf to crlf automatically.  in binary mode, lf is not translated.
  123.  */
  124. #define CRLF            1
  125. #define LF              2
  126.  
  127.  
  128. /*
  129.  * character used in tdeasm.c to display the eol
  130.  */
  131. #define EOL_CHAR        0x11
  132. #define RULER_CHAR      0x19
  133.  
  134.  
  135. /*
  136.  * character used two separate vertical screens
  137.  */
  138. #define VERTICAL_CHAR   0xba
  139.  
  140.  
  141. /*
  142.  * cursor size
  143.  */
  144. #define SMALL_INS       0
  145. #define BIG_INS         1
  146.  
  147.  
  148. /*
  149.  * possible answers to various questions - see get_yn, get_ynaq and get_oa
  150.  */
  151. #define A_YES           1
  152. #define A_NO            2
  153. #define A_ALWAYS        3
  154. #define A_QUIT          4
  155. #define A_ABORT         5
  156. #define A_OVERWRITE     6
  157. #define A_APPEND        7
  158.  
  159. /*
  160.  * The following defines specify which video attributes give desired
  161.  *  effects on different display devices.
  162.  * REVERSE is supposed to be reverse video - a different background color,
  163.  *  so that even a blank space can be identified.
  164.  * HIGH is supposed to quickly draw the user's eye to the relevant part of
  165.  *  the screen, either for a message or for matched text in find/replace.
  166.  * NORMAL is supposed to be something pleasant to look at for the main
  167.  *  body of the text.
  168.  * These defines may not be optimal for all types of display. Eventually
  169.  *  the user should be allowed to select which attribute is used where.
  170.  */
  171. #define VIDEO_INT       0x10
  172.  
  173. #define HERC_REVERSE    0x70
  174. #define HERC_UNDER      0x01
  175. #define HERC_NORMAL     0x07
  176. #define HERC_HIGH       0x0f
  177.  
  178. #define COLOR_HEAD      0x4b
  179. #define COLOR_TEXT      0x07
  180. #define COLOR_MODE      0x17
  181. #define COLOR_BLOCK     0x71
  182. #define COLOR_MESSAGE   0x0f
  183. #define COLOR_HELP      0x1a
  184. #define COLOR_DIAG      0x0e
  185. #define COLOR_EOF       0x09
  186. #define COLOR_CURL      0x0f
  187. #define COLOR_RULER     0x02
  188. #define COLOR_POINTER   0x0a
  189.  
  190. #define COLOR_80        3
  191. #define MONO_80         7
  192.  
  193. #define VGA             3
  194. #define EGA             2
  195. #define CGA             1
  196. #define MDA             0
  197.  
  198. /*
  199.  * Some systems (like the PC) require a special kind of pointer for
  200.  *  arrays or structures larger than 64K.  For Microsoft C compilers, I handle
  201.  *  the special pointer arithmetic internally.  See the functions in tdeasm.c
  202.  *  for those special pointer routines.
  203.  */
  204. #ifdef __TURBOC__
  205.    typedef char huge *text_ptr;
  206. #elif __MSC__
  207.    typedef char far * text_ptr;
  208. #else
  209.    typedef char *text_ptr;
  210. #endif
  211.  
  212.  
  213. struct vcfg {
  214.    int color;
  215.    int rescan;
  216.    int mode;
  217.    int far *videomem;
  218. };
  219.  
  220.  
  221. /*
  222.  * structure used in directory list.
  223.  */
  224. typedef struct {
  225.    char fname[14];              /* file name */
  226.    long fsize;                  /* file size in bytes */
  227. } FTYPE;
  228.  
  229.  
  230. /*
  231.  * stuff we need to know about how to display a directory listing.
  232.  */
  233. typedef struct {
  234.    int  row;                    /* absolute row to display dir box */
  235.    int  col;                    /* absolute column to display dir box */
  236.    int  wid;                    /* absolute number of columns in dir box */
  237.    int  hgt;                    /* absolute number of rows in dir box */
  238.    int  max_cols;               /* number of columns of files in box */
  239.    int  max_lines;              /* number of lines of files in box */
  240.    int  cnt;                    /* file count */
  241.    int  cols;                   /* logical number of columns in list */
  242.    int  lines;                  /* logical number of rows in list */
  243.    int  prow;                   /* logical number of rows in partial row */
  244.    int  vcols;                  /* number of virtual columns, if any */
  245.    int  nfiles;                 /* number of files on screen */
  246.    int  avail;                  /* number of available slots for files */
  247.    int  select;                 /* current file under cursor */
  248.    int  flist_col[5];           /* offset from col to display each column */
  249. } DIRECTORY;
  250.  
  251.  
  252. typedef struct {
  253.    int  pattern_length;                 /* number of chars in pattern */
  254.    int  search_case;                    /* ignore or match? */
  255.    int  search_defined;                 /* search pattern defined? */
  256.    unsigned char pattern[MAX_COLS];     /* search pattern */
  257.    char skip_forward[256];              /* boyer array for forward searches */
  258.    char skip_backward[256];             /* boyer array for back searches */
  259. } boyer_moore_type;
  260.  
  261.  
  262. /*
  263.  * "mode_infos" contain the editor mode variables.  The configuration
  264.  *  utility modifies this structure to custimize the start-up tde
  265.  *  configuration
  266.  */
  267. typedef struct {
  268.    int  color_scheme;           /* color to start out with */
  269.    int  sync;                   /* sync the cursor movement command? */
  270.    int  sync_sem;               /* sync the cursor movement command? */
  271.    int  record;                 /* are we recording keystrokes? */
  272.    int  insert;                 /* in insert mode? */
  273.    int  indent;                 /* in auto-indent mode? */
  274.    int  tab_size;               /* characters between tab stops */
  275.    int  backup;                 /* copy file to .bak? */
  276.    int  enh_kbd;                /* type of keyboard */
  277.    int  cursor_size;            /* insert cursor big or small? */
  278.    char *eof;                   /* message to display at end of file */
  279.    int  control_z;              /* write ^Z - t or f */
  280.    int  crlf;                   /* <cr><lf> toggle CRLF or LF */
  281.    int  trailing;               /* remove trailing space? T or F */
  282.    int  show_eol;               /* show lf at eol? T or F */
  283.    int  word_wrap;              /* in word wrap mode? */
  284.    int  left_margin;            /* left margin */
  285.    int  parg_margin;            /* column for 1st word in paragraph */
  286.    int  right_margin;           /* right margin */
  287.    int  do_backups;             /* create backup or ".bak" files? T or F */
  288.    int  ruler;                  /* show ruler at top of window? T or F */
  289. } mode_infos;
  290.  
  291.  
  292. /*
  293.  * "displays" contain all the status information about what attributes are
  294.  *  used for what purposes, which attribute is currently set, and so on.
  295.  * The editor only knows about one physical screen.
  296.  */
  297. typedef struct {
  298.    int line;                    /* actual line cursor currently on */
  299.    int col;                     /* actual column cursor currently in */
  300.    int nlines;                  /* lines on display device */
  301.    int ncols;                   /* columns on display device */
  302.    int line_length;             /* length of longest line */
  303.    int mode_line;               /* line to display editor modes - fmd */
  304.    int head_color;              /* file header color */
  305.    int text_color;              /* text area color */
  306.    int mode_color;              /* mode line color - footer */
  307.    int block_color;             /* hilited area of blocked region */
  308.    int message_color;           /* color of editor messages */
  309.    int help_color;              /* color of help screen */
  310.    int diag_color;              /* color for diagnostics in mode line */
  311.    int eof_color;               /* color for end of file line */
  312.    int curl_color;              /* color of cursor line */
  313.    int ruler_color;             /* color of ruler line */
  314.    int ruler_pointer;           /* color of ruler pointer */
  315.    int hilited_file;            /* color of current file in dir list */
  316.    int adapter;                 /* VGA, EGA, CGA, or MDA? */
  317.    unsigned int overw_cursor;   /* hi part = top scan line, lo part = bottom */
  318.    unsigned int insert_cursor;  /* hi part = top scan line, lo part = bottom */
  319.    char far *display_address;   /* address of display memory */
  320. } displays;
  321.  
  322.  
  323. /*
  324.  * "WINDOW" contains all the information that is unique to a given
  325.  *  window.
  326.  */
  327. typedef struct s_window {
  328.    struct s_file_infos *file_info;       /* file in window */
  329.    text_ptr cursor;             /* start of line containing cursor */
  330.    int  ccol;                   /* column cursor logically in */
  331.    int  rcol;                   /* column cursor actually in */
  332.    int  bcol;                   /* base column to start display */
  333.    int  cline;                  /* line cursor logically in */
  334.    long rline;                  /* real line cursor in */
  335.    int  top_line;               /* top line in window */
  336.    int  bottom_line;            /* bottom line in window */
  337.    int  vertical;               /* boolean. is window split vertically? */
  338.    int  start_col;              /* starting column on physical screen */
  339.    int  end_col;                /* ending column on physical screen */
  340.    int  page;                   /* no. of lines to scroll for one page */
  341.    int  visible;                /* window hidden or visible */
  342.    int  letter;                 /* window letter */
  343.    int  ruler;                  /* show ruler in this window? */
  344.    char ruler_line[MAX_COLS+2]; /* ruler for this window */
  345.    struct s_window *next;       /* next window in doubly linked list */
  346.    struct s_window *prev;       /* previous window in doubly linked list */
  347. } WINDOW;
  348.  
  349.  
  350. /*
  351.  * struct for find first and find next functions.  see DOS technical ref
  352.  * manuals for more info on DTA structures.
  353.  */
  354. typedef struct {
  355.    char          reserved[21];
  356.    unsigned char attrib;
  357.    unsigned      time;
  358.    unsigned      date;
  359.    long          size;
  360.    char          name[13];
  361. } DTA;
  362.  
  363.  
  364. /*
  365.  * "status_infos" contain all the editor status information that is
  366.  *  global to the entire editor (i.e. not dependent on the file or
  367.  *  window)
  368.  */
  369. typedef struct {
  370.    WINDOW *current_window;      /* current active window */
  371.    struct s_file_infos *current_file; /* current active file */
  372.    struct s_file_infos *file_list; /* all active files */
  373.    WINDOW *window_list;         /* all active windows */
  374.    int  window_count;           /* number of windows - displayed and hidden */
  375.    int  file_count;             /* number of files currently open */
  376.    text_ptr start_mem;          /* first char in main text buffer */
  377.    text_ptr end_mem;            /* last char in main text buffer used+1 */
  378.    text_ptr temp_end;           /* temporary end_mem marker */
  379.    text_ptr max_mem;            /* last char available for storage (+1) */
  380.    int  arg;                    /* current argument pointer */
  381.    int  found_first;            /* have we found the first file? */
  382.    int  argc;                   /* argument count */
  383.    char **argv;                 /* argument variables - same as *argv[] */
  384.    char path[MAX_COLS];         /* path for files on command line */
  385.    DTA  dta;                    /* disk transfer address for find next */
  386.    int  marked;                 /* has block been marked? */
  387.    int  prompt_line;            /* line to display cursor */
  388.    int  prompt_col;             /* column to display cursor */
  389.    struct s_file_infos *marked_file;  /* pointer to file w/ marked block */
  390.    char rw_name[MAX_COLS];      /* name of last file read or written */
  391.    char pattern[MAX_COLS];      /* last search pattern */
  392.    char subst[MAX_COLS];        /* last substitute text */
  393.    int  replace_flag;           /* prompt or noprompt b4 replacing */
  394.    int  overlap;                /* overlap between pages for page up etc */
  395.    text_ptr buff_line;          /* address of line in line_buff */
  396.    int  copied;                 /* has line been copied to file? */
  397.    char line_buff[BUFF_SIZE*2+2]; /* for currently edited line */
  398.    int  command;                /* function of key just entered */
  399.    int  key_pressed;            /* key pressed by user */
  400.    int  wrapped;                /* is the wrapped message on mode line? */
  401.    int  stop;                   /* stop indicator */
  402.    int  recording_key;          /* key we are assigning keystrokes to */
  403.    int  stroke_count;           /* free keys in stroke buffer */
  404.    int  undo_head;                        /* pointer to last line in buffer */
  405.    char undo_buffer[UNDO_MAX][BUFF_SIZE]; /* room for last 20 changed lines */
  406. } status_infos;
  407.  
  408.  
  409. /*
  410.  * marker structure used to save file positions.
  411.  */
  412. typedef struct {
  413.    long rline;                  /* real line of marker */
  414.    int  rcol;                   /* real column of marker */
  415.    int  ccol;                   /* logical column of marker */
  416.    int  bcol;                   /* base column of marker */
  417.    int  marked;                 /* boolean:  has this marker been set? */
  418. } MARKER;
  419.  
  420.  
  421. /*
  422.  * "file_infos" contain all the information unique to a given file
  423.  */
  424. typedef struct s_file_infos {
  425.    text_ptr start_text;        /* first char in file */
  426.    text_ptr end_text;          /* last char in file (+1) */
  427.    MARKER marker[NO_MARKERS];  /* number of file markers */
  428.    long length;                /* number of lines in file */
  429.    int  modified;              /* file has been modified since save? */
  430.    int  dirty;                 /* file in window modified? */
  431.    int  new_file;              /* is current file new? */
  432.    int  backed_up;             /* has ".bak" file been created? */
  433.    char file_name[MAX_COLS];   /* name of current file being edited */
  434.    char backup_fname[MAX_COLS];/* name of backup of current file */
  435.    int block_type;             /* block type - line or box */
  436.    text_ptr block_start;       /* beginning block position */
  437.    text_ptr block_end;         /* ending block position */
  438.    int  block_bc;              /* beginning column */
  439.    long block_br;              /* beginning row */
  440.    int  block_ec;              /* ending column */
  441.    long block_er;              /* ending row */
  442.    int  file_no;               /* file number */
  443.    int  ref_count;             /* no. of windows referring to file */
  444.    int  next_letter;           /* next window letter */
  445.    unsigned int  file_attrib;  /* file attributes (rwx etc) */
  446.    struct s_file_infos *next;  /* next file in doubly linked list */
  447.    struct s_file_infos *prev;  /* previous file in doubly linked list */
  448. } file_infos;
  449.  
  450.  
  451. /*
  452.  * structure for recording and playing back one keystroke.
  453.  */
  454. typedef struct {
  455.   int key;      /* key assinged to this node, which may be text or function */
  456.   int next;     /* pointer to next node in macro def */
  457. } STROKES;
  458.  
  459.  
  460. /*
  461.  * structure for the macro buffer.
  462.  */
  463. typedef struct {
  464.    int  first_stroke[MAX_KEYS];         /* pointer to first key in macro */
  465.    STROKES strokes[STROKE_LIMIT];       /* buffer to hold key strokes */
  466. } MACRO;
  467.  
  468.  
  469. /*
  470.  * structure for critical error handler.  check the flag for errors on
  471.  * each I/O call.
  472.  */
  473. typedef struct {
  474.    int  flag;                   /* 0 = no error, -1 = error */
  475.    int  code;                   /* error code from di */
  476.    int  rw;                     /* read or write operation? */
  477.    int  drive;                  /* drive number of error */
  478.    int  extended;               /* extended error code, func 0x59 */
  479.    int  class;                  /* error class */
  480.    int  action;                 /* suggested action from DOS */
  481.    int  locus;                  /* locus of error: drive, network, etc... */
  482.    int  dattr;                  /* device attribute, 0 = drive, 1 = serial */
  483.    char dname[10];              /* device name */
  484. } CEH;
  485.