home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / the.h < prev    next >
C/C++ Source or Header  |  1993-11-25  |  26KB  |  787 lines

  1. /*
  2.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  3.  * Copyright (C) 1991-1993 Mark Hessling
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License as
  7.  * published by the Free Software Foundation; either version 2 of
  8.  * the License, or any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13.  * General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to:
  17.  *
  18.  *    The Free Software Foundation, Inc.
  19.  *    675 Mass Ave,
  20.  *    Cambridge, MA 02139 USA.
  21.  *
  22.  *
  23.  * If you make modifications to this software that you feel increases
  24.  * it usefulness for the rest of the community, please email the
  25.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  26.  * This software is going to be maintained and enhanced as deemed
  27.  * necessary by the community.
  28.  *
  29.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  30.  * 36 David Road                     Phone: +61 7 849 7731
  31.  * Holland Park                      Fax:   +61 7 875 5314
  32.  * QLD 4121
  33.  * Australia
  34.  */
  35.  
  36. /*
  37. $Header: C:\THE\RCS\the.h 1.4 1993/09/01 16:27:20 MH Interim MH $
  38. */
  39.  
  40. #include "defines.h"
  41.  
  42. #if defined(USE_NCURSES)
  43. #   include <ncurses.h>
  44. #   define SYSVR32
  45. #else
  46. #   if defined(USE_EXTCURSES)
  47. #      include <cur00.h>
  48. #      define SYSVR32
  49. #      define A_COLOR
  50. #      define COLOR_BLACK        0
  51. #      define COLOR_BLUE        1
  52. #      define COLOR_GREEN        2
  53. #      define COLOR_CYAN        3
  54. #      define COLOR_RED        4
  55. #      define COLOR_MAGENTA        5
  56. #      define COLOR_YELLOW        6
  57. #      define COLOR_WHITE        7
  58.        typedef char bool;
  59. #      define chtype NLSCHAR
  60. #      define COLOR_PAIRS 64
  61.        extern chtype color_pair[COLOR_PAIRS];
  62. #      define COLOR_PAIR(n) color_pair[n]
  63. #      define wattrset(win,attr) xstandout(win,attr)
  64. #      define attrset(attr) xstandout(stdscr,attr)
  65. #      define nocbreak() nocrmode()
  66. #      define cbreak() crmode()
  67. #      define wnoutrefresh(win) wrefresh(win)
  68. #   else
  69. #      include <curses.h>
  70. #   endif
  71. #endif
  72.  
  73. #ifdef __OS2__
  74. #  undef MSDOS                 /* in case you are using MSC 6.0 for OS/2 */
  75. #  undef SYSV                  /* set in curses.h */
  76. #  undef BSD                   /* set in curses.h */
  77. #  define SYSVR32curses
  78. #  define SYSVR31curses
  79. #  define SYSVR3curses
  80. #  include <stdlib.h>
  81. #  include <memory.h>
  82. #  include <string.h>
  83. #  include <process.h>
  84. #  include <errno.h>
  85. #  include <ctype.h>
  86. #  include <sys\types.h>
  87. #  include <sys\stat.h>
  88. #  define         W_OK          02
  89. #  define         F_OK          00
  90. #  define         R_OK          04
  91. #  define ESLASH '\\'
  92. #  define ESTR_SLASH (char *)"\\"
  93. #  ifdef EMX
  94. #    define OSLASH '\\'
  95. #    define OSTR_SLASH (char *)"\\"
  96. #    define ISLASH '/'
  97. #    define ISTR_SLASH (char *)"/"
  98. #  else
  99. #    define OSLASH '/'
  100. #    define OSTR_SLASH (char *)"/"
  101. #    define ISLASH '\\'
  102. #    define ISTR_SLASH (char *)"\\"
  103. #  endif
  104. #  define CURRENT_DIR (char *)"."
  105. #  define FMODE (0)
  106. #  ifdef MSC
  107. /* the following 2 defines are to make MSC recognise the new names */
  108. /* of the following OS/2 calls */
  109. #    define DosSetDefaultDisk DosSelectDisk
  110. #    define DosQueryCurrentDisk DosQCurDisk
  111. #  endif
  112. #endif
  113.  
  114. #if defined(__MSDOS__) || defined(MSDOS)
  115. #  define SYSVR32curses
  116. #  define SYSVR31curses
  117. #  define SYSVR3curses
  118. #  undef SYSV                  /* set in curses.h */
  119. #  undef BSD                   /* set in curses.h */
  120. #  include <stdlib.h>
  121. #  include <memory.h>
  122. #  include <string.h>
  123. #  ifdef GO32
  124. #    include <dir.h>
  125. #  else
  126. #    include <process.h>
  127. #    include <direct.h>
  128. #  endif
  129. #  include <errno.h>
  130. #  include <io.h>
  131. #  include <ctype.h>
  132. #  include <sys\types.h>
  133. #  include <sys\stat.h>
  134. #  define         W_OK          02
  135. #  define         F_OK          00
  136. #  define         R_OK          04
  137. #  define ESLASH '\\'
  138. #  define ESTR_SLASH (char *)"\\"
  139. #  ifdef GO32
  140. #    define OSLASH '\\'
  141. #    define OSTR_SLASH (char *)"\\"
  142. #    define ISLASH '/'
  143. #    define ISTR_SLASH (char *)"/"
  144. #  else
  145. #    define OSLASH '/'
  146. #    define OSTR_SLASH (char *)"/"
  147. #    define ISLASH '\\'
  148. #    define ISTR_SLASH (char *)"\\"
  149. #  endif
  150. #  define CURRENT_DIR (char *)"."
  151. #  define FMODE (0)
  152. /*#define FMODE (S_IREAD | S_IWRITE)*/
  153. #endif
  154.  
  155. #ifdef SYSVR4
  156. #  undef BSD
  157. #  ifndef SYSV
  158. #    define SYSV
  159. #  endif
  160. #  include <ctype.h>
  161. #  include <unistd.h>
  162. #  define SYSVR4curses
  163. #  define SYSVR32curses
  164. #  define SYSVR31curses
  165. #  define SYSVR3curses
  166. #endif
  167.  
  168. #ifdef SYSVR32
  169. #  undef BSD
  170. #  ifndef SYSV
  171. #    define SYSV
  172. #  endif
  173. #  include <ctype.h>
  174. #  include <unistd.h>
  175. #  define SYSVR32curses
  176. #  define SYSVR31curses
  177. #  define SYSVR3curses
  178. #endif
  179.  
  180. #ifdef SYSVR31
  181. #  undef BSD
  182. #  ifndef SYSV
  183. #    define SYSV
  184. #  endif
  185. #  define SYSVR31curses
  186. #  define SYSVR3curses
  187. #endif
  188.  
  189. #ifdef SYSVR3
  190. #  undef BSD
  191. #  ifndef SYSV
  192. #    define SYSV
  193. #  endif
  194. #  define SYSVR3curses
  195. #endif
  196.  
  197. #ifdef SYSV
  198. #  undef BSD
  199. #  define SYSVcurses
  200. #  if !defined(ATT)
  201. #    include <stdlib.h>
  202. #    include <sys/file.h>
  203. #  endif
  204. #  include <memory.h>
  205. #  include <string.h>
  206. #  include <sys/types.h>
  207. #  include <sys/stat.h>
  208. #  define FMODE (0)
  209. #  define UNIX 1
  210. #endif
  211.  
  212.  
  213. #ifdef BSD
  214. #  include <stdlib.h>
  215. #  include <memory.h>
  216. #  include <string.h>
  217. #  include <sys/file.h>
  218. #  include <sys/types.h>
  219. #  include <sys/stat.h>
  220. #  define FMODE (0)
  221. #  define chtype short
  222. #  define UNIX 1
  223. #  define BSDcurses 1
  224. #  define NO_KEYPAD 1
  225. #  define attrset(attr) wattrset(stdscr,attr)
  226. #  ifdef linux
  227. #    include <unistd.h>
  228. #  endif
  229. #endif
  230.  
  231. #ifdef M_XENIX
  232. #  include <ctype.h>
  233. #  include <sys/types.h>
  234. #  include <sys/stat.h>
  235. #  include <memory.h>
  236. #  include <string.h>
  237. #  include <sys/file.h>
  238. #  define         F_OK          00
  239. #  define         W_OK          02
  240. #  define         R_OK          04
  241. #  define touchline(WIN,START,NUM)       touchwin(WIN)
  242. #  define FMODE (0)
  243. #  define UNIX 1
  244. #endif
  245.  
  246. #ifdef MINIX
  247. #  include <string.h>
  248. #  define short int
  249. #  define UNIX 1
  250. #endif
  251.  
  252. #ifdef UNIX
  253. #  define ESLASH '/'
  254. #  define ESTR_SLASH (char *)"/"
  255. #  define OSLASH '\\'
  256. #  define OSTR_SLASH (char *)"\\"
  257. #  define ISLASH ESLASH
  258. #  define ISTR_SLASH ESTR_SLASH
  259. #  define CURRENT_DIR (char *)"."
  260. #endif
  261.  
  262. #ifdef VMS
  263. #  include <string.h>
  264. #  include <file.h>
  265. #  include <types.h>
  266. #  include <stat.h>
  267. #  include <ctype.h>
  268. #  define         W_OK          02
  269. #  define         F_OK          00
  270. #  define         R_OK          04
  271. #  define ISLASH ']'
  272. #  define ISTR_SLASH (char *)"]"
  273. #  define OSLASH ISLASH
  274. #  define OSTR_SLASH ISTR_SLASH
  275. #  define ESLASH ISLASH
  276. #  define ESTR_SLASH ISTR_SLASH
  277. #  define CURRENT_DIR (char *)"[]"
  278. /*#define FMODE (S_IRWXU | S_IRGRP | S_IROTH)*/
  279. #  define FMODE (0)
  280. #  ifdef BSD
  281. #    define chtype short
  282. #    define BSDcurses 1
  283. #  endif
  284. #  define touchline(WIN,START,NUM)       touchwin(WIN)
  285. /* #define isdigit(c)   (_ctype[(c) + 1] & 2)
  286. #  define islower(c)   (_ctype[(c) + 1] & 8)
  287. #  define isupper(c)   (_ctype[(c) + 1] & 4)*/
  288. #  define NO_KEYPAD 1
  289. #endif
  290. /*---------------------------------------------------------------------*/
  291. /* End of OS-specific defines                                          */
  292. /*---------------------------------------------------------------------*/
  293.  
  294. #ifndef A_NORMAL
  295. /* Various video attributes */
  296. #ifdef BSD
  297. #define A_STANDOUT      _STANDOUT    /* for compatability with old curses */
  298. #define A_REVERSE       _STANDOUT    /* for compatability with old curses */
  299. #define A_UNDERLINE     0
  300. #define A_BLINK         0
  301. #define A_DIM           0
  302. #define A_BOLD          _STANDOUT
  303.  
  304. /* The next two are subject to change so don't depend on them */
  305. #define A_INVIS         0
  306. #define A_PROTECT       0
  307.  
  308. #define A_NORMAL        0
  309. #define A_CHARTEXT      0x007F
  310. #define A_ATTRIBUTES    ~A_CHARTEXT
  311. #define A_ALTCHARSET    0
  312.  
  313. #else
  314.  
  315. #define A_STANDOUT      000000200000L
  316. #define A_UNDERLINE     000000400000L
  317. #define A_REVERSE       000001000000L
  318. #define A_BLINK         000002000000L
  319. #define A_DIM           000004000000L
  320. #define A_BOLD          000010000000L
  321. #define A_ALTCHARSET    000100000000L
  322.  
  323. /* The next two are subject to change so don't depend on them */
  324. #define A_INVIS         000020000000L
  325. #define A_PROTECT       000040000000L
  326.  
  327. #define A_NORMAL        000000000000L
  328. #define A_ATTRIBUTES    037777600000L   /* 0xFFFF0000 */
  329. #define A_CHARTEXT      000000177777L   /* 0x0000FFFF */
  330.  
  331. #endif
  332. #endif
  333.  
  334. #ifndef max
  335. #define max(a,b)        (((a) > (b)) ? (a) : (b))
  336. #endif
  337.  
  338. #ifndef min
  339. #define min(a,b)        (((a) < (b)) ? (a) : (b))
  340. #endif
  341.  
  342. #ifndef getmaxy
  343. #ifdef VMS
  344. #define getmaxy(win)    ((win)->_max_y)
  345. #else
  346. #define getmaxy(win)    ((win)->_maxy)
  347. #endif
  348. #endif
  349.  
  350. #ifndef getmaxx
  351. #ifdef VMS
  352. #define getmaxx(win)    ((win)->_max_x)
  353. #else
  354. #define getmaxx(win)    ((win)->_maxx)
  355. #endif
  356. #endif
  357.  
  358. #ifndef getmaxyx
  359. #define getmaxyx(win,y,x)  ((y) = getmaxy(win), (x) = getmaxx(win))
  360. #endif
  361.  
  362. #define OFF             0
  363. #define ON              1
  364. #define NO              0
  365. #define YES             1
  366. #define NA              2
  367.  
  368. /*#define ERROR         (-128)*/
  369. #define QUIT          (-127)
  370. #define SKIP          (-126)
  371. #define QUITOK        (-125)
  372. #define RAW_KEY       (128)
  373.  
  374. #define MAX_SCREENS         2             /* maximum number of screens*/
  375. #define VIEW_WINDOWS        5             /* number of windows per view */
  376. #define MAX_INT             32766         /* maximum size for integer */
  377. #define MAX_LONG            2147483001    /* maximum size for long */
  378. #define TARGET_ERROR        -2147483000   /* number returned as target error */
  379. #define TARGET_NOT_FOUND    -2147482999   /* number returned not found target */
  380. #define WORD_DELIMS         " \t"         /* word delimiter characters */
  381.  
  382. #define TOP_OF_FILE         (char *)"*** Top of File ***"
  383. #define BOTTOM_OF_FILE      (char *)"*** Bottom of File ***"
  384. #define DIRECTION_NONE      0
  385. #define DIRECTION_FORWARD   1
  386. #define DIRECTION_BACKWARD  (-1)
  387.  
  388. #define UNDEFINED_OPERAND (-1)
  389.  
  390. #define WINDOW_MAIN     0
  391. #define WINDOW_PREFIX   1
  392. #define WINDOW_COMMAND  2
  393. #define WINDOW_ARROW    3
  394. #define WINDOW_IDLINE   4
  395. #define WINDOW_FOOTING  5
  396. #define WINDOW_ERROR    6
  397. #define WINDOW_DIVIDER  7
  398. #define WINDOW_RESERVED 8
  399.  
  400. #define PREFIX_WIDTH    6
  401.  
  402. #define CURRENT_VIEW              (vd_current)
  403. #define PREVIOUS_VIEW             (vd_current->prev)
  404. #define NEXT_VIEW                 (vd_current->next)
  405.  
  406. #define CURRENT_FILE              (vd_current->file_for_view)
  407. #define CURRENT_WINDOW            (vd_current->win[vd_current->current_window])
  408. #define PREVIOUS_WINDOW           (vd_current->win[vd_current->previous_window])
  409. #define CURRENT_WINDOW_MAIN       (vd_current->win[WINDOW_MAIN])
  410. #define CURRENT_WINDOW_PREFIX     (vd_current->win[WINDOW_PREFIX])
  411. #define CURRENT_WINDOW_COMMAND    (vd_current->win[WINDOW_COMMAND])
  412. #define CURRENT_WINDOW_ARROW      (vd_current->win[WINDOW_ARROW])
  413. #define CURRENT_WINDOW_IDLINE     (vd_current->win[WINDOW_IDLINE])
  414.  
  415. #define MARK_VIEW (vd_mark)
  416. #define MARK_FILE (vd_mark->file_for_view)
  417.  
  418. #define CURRENT_SCREEN (screen[current_screen])
  419. #define OTHER_SCREEN (screen[(current_screen == 0) ? 1 : 0])
  420.  
  421. #define COMMAND_COPY             1
  422. #define COMMAND_DELETE           2
  423. #define COMMAND_DUPLICATE        3
  424. #define COMMAND_MOVE_COPY_SAME   4
  425. #define COMMAND_MOVE_COPY_DIFF   5
  426. #define COMMAND_MOVE_DELETE_SAME 6
  427. #define COMMAND_MOVE_DELETE_DIFF 7
  428.  
  429. #define SOURCE_COMMAND      1
  430. #define SOURCE_PREFIX       2
  431. #define SOURCE_BLOCK        3
  432. #define SOURCE_BLOCK_RESET  4
  433.  
  434. struct line
  435.  {
  436.   struct line *prev;                  /* pointer to previous line */
  437.   struct line *next;                  /* pointer to next line */
  438.   unsigned short length;              /* number of characters in line */
  439.   char *line;                /* pointer to contents of line */
  440.   char *name;                /* pointer to name of line (for SET POINT)*/
  441.   char display;              /* display level for each line */
  442.   int pre;                            /* index to contents of prefix command */
  443.  };
  444. typedef struct line LINE;
  445.  
  446. struct targets
  447.  {
  448.   char *prefix;              /* pointer to target prefix */
  449.   int length;                         /* length of prefix */
  450.   char delim;                /* target delimiter */
  451.   int direction;                      /* search direction for target */
  452.  };
  453. typedef struct targets SEARCH_TARGET;
  454.  
  455. struct prefix_commands
  456.  {
  457.   char *cmd;                 /* prefix command */
  458.   int cmd_len;                        /* length of prefix command */
  459.   bool action_prefix;                 /* is command an action or a target */
  460.   bool multiples_allowed;             /* are multiples allowed */
  461.   bool full_target_allowed;           /* full target multiple allowed */
  462.   bool block_prefix_command;          /* is command a block command */
  463.   bool target_required;               /* does command require target */
  464.   bool valid_on_tof;                  /* is command allowed on Top of File line */
  465.   bool valid_on_bof;                  /* is command allowed on Bottom of File line */
  466. #ifdef PROTO
  467.  int (*function)(int,int,long);
  468. #else
  469.  int (*function)();
  470. #endif
  471.  };
  472. typedef struct prefix_commands PREFIX_COMMAND;
  473.  
  474. struct pending_prefix_command
  475.  {
  476.   char ppc_command[PREFIX_WIDTH+1];     /* prefix command */
  477.   long ppc_line_number;               /* line number in file */
  478.   long ppc_cmd_param;                 /* prefix command parameter */
  479.   int ppc_cmd_idx;                    /* prefix command index */
  480.   bool ppc_block_command;             /* is it a BLOCK command */
  481.  };
  482. typedef struct pending_prefix_command PENDING_PREFIX_COMMAND;
  483.  
  484. typedef struct
  485.  {
  486.   char backup;               /* indicates if backup file kept */
  487.   char autosave;             /* number of alterations before autosaving */
  488.   char eolout;               /* indicates how lines are terminated on output */
  489.   char status_row;           /* row on which status line is displayed */
  490.   char tabsout_on;           /* indicates if tabs to replace spaces on file */
  491.   char tabsout_num;          /* length of tab stops on file */
  492.   char pseudo_file;          /* indicates if file is a "pseudo" file and if so, what sort */
  493.   unsigned short autosave_alt;        /* number of alterations since last autosave */
  494.   unsigned short save_alt;            /* number of alterations since last save */
  495.   FILE *fp;                           /* file handle for this file */
  496.   char *fname;               /* file name */
  497.   char *fpath;               /* file path */
  498.   unsigned short fmode;               /* file mode of file */
  499.   LINE *first_line;                   /* pointer to first line */
  500.   LINE *curr_line;                    /* pointer to current line */
  501.   LINE *last_line;                    /* pointer to last line */
  502.   unsigned long  number_lines;        /* number of actual lines in file */
  503.   char file_views;           /* number of views of current file */
  504.  } FILE_DETAILS;
  505.  
  506. struct view_details
  507.  {
  508.   struct view_details *prev;          /* pointer to previous view */
  509.   struct view_details *next;          /* pointer to next view */
  510.   char arbchar_status;       /* indicates if arbchar is on */
  511.   char arbchar_char;         /* arbitrary character value */
  512.   char cmd_line;             /* line where command line is displayed */
  513.   char command_row;          /* row on which command line is displayed */
  514.   char error_row;            /* row on which errors are to be displayed */
  515.   char tab_row;              /* row on which tab line is displayed */
  516.   char tab_on;               /* indicates if tab line is to be displayed */
  517.   char scale_row;            /* row on which scale row is displayed */
  518.   char scale_on;             /* indicates if scale is displayed */
  519.   char current_row;          /* row which is current row */
  520.   char current_base;         /* indicates relative position of current line */
  521.   char current_off;                   /* offset from current_base for current_row */
  522.   char prefix;               /* indicates if and where prefix is displayed */
  523.   char number;               /* indicates if numbers in prefix are to be displayed */
  524.   char message_mode;         /* indicates if messages are to be displayed */
  525.   char imp_macro;            /* indicates if implied macro processing is on */
  526.   char imp_os;               /* indicates if implied os processing is on */
  527.   char case_enter;           /* indicates case of data entered */
  528.   char case_locate;          /* indicates case of data located */
  529.   char case_change;          /* indicates case of data changed */
  530.   char case_sort;            /* indicates case significance for sorting */
  531.   char display_low;          /* low range of display level */
  532.   char display_high;         /* high range of display level */
  533.   char scope;                /* indicates if commands act on All lines or only those Displayed */
  534.   char stay;                 /* indicates status of STAY */
  535.   char tabs;                 /* tab stop increments */
  536.   char newline_aligned;      /* TRUE if adding a new line results in cursor appearing under 1st non-blank of previous line */
  537.   char hex;                  /* TRUE if hex conversion is done on string operands */
  538.   unsigned short margin_left;         /* left margin column 1 based */
  539.   unsigned short margin_right;        /* right margin column 1 based */
  540.   short margin_indent;                /* paragraph indentation */
  541.   bool margin_indent_offset;          /* TRUE if paragraph indentation is an offset from left column */
  542.   unsigned short verify_col;          /* left col for current verify */
  543.   unsigned short verify_start;        /* col of start of verify */
  544.   unsigned short verify_end;          /* col of end of verify */
  545.   bool wordwrap;                      /* wordwrap setting */
  546.   unsigned short zone_start;          /* col of start of zone */
  547.   unsigned short zone_end;            /* col of end of zone */
  548.   bool linend_status;                 /* indicates if multiple commands allowed on command line */
  549.   char linend_value;         /* specifies command delimiter */
  550.   long  current_line;                 /* line in file displayed on current row */
  551.   long  focus_line;                   /* line in file where cursor is */
  552.   short mark_type;                    /* type of marked block */
  553.   long  mark_start_line;              /* first line to be marked */
  554.   long  mark_end_line;                /* last line to be marked */
  555.   short mark_start_col;               /* first column marked */
  556.   short mark_end_col;                 /* last column marked */
  557.   WINDOW *win[VIEW_WINDOWS];          /* curses windows for the file contents */
  558.   char current_window;       /* current window for current file */
  559.   char previous_window;      /* previous window for current file */
  560.   PENDING_PREFIX_COMMAND ppc[MAX_PENDING_PREFIX_COMMANDS];
  561.   unsigned short prefix_command_index;
  562.   FILE_DETAILS *file_for_view;        /* pointer to file structure */
  563.  };
  564. typedef struct view_details VIEW_DETAILS;
  565.  
  566. typedef struct
  567.  {
  568.   char origin_x;             /* top left corner of physical screen */
  569.   char origin_y;
  570.   char screen_rows;          /* physical rows */
  571.   char screen_cols;          /* physical cols */
  572.   char rows;                 /* rows in data window */
  573.   char cols;                 /* cols in data window */
  574.   char top_row;              /* start row of data window */
  575.   char top_col;              /* start col of data window */
  576.   VIEW_DETAILS *screen_view;          /* view being displayed in this screen */
  577.  } SCREEN_DETAILS;
  578.  
  579. #define STATUS_ROW         (screen_rows-1)
  580. #define COMMAND_ROW        (screen_rows-2)
  581. #define ERROR_ROW          1
  582. #define TAB_ROW            6
  583. #define TAB_ON             NO
  584. #define SCALE_ROW          6
  585. #define SCALE_ON           NO
  586. #define CURSOR_ROW         COMMAND_ROW
  587. #define CURSOR_COL         5
  588. #define CURRENT_ROW_POS    0
  589. #define CURRENT_ROW        0
  590. #define ZONE_START         1
  591. #define ZONE_END           MAX_INT
  592.  
  593. /* defines for current_base */
  594. #define CURLINE_TOP        0
  595. #define CURLINE_MIDDLE     1
  596. #define CURLINE_BOTTOM     2
  597.  
  598. /* defines for pseudo file types */
  599. #define PSEUDO_REAL        0
  600. #define PSEUDO_DIR         1
  601. #define PSEUDO_REXX        2
  602.  
  603. /* defines for prefix settings */
  604. #define PREFIX_OFF         0
  605. #define PREFIX_LEFT        1
  606. #define PREFIX_RIGHT       2
  607.  
  608. /* defines for query types */
  609. #define QUERY_NONE         0
  610. #define QUERY_QUERY        1
  611. #define QUERY_STATUS       2
  612. #define QUERY_EXTRACT      4
  613. #define QUERY_FUNCTION     8
  614. #define QUERY_MODIFY      16
  615.  
  616. /* defines for case settings */
  617. #define CASE_MIXED         'M'
  618. #define CASE_UPPER         'U'
  619. #define CASE_LOWER         'L'
  620. #define CASE_IGNORE        'I'
  621. #define CASE_RESPECT       'R'
  622.  
  623. /* type of marked blocks */
  624. #define M_LINE             1
  625. #define M_BOX              2
  626. #define M_STREAM           3
  627.  
  628. /* defines for temporary space allocation */
  629. #define TEMP_PARAM         1
  630. #define TEMP_MACRO         2
  631. #define TEMP_TMP_CMD       3
  632. #define TEMP_TEMP_CMD      4
  633.  
  634. /* split/join commands */
  635. #define SPLIT_TRUE         TRUE
  636. #define SPLIT_FALSE        FALSE
  637. #define ALIGNED_TRUE       TRUE
  638. #define ALIGNED_FALSE      FALSE
  639.  
  640. /* box opertaions */
  641. #define BOX_C           1
  642. #define BOX_M           2
  643. #define BOX_D           3
  644. #define BOX_F           4
  645.  
  646. #ifndef FILE_NORMAL
  647. #define FILE_NORMAL        0
  648. #endif
  649.  
  650. #ifndef FILE_READONLY
  651. #define FILE_READONLY      1
  652. #endif
  653.  
  654. #ifndef FILE_NEW
  655. #define FILE_NEW          99
  656. #endif
  657.  
  658. #define COMMAND_ONLY_TRUE    TRUE
  659. #define COMMAND_ONLY_FALSE   FALSE
  660.  
  661. #define ADDCHAR            0
  662. #define INSCHAR            1
  663.  
  664. #ifndef getbegyx
  665. #define getbegyx(win,y,x)       (y = (win)->_begy, x = (win)->_begx)
  666. #endif
  667.  
  668. #define HIT_ANY_KEY "Hit any key to continue..."
  669.  
  670. /*---------------------- return code constants ------------------------*/
  671. #define     RC_OK               0
  672. #define     RC_NOT_COMMAND     -1
  673. #define     RC_INVALID_ENVIRON -3
  674. #define     RC_TOF_EOF_REACHED  1
  675. #define     RC_TARGET_NOT_FOUND 2
  676. #define     RC_TRUNCATED        3
  677. #define     RC_NO_LINES_CHANGED 4
  678. #define     RC_INVALID_OPERAND  5
  679. #define     RC_COMMAND_NO_FILES 6
  680. #define     RC_FILE_CHANGED    12
  681. #define     RC_ACCESS_DENIED   12
  682. #define     RC_DISK_FULL       13
  683. #define     RC_BAD_FILEID      20
  684. #define     RC_BAD_DRIVE       24
  685. #define     RC_FILE_NOT_FOUND  28
  686. #define     RC_OUT_OF_MEMORY   94
  687. #define     RC_SYSTEM_ERROR    99
  688. /*---------------------- useful macros --------------------------------*/
  689. #define     TOF(line)           ((line == 0L) ? TRUE : FALSE)
  690. #define     BOF(line)           ((line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  691. #define     CURRENT_TOF         ((CURRENT_VIEW->current_line == 0L) ? TRUE : FALSE)
  692. #define     CURRENT_BOF         ((CURRENT_VIEW->current_line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  693. #define     FOCUS_TOF           ((CURRENT_VIEW->focus_line == 0L) ? TRUE : FALSE)
  694. #define     FOCUS_BOF           ((CURRENT_VIEW->focus_line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  695. #define     IN_VIEW(view,line)   ((line >= (view->current_line - (long)view->current_row)) && (line <= (view->current_line + ((long)CURRENT_SCREEN.rows - (long)view->current_row))))
  696. /*---------------------- system specific redefines --------------------*/
  697. #ifdef VAX
  698. #define     wattrset     wsetattr
  699. #define     A_REVERSE    _REVERSE
  700. #define     A_BOLD       _BOLD
  701. #endif
  702. /*---------------------- global parameters ----------------------------*/
  703. #define EOLOUT_LF                0
  704. #define EOLOUT_CRLF              1
  705. /*---------------------- extract return codes -------------------------*/
  706. #define EXTRACT_ARG_ERROR        (-2)
  707. #define EXTRACT_VARIABLES_SET    (-1)
  708. /*---------------------- attribute defines ----------------------------*/
  709. #define ATTR_FILEAREA   0
  710. #define ATTR_CURLINE    1
  711. #define ATTR_BLOCK      2
  712. #define ATTR_CBLOCK     3
  713. #define ATTR_CMDLINE    4
  714. #define ATTR_IDLINE     5
  715. #define ATTR_MSGLINE    6
  716. #define ATTR_ARROW      7
  717. #define ATTR_PREFIX     8
  718. #define ATTR_PENDING    9
  719. #define ATTR_SCALE     10
  720. #define ATTR_TOFEOF    11
  721. #define ATTR_CTOFEOF   12
  722. #define ATTR_TABLINE   13
  723. #define ATTR_SHADOW    14
  724. #define ATTR_STATAREA  15
  725. #define ATTR_DIVIDER   16
  726. #define ATTR_RESERVED  17
  727. #define ATTR_MAX       18
  728.  
  729. #ifdef MAIN
  730. /*---------------------------------------------------------------------*/
  731. /* Following is  for colour support.                                   */
  732. /*---------------------------------------------------------------------*/
  733.  
  734. chtype colour[ATTR_MAX];
  735. chtype save_fg[ATTR_MAX];
  736. chtype save_bg[ATTR_MAX];
  737. chtype save_mod[ATTR_MAX];
  738.  
  739. short max_line_length=MAX_LENGTH_OF_LINE;
  740.  
  741. #else
  742.  
  743. extern chtype colour[ATTR_MAX];
  744. extern chtype save_fg[ATTR_MAX];
  745. extern chtype save_bg[ATTR_MAX];
  746. extern chtype save_mod[ATTR_MAX];
  747.  
  748. extern short max_line_length;
  749. #endif
  750.  
  751. #define PARACOL (CURRENT_VIEW->margin_indent_offset ? CURRENT_VIEW->margin_left + CURRENT_VIEW->margin_indent : CURRENT_VIEW->margin_indent)
  752.  
  753. /* structure for passing box parameters */
  754. struct _boxp
  755.  {
  756.   int action;
  757.   int src_start_col;
  758.   int dst_start_col;
  759.   int num_cols;
  760.   long src_start_line;
  761.   long dst_start_line;
  762.   long num_lines;
  763.   LINE *curr_src;
  764.   LINE *curr_dst;
  765.  };
  766. typedef struct _boxp BOXP;
  767.  
  768. /* structure for passing queryable values parameters */
  769. struct query_values
  770.  {
  771.   char *value;                       /* value of item */
  772.   int len;                 /* length of string representation of value */
  773.  };
  774. typedef struct query_values VALUE;
  775.  
  776. /* structure for function key redefinition */
  777. struct defines
  778. {
  779.  struct defines *prev;
  780.  struct defines *next;
  781.  unsigned int def_funkey;
  782.  short def_command;
  783.  char *def_params;
  784.  char def_delim;
  785. };
  786. typedef struct defines DEFINE;
  787.