home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / thesrc251.zip / the.h < prev    next >
C/C++ Source or Header  |  1998-07-23  |  51KB  |  1,353 lines

  1. /*
  2.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  3.  * Copyright (C) 1991-1997 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@qut.edu.au
  30.  * PO Box 203                    Phone:                    +617 3802 0800
  31.  * Bellara                       http://www.gu.edu.au/gext/the/markh.html
  32.  * QLD 4507                      **** Maintainer PDCurses & REXX/SQL ****
  33.  * Australia                     ************* Author of THE ************
  34.  */
  35.  
  36. /*
  37. $Id: the.h 2.1 1995/06/24 16:31:26 MH Rel MH $
  38. */
  39.  
  40. #include <defines.h>
  41.  
  42. #if defined(USE_XCURSES)
  43. #  define XCURSES
  44. #  include <xcurses.h>
  45. #  define CURSES_H_INCLUDED
  46. #endif
  47.  
  48. #if defined(USE_NCURSES)
  49. #  include <ncurses.h>
  50. #  define CURSES_H_INCLUDED
  51. #endif
  52.  
  53. #if defined(USE_EXTCURSES)
  54. #  include <cur00.h>
  55. #  define A_COLOR
  56. #  define COLOR_BLACK        0
  57. #  define COLOR_BLUE        1
  58. #  define COLOR_GREEN        2
  59. #  define COLOR_CYAN        3
  60. #  define COLOR_RED        4
  61. #  define COLOR_MAGENTA        5
  62. #  define COLOR_YELLOW        6
  63. #  define COLOR_WHITE        7
  64.    typedef char bool;
  65. #  ifdef chtype
  66. #    undef chtype
  67. #  endif
  68. #  define chtype NLSCHAR
  69. #  define COLORS       8
  70. #  define COLOR_PAIRS 64
  71.    extern chtype color_pair[COLOR_PAIRS];
  72. #  define COLOR_PAIR(n) color_pair[n]
  73. #  ifndef HAVE_WATTRSET
  74. #    define HAVE_WATTRSET
  75. #    define wattrset(win,attr) xstandout(win,attr)
  76. #    define attrset(attr) xstandout(stdscr,attr)
  77. #  endif
  78. #  ifndef HAVE_NOCBREAK
  79. #    define HAVE_NOCBREAK
  80. #    define nocbreak() nocrmode()
  81. #  endif
  82. #  ifndef HAVE_CBREAK
  83. #    define HAVE_CBREAK
  84. #    define cbreak() crmode()
  85. #  endif
  86. #  define CURSES_H_INCLUDED
  87. #endif
  88.  
  89. #ifndef CURSES_H_INCLUDED
  90. #  include <curses.h>
  91. #endif
  92.  
  93. #if defined(__OS2__)
  94. #  if defined(MSDOS) && defined(EMX)
  95. #     undef __OS2__
  96. #     if !defined(DOS)
  97. #        define DOS
  98. #     endif
  99. #     if defined(OS2)
  100. #        undef OS2
  101. #     endif
  102. #  else
  103. #     undef MSDOS          /* in case you are using MSC 6.0 for OS/2 */
  104. #     if defined(__EMX__) && defined(USE_REGINA)
  105. #        include <os2.h>
  106. #        undef RXAUTOBUFLEN
  107. #        undef MAKERXSTRING
  108. #        undef RXNULLSTRING
  109. #        undef RXSTRLEN
  110. #        undef RXSTRPTR
  111. #        undef RXVALIDSTRING
  112. #        undef RXZEROLENSTRING
  113. #      endif
  114. #  endif
  115. #  include <stdlib.h>
  116. #  include <memory.h>
  117. #  include <string.h>
  118. #  include <process.h>
  119. #  include <errno.h>
  120. #  include <ctype.h>
  121. #  include <fcntl.h>
  122. #  include <io.h>
  123. #  include <sys\types.h>
  124. #  include <sys\stat.h>
  125. #  define ESLASH '\\'
  126. #  define ESTR_SLASH (CHARTYPE *)"\\"
  127. #  if defined(EMX)
  128. #    define OSLASH '\\'
  129. #    define OSTR_SLASH (CHARTYPE *)"\\"
  130. #    define ISLASH '/'
  131. #    define ISTR_SLASH (CHARTYPE *)"/"
  132. #    define HAVE_BROKEN_TMPNAM 1
  133. #  else
  134. #    define OSLASH '/'
  135. #    define OSTR_SLASH (CHARTYPE *)"/"
  136. #    define ISLASH '\\'
  137. #    define ISTR_SLASH (CHARTYPE *)"\\"
  138. #  endif
  139. #  define CURRENT_DIR (CHARTYPE *)"."
  140. #  if defined(MSC)
  141. /* the following 2 defines are to make MSC recognise the new names */
  142. /* of the following OS/2 calls */
  143. #    define DosSetDefaultDisk DosSelectDisk
  144. #    define DosQueryCurrentDisk DosQCurDisk
  145. #  endif
  146. /* the following #define is to eliminate need for the getch.c/getch.h */
  147. /* modules in the OS/2 compilation */
  148. #  define my_getch(win)  wgetch(win)
  149. #endif
  150.  
  151. #if defined(__MSDOS__) || defined(MSDOS)
  152. #  include <stdlib.h>
  153. #  include <memory.h>
  154. #  include <string.h>
  155. #  include <fcntl.h>
  156. #  include <io.h>
  157. #  if defined(GO32)
  158. #    include <dir.h>
  159. #  else
  160. #    include <process.h>
  161. #    if !defined(EMX)
  162. #      include <direct.h>
  163. #    endif
  164. #  endif
  165. #  include <errno.h>
  166. #  include <io.h>
  167. #  include <ctype.h>
  168. #  include <sys\types.h>
  169. #  include <sys\stat.h>
  170. #  define ESLASH '\\'
  171. #  define ESTR_SLASH (CHARTYPE *)"\\"
  172. #  if defined(GO32) || defined(EMX)
  173. #    define OSLASH '\\'
  174. #    define OSTR_SLASH (CHARTYPE *)"\\"
  175. #    define ISLASH '/'
  176. #    define ISTR_SLASH (CHARTYPE *)"/"
  177. #  else
  178. #    define OSLASH '/'
  179. #    define OSTR_SLASH (CHARTYPE *)"/"
  180. #    define ISLASH '\\'
  181. #    define ISTR_SLASH (CHARTYPE *)"\\"
  182. #  endif
  183. #  if defined(__TURBOC__) || defined(MSC)
  184. #    define HAVE_BROKEN_TMPNAM 1
  185. #  endif
  186. #  define CURRENT_DIR (CHARTYPE *)"."
  187. /* the following #define is to eliminate need for the getch.c/getch.h */
  188. /* modules in the DOS compilation */
  189. #  define my_getch(win)  wgetch(win)
  190. #endif
  191.  
  192. #if defined(__NT__) || defined(WIN32)
  193. #  include <stdlib.h>
  194. #  include <memory.h>
  195. #  include <string.h>
  196. #  include <process.h>
  197. #  include <errno.h>
  198. #  include <ctype.h>
  199. #  include <fcntl.h>
  200. #  include <io.h>
  201. #  include <sys\types.h>
  202. #  include <sys\stat.h>
  203. #  define ESLASH '\\'
  204. #  define ESTR_SLASH (CHARTYPE *)"\\"
  205. #  if defined(__CYGWIN32__)
  206. #    if defined(UNIX)
  207. #       undef UNIX
  208. #    endif
  209. #    define OSLASH '\\'
  210. #    define OSTR_SLASH (CHARTYPE *)"\\"
  211. #    define ISLASH '/'
  212. #    define ISTR_SLASH (CHARTYPE *)"/"
  213. #  else
  214. #    define OSLASH '/'
  215. #    define OSTR_SLASH (CHARTYPE *)"/"
  216. #    define ISLASH '\\'
  217. #    define ISTR_SLASH (CHARTYPE *)"\\"
  218. #  endif
  219. #  if defined(__WATCOMC__)
  220. #    define HAVE_BROKEN_TMPNAM 1
  221. #  endif
  222. #  define CURRENT_DIR (CHARTYPE *)"."
  223. #  define CAN_RESIZE 1
  224. /* the following #define is to eliminate need for the getch.c/getch.h */
  225. /* modules in the WIN32 compilation */
  226. #  define my_getch(win)  wgetch(win)
  227. #endif
  228.  
  229. #ifdef HAVE_CONFIG_H
  230. # ifndef HAVE_WATTRSET
  231. #  define wattrset(win,attr) ((attr == A_NORMAL) ? wstandend(win) : wstandout(win))
  232. #  define attrset(attr)      wattrset(stdscr,attr)
  233. # endif
  234. # ifndef HAVE_KEYPAD
  235. #  define keypad(win,bf)
  236. # endif
  237. # ifndef HAVE_NOTIMEOUT
  238. #  define notimeout(win,bf)
  239. # endif
  240. # ifndef HAVE_RAW
  241. #  define raw()
  242. # endif
  243. # ifndef HAVE_NOCBREAK
  244. #  define nocbreak()
  245. # endif
  246. # ifndef HAVE_CBREAK
  247. #  define cbreak()
  248. # endif
  249. # ifndef HAVE_WNOUTREFRESH
  250. #  define wnoutrefresh(win) wrefresh(win)
  251. # endif
  252. # ifndef HAVE_TOUCHLINE
  253. #  define touchline(win,start,num) touchwin(win)
  254. # endif
  255. # ifndef HAVE_RESET_SHELL_MODE
  256. #  define reset_shell_mode()
  257. # endif
  258. # ifndef HAVE_RESET_PROG_MODE
  259. #  define reset_prog_mode()
  260. # endif
  261. #endif
  262.  
  263. #ifdef M_XENIX
  264. #  define UNIX 1
  265. #endif
  266.  
  267. #ifdef MINIX
  268. #  define short int
  269. #  define UNIX 1
  270. #endif
  271.  
  272. #ifdef UNIX
  273. #  define ESLASH '/'
  274. #  define ESTR_SLASH (CHARTYPE *)"/"
  275. #  define OSLASH '\\'
  276. #  define OSTR_SLASH (CHARTYPE *)"\\"
  277. #  define ISLASH ESLASH
  278. #  define ISTR_SLASH ESTR_SLASH
  279. #  define CURRENT_DIR (CHARTYPE *)"."
  280. #endif
  281.  
  282. #ifdef HAVE_CTYPE_H
  283. # include <ctype.h>
  284. #endif
  285.  
  286. #ifdef HAVE_SYS_TYPES_H
  287. # include <sys/types.h>
  288. #endif
  289.  
  290. #ifdef HAVE_UNISTD_H
  291. # include <unistd.h>
  292. #endif
  293.  
  294. #ifdef HAVE_STDLIB_H
  295. # include <stdlib.h>
  296. #endif
  297.  
  298. #ifdef HAVE_SYS_STAT_H
  299. # include <sys/stat.h>
  300. #endif
  301.  
  302. #ifdef HAVE_SYS_FILE_H
  303. # include <sys/file.h>
  304. #endif
  305.  
  306. #ifdef HAVE_MEMORY_H
  307. # include <memory.h>
  308. #endif
  309.  
  310. #ifdef HAVE_STRING_H
  311. # include <string.h>
  312. #endif
  313.        
  314. #ifdef HAVE_FCNTL_H
  315. # include <fcntl.h>
  316. #endif
  317.  
  318. #include <signal.h>
  319.  
  320. #if defined(USE_XCURSES)
  321. #  if defined(SIGWINCH) && defined(HAVE_RESIZE_TERM)
  322. #    define CAN_RESIZE
  323. #  endif
  324. #endif
  325.  
  326. #if defined(USE_NCURSES)
  327. #  if defined(SIGWINCH) && defined(TIOCGWINSZ) && !defined(BROKEN_TIOCGWINSZ) && defined(HAVE_RESIZETERM)
  328. #    define CAN_RESIZE
  329. #  endif
  330. #endif
  331.  
  332. #if defined(HAVE_SLK_INIT)
  333. # if defined(__PDCURSES__)
  334. #  define MAX_SLK    10
  335. # else
  336. #  define MAX_SLK     8
  337. # endif
  338. #else
  339. # define MAX_SLK      0
  340. #endif
  341.  
  342. #ifdef VMS
  343. #  include <string.h>
  344. #  include <file.h>
  345. #  include <types.h>
  346. #  include <stat.h>
  347. #  include <ctype.h>
  348. #  define ISLASH ']'
  349. #  define ISTR_SLASH (CHARTYPE *)"]"
  350. #  define OSLASH ISLASH
  351. #  define OSTR_SLASH ISTR_SLASH
  352. #  define ESLASH ISLASH
  353. #  define ESTR_SLASH ISTR_SLASH
  354. #  define CURRENT_DIR (CHARTYPE *)"[]"
  355. #  ifdef BSD
  356. #    define chtype short
  357. #    define BSDcurses 1
  358. #  endif
  359. #  define touchline(WIN,START,NUM)       touchwin(WIN)
  360. /* #define isdigit(c)   (_ctype[(c) + 1] & 2)
  361. #  define islower(c)   (_ctype[(c) + 1] & 8)
  362. #  define isupper(c)   (_ctype[(c) + 1] & 4)*/
  363. #  define NO_KEYPAD 1
  364. #endif
  365.  
  366. #ifndef F_OK
  367. #  define         F_OK          00
  368. #endif
  369. #ifndef W_OK
  370. #  define         W_OK          02
  371. #endif
  372. #ifndef R_OK
  373. #  define         R_OK          04
  374. #endif
  375. /*---------------------------------------------------------------------*/
  376. /* End of OS-specific defines                                          */
  377. /*---------------------------------------------------------------------*/
  378. /*
  379.  * This define ensures that any changes in the configure
  380.  * cause the user to have to re-run configure.
  381.  * This is set in defines.h or config.h
  382.  */
  383. #ifndef BUILD2502
  384. # include "This release requires that you run configure again"
  385. #endif
  386.  
  387. /*
  388.  * This define ensures that any mismatching of version of
  389.  * THE and PDCurses are picked up
  390.  * 
  391.  */
  392. #if defined(PDCURSES) && !defined(PDC_BUILD2303)
  393. # include "You need a version of PDCurses with PDC_BUILD2303 defined in curses.h"
  394. #endif
  395.  
  396. #if !defined(A_COLOR)
  397. #   define COLOR_BLACK        0
  398. #   define COLOR_BLUE        0
  399. #   define COLOR_GREEN        0
  400. #   define COLOR_CYAN        0
  401. #   define COLOR_RED        0
  402. #   define COLOR_MAGENTA        0
  403. #   define COLOR_YELLOW        0
  404. #   define COLOR_WHITE        0
  405. #endif
  406.  
  407. #ifndef A_NORMAL
  408. /* Various video attributes */
  409. # define A_STANDOUT      BSD_STANDOUT /* for compatability with BSD curses */
  410. # define A_REVERSE       BSD_STANDOUT /* for compatability with BSD curses */
  411. # define A_UNDERLINE     0
  412. # define A_BLINK         0
  413. # define A_DIM           0
  414. # define A_BOLD          BSD_STANDOUT
  415.  
  416. /* The next two are subject to change so don't depend on them */
  417. # define A_INVIS         0
  418. # define A_PROTECT       0
  419.  
  420. # define A_NORMAL        0
  421. # define A_CHARTEXT      0x007F
  422. # define A_ATTRIBUTES    ~A_CHARTEXT
  423. # define A_ALTCHARSET    0
  424. #endif
  425.  
  426. #if THE_FOLLOWING_REMOVED_IN_22
  427. #ifndef A_NORMAL
  428. /* Various video attributes */
  429. # ifdef HAVE_BSD_CURSES
  430. #  define A_STANDOUT      BSD_STANDOUT /* for compatability with BSD curses */
  431. #  define A_REVERSE       BSD_STANDOUT /* for compatability with BSD curses */
  432. #  define A_UNDERLINE     0
  433. #  define A_BLINK         0
  434. #  define A_DIM           0
  435. #  define A_BOLD          BSD_STANDOUT
  436.  
  437. /* The next two are subject to change so don't depend on them */
  438. #  define A_INVIS         0
  439. #  define A_PROTECT       0
  440.  
  441. #  define A_NORMAL        0
  442. #  define A_CHARTEXT      0x007F
  443. #  define A_ATTRIBUTES    ~A_CHARTEXT
  444. #  define A_ALTCHARSET    0
  445.  
  446. # else
  447.  
  448. #  define A_STANDOUT      000000200000L
  449. #  define A_UNDERLINE     000000400000L
  450. #  define A_REVERSE       000001000000L
  451. #  define A_BLINK         000002000000L
  452. #  define A_DIM           000004000000L
  453. #  define A_BOLD          000010000000L
  454. #  define A_ALTCHARSET    000100000000L
  455.  
  456. /* The next two are subject to change so don't depend on them */
  457. #  define A_INVIS         000020000000L
  458. #  define A_PROTECT       000040000000L
  459.  
  460. #  define A_NORMAL        000000000000L
  461. #  define A_ATTRIBUTES    037777600000L   /* 0xFFFF0000 */
  462. #  define A_CHARTEXT      000000177777L   /* 0x0000FFFF */
  463.  
  464. # endif
  465. #endif
  466. #endif
  467.  
  468.  
  469. #define ATTR2PAIR(fg,bg) (bg|(fg<<3))
  470. #define FOREFROMPAIR(p)  (p>>3)
  471. #define BACKFROMPAIR(p)  (p&0x07)
  472.  
  473. #ifndef max
  474. # define max(a,b)        (((a) > (b)) ? (a) : (b))
  475. #endif
  476.  
  477. #ifndef min
  478. # define min(a,b)        (((a) < (b)) ? (a) : (b))
  479. #endif
  480.  
  481. #ifndef getmaxy
  482. # ifdef VMS
  483. #  define getmaxy(win)    ((win)->_max_y)
  484. # else
  485. #  define getmaxy(win)    ((win)->_maxy)
  486. # endif
  487. #endif
  488.  
  489. #ifndef getmaxx
  490. # ifdef VMS
  491. #  define getmaxx(win)    ((win)->_max_x)
  492. # else
  493. #  define getmaxx(win)    ((win)->_maxx)
  494. # endif
  495. #endif
  496.  
  497. #ifndef getmaxyx
  498. # define getmaxyx(win,y,x)  ((y) = getmaxy(win), (x) = getmaxx(win))
  499. #endif
  500.  
  501. #define QUIT          (-127)
  502. #define SKIP          (-126)
  503. #define QUITOK        (-125)
  504. #define RAW_KEY       (128)
  505.  
  506. #define MAX_SCREENS         2              /* maximum number of screens*/
  507. #define VIEW_WINDOWS        6            /* number of windows per view */
  508. #define MAX_INT             32766          /* maximum size for integer */
  509. #define MAX_LONG            2147483001L       /* maximum size for long */
  510. #define WORD_DELIMS         (CHARTYPE *)" \t" /* word delimiter characters */
  511.  
  512. #define TOP_OF_FILE         (CHARTYPE *)"*** Top of File ***"
  513. #define BOTTOM_OF_FILE      (CHARTYPE *)"*** Bottom of File ***"
  514. #define DIRECTION_NONE      0
  515. #define DIRECTION_FORWARD   1
  516. #define DIRECTION_BACKWARD  (-1)
  517.  
  518. #define UNDEFINED_OPERAND (-1)
  519.  
  520. /* the first 6 windows MUST be numbered 0-5 */
  521. #define WINDOW_FILEAREA 0
  522. #define WINDOW_PREFIX   1
  523. #define WINDOW_COMMAND  2
  524. #define WINDOW_ARROW    3
  525. #define WINDOW_IDLINE   4
  526. #define WINDOW_GAP      5
  527. #define WINDOW_STATAREA 6
  528. #define WINDOW_ERROR    7
  529. #define WINDOW_DIVIDER  8
  530. #define WINDOW_RESERVED 9
  531. #define WINDOW_SLK     10
  532.  
  533. #define MAX_PREFIX_WIDTH     20
  534. #define DEFAULT_PREFIX_WIDTH  6
  535. #define DEFAULT_PREFIX_GAP    0
  536.  
  537. #define CURRENT_SCREEN              screen[current_screen]
  538. #define other_screen                ((current_screen==0)?1:0)
  539. #define OTHER_SCREEN                screen[other_screen]
  540.  
  541. #define PREVIOUS_VIEW               (vd_current->prev)
  542. #define NEXT_VIEW                   (vd_current->next)
  543.  
  544. #define CURRENT_VIEW                (vd_current)
  545. #define CURRENT_FILE                (vd_current->file_for_view)
  546. #define CURRENT_WINDOW              (CURRENT_SCREEN.win[vd_current->current_window])
  547. #define CURRENT_PREV_WINDOW         (CURRENT_SCREEN.win[vd_current->previous_window])
  548. #define CURRENT_WINDOW_FILEAREA     (CURRENT_SCREEN.win[WINDOW_FILEAREA])
  549. #define CURRENT_WINDOW_PREFIX       (CURRENT_SCREEN.win[WINDOW_PREFIX])
  550. #define CURRENT_WINDOW_GAP          (CURRENT_SCREEN.win[WINDOW_GAP])
  551. #define CURRENT_WINDOW_COMMAND      (CURRENT_SCREEN.win[WINDOW_COMMAND])
  552. #define CURRENT_WINDOW_ARROW        (CURRENT_SCREEN.win[WINDOW_ARROW])
  553. #define CURRENT_WINDOW_IDLINE       (CURRENT_SCREEN.win[WINDOW_IDLINE])
  554.  
  555. #define OTHER_VIEW                  (OTHER_SCREEN.screen_view)
  556. #define OTHER_FILE                  (OTHER_VIEW->file_for_view)
  557. #define OTHER_WINDOW                (OTHER_SCREEN.win[OTHER_VIEW->current_window])
  558. #define OTHER_PREV_WINDOW           (OTHER_SCREEN.win[OTHER_VIEW->previous_window])
  559. #define OTHER_WINDOW_FILEAREA       (OTHER_SCREEN.win[WINDOW_FILEAREA])
  560. #define OTHER_WINDOW_PREFIX         (OTHER_SCREEN.win[WINDOW_PREFIX])
  561. #define OTHER_WINDOW_GAP            (OTHER_SCREEN.win[WINDOW_GAP])
  562. #define OTHER_WINDOW_COMMAND        (OTHER_SCREEN.win[WINDOW_COMMAND])
  563. #define OTHER_WINDOW_ARROW          (OTHER_SCREEN.win[WINDOW_ARROW])
  564. #define OTHER_WINDOW_IDLINE         (OTHER_SCREEN.win[WINDOW_IDLINE])
  565.  
  566. #define SCREEN_VIEW(scr)            (screen[(scr)].screen_view)
  567. #define SCREEN_FILE(scr)            (screen[(scr)].screen_view->file_for_view)
  568. #define SCREEN_WINDOW(scr)          (screen[(scr)].win[screen[(scr)].screen_view->current_window])
  569. #define SCREEN_PREV_WINDOW(scr)     (screen[(scr)].win[screen[(scr)].screen_view->previous_window])
  570. #define SCREEN_WINDOW_FILEAREA(scr) (screen[(scr)].win[WINDOW_FILEAREA])
  571. #define SCREEN_WINDOW_PREFIX(scr)   (screen[(scr)].win[WINDOW_PREFIX])
  572. #define SCREEN_WINDOW_GAP(scr)      (screen[(scr)].win[WINDOW_GAP])
  573. #define SCREEN_WINDOW_COMMAND(scr)  (screen[(scr)].win[WINDOW_COMMAND])
  574. #define SCREEN_WINDOW_ARROW(scr)    (screen[(scr)].win[WINDOW_ARROW])
  575. #define SCREEN_WINDOW_IDLINE(scr)   (screen[(scr)].win[WINDOW_IDLINE])
  576.  
  577. #define MARK_VIEW (vd_mark)
  578. #define MARK_FILE (vd_mark->file_for_view)
  579.  
  580. /*------------------------ split/join actions ------------------------*/
  581. #define SPLTJOIN_SPLIT           1
  582. #define SPLTJOIN_JOIN            2
  583. #define SPLTJOIN_SPLTJOIN        3
  584. /*----------------- adjustments for calculating rec_len --------------*/
  585. #define ADJUST_DELETE            1
  586. #define ADJUST_INSERT            2
  587. #define ADJUST_OVERWRITE         3
  588. /*------------------------ column command types ----------------------*/
  589. #define COLUMN_CAPPEND           1
  590. #define COLUMN_CINSERT           2
  591. #define COLUMN_CREPLACE          3
  592. #define COLUMN_COVERLAY          4
  593. /*------------------------ block move command types ------------------*/
  594. #define COMMAND_COPY             1
  595. #define COMMAND_DELETE           2
  596. #define COMMAND_DUPLICATE        3
  597. #define COMMAND_MOVE_COPY_SAME   4
  598. #define COMMAND_MOVE_COPY_DIFF   5
  599. #define COMMAND_MOVE_DELETE_SAME 6
  600. #define COMMAND_MOVE_DELETE_DIFF 7
  601. #define COMMAND_OVERLAY_COPY     8
  602. #define COMMAND_OVERLAY_DELETE   9
  603. /*------------------------ block move source types -------------------*/
  604. #define SOURCE_UNKNOWN      0
  605. #define SOURCE_COMMAND      1
  606. #define SOURCE_PREFIX       2
  607. #define SOURCE_BLOCK        3
  608. #define SOURCE_BLOCK_RESET  4
  609. /*---------------------- return code constants ------------------------*/
  610. #define RC_OK               0
  611. #define RC_NOT_COMMAND     -1
  612. #define RC_INVALID_ENVIRON -3
  613. #define RC_TOF_EOF_REACHED  1
  614. #define RC_TARGET_NOT_FOUND 2
  615. #define RC_TRUNCATED        3
  616. #define RC_NO_LINES_CHANGED 4
  617. #define RC_INVALID_OPERAND  5
  618. #define RC_COMMAND_NO_FILES 6
  619. #define RC_FILE_CHANGED    12
  620. #define RC_ACCESS_DENIED   12
  621. #define RC_DISK_FULL       13
  622. #define RC_BAD_FILEID      20
  623. #define RC_BAD_DRIVE       24
  624. #define RC_FILE_NOT_FOUND  28
  625. #define RC_OUT_OF_MEMORY   94
  626. #define RC_NOREXX_ERROR    98
  627. #define RC_SYSTEM_ERROR    99
  628. #define RC_IO_ERROR       100
  629. #define RC_READV_TERM     101
  630. /*---------------------- global parameters ----------------------------*/
  631. #define EOLOUT_NONE              0
  632. #define EOLOUT_LF                1
  633. #define EOLOUT_CRLF              2
  634. #define EOLOUT_CR                3
  635. /*---------------------- extract return codes -------------------------*/
  636. #define EXTRACT_ARG_ERROR        (-2)
  637. #define EXTRACT_VARIABLES_SET    (-1)
  638. /*---------------------- attribute defines ----------------------------*/
  639. #define ATTR_FILEAREA    0
  640. #define ATTR_CURLINE     1
  641. #define ATTR_BLOCK       2
  642. #define ATTR_CBLOCK      3
  643. #define ATTR_CMDLINE     4
  644. #define ATTR_IDLINE      5
  645. #define ATTR_MSGLINE     6
  646. #define ATTR_ARROW       7
  647. #define ATTR_PREFIX      8
  648. #define ATTR_PENDING     9
  649. #define ATTR_SCALE      10
  650. #define ATTR_TOFEOF     11
  651. #define ATTR_CTOFEOF    12
  652. #define ATTR_TABLINE    13
  653. #define ATTR_SHADOW     14
  654. #define ATTR_STATAREA   15
  655. #define ATTR_DIVIDER    16
  656. #define ATTR_RESERVED   17
  657. #define ATTR_NONDISP    18
  658. #define ATTR_HIGHLIGHT  19
  659. #define ATTR_CHIGHLIGHT 20
  660. #define ATTR_SLK        21
  661. #define ATTR_GAP        22
  662. #define ATTR_MAX        23
  663. /*---------------------- display line types --------------------------*/
  664. #define LINE_LINE                  0
  665. #define LINE_TABLINE               1
  666. #define LINE_SCALE                 2
  667. #define LINE_SHADOW                4
  668. #define LINE_TOF                   8
  669. #define LINE_EOF                  16
  670. #define LINE_RESERVED             32
  671. #define LINE_OUT_OF_BOUNDS_ABOVE  64
  672. #define LINE_OUT_OF_BOUNDS_BELOW 128
  673. #define LINE_HEXSHOW             256
  674. /*--------------------------- target types ---------------------------*/
  675. #define TARGET_ERR          (-1)
  676. #define TARGET_UNFOUND        0x0000
  677. #define TARGET_ABSOLUTE       0x0001
  678. #define TARGET_RELATIVE       0x0002
  679. #define TARGET_STRING         0x0004
  680. #define TARGET_POINT          0x0008
  681. #define TARGET_BLANK          0x0010
  682. #define TARGET_NORMAL         TARGET_ABSOLUTE|TARGET_RELATIVE|TARGET_STRING|TARGET_POINT|TARGET_BLANK
  683. #define TARGET_ALL            0x0020
  684. #define TARGET_BLOCK          0x0040
  685. #define TARGET_BLOCK_ANY      0x0080
  686. #define TARGET_BLOCK_CURRENT  0x0100
  687. #define TARGET_SPARE          0x0200
  688. #define TARGET_FIND           0x0400
  689. #define TARGET_NFIND          0x0800
  690. #define TARGET_FINDUP         0x1000
  691. #define TARGET_NFINDUP        0x2000
  692. /*--------------------------- compatiblility modes -------------------*/
  693. #define COMPAT_THE            1
  694. #define COMPAT_XEDIT          2
  695. #define COMPAT_KEDIT          3
  696. /*--------------------------- cursor commands ------------------------*/
  697. #define CURSOR_START          (-1)
  698. #define CURSOR_ERROR          (-2)
  699. #define CURSOR_HOME           0
  700. #define CURSOR_HOME_LAST      1
  701. #define CURSOR_SCREEN         2
  702. #define CURSOR_SCREEN_UP      3
  703. #define CURSOR_SCREEN_DOWN    4
  704. #define CURSOR_SCREEN_LEFT    5
  705. #define CURSOR_SCREEN_RIGHT   6
  706. #define CURSOR_ESCREEN        7
  707. #define CURSOR_ESCREEN_UP     8
  708. #define CURSOR_ESCREEN_DOWN   9
  709. #define CURSOR_ESCREEN_LEFT   10
  710. #define CURSOR_ESCREEN_RIGHT  11
  711. #define CURSOR_COLUMN         12
  712. #define CURSOR_FILE           13
  713. #define CURSOR_CMDLINE        14
  714. #define CURSOR_KEDIT          15
  715. #define CURSOR_MOUSE          16
  716. /*--------------------------- defines for tabbing to fields ----------*/
  717. #define WHERE_WINDOW_MASK             0x0000FF00L
  718. #define WHERE_WINDOW_FILEAREA         0x00000100L
  719. #define WHERE_WINDOW_PREFIX_LEFT      0x00000200L
  720. #define WHERE_WINDOW_PREFIX_RIGHT     0x00000400L
  721. #define WHERE_WINDOW_CMDLINE_TOP      0x00000800L
  722. #define WHERE_WINDOW_CMDLINE_BOTTOM   0x00001000L
  723. #define WHERE_ROW_MASK                0x000000FFL
  724. #define WHERE_SCREEN_MASK             0x000F0000L
  725. #define WHERE_SCREEN_FIRST            0x00010000L
  726. #define WHERE_SCREEN_LAST             0x00020000L
  727. #define WHERE_SCREEN_ONLY             0x00040000L
  728.  
  729. struct pending_prefix_command
  730.  {
  731.   struct pending_prefix_command *next;
  732.   struct pending_prefix_command *prev;
  733.   CHARTYPE ppc_command[MAX_PREFIX_WIDTH+1];          /* prefix command */
  734.   LINETYPE ppc_line_number;                     /* line number in file */
  735.   LINETYPE ppc_cmd_param;                  /* prefix command parameter */
  736.   short ppc_cmd_idx;                           /* prefix command index */
  737.   bool ppc_block_command;                     /* is it a BLOCK command */
  738.   bool ppc_shadow_line;        /* was command entered on SHADOW line ? */
  739.  };
  740. typedef struct pending_prefix_command PPC;
  741.  
  742. struct line
  743.  {
  744.   struct line *prev;                       /* pointer to previous line */
  745.   struct line *next;                           /* pointer to next line */
  746.   CHARTYPE *name;            /* pointer to name of line (for SET POINT)*/
  747.   CHARTYPE *line;                       /* pointer to contents of line */
  748.   LENGTHTYPE length;                   /* number of characters in line */
  749. #ifdef FILENAME_LENGTH
  750.   LENGTHTYPE filename_length;    /* length of filename in DIR.DIR file */
  751. #endif
  752.   PPC *pre;
  753.   SELECTTYPE select;                     /* select level for each line */
  754.   SELECTTYPE save_select;          /* saved select level (used by ALL) */
  755.   bool new_flag;                   /* indicates if line has been added */
  756.   bool changed_flag;             /* indicates if line has been changed */
  757.   bool tag_flag;                                    /* for TAG command */
  758.  };
  759. typedef struct line LINE;
  760.  
  761. struct colour_attr
  762.  {
  763.   int pair;                                  /* pair number for colour */
  764.   chtype mod;                                       /* colour modifier */
  765.   chtype mono;                                      /* mono attributes */
  766.  };
  767. typedef struct colour_attr COLOUR_ATTR;
  768.  
  769. struct reserved
  770.  {
  771.   struct reserved *prev;          /* pointer to previous reserved line */
  772.   struct reserved *next;              /* pointer to next reserved line */
  773.   CHARTYPE *line;                       /* pointer to contents of line */
  774.   CHARTYPE *spec;                        /* row position specification */
  775.   short length;                             /* length of reserved line */
  776.   short base;                                              /* row base */
  777.   short off;                                   /* row offset from base */
  778.   COLOUR_ATTR *attr;                              /* colour attributes */
  779.  };
  780. typedef struct reserved RESERVED;
  781.  
  782. struct prefix_commands
  783.  {
  784.   CHARTYPE *cmd;                                     /* prefix command */
  785.   LENGTHTYPE cmd_len;                      /* length of prefix command */
  786.   bool action_prefix;              /* is command an action or a target */
  787.   bool multiples_allowed;                     /* are multiples allowed */
  788.   bool full_target_allowed;            /* full target multiple allowed */
  789.   bool block_prefix_command;             /* is command a block command */
  790.   bool target_required;                 /* does command require target */
  791.   bool valid_on_tof;         /* is command allowed on Top of File line */
  792.   bool valid_on_bof;      /* is command allowed on Bottom of File line */
  793.   bool valid_in_readonly;    /* TRUE if command valid in readonly mode */
  794. #ifdef HAVE_PROTO
  795.  short (*function)(PPC *,short,LINETYPE);
  796. #else
  797.  short (*function)();
  798. #endif
  799.   LINETYPE default_target;/* number of lines to process if not specified */
  800.   bool ignore_scope;/* TRUE if scope to be ignored when finding target */
  801.   bool use_last_not_in_scope;/* TRUE if starting at end of shadow lines*/
  802.   int  priority;                         /* priority of prefix command */
  803. #ifdef HAVE_PROTO
  804.  short (*post_function)(PPC *,short,LINETYPE);
  805. #else
  806.  short (*post_function)();
  807. #endif
  808.  
  809.  };
  810. typedef struct prefix_commands PREFIX_COMMAND;
  811.  
  812. typedef struct
  813.  {
  814.   CHARTYPE autosave;
  815.   short backup;
  816.   COLOUR_ATTR *attr;
  817.   CHARTYPE eolout;
  818.   bool tabsout_on;
  819.   bool display_actual_filename;
  820.   bool undoing;
  821.   CHARTYPE tabsout_num;
  822.  } PRESERVED_FILE_DETAILS;
  823.  
  824. typedef struct
  825.  {
  826.   CHARTYPE autosave;        /* number of alterations before autosaving */
  827.   short backup;           /* indicates type of backup file to be saved */
  828.   COLOUR_ATTR *attr;                              /* colour attributes */
  829.   CHARTYPE eolout;     /* indicates how lines are terminated on output */
  830.   bool tabsout_on;      /* indicates if tabs to replace spaces on file */
  831.   bool display_actual_filename;
  832.   bool undoing;
  833.   CHARTYPE tabsout_num;                 /* length of tab stops on file */
  834.   /*
  835.    * All settings above this line are saveable.
  836.    * Ensure that PRESERVED_FILE_DETAILS structure reflects this.
  837.    */
  838.   PRESERVED_FILE_DETAILS *preserved_file_details;
  839.   ROWTYPE status_row;         /* row on which status line is displayed */
  840.   CHARTYPE pseudo_file;   /* indicates if file is a "pseudo" file and if so, what sort */
  841.   CHARTYPE disposition;        /* indicates if file is new or existing */
  842.   unsigned short autosave_alt;  /* number of alterations since last autosave */
  843.   unsigned short save_alt;    /* number of alterations since last save */
  844.   CHARTYPE *autosave_fname;             /* file name for AUTOSAVE file */
  845.   FILE *fp;                               /* file handle for this file */
  846.   CHARTYPE *fname;                                        /* file name */
  847.   CHARTYPE *fpath;                                        /* file path */
  848.   CHARTYPE *actualfname;                                  /* file path */
  849.   unsigned short fmode;                           /* file mode of file */
  850. #if defined(HAVE_CHOWN)
  851.   uid_t uid;                                         /* userid of file */
  852.   gid_t gid;                                        /* groupid of file */
  853. #endif
  854.   LINE *first_line;                           /* pointer to first line */
  855.   LINE *last_line;                             /* pointer to last line */
  856.   LINE *editv;                          /* pointer for EDITV variables */
  857.   LINETYPE  number_lines;            /* number of actual lines in file */
  858.   LINETYPE  max_line_length;            /* Maximum line length in file */
  859.   CHARTYPE file_views;              /* number of views of current file */
  860.   RESERVED *first_reserved;          /* pointer to first reserved line */
  861.   PPC *first_ppc;                      /* first pending prefix command */
  862.   PPC *last_ppc;                        /* last pending prefix command */
  863.  } FILE_DETAILS;
  864.  
  865. typedef struct
  866.  {
  867.   struct view_details *prev;               /* pointer to previous view */
  868.   struct view_details *next;                   /* pointer to next view */
  869.   bool arbchar_status;                   /* indicates if arbchar is on */
  870.   CHARTYPE arbchar_single;         /* single arbitrary character value */
  871.   CHARTYPE arbchar_multiple;     /* multiple arbitrary character value */
  872.   bool arrow_on;                    /* indicates if arrow is displayed */
  873.   CHARTYPE case_enter;               /* indicates case of data entered */
  874.   CHARTYPE case_locate;              /* indicates case of data located */
  875.   CHARTYPE case_change;              /* indicates case of data changed */
  876.   CHARTYPE case_sort;       /* indicates case significance for sorting */
  877.   ROWTYPE cmd_line;                        /* position of command line */
  878.   ROWTYPE current_row;                     /* row which is current row */
  879.   CHARTYPE current_base;/* indicates relative position of current line */
  880.   short current_off;       /* offset from current_base for current_row */
  881.   SELECTTYPE display_low;                /* low range of display level */
  882.   SELECTTYPE display_high;              /* high range of display level */
  883.   bool hex;       /* TRUE if hex conversion is done on string operands */
  884.   bool hexshow_on;                                /* status of hexshow */
  885.   CHARTYPE hexshow_base;  /* base position for starting row of hexshow */
  886.   short hexshow_off;           /* offset from base of start of hexshow */
  887.   CHARTYPE highlight;                    /* lines to highlight, if any */
  888.   SELECTTYPE highlight_high; /* high select level of highlighted lines */
  889.   SELECTTYPE highlight_low;   /* low select level of highlighted lines */
  890.   bool id_line;                            /* TRUE if IDLINE displayed */
  891.   bool imp_macro;       /* indicates if implied macro processing is on */
  892.   bool imp_os;             /* indicates if implied os processing is on */
  893.   CHARTYPE inputmode;            /* indicates type of input processing */
  894.   bool linend_status; /* indicates if multiple commands allowed on command line */
  895.   CHARTYPE linend_value;                /* specifies command delimiter */
  896.   bool macro;      /* indicates if macros are executed before commands */
  897.   LENGTHTYPE margin_left;                /* left margin column 1 based */
  898.   LENGTHTYPE margin_right;              /* right margin column 1 based */
  899.   short margin_indent;                        /* paragraph indentation */
  900.   bool margin_indent_offset_status; /* TRUE if paragraph indentation is an offset from left margin */
  901.   CHARTYPE msgline_base;     /* indicates relative position of msgline */
  902.   short msgline_off;           /* offset from msgline_base for msgline */
  903.   ROWTYPE msgline_rows;                   /* number of rows in msgline */
  904.   bool msgmode_status;    /* indicates if messages are to be displayed */
  905.   bool newline_aligned; /* TRUE if adding a new line results in cursor appearing under 1st non-blank of previous line */
  906.   bool number;   /* indicates if numbers in prefix are to be displayed */
  907.   bool position_status;     /* TRUE if LINE/COL is displayed on IDLINE */
  908.   CHARTYPE prefix;       /* indicates if and where prefix is displayed */
  909.   short prefix_width;                       /* overall width of prefix */
  910.   short prefix_gap;        /* width of gap between prefix and filearea */
  911.   bool scale_on;                    /* indicates if scale is displayed */
  912.   CHARTYPE scale_base;/* base position on which scale row is displayed */
  913.   short  scale_off; /* offset from base position on which scale row is displayed */
  914.   bool scope_all; /* indicates if commands act on All lines or only those Displayed */
  915.   bool shadow;        /* indicates if shadow lines are to be displayed */
  916.   bool stay;                               /* indicates status of STAY */
  917.   bool synonym;       /* indicates if synonym processing is in effect */
  918.   bool tab_on;             /* indicates if tab line is to be displayed */
  919.   CHARTYPE tab_base;   /* base position on which tab line is displayed */
  920.   short  tab_off;  /* offset from base position on which tab line is displayed */
  921.   bool tabsinc;                    /* tab increment or 0 if fixed tabs */
  922.   COLTYPE numtabs;                      /* number of tab stops defined */
  923.   LENGTHTYPE tabs[MAX_NUMTABS];      /* tab settings for each tab stop */
  924.   LENGTHTYPE verify_col;                /* left col for current verify */
  925.   LENGTHTYPE verify_start;                   /* col of start of verify */
  926.   LENGTHTYPE verify_end;                       /* col of end of verify */
  927.   CHARTYPE word;                                       /* word setting */
  928.   bool wordwrap;                                   /* wordwrap setting */
  929.   bool wrap;                                           /* wrap setting */
  930.   LENGTHTYPE zone_start;                       /* col of start of zone */
  931.   LENGTHTYPE zone_end;                           /* col of end of zone */
  932.  } PRESERVED_VIEW_DETAILS;
  933.  
  934. struct view_details
  935.  {
  936.   struct view_details *prev;               /* pointer to previous view */
  937.   struct view_details *next;                   /* pointer to next view */
  938.   bool arbchar_status;                   /* indicates if arbchar is on */
  939.   CHARTYPE arbchar_single;         /* single arbitrary character value */
  940.   CHARTYPE arbchar_multiple;     /* multiple arbitrary character value */
  941.   bool arrow_on;                    /* indicates if arrow is displayed */
  942.   CHARTYPE case_enter;               /* indicates case of data entered */
  943.   CHARTYPE case_locate;              /* indicates case of data located */
  944.   CHARTYPE case_change;              /* indicates case of data changed */
  945.   CHARTYPE case_sort;       /* indicates case significance for sorting */
  946.   ROWTYPE cmd_line;                        /* position of command line */
  947.   ROWTYPE current_row;                     /* row which is current row */
  948.   CHARTYPE current_base;/* indicates relative position of current line */
  949.   short current_off;       /* offset from current_base for current_row */
  950.   SELECTTYPE display_low;                /* low range of display level */
  951.   SELECTTYPE display_high;              /* high range of display level */
  952.   bool hex;       /* TRUE if hex conversion is done on string operands */
  953.   bool hexshow_on;                                /* status of hexshow */
  954.   CHARTYPE hexshow_base;  /* base position for starting row of hexshow */
  955.   short hexshow_off;           /* offset from base of start of hexshow */
  956.   CHARTYPE highlight;                    /* lines to highlight, if any */
  957.   SELECTTYPE highlight_high; /* high select level of highlighted lines */
  958.   SELECTTYPE highlight_low;   /* low select level of highlighted lines */
  959.   bool id_line;                            /* TRUE if IDLINE displayed */
  960.   bool imp_macro;       /* indicates if implied macro processing is on */
  961.   bool imp_os;             /* indicates if implied os processing is on */
  962.   CHARTYPE inputmode;            /* indicates type of input processing */
  963.   bool linend_status; /* indicates if multiple commands allowed on command line */
  964.   CHARTYPE linend_value;                /* specifies command delimiter */
  965.   bool macro;      /* indicates if macros are executed before commands */
  966.   LENGTHTYPE margin_left;                /* left margin column 1 based */
  967.   LENGTHTYPE margin_right;              /* right margin column 1 based */
  968.   short margin_indent;                        /* paragraph indentation */
  969.   bool margin_indent_offset_status; /* TRUE if paragraph indentation is an offset from left margin */
  970.   CHARTYPE msgline_base;     /* indicates relative position of msgline */
  971.   short msgline_off;           /* offset from msgline_base for msgline */
  972.   ROWTYPE msgline_rows;                   /* number of rows in msgline */
  973.   bool msgmode_status;    /* indicates if messages are to be displayed */
  974.   bool newline_aligned; /* TRUE if adding a new line results in cursor appearing under 1st non-blank of previous line */
  975.   bool number;   /* indicates if numbers in prefix are to be displayed */
  976.   bool position_status;     /* TRUE if LINE/COL is displayed on IDLINE */
  977.   CHARTYPE prefix;       /* indicates if and where prefix is displayed */
  978.   short prefix_width;                       /* overall width of prefix */
  979.   short prefix_gap;        /* width of gap between prefix and filearea */
  980.   bool scale_on;                    /* indicates if scale is displayed */
  981.   CHARTYPE scale_base;/* base position on which scale row is displayed */
  982.   short  scale_off; /* offset from base position on which scale row is displayed */
  983.   bool scope_all; /* indicates if commands act on All lines or only those Displayed */
  984.   bool shadow;        /* indicates if shadow lines are to be displayed */
  985.   bool stay;                               /* indicates status of STAY */
  986.   bool synonym;       /* indicates if synonym processing is in effect */
  987.   bool tab_on;             /* indicates if tab line is to be displayed */
  988.   CHARTYPE tab_base;   /* base position on which tab line is displayed */
  989.   short  tab_off;  /* offset from base position on which tab line is displayed */
  990.   bool tabsinc;                    /* tab increment or 0 if fixed tabs */
  991.   COLTYPE numtabs;                      /* number of tab stops defined */
  992.   LENGTHTYPE tabs[MAX_NUMTABS];      /* tab settings for each tab stop */
  993.   LENGTHTYPE verify_col;                /* left col for current verify */
  994.   LENGTHTYPE verify_start;                   /* col of start of verify */
  995.   LENGTHTYPE verify_end;                       /* col of end of verify */
  996.   CHARTYPE word;                                       /* word setting */
  997.   bool wordwrap;                                   /* wordwrap setting */
  998.   bool wrap;                                           /* wrap setting */
  999.   LENGTHTYPE zone_start;                       /* col of start of zone */
  1000.   LENGTHTYPE zone_end;                           /* col of end of zone */
  1001.   /*
  1002.    * All settings above this line are saveable.
  1003.    * Ensure that PRESERVED_VIEW_DETAILS structure reflects this.
  1004.    */
  1005.   PRESERVED_VIEW_DETAILS *preserved_view_details;
  1006.   LINETYPE current_line;      /* line in file displayed on current row */
  1007.   LENGTHTYPE current_column;   /* column in line of last column target */
  1008.   short y[VIEW_WINDOWS];               /* y coordinate for each window */
  1009.   short x[VIEW_WINDOWS];               /* x coordinate for each window */
  1010.   LINETYPE focus_line;                 /* line in file where cursor is */
  1011.   short mark_type;                             /* type of marked block */
  1012.   LINETYPE mark_start_line;                 /* first line to be marked */
  1013.   LINETYPE mark_end_line;                    /* last line to be marked */
  1014.   bool marked_line;                             /* TRUE if line marked */
  1015.   bool in_ring;                   /* TRUE if file already in edit ring */
  1016.   LENGTHTYPE mark_start_col;                    /* first column marked */
  1017.   LENGTHTYPE mark_end_col;                       /* last column marked */
  1018.   bool marked_col;                            /* TRUE if column marked */
  1019.   CHARTYPE current_window;        /* current window for current screen */
  1020.   CHARTYPE previous_window;      /* previous window for current screen */
  1021.   FILE_DETAILS *file_for_view;            /* pointer to file structure */
  1022.  };
  1023. typedef struct view_details VIEW_DETAILS;
  1024.  
  1025. /* structure for each line to be displayed */
  1026. struct show_line
  1027.  {
  1028.   CHARTYPE *contents;                   /* pointer to contents of line */
  1029.   LENGTHTYPE length;                   /* number of characters in line */
  1030.   chtype normal_colour;                      /* normal colour for line */
  1031.   chtype other_colour;                        /* other colour for line */
  1032.   LENGTHTYPE other_start_col; /* start column of other colour from col 0 */
  1033.   LENGTHTYPE other_end_col;   /* end column of other colour from col 0 */
  1034.   LINETYPE number_lines_excluded;          /* number of lines excluded */
  1035.   LINETYPE line_number;                     /* line number within file */
  1036.   LINE *current;                            /* pointer to current line */
  1037.   chtype prefix_colour;                            /* colour of prefix */
  1038.   chtype gap_colour;                           /* colour of prefix gap */
  1039.   CHARTYPE prefix[MAX_PREFIX_WIDTH+1];      /* contents of prefix area */
  1040.   CHARTYPE gap[MAX_PREFIX_WIDTH+1];          /* contents of prefix gap */
  1041.   short line_type;                                     /* type of line */
  1042.   bool full_length;                 /* TRUE if all columns to be drawn */
  1043.   bool prefix_enterable;            /* TRUE if prefix can be tabbed to */
  1044.   bool main_enterable;            /* TRUE if filearea can be tabbed to */
  1045.   bool highlight;                       /* TRUE if line is highlighted */
  1046.  };
  1047. typedef struct show_line SHOW_LINE;
  1048.  
  1049. /* structure for each screen */
  1050. typedef struct
  1051.  {
  1052.   ROWTYPE screen_start_row;                     /* start row of screen */
  1053.   COLTYPE screen_start_col;                     /* start col of screen */
  1054.   ROWTYPE screen_rows;                                /* physical rows */
  1055.   COLTYPE screen_cols;                                /* physical cols */
  1056.   ROWTYPE rows[VIEW_WINDOWS];                        /* rows in window */
  1057.   COLTYPE cols[VIEW_WINDOWS];                        /* cols in window */
  1058.   ROWTYPE start_row[VIEW_WINDOWS];              /* start row of window */
  1059.   COLTYPE start_col[VIEW_WINDOWS];              /* start col of window */
  1060.   WINDOW *win[VIEW_WINDOWS];  /* curses windows for the screen display */
  1061.   VIEW_DETAILS *screen_view;    /* view being displayed in this screen */
  1062.   SHOW_LINE *sl;       /* pointer to SHOW_DETAILS structure for screen */
  1063.  } SCREEN_DETAILS;
  1064.  
  1065. #define STATUS_ROW         (screen_rows-1)
  1066. #define COMMAND_ROW        (screen_rows-2)
  1067. #define ERROR_ROW          1
  1068. #define TAB_ROW            6
  1069. #define TAB_ON             NO
  1070. #define SCALE_ROW          6
  1071. #define SCALE_ON           NO
  1072. #define CURSOR_ROW         COMMAND_ROW
  1073. #define CURSOR_COL         5
  1074. #define CURRENT_ROW_POS    0
  1075. #define CURRENT_ROW        0
  1076. #define ZONE_START         1
  1077. #define ZONE_END           MAX_INT
  1078.  
  1079. /* defines for base value for relative row positions */
  1080. #define POSITION_TOP       0
  1081. #define POSITION_MIDDLE    1
  1082. #define POSITION_BOTTOM    2
  1083.  
  1084. /* defines for function_key() function calling */
  1085. #define OPTION_NORMAL      0
  1086. #define OPTION_EXTRACT     1
  1087. #define OPTION_READV       2
  1088.  
  1089. /* defines for pseudo file types */
  1090. #define PSEUDO_REAL        0
  1091. #define PSEUDO_DIR         1
  1092. #define PSEUDO_REXX        2
  1093. #define PSEUDO_KEY         3
  1094.  
  1095. /* defines for prefix settings */
  1096. #define PREFIX_OFF           0x00
  1097. #define PREFIX_ON            0x10
  1098. #define PREFIX_NULLS         0x20
  1099. #define PREFIX_LEFT          0x01
  1100. #define PREFIX_RIGHT         0x02
  1101. #define PREFIX_LOCATION_MASK 0x0F
  1102. #define PREFIX_STATUS_MASK   0xF0
  1103.  
  1104. /* defines for query types */
  1105. #define QUERY_NONE         0
  1106. #define QUERY_QUERY        1
  1107. #define QUERY_STATUS       2
  1108. #define QUERY_EXTRACT      4
  1109. #define QUERY_FUNCTION     8
  1110. #define QUERY_MODIFY      16
  1111. #define QUERY_READV       32
  1112.  
  1113. /* defines for case settings */
  1114. #define CASE_MIXED         (CHARTYPE)'M'
  1115. #define CASE_UPPER         (CHARTYPE)'U'
  1116. #define CASE_LOWER         (CHARTYPE)'L'
  1117. #define CASE_IGNORE        (CHARTYPE)'I'
  1118. #define CASE_RESPECT       (CHARTYPE)'R'
  1119.  
  1120. /* type of marked blocks */
  1121. #define M_LINE             1
  1122. #define M_BOX              2
  1123. #define M_STREAM           3
  1124. #define M_COLUMN           4
  1125. #define M_WORD             5
  1126.  
  1127. /* defines for temporary space allocation */
  1128. #define TEMP_PARAM         1
  1129. #define TEMP_MACRO         2
  1130. #define TEMP_TMP_CMD       3
  1131. #define TEMP_TEMP_CMD      4
  1132.  
  1133. /* defines for [SET] BACKUP */
  1134. #define BACKUP_OFF         1
  1135. #define BACKUP_TEMP        2
  1136. #define BACKUP_KEEP        3
  1137. #define BACKUP_ON          BACKUP_KEEP
  1138.  
  1139. /* defines for [SET] DIRSORT */
  1140. #define DIRSORT_NONE       0
  1141. #define DIRSORT_DIR        1
  1142. #define DIRSORT_SIZE       2
  1143. #define DIRSORT_NAME       3
  1144. #define DIRSORT_DATE       4
  1145. #define DIRSORT_TIME       5
  1146. #define DIRSORT_ASC        0
  1147. #define DIRSORT_DESC       1
  1148.  
  1149. /* box opertaions */
  1150. #define BOX_C           1
  1151. #define BOX_M           2
  1152. #define BOX_D           3
  1153. #define BOX_F           4
  1154.  
  1155. /* defines for highlighting */
  1156. #define HIGHLIGHT_NONE     0
  1157. #define HIGHLIGHT_TAG      1
  1158. #define HIGHLIGHT_ALT      2
  1159. #define HIGHLIGHT_SELECT   3
  1160.  
  1161. /* defines for INPUTMODE */
  1162. #define INPUTMODE_OFF      0
  1163. #define INPUTMODE_FULL     1
  1164. #define INPUTMODE_LINE     2
  1165.  
  1166. /* defines for EDITV - suprise! */
  1167. #define EDITV_GET    1
  1168. #define EDITV_PUT    2
  1169. #define EDITV_SET    3
  1170. #define EDITV_SETL   4
  1171. #define EDITV_LIST   5
  1172.  
  1173. #ifndef FILE_NORMAL
  1174. #define FILE_NORMAL        0
  1175. #endif
  1176.  
  1177. #ifndef FILE_READONLY
  1178. #define FILE_READONLY      1
  1179. #endif
  1180.  
  1181. #ifndef FILE_NEW
  1182. #define FILE_NEW          99
  1183. #endif
  1184.  
  1185. #define COMMAND_ONLY_TRUE    TRUE
  1186. #define COMMAND_ONLY_FALSE   FALSE
  1187.  
  1188. #define ADDCHAR            0
  1189. #define INSCHAR            1
  1190.  
  1191. /*
  1192.  * following #defines for MyStrip() function
  1193.  */
  1194. #define STRIP_NONE         0
  1195. #define STRIP_LEADING      1
  1196. #define STRIP_TRAILING     2
  1197. #define STRIP_BOTH         (STRIP_LEADING|STRIP_TRAILING)
  1198. #define STRIP_ALL          (STRIP_LEADING|STRIP_TRAILING|4)
  1199.  
  1200. #ifndef getbegyx
  1201. #define getbegyx(win,y,x)       (y = (win)->_begy, x = (win)->_begx)
  1202. #endif
  1203.  
  1204. #define HIT_ANY_KEY "Hit any key to continue..."
  1205.  
  1206. /*---------------------- useful macros --------------------------------*/
  1207. #define     TOF(line)           ((line == 0L) ? TRUE : FALSE)
  1208. #define     BOF(line)           ((line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  1209. #define     VIEW_TOF(view,line) ((line == 0L) ? TRUE : FALSE)
  1210. #define     VIEW_BOF(view,line) ((line == view->file_for_view->number_lines+1L) ? TRUE : FALSE)
  1211. #define     CURRENT_TOF         ((CURRENT_VIEW->current_line == 0L) ? TRUE : FALSE)
  1212. #define     CURRENT_BOF         ((CURRENT_VIEW->current_line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  1213. #define     FOCUS_TOF           ((CURRENT_VIEW->focus_line == 0L) ? TRUE : FALSE)
  1214. #define     FOCUS_BOF           ((CURRENT_VIEW->focus_line == CURRENT_FILE->number_lines+1L) ? TRUE : FALSE)
  1215. #define     IN_VIEW(view,line)   ((line >= (view->current_line - (LINETYPE)view->current_row)) && (line <= (view->current_line + ((LINETYPE)CURRENT_SCREEN.rows - (LINETYPE)view->current_row))))
  1216. /*---------------------- system specific redefines --------------------*/
  1217. #ifdef VAX
  1218. #define     wattrset     wsetattr
  1219. #define     A_REVERSE    _REVERSE
  1220. #define     A_BOLD       _BOLD
  1221. #endif
  1222.  
  1223. extern VIEW_DETAILS *vd_current;
  1224. extern CHARTYPE current_screen;
  1225. extern SCREEN_DETAILS screen[MAX_SCREENS];
  1226.  
  1227. #ifdef MAIN
  1228. LENGTHTYPE max_line_length=MAX_LENGTH_OF_LINE;
  1229. #else
  1230. extern LENGTHTYPE max_line_length;
  1231. #endif
  1232.  
  1233. #define PARACOL (CURRENT_VIEW->margin_indent_offset_status?CURRENT_VIEW->margin_left+CURRENT_VIEW->margin_indent:CURRENT_VIEW->margin_indent)
  1234.  
  1235. /* structure for passing box parameters */
  1236. struct _boxp
  1237.  {
  1238.   short action;
  1239.   LENGTHTYPE src_start_col;
  1240.   LENGTHTYPE dst_start_col;
  1241.   LENGTHTYPE num_cols;
  1242.   LINETYPE src_start_line;
  1243.   LINETYPE dst_start_line;
  1244.   LINETYPE num_lines;
  1245.   LINE *curr_src;
  1246.   LINE *curr_dst;
  1247.   VIEW_DETAILS *src_view;
  1248.   VIEW_DETAILS *dst_view;
  1249.  };
  1250. typedef struct _boxp BOXP;
  1251.  
  1252. /* structure for passing queryable values parameters */
  1253. struct query_values
  1254.  {
  1255.   CHARTYPE *value;                                    /* value of item */
  1256.   short len;               /* length of string representation of value */
  1257.  };
  1258. typedef struct query_values VALUE;
  1259.  
  1260. /* structure for function key redefinition */
  1261. struct defines
  1262. {
  1263.  struct defines *prev;
  1264.  struct defines *next;
  1265.  int def_funkey;
  1266.  short def_command;
  1267.  CHARTYPE *def_params;
  1268. };
  1269. typedef struct defines DEFINE;
  1270.  
  1271. /* structure for repeating targets */
  1272. struct rtarget
  1273.  {
  1274.   CHARTYPE *string;                               /* pointer to target */
  1275.   unsigned short length;                           /* length of target */
  1276.   CHARTYPE boolean;                                /* boolean operator */
  1277.   bool not;                                      /* TRUE if NOT target */
  1278.   LINETYPE numeric_target;                     /* numeric target value */
  1279.   short  target_type;                                /* type of target */
  1280.   bool negative;                         /* TRUE if direction backward */
  1281.  };
  1282. typedef struct rtarget RTARGET;
  1283.  
  1284. /* structure for targets */
  1285. struct target
  1286.  {
  1287.   CHARTYPE *string;                      /* pointer to original target */
  1288.   LINETYPE num_lines;                     /* number of lines to target */
  1289.   LINETYPE true_line;                     /* line number to start with */
  1290.   LINETYPE last_line;            /* line number of last line in target */
  1291.   RTARGET *rt;                         /* pointer to repeating targets */
  1292.   short num_targets;                        /* number of targets found */
  1293.   short spare;             /* index to which repeating target is spare */
  1294.   bool ignore_scope;/* TRUE if scope to be ignored when finding target */
  1295.  };
  1296. typedef struct target TARGET;
  1297.  
  1298. /* structure for window areas */
  1299. struct window_areas
  1300.  {
  1301.   CHARTYPE *area;            /* window area - used for COLOUR command */
  1302.   short area_min_len;                     /* min abbrev for area name */
  1303.   short area_window;                          /* window where area is */
  1304.   bool  actual_window;                    /* TRUE if area is a window */
  1305.  };
  1306. typedef struct window_areas AREAS;
  1307.  
  1308. #if defined(MAIN)
  1309. #  ifdef MSWIN
  1310. void far * (*the_malloc)(unsigned long);             /* ptr to some malloc(size) */
  1311. void far * (*the_calloc)();                          /* ptr to some ecalloc(num,size)*/
  1312. void  (*the_free)();                            /* ptr to some free(ptr) */
  1313. void far * (*the_realloc)(void far *,unsigned long); /* ptr to some realloc(ptr,size) */
  1314. #  else
  1315. void* (*the_malloc)();  /* ptr to some malloc(size) */
  1316. void* (*the_calloc)();  /* ptr to some calloc(num,size)*/
  1317. void  (*the_free)();    /* ptr to some free(ptr) */
  1318. void* (*the_realloc)(); /* ptr to some realloc(ptr,size) */
  1319. #  endif
  1320. #else
  1321. #  ifdef MSWIN
  1322. extern void far * (*the_malloc)(unsigned long);
  1323. extern void far * (*the_calloc)();
  1324. extern void  (*the_free)();
  1325. extern void far * (*the_realloc)(void far *,unsigned long);
  1326. #  else
  1327. extern void* (*the_malloc)();
  1328. extern void* (*the_calloc)();
  1329. extern void  (*the_free)();
  1330. extern void* (*the_realloc)();
  1331. #  endif
  1332. #endif
  1333.  
  1334. #if defined (XCURSES) || defined (WIN32)
  1335. #  define MOUSE_SUPPORT_ENABLED 1
  1336. #endif
  1337.  
  1338. #if defined(TRACE)
  1339. #  if defined(HAVE_PROTO)
  1340. void trace_initialise(void);
  1341. void trace_function(char *);
  1342. void trace_return(void);
  1343. void trace_string(char *,...);
  1344. void trace_constant(char *);
  1345. #  else
  1346. void trace_initialise(/* void */);
  1347. void trace_function(/* char* */);
  1348. void trace_return(/* void */);
  1349. void trace_string(/* char*,... */);
  1350. void trace_constant(/* char * */);
  1351. # endif
  1352. #endif
  1353.