home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / vim-2.0.lha / Vim-2.0 / src / vim.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-15  |  7.9 KB  |  360 lines

  1. /* vi:ts=4:sw=4
  2.  *
  3.  * VIM - Vi IMproved
  4.  *
  5.  * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  6.  *                            Tim Thompson            twitch!tjt
  7.  *                            Tony Andrews            onecom!wldrdg!tony 
  8.  *                            G. R. (Fred) Walter        watmath!watcgl!grwalter 
  9.  */
  10.  
  11. #if defined(SYSV_UNIX) || defined(BSD_UNIX)
  12. # ifndef UNIX
  13. #  define UNIX
  14. # endif
  15. #endif
  16.  
  17. #include "debug.h"
  18.  
  19. #include <stdio.h>
  20.  
  21. #include <ctype.h>
  22. #ifndef DOMAIN
  23. #include <limits.h>        /* For MAX_INT, remove this if it does not exist */
  24. #endif
  25.  
  26. #ifdef BSD_UNIX
  27. # include <strings.h>
  28. # ifdef __STDC__
  29. #  include <string.h>
  30. # endif
  31. #else
  32. # include <string.h>
  33. #endif
  34.  
  35. #include "ascii.h"
  36. #include "keymap.h"
  37. #include "term.h"
  38. #include "macros.h"
  39. #ifdef LATTICE
  40. # include <sys/types.h>
  41. # include <sys/stat.h>
  42. #else
  43. # ifdef _DCC
  44. #  include <sys/stat.h>
  45. # else
  46. #  ifdef MSDOS 
  47. #   include <sys\stat.h>
  48. #  else
  49. #   ifdef UNIX
  50. #     ifndef linux
  51. #      define volatile        /* needed for gcc */
  52. #      define signed            /* needed for gcc */
  53. #    endif
  54. #    include <sys/types.h>
  55. #    include <sys/stat.h>
  56. #   else
  57. #     include <stat.h>
  58. #   endif
  59. #  endif
  60. # endif
  61. #endif
  62.  
  63. #ifndef DOMAIN
  64. # include <stdlib.h>
  65. #endif
  66.  
  67. #ifdef AMIGA
  68. /*
  69.  * arpbase.h must be included before functions.h
  70.  */
  71. # include <libraries/arpbase.h>
  72.  
  73. /*
  74.  * This won't be needed if you have a version of Lattice 4.01 without broken
  75.  * break signal handling.
  76.  */
  77. #include <signal.h>
  78. #endif
  79.  
  80. #ifndef AMIGA
  81. /*
  82.  * For the Amiga we use a version of getenv that does local variables under 2.0
  83.  */
  84. #define vimgetenv(x) getenv(x)
  85. #endif
  86.  
  87. #ifdef AZTEC_C
  88. # include <functions.h>
  89. # define __ARGS(x)    x
  90. # define __PARMS(x)    x
  91. #endif
  92.  
  93. #ifdef SASC
  94. # include <clib/exec_protos.h>
  95. # define __ARGS(x)    x
  96. # define __PARMS(x)    x
  97. #endif
  98.  
  99. #ifdef _DCC
  100. # include <functions.h>
  101. # define __ARGS(x)    x
  102. # define __PARMS(x)    x
  103. #endif
  104.  
  105. #ifdef __TURBOC__
  106. # define __ARGS(x) x
  107. #endif
  108.  
  109. #ifdef MSDOS
  110. # include <dos.h>
  111. # include <dir.h>
  112. #endif
  113.  
  114. #ifdef SOLARIS
  115. # include <stdlib.h>
  116. # include <unistd.h>
  117. #endif
  118.  
  119. #ifdef UNIX
  120. # ifdef SCO
  121. #  undef M_XENIX
  122. #  include <sys/ndir.h>        /* for MAXNAMLEN */
  123. # else
  124. #  if defined(SOLARIS) || defined(AIX)
  125. #   include <dirent.h>        /* for MAXNAMLEN */
  126. #  else
  127. #   include <sys/dir.h>        /* for MAXNAMLEN */
  128. #  endif
  129. # endif
  130. # ifdef USL
  131. #  define MAXNAMLEN DIRSIZ
  132. # endif
  133. # if defined(UFS_MAXNAMLEN) && !defined(MAXNAMLEN)
  134. #  define MAXNAMLEN UFS_MAXNAMLEN        /* for dynix/ptx */
  135. # endif
  136. # if defined(NAME_MAX) && !defined(MAXNAMLEN)
  137. #  define MAXNAMLEN NAME_MAX            /* for Linux before .99p3 */
  138. # endif
  139. # if !defined(MAXNAMLEN)
  140. #  define MAXNAMLEN 512                 /* for all other Unix */
  141. # endif
  142. #endif
  143.  
  144. #ifdef UNICOS        /* would make sense for other systems too */
  145. # include <errno.h>
  146. #endif
  147.  
  148. #if defined(__STDC__) || defined(__GNUC__)
  149. # ifndef __ARGS
  150. #  define __ARGS(x) x
  151. # endif /* __ARGS */
  152. # if defined(_SEQUENT_)
  153. #  include "ptx_stdlib.h"
  154. # endif
  155. # if defined(sun) && !defined(SOLARIS)
  156. #  include "sun_stdlib.h"
  157. # endif
  158. # if defined(linux) || defined(SCO) || defined(M_UNIX)
  159. #  include <unistd.h>  /* may make sense for others too. jw. */
  160. # endif
  161. #else /*__STDC__*/
  162. # if defined(_SEQUENT_) && !defined(_STDLIB_H_)
  163.   extern char *getenv();
  164.   extern void *malloc();
  165. # endif
  166. #endif /* __STDC__ */
  167.  
  168. #ifndef __ARGS
  169. #define __ARGS(x)    ()
  170. #endif
  171. #ifndef __PARMS
  172. #define __PARMS(x)    ()
  173. #endif
  174.  
  175. /*
  176.  * for systems that do not allow free(NULL)
  177.  */
  178. #ifdef NO_FREE_NULL
  179. # define free(x)    nofreeNULL(x)
  180.   extern void nofreeNULL __ARGS((void *));
  181. #endif
  182.  
  183. /*
  184.  * fnamecmp() is used to compare filenames.
  185.  * On some systems case in a filename does not matter, on others it does.
  186.  * (this does not account for maximum name lengths, thus it is not 100% accurate!)
  187.  */
  188. #if defined(AMIGA) || defined(MSDOS)
  189. # define fnamecmp(x, y) stricmp((x), (y))
  190. #else
  191. # define fnamecmp(x, y) strcmp((x), (y))
  192. #endif
  193.  
  194. /* flags for updateScreen() */
  195. #define VALID                    90    /* buffer not changed */
  196. #define NOT_VALID                91    /* buffer changed */
  197. #define VALID_TO_CURSCHAR        92    /* buffer before cursor not changed */
  198. #define INVERTED                93    /* redisplay inverted part */
  199. #define CLEAR                    94    /* first clear screen */
  200. #define CURSUPD                    95    /* update cursor first */
  201.  
  202. /* values for State */
  203. /*
  204.  * The lowest three bits are used to distinguish normal/cmdline/insert+replace
  205.  * mode. This is used for mapping.
  206.  */
  207. #define NORMAL                    0x01
  208. #define NORMAL_BUSY                0x11    /* busy interpreting a command */
  209. #define CMDLINE                 0x02
  210. #define INSERT                    0x04
  211. #define REPLACE                 0x24    /* replace mode */
  212. #define HELP                    0x30    /* displaying help */
  213. #define NOMAPPING                 0x40    /* no :mapping mode for vgetc() */
  214. #define HITRETURN                0x51    /* waiting for a return */
  215. #define SETWSIZE                0x60    /* window size has changed */
  216. #define ABBREV                    0x80    /* abbreviation instead of mapping */
  217.  
  218. /* directions */
  219. #define FORWARD                  1
  220. #define BACKWARD                 -1
  221.  
  222. /* for GetChars */
  223. #define T_PEEK                    1    /* do not wait at all */
  224. #define T_WAIT                    2    /* wait for a short time */
  225. #define T_BLOCK                    3    /* wait forever */
  226.  
  227. #define VISUALLINE            MAXCOL    /* Visual is linewise */
  228.  
  229. /*
  230.  * Names for the EXRC, HELP and temporary files.
  231.  * Some of these may have been defined in the makefile.
  232.  */
  233. #ifndef SYSVIMRC_FILE
  234. # define SYSVIMRC_FILE    "s:.vimrc"
  235. #endif
  236. #ifndef SYSEXRC_FILE
  237. # define SYSEXRC_FILE    "s:.exrc"
  238. #endif
  239. #ifndef VIMRC_FILE
  240. # define VIMRC_FILE        ".vimrc"
  241. #endif
  242. #ifndef EXRC_FILE
  243. # define EXRC_FILE        ".exrc"
  244. #endif
  245. #ifndef VIM_HLP
  246. # define VIM_HLP        "vim:vim.hlp"
  247. #endif
  248. #define TMPNAME1        "t:viXXXXXX"
  249. #define TMPNAME2        "t:voXXXXXX"
  250. #define TMPNAMELEN        12
  251.  
  252. /*
  253.  * Boolean constants
  254.  */
  255. #ifndef TRUE
  256. #define FALSE    (0)            /* note: this is an int, not a long! */
  257. #define TRUE    (1)
  258. #endif
  259.  
  260. /*
  261.  * Maximum screen width
  262.  */
  263. #define MAX_COLUMNS 255L
  264.  
  265. /*
  266.  * Buffer sizes
  267.  */
  268. #ifdef UNIX        /* Unix has plenty of memory */
  269. # define CMDBUFFSIZE    1024    /* size of the command processing buffer */
  270. #else
  271. # define CMDBUFFSIZE    256        /* size of the command processing buffer */
  272. #endif
  273.  
  274. #define LSIZE        512            /* max. size of a line in the tags file */
  275.  
  276. #define IOSIZE       (1024+1)     /* file i/o and sprintf buffer size */
  277.  
  278. #define    TERMBUFSIZE    1024
  279.  
  280. #ifdef linux
  281. # define TBUFSZ 2048            /* buffer size for termcap entry */
  282. #else
  283. # define TBUFSZ 1024            /* buffer size for termcap entry */
  284. #endif
  285.  
  286. /*
  287.  * maximum length of a file name path
  288.  */
  289. #ifdef UNIX
  290. # define MAXPATHL    1024        /* Unix has long paths and plenty of memory */
  291. #else
  292. # define MAXPATHL    128            /* not too long to put name on stack */
  293. #endif
  294.  
  295. #ifdef MSDOS
  296. # define BASENAMELEN    8        /* length of base of file name */
  297. #else
  298. # ifdef UNIX
  299. #  define BASENAMELEN    (MAXNAMLEN - 5)
  300. # else
  301. #  define BASENAMELEN    26        /* Amiga */
  302. # endif
  303. #endif
  304.  
  305. #ifdef MSDOS
  306. # define WRITEBIN    "wb"        /* no CR-LF translation */
  307. # define READBIN    "rb"
  308. #else
  309. # define WRITEBIN    "w"
  310. # define READBIN    "r"
  311. #endif
  312.  
  313. #define CHANGED   set_Changed()
  314. #define UNCHANGED Changed = 0
  315.  
  316. #if !defined(BSD_UNIX) && !defined(linux) && !defined(SASC) && !defined(__sgi) && !defined(SCO) && !defined(hpux) && !defined(SOLARIS) && !defined(M_UNIX) && !defined(AIX) && !defined(_UTS) && !defined(USL)
  317. typedef unsigned char    u_char;        /* shorthand */
  318. typedef unsigned short    u_short;    /* shorthand */
  319. typedef unsigned int    u_int;        /* shorthand */
  320. typedef unsigned long    u_long;        /* shorthand */
  321. #endif
  322.  
  323. #if defined(BSD_UNIX) && !defined(__STDC__)
  324. # define strchr(ptr, c)            index((ptr), (c))
  325. # define strrchr(ptr, c)        rindex((ptr), (c))
  326. #endif
  327.  
  328. #ifdef BSD_UNIX
  329. # define memset(ptr, c, size)    bsdmemset((ptr), (c), (size))
  330. char *bsdmemset __ARGS((char *, int, long));
  331. #endif
  332.  
  333. typedef long            linenr_t;    /* line number type */
  334. typedef unsigned        colnr_t;    /* column number type */
  335. typedef struct fpos        FPOS;        /* file position type */
  336.  
  337. #define INVLNUM (0x7fffffff)        /* invalid line number */
  338. #ifdef MAX_INT
  339. # define MAXCOL    MAX_INT                /* maximum column number */
  340. #else
  341. # define MAXCOL    32767                /* maximum column number */
  342. #endif
  343.  
  344. struct fpos
  345. {
  346.         linenr_t        lnum;    /* line number */
  347.         colnr_t         col;    /* column number */
  348. };
  349.  
  350. /*
  351.  * Some versions of isspace() handle Meta character like a space!
  352.  * This define fixes that.
  353.  */
  354. #ifdef VIM_ISSPACE
  355. # ifdef isspace
  356. #  undef isspace
  357. # endif /* isspace */
  358. # define isspace(x)  (((x) >= 9 && (x) <= 13) || ((x) == 32))
  359. #endif /* VIM_ISSPACE */
  360.