home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / TDE32.ZIP / TDESTR.H < prev    next >
C/C++ Source or Header  |  1993-11-13  |  29KB  |  854 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.  * I'm so stupid, I can't keep up with which declarations are in which
  13.  * file.  I decided to put all typedefs, structs, and defines in one file.
  14.  * If I don't, I end up defining a typedef one way in one file and a
  15.  * completely different way in another file.
  16.  */
  17.  
  18.  
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include <stdlib.h>
  22. #include <ctype.h>
  23.  
  24. #include <assert.h>
  25. #if !defined( __UNIX__ )
  26.  #if defined( __MSC__ )
  27.   #include <malloc.h>          /* for memory allocation */
  28.   #if defined( toupper )
  29.     #undef toupper
  30.   #endif
  31.  #else
  32.   #include <alloc.h>           /* for memory allocation */
  33.  #endif
  34. #endif
  35.  
  36. /*
  37.  * in unix (POSIX?), getch( ) is in the curses package.  in Linux, ncurses
  38.  *  seems to be the best of the worst curses.
  39.  */
  40. #if defined(__UNIX__)
  41.    #include <dirent.h>          /* walking down directories */
  42.    #include <limits.h>          /* NAME_MAX and PATH_MAX, POSIX stuff */
  43.    #include <malloc.h>           /* for memory allocation */
  44.    #include <ncurses.h>
  45.    #include <unistd.h>          /* chdir, getcwd, etc... */
  46.    #include <sys/types.h>
  47.    #include <sys/stat.h>
  48. #else
  49.    #include <conio.h>
  50. #endif
  51.  
  52. #include "bj_ctype.h"
  53. #include "letters.h"
  54.  
  55. /*
  56.  * defines for the inline assembler.
  57.  */
  58. #if defined( __MSC__ )
  59.    #define  ASSEMBLE   _asm
  60. #else
  61.    #define  ASSEMBLE   asm
  62. #endif
  63.  
  64.  
  65. #if defined( __UNIX__ )
  66.    #define FAR
  67.    #define my_stdprn stderr
  68. #else
  69.    #define FAR far
  70.    #define my_stdprn stdprn
  71. #endif
  72.  
  73. #if defined( __UNIX__ )
  74. #define MAX_COLS           132  /* screen can be 132 columns in UNIX */
  75. #else
  76. #define MAX_COLS            80  /* widest screen ever used */
  77. #endif
  78. #define MAX_LINES           24  /* highest screen ever used */
  79. #define BUFF_SIZE         1042  /* buffer size for lines */
  80. #define MAX_LINE_LENGTH   1040  /* longest line allowed in file */
  81. #define FNAME_LENGTH        45  /* maximum file name length in lite bar */
  82. #define NO_MARKERS           3  /* maximum no. of markers */
  83. #define UNDO_STACK_LEN     200  /* number of lines in undo stack */
  84.  
  85. /*
  86.  * when we read in a file, lets try to match the size of the read buffer
  87.  *   with some multiple of a hardware or software cache that may be present.
  88.  */
  89. #define READ_LENGTH             1024
  90. #define DEFAULT_BIN_LENGTH      64
  91.  
  92.  
  93. #define REGX_SIZE               200     /* maximum number of nodes in nfa */
  94.  
  95.  
  96. /*
  97.  * general defines.
  98.  */
  99. #ifndef ERROR
  100. # define ERROR            (-1)  /* abnormal termination */
  101. #endif
  102. #ifndef OK
  103. # define OK                  0  /* normal termination */
  104. #endif
  105. #ifndef TRUE
  106. # define TRUE                1  /* logical true */
  107. #endif
  108. #ifndef FALSE
  109. # define FALSE               0  /* logical false */
  110. #endif
  111.  
  112. #define MAX_KEYS           256  /* number of special keys recognized by TDE */
  113. #define MAX_TWO_KEYS       128  /* number of two key-combos allowed by TDE  */
  114. #define STROKE_LIMIT      1024  /* number of key strokes in playback buffer */
  115. #if defined( __UNIX__ )
  116.  #define MAX_CURSES_KEYS   153  /* number of keys in ncurses  */
  117. #endif
  118.  
  119.  
  120. #define STACK_UNDERFLOW      1  /* code for underflowing macro stack */
  121. #define STACK_OVERFLOW       2  /* code for overflowing macro stack */
  122. #define SAS_P               20  /* number of sas pointers to tokens */
  123. #define NUM_FUNCS          142
  124.  
  125. #define NUM_COLORS          14  /* number of color fields in TDE */
  126.  
  127. /*
  128.  * special cases for keyboard mapping -  see bottom of main.c
  129.  */
  130. #define RTURN           262           /* Return key = 262 */
  131. #define ESC             258           /* Escape key = 258 */
  132. #define CONTROL_BREAK   269           /* Control-Break = 269 */
  133.  
  134.  
  135. /*
  136.  * The following defines are used by the "error" function to indicate
  137.  *  how serious the error is.
  138.  */
  139. #define WARNING         1    /* user must acknowledge, editor continues */
  140. #define FATAL           2    /* editor aborts - very rare! */
  141. #define INFO            3    /* display message, acknowledge, continue */
  142.  
  143.  
  144. /*
  145.  * define the type of block marked by user and block actions
  146.  */
  147. #define NOTMARKED       0    /* block type undefined */
  148. #define BOX             1    /* block marked by row and column */
  149. #define LINE            2    /* block marked by begin and end lines */
  150. #define STREAM          3    /* block marked by begin and end characters */
  151.  
  152. #define MOVE            1
  153. #define DELETE          2
  154. #define COPY            3
  155. #define KOPY            4
  156. #define FILL            5
  157. #define OVERLAY         6
  158. #define NUMBER          7
  159. #define SWAP            8
  160.  
  161. #define LEFT            1
  162. #define RIGHT           2
  163.  
  164. #define ASCENDING       1
  165. #define DESCENDING      2
  166.  
  167.  
  168. /*
  169.  * three types of ways to update windows
  170.  */
  171. #define LOCAL           1
  172. #define NOT_LOCAL       2
  173. #define GLOBAL          3
  174.  
  175. #define CURLINE         1
  176. #define NOTCURLINE      2
  177.  
  178.  
  179. /*
  180.  * search/replace flags.
  181.  */
  182. #define BOYER_MOORE     0
  183. #define REG_EXPRESSION  1
  184.  
  185. #define CLR_SEARCH      0
  186. #define WRAPPED         1
  187. #define SEARCHING       2
  188. #define REPLACING       3
  189. #define NFA_GAVE_UP     4
  190.  
  191. #define IGNORE          1
  192. #define MATCH           2
  193.  
  194. #define PROMPT          1
  195. #define NOPROMPT        2
  196.  
  197. #define FORWARD         1
  198. #define BACKWARD        2
  199.  
  200. #define BEGIN           1
  201. #define END             2
  202.  
  203.  
  204. #define BEGINNING       1
  205. #define CURRENT         2
  206.  
  207. /*
  208.  * word wrap flag.
  209.  */
  210. #define NO_WRAP         0
  211. #define FIXED_WRAP      1
  212. #define DYNAMIC_WRAP    2
  213.  
  214. /*
  215.  * date and time formats
  216.  */
  217. #define MM_DD_YY        0
  218. #define DD_MM_YY        1
  219. #define YY_MM_DD        2
  220. #define MM_DD_YYYY      3
  221. #define DD_MM_YYYY      4
  222. #define YYYY_MM_DD      5
  223.  
  224. #define _12_HOUR        0
  225. #define _24_HOUR        1
  226.  
  227.  
  228. /*
  229.  * used in interrupt 0x21 function xx for checking file status
  230.  */
  231. #define EXIST           0
  232. #define WRITE           2
  233. #define READ            4
  234. #define READ_WRITE      6
  235.  
  236. #define NORMAL          0x00
  237. #define READ_ONLY       0x01
  238. #define HIDDEN          0x02
  239. #define SYSTEM          0x04
  240. #define VOLUME_LABEL    0x08
  241. #define SUBDIRECTORY    0x10
  242. #define ARCHIVE         0x20
  243.  
  244. /*
  245.  * critical error def's
  246.  */
  247. #define RETRY           1
  248. #define ABORT           2
  249. #define FAIL            3
  250.  
  251.  
  252. /*
  253.  * flags used for opening files to write either in binary or text mode.
  254.  * crlf is for writing files in text mode - Operating System converts
  255.  * lf to crlf automatically on output.  in binary mode, lf is not translated.
  256.  */
  257. #define NATIVE          1
  258. #define CRLF            2
  259. #define LF              3
  260. #define BINARY          4
  261. #define TEXT            5
  262.  
  263. #define OVERWRITE       1
  264. #define APPEND          2
  265.  
  266. /*
  267.  * characters used in tdeasm.c to display eol and column pointer in ruler
  268.  */
  269. /*
  270. #if defined( __UNIX__ )
  271.  #define EOL_CHAR        0x1c
  272.  #define RULER_PTR       0x21
  273.  #define RULER_FILL      0x2e
  274.  #define RULER_TICK      0x2b
  275.  #define LM_CHAR         0x6c
  276.  #define RM_CHAR_RAG     0x3c
  277.  #define RM_CHAR_JUS     0x7c
  278.  #define PGR_CHAR        0x70
  279.  #define VERTICAL_CHAR   0x7c
  280. #else
  281.  #define EOL_CHAR        0x11
  282.  #define RULER_PTR       0x19
  283.  #define RULER_FILL      0x2e
  284.  #define RULER_TICK      0x04
  285.  #define LM_CHAR         0xb4
  286.  #define RM_CHAR_RAG     0x3c
  287.  #define RM_CHAR_JUS     0xc3
  288.  #define PGR_CHAR        0x14
  289.  #define VERTICAL_CHAR   0xba
  290. #endif
  291. */
  292.  
  293.  
  294.  
  295.  
  296. /*
  297.  * cursor size
  298.  */
  299. #define SMALL_INS       0
  300. #define BIG_INS         1
  301.  
  302. #define CURSES_INVISBL  0
  303. #define CURSES_SMALL    1
  304. #define CURSES_LARGE    2
  305.  
  306.  
  307. /*
  308.  * possible answers to various questions - see get_yn, get_ynaq and get_oa
  309.  */
  310. #define A_YES           1
  311. #define A_NO            2
  312. #define A_ALWAYS        3
  313. #define A_QUIT          4
  314. #define A_ABORT         5
  315. #define A_OVERWRITE     6
  316. #define A_APPEND        7
  317.  
  318. /*
  319.  * The following defines specify which video attributes give desired
  320.  *  effects on different display devices.
  321.  * REVERSE is supposed to be reverse video - a different background color,
  322.  *  so that even a blank space can be identified.
  323.  * HIGH is supposed to quickly draw the user's eye to the relevant part of
  324.  *  the screen, either for a message or for matched text in find/replace.
  325.  * NORMAL is supposed to be something pleasant to look at for the main
  326.  *  body of the text.
  327.  */
  328. #define VIDEO_INT       0x10
  329.  
  330. #define HERC_REVERSE    0x70
  331. #define HERC_UNDER      0x01
  332. #define HERC_NORMAL     0x07
  333. #define HERC_HIGH       0x0f
  334.  
  335. #define COLOR_HEAD      0x4b
  336. #define COLOR_TEXT      0x07
  337. #define COLOR_DIRTY     0x02
  338. #define COLOR_MODE      0x17
  339. #define COLOR_BLOCK     0x71
  340. #define COLOR_MESSAGE   0x0f
  341. #define COLOR_HELP      0x1a
  342. #define COLOR_DIAG      0x0e
  343. #define COLOR_EOF       0x09
  344. #define COLOR_CURL      0x0f
  345. #define COLOR_RULER     0x02
  346. #define COLOR_POINTER   0x0a
  347. #define COLOR_OVRS      0x00
  348.  
  349. #define COLOR_80        3
  350. #define MONO_80         7
  351.  
  352. #define VGA             3
  353. #define EGA             2
  354. #define CGA             1
  355. #define MDA             0
  356.  
  357.  
  358. #define  MAJOR   7        /* number of pull-down main menu options */
  359.  
  360.  
  361. #define SAS_DELIMITERS  " \n"
  362.  
  363. /*
  364.  * let's explicitly treat characters as unsigned.
  365.  */
  366. typedef unsigned char FAR *text_ptr;
  367.  
  368.  
  369. /*
  370.  * "s_line_list" contains contains struct defs for a node of text.
  371.  */
  372. typedef struct s_line_list {
  373.    text_ptr line;                       /* pointer to line */
  374.    int      len;                        /* length of line */
  375.    int      dirty;                      /* boolean - dirty line indicator */
  376.    struct s_line_list FAR *next;        /* next line in doubly linked list */
  377.    struct s_line_list FAR *prev;        /* prev line in doubly linked list */
  378. } line_list_struc;
  379.  
  380. typedef line_list_struc FAR *line_list_ptr;
  381.  
  382.  
  383. typedef struct {
  384.    char *minor_name;
  385.    int  minor_func;
  386. } MINOR_STR;
  387.  
  388.  
  389. typedef struct {
  390.    char *major_name;
  391.    int  minor_cnt;
  392.    MINOR_STR *minor;
  393. } MENU_STR[MAJOR];
  394.  
  395.  
  396. struct vcfg {
  397.    int color;
  398.    int rescan;
  399.    int mode;
  400.    int FAR *videomem;
  401. };
  402.  
  403.  
  404. typedef struct {
  405.    char sig[8];                 /* signature, so we can find struct in .exe */
  406.    int  clr[2][NUM_COLORS];     /* one array for mono and another for color */
  407. } TDE_COLORS;
  408.  
  409.  
  410. /*
  411.  * structure for two key combos
  412.  */
  413. typedef struct {
  414.    int parent_key;
  415.    int child_key;
  416.    int func;
  417. } TWO_KEY_TYPE;
  418.  
  419.  
  420. typedef struct {
  421.    char sig[8];
  422.    TWO_KEY_TYPE key[MAX_TWO_KEYS];
  423. } TWO_KEY;
  424.  
  425.  
  426. typedef struct {
  427.    char sig[8];
  428.    unsigned char key[MAX_KEYS];
  429. } KEY_FUNC;
  430.  
  431.  
  432. /*
  433.  * structure used in directory list.  file names in unix can be up to
  434.  * 255 characters.
  435.  */
  436. typedef struct {
  437. #if defined( __UNIX__ )
  438.    char fname[NAME_MAX+2];      /* file name */
  439.    long fsize;                  /* file size in bytes */
  440. #else
  441.    char fname[14];              /* file name */
  442.    long fsize;                  /* file size in bytes */
  443. #endif
  444. } FTYPE;
  445.  
  446.  
  447. /*
  448.  * stuff we need to know about how to display a directory listing.
  449.  */
  450. typedef struct {
  451.    int  row;                    /* absolute row to display dir box */
  452.    int  col;                    /* absolute column to display dir box */
  453.    int  wid;                    /* absolute number of columns in dir box */
  454.    int  hgt;                    /* absolute number of rows in dir box */
  455.    int  max_cols;               /* number of columns of files in box */
  456.    int  max_lines;              /* number of lines of files in box */
  457.    int  cnt;                    /* file count */
  458.    int  cols;                   /* logical number of columns in list */
  459.    int  lines;                  /* logical number of rows in list */
  460.    int  prow;                   /* logical number of rows in partial row */
  461.    int  vcols;                  /* number of virtual columns, if any */
  462.    int  nfiles;                 /* number of files on screen */
  463.    int  avail;                  /* number of available slots for files */
  464.    int  select;                 /* current file under cursor */
  465.    int  flist_col[5];           /* offset from col to display each column */
  466. } DIRECTORY;
  467.  
  468.  
  469. typedef struct {
  470.    int  pattern_length;                 /* number of chars in pattern */
  471.    int  search_defined;                 /* search pattern defined? */
  472.    unsigned char pattern[MAX_COLS];     /* search pattern */
  473.    int  forward_md2;                    /* forward mini-delta2 */
  474.    int  backward_md2;                   /* backward mini-delta2 */
  475.    char skip_forward[256];              /* boyer array for forward searches */
  476.    char skip_backward[256];             /* boyer array for back searches */
  477. } boyer_moore_type;
  478.  
  479.  
  480. /*
  481.  * "mode_infos" contain the editor mode variables.  The configuration
  482.  *  utility modifies this structure to custimize the start-up tde
  483.  *  configuration
  484.  */
  485. typedef struct {
  486.    char sig[8];                 /* signature, so we can find struct in .exe */
  487.    int  color_scheme;           /* color to start out with */
  488.    int  sync;                   /* sync the cursor movement command? */
  489.    int  sync_sem;               /* sync the cursor movement command? */
  490.    int  record;                 /* are we recording keystrokes? */
  491.    int  insert;                 /* in insert mode? */
  492.    int  indent;                 /* in auto-indent mode? */
  493.    int  ptab_size;              /* physical tab stops */
  494.    int  ltab_size;              /* logical tab stops */
  495.    int  smart_tab;              /* smart tab mode on or off? */
  496.    int  inflate_tabs;           /* inflate tabs?  T or F */
  497.    int  search_case;            /* consider case? IGNORE or MATCH */
  498.    int  enh_kbd;                /* type of keyboard */
  499.    int  cursor_size;            /* insert cursor big or small? */
  500.    char *eof;                   /* message to display at end of file */
  501.    int  control_z;              /* write ^Z - t or f */
  502.    int  crlf;                   /* <cr><lf> toggle CRLF or LF */
  503.    int  trailing;               /* remove trailing space? T or F */
  504.    int  show_eol;               /* show lf at eol? T or F */
  505.    int  word_wrap;              /* in word wrap mode? */
  506.    int  left_margin;            /* left margin */
  507.    int  parg_margin;            /* column for 1st word in paragraph */
  508.    int  right_margin;           /* right margin */
  509.    int  right_justify;          /* boolean, justify right margin?  T or F */
  510.    int  format_sem;             /* format semaphore */
  511.    int  undo_max;               /* max number of lines in undo stack */
  512.    int  do_backups;             /* create backup or ".bak" files? T or F */
  513.    int  ruler;                  /* show ruler at top of window? T or F */
  514.    int  date_style;             /* date style for date and time stamp */
  515.    int  time_style;             /* time style for date and time stamp */
  516. } mode_infos;
  517.  
  518.  
  519. /*
  520.  * "displays" contain all the status information about what attributes are
  521.  *  used for what purposes, which attribute is currently set, and so on.
  522.  * The editor only knows about one physical screen.
  523.  */
  524. typedef struct {
  525.    int nlines;                  /* lines on display device */
  526.    int ncols;                   /* columns on display device */
  527.    int line_length;             /* length of longest line */
  528.    int mode_line;               /* line to display editor modes - fmd */
  529.    int head_color;              /* file header color */
  530.    int text_color;              /* text area color */
  531.    int dirty_color;             /* text area color */
  532.    int mode_color;              /* mode line color - footer */
  533.    int block_color;             /* hilited area of blocked region */
  534.    int message_color;           /* color of editor messages */
  535.    int help_color;              /* color of help screen */
  536.    int diag_color;              /* color for diagnostics in mode line */
  537.    int eof_color;               /* color for end of file line */
  538.    int curl_color;              /* color of cursor line */
  539.    int ruler_color;             /* color of ruler line */
  540.    int ruler_pointer;           /* color of ruler pointer */
  541.    int hilited_file;            /* color of current file in dir list */
  542.    int overscan;                /* color of overscan color */
  543.    int old_overscan;            /* color of old overscan   */
  544.    int adapter;                 /* VGA, EGA, CGA, or MDA? */
  545.    int curses_cursor;           /* what state is CURSES cursor? */
  546.    unsigned int overw_cursor;   /* hi part = top scan line, lo part = bottom */
  547.    unsigned int insert_cursor;  /* hi part = top scan line, lo part = bottom */
  548.    char FAR *display_address;   /* address of display memory */
  549. } displays;
  550.  
  551.  
  552. /*
  553.  * "TDE_WIN" contains all the information that is unique to a given
  554.  *  window.
  555.  */
  556. typedef struct s_tdewin {
  557.    struct s_file_infos *file_info;       /* file in window */
  558.    line_list_ptr ll;            /* pointer to current node in linked list */
  559.    int  ccol;                   /* column cursor logically in */
  560.    int  rcol;                   /* column cursor actually in */
  561.    int  bcol;                   /* base column to start display */
  562.    int  cline;                  /* line cursor logically in */
  563.    long rline;                  /* real line cursor in */
  564.    long bin_offset;             /* offset, in bytes from beg of bin file */
  565.    int  top_line;               /* top line in window */
  566.    int  bottom_line;            /* bottom line in window */
  567.    int  vertical;               /* boolean. is window split vertically? */
  568.    int  start_col;              /* starting column on physical screen */
  569.    int  end_col;                /* ending column on physical screen */
  570.    int  page;                   /* no. of lines to scroll for one page */
  571.    int  visible;                /* window hidden or visible */
  572.    int  letter;                 /* window letter */
  573.    int  ruler;                  /* show ruler in this window? */
  574.    char ruler_line[MAX_COLS+2]; /* ruler for this window */
  575.    struct s_tdewin *next;       /* next window in doubly linked list */
  576.    struct s_tdewin *prev;       /* previous window in doubly linked list */
  577. } TDE_WIN;
  578.  
  579.  
  580. /*
  581.  * struct for find first and find next functions.  see DOS technical ref
  582.  * manuals for more info on DTA structures.
  583.  */
  584. typedef struct {
  585.    char          reserved[21];
  586.    unsigned char attrib;
  587.    unsigned      time;
  588.    unsigned      date;
  589.    long          size;
  590.    char          name[13];
  591. } DTA;
  592.  
  593.  
  594. #if defined( __UNIX__ )
  595. typedef struct {
  596.    char fname[NAME_MAX];
  597.    int  name_len;
  598. } UNIX_DTA;
  599. #endif
  600.  
  601.  
  602. /*
  603.  * "status_infos" contain all the editor status information that is
  604.  *  global to the entire editor (i.e. not dependent on the file or
  605.  *  window)
  606.  */
  607. typedef struct {
  608.    TDE_WIN *current_window;     /* current active window */
  609.    struct s_file_infos *current_file; /* current active file */
  610.    struct s_file_infos *file_list; /* all active files */
  611.    TDE_WIN *window_list;        /* all active windows */
  612.    int  window_count;           /* number of windows - displayed and hidden */
  613.    int  file_count;             /* number of files currently open */
  614.    int  max_window_letters;     /* number of letters in window letter list */
  615.    int  arg;                    /* current argument pointer */
  616.    int  found_first;            /* have we found the first file? */
  617.    int  argc;                   /* argument count */
  618.    char **argv;                 /* argument variables - same as *argv[] */
  619.    int  file_mode;              /* mode to open sas files, TEXT or BINARY */
  620.    int  file_chunk;             /* if opened BINARY, bytes per line */
  621.    int  sas_defined;            /* has search and seize been defined */
  622.    int  sas_search_type;        /* if defined, Boyer-Moore or reg expression? */
  623.    int  sas_arg;                /* current argument pointer */
  624.    int  sas_argc;               /* argument count */
  625.    char **sas_argv;             /* argument variables - same as *argv[] */
  626.    char *sas_arg_pointers[SAS_P]; /* array of pointers to tokens in sas_path */
  627.    int  sas_found_first;        /* have we found the first file? */
  628.    long sas_rline;              /* line number of sas find */
  629.    int  sas_rcol;               /* column number of sas find */
  630.    int  sas_mode;               /* mode to open sas files, TEXT or BINARY */
  631.    int  sas_chunk;              /* if opened BINARY, bytes per line */
  632.    line_list_ptr sas_ll;        /* linked list node pointing to line */
  633.    int  marked;                 /* has block been marked? */
  634.    int  prompt_line;            /* line to display cursor */
  635.    int  prompt_col;             /* column to display cursor */
  636.    struct s_file_infos *marked_file;  /* pointer to file w/ marked block */
  637. #if defined( __UNIX__ )
  638.    char sas_path[PATH_MAX];     /* path for files on search list */
  639.    char sas_tokens[PATH_MAX];   /* storage for file tokens */
  640.    char path[PATH_MAX];         /* path for files on command line */
  641.    char rw_name[PATH_MAX];      /* name of last file read or written */
  642.    UNIX_DTA  dta;               /* disk transfer address for find next */
  643.    UNIX_DTA  sas_dta;           /* disk transfer address for find next */
  644.    DIR *dp;                     /* directory pointer for unix opendir( ) */
  645.    DIR *sas_dp;                 /* directory pointer for unix opendir( ) */
  646. #else
  647.    char sas_path[MAX_COLS];     /* path for files on search list */
  648.    char sas_tokens[MAX_COLS];   /* storage for file tokens */
  649.    char path[MAX_COLS];         /* path for files on command line */
  650.    char rw_name[MAX_COLS];      /* name of last file read or written */
  651.    DTA  dta;                    /* disk transfer address for find next */
  652.    DTA  sas_dta;                /* disk transfer address for find next */
  653. #endif
  654.    char pattern[MAX_COLS];      /* last search pattern */
  655.    char subst[MAX_COLS];        /* last substitute text */
  656.    int  replace_flag;           /* prompt or noprompt b4 replacing */
  657.    int  replace_defined;        /* replace defined ? */
  658.    int  overlap;                /* overlap between pages for page up etc */
  659.    line_list_ptr buff_node;     /* address of node in line_buff */
  660.    int  copied;                 /* has line been copied to file? */
  661.    char line_buff[BUFF_SIZE*2+8]; /* for currently edited line */
  662.    char tabout_buff[BUFF_SIZE+8]; /* for exanding tabs */
  663.    int  line_buff_len;          /* length of line in the line_buff */
  664.    int  tabout_buff_len;        /* length of line in the tabout_buff */
  665.    int  command;                /* function of key just entered */
  666.    int  key_pressed;            /* key pressed by user */
  667.    int  key_pending;            /* is two-key command waiting for next key? */
  668.    int  first_key;              /* first key of the two-key sequence */
  669.    int  wrapped;                /* is the wrapped message on mode line? */
  670.    int  stop;                   /* stop indicator */
  671.    int  control_break;          /* control break pressed? */
  672.    int  recording_key;          /* key we are assigning keystrokes to */
  673.    int  stroke_count;           /* free keys in stroke buffer */
  674.    int  macro_next;             /* pointer to next key in macro */
  675.    int  macro_executing;        /* flag set if macro is executing */
  676.    int  mstack_pointer;         /* pointer to macro stack */
  677.    int  current_macro;          /* index of currently executing macro */
  678.    int  screen_display;         /* screen display off or on? */
  679. } status_infos;
  680.  
  681.  
  682. typedef struct {
  683.    char *misc;          /* miscellaneaous buffer */
  684. } BUFFERS;
  685.  
  686.  
  687. /*
  688.  * marker structure used to save file positions.
  689.  */
  690. typedef struct {
  691.    long rline;                  /* real line of marker */
  692.    int  rcol;                   /* real column of marker */
  693.    int  ccol;                   /* logical column of marker */
  694.    int  bcol;                   /* base column of marker */
  695.    int  marked;                 /* boolean:  has this marker been set? */
  696. } MARKER;
  697.  
  698.  
  699. /*
  700.  * "file_infos" contain all the information unique to a given file
  701.  */
  702. typedef struct s_file_infos {
  703.    line_list_ptr line_list;    /* pointer to first node in linked list */
  704.    line_list_ptr line_list_end; /* pointer to last node in linked list */
  705.    line_list_ptr undo_top;     /* pointer to top node in undo stack */
  706.    line_list_ptr undo_bot;     /* pointer to last node in undo stack */
  707.    int  undo_count;            /* number of lines in undo stack */
  708.    MARKER marker[NO_MARKERS];  /* number of file markers */
  709.    long length;                /* number of lines in file */
  710.    int  modified;              /* file has been modified since save? */
  711.    int  dirty;                 /* file in window modified? */
  712.    int  new_file;              /* is current file new? */
  713.    int  backed_up;             /* has ".bak" file been created? */
  714.    int  crlf;                  /* when read, did lines end CRLF or LF? */
  715.    int  open_mode;             /* opened in BINARY or TEXT */
  716. #if defined( __UNIX__ )
  717.    char file_name[PATH_MAX];   /* name of current file being edited */
  718.    char backup_fname[PATH_MAX];/* name of backup of current file */
  719.    mode_t   file_attrib;       /* unix file attributes (e.g. -rwxrwxrwx ) */
  720. #else
  721.    char file_name[MAX_COLS];   /* name of current file being edited */
  722.    char backup_fname[MAX_COLS];/* name of backup of current file */
  723.    unsigned int  file_attrib;  /* file attributes (rwx etc) */
  724. #endif
  725.    int  block_type;            /* block type - line or box */
  726.    line_list_ptr block_start;  /* beginning block position */
  727.    line_list_ptr block_end;    /* ending block position */
  728.    int  block_bc;              /* beginning column */
  729.    long block_br;              /* beginning row */
  730.    int  block_ec;              /* ending column */
  731.    long block_er;              /* ending row */
  732.    int  file_no;               /* file number */
  733.    int  ref_count;             /* no. of windows referring to file */
  734.    int  next_letter;           /* next window letter */
  735.    struct s_file_infos *next;  /* next file in doubly linked list */
  736.    struct s_file_infos *prev;  /* previous file in doubly linked list */
  737. } file_infos;
  738.  
  739.  
  740. /*
  741.  * structure for recording and playing back one keystroke.
  742.  */
  743. typedef struct {
  744.   int key;      /* key assinged to this node, which may be text or function */
  745.   int next;     /* pointer to next node in macro def */
  746. } STROKES;
  747.  
  748.  
  749. /*
  750.  * structure for the macro buffer.
  751.  */
  752. typedef struct {
  753.    char sig[8];                         /* signature, easy to find in .exe */
  754.    int  first_stroke[MAX_KEYS];         /* pointer to first key in macro */
  755.    STROKES strokes[STROKE_LIMIT];       /* buffer to hold key strokes */
  756. } MACRO;
  757.  
  758.  
  759. /*
  760.  * structure for the local macro stack in macro processor.
  761.  */
  762. typedef struct {
  763.    int key;                             /* key to begin execution in macro */
  764.    int macro;                           /* macro we were executing */
  765. } MACRO_STACK;
  766.  
  767.  
  768. /*
  769.  * structure for critical error handler.  check the flag for errors on
  770.  * each I/O call.
  771.  */
  772. typedef struct {
  773.    int  flag;                   /* 0 = no error, -1 = error */
  774.    int  code;                   /* error code from di */
  775.    int  rw;                     /* read or write operation? */
  776.    int  drive;                  /* drive number of error */
  777.    int  extended;               /* extended error code, func 0x59 */
  778.    int  class;                  /* error class */
  779.    int  action;                 /* suggested action from DOS */
  780.    int  locus;                  /* locus of error: drive, network, etc... */
  781.    int  dattr;                  /* device attribute, 0 = drive, 1 = serial */
  782.    char dname[10];              /* device name */
  783. } CEH;
  784.  
  785.  
  786. /*
  787.  * structure for sort strings
  788.  */
  789. typedef struct {
  790.    text_ptr pivot_ptr;
  791.    int  direction;
  792.    unsigned char *order_array;
  793.    int  block_len;
  794.    int  pivot_len;
  795.    int  bc;
  796.    int  ec;
  797. } SORT;
  798.  
  799.  
  800. typedef struct {
  801.    unsigned char ignore[256];
  802.    unsigned char match[256];
  803. } SORT_ORDER;
  804.  
  805.  
  806. /*
  807.  * structure for diff.  let's only diff two windows at a time.
  808.  */
  809. typedef struct {
  810.    int       defined;           /* initially FALSE */
  811.    int       leading;           /* skip leading spaces t/f */
  812.    int       all_space;         /* skip all space t/f */
  813.    int       blank_lines;       /* skip blank lines t/f */
  814.    int       ignore_eol;        /* skip end of line t/f */
  815.    TDE_WIN   *w1;               /* pointer to first diff window */
  816.    TDE_WIN   *w2;               /* pointer to second diff window */
  817.    line_list_ptr  d1;           /* pointer to text in window 1 */
  818.    line_list_ptr  d2;           /* pointer to text in window 2 */
  819.    long      rline1;            /* line number in window 1 */
  820.    long      rline2;            /* line number in window 2 */
  821.    long      bin_offset1;       /* binary offset in window 1 */
  822.    long      bin_offset2;       /* binary offset in window 2 */
  823. } DIFF;
  824.  
  825.  
  826. /*
  827.  * structures for regular expression searches.
  828.  */
  829. typedef struct {
  830.    int  pattern_length;                 /* number of chars in pattern */
  831.    int  search_defined;                 /* search pattern defined? */
  832.    int  node_count;                     /* number of nodes in the nfa */
  833.    unsigned char pattern[MAX_COLS];     /* search pattern */
  834. } REGX_INFO;
  835.  
  836.  
  837. typedef struct {
  838.    int  node_type[REGX_SIZE];
  839.    int  term_type[REGX_SIZE];
  840.    int  c[REGX_SIZE];
  841.    char *class[REGX_SIZE];
  842.    int  next1[REGX_SIZE];
  843.    int  next2[REGX_SIZE];
  844. } NFA_TYPE;
  845.  
  846.  
  847. typedef struct parse_tree {
  848.    int node_type;
  849.    int leaf_char;
  850.    char *leaf_string;
  851.    struct parse_tree *r_pt;
  852.    struct parse_tree *l_pt;
  853. } PARSE_TREE;
  854.