home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / amiga / vim46src.lha / vim-4.6 / src / vim.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-13  |  15.2 KB  |  545 lines

  1. /* vi:set ts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved        by Bram Moolenaar
  4.  *
  5.  * Do ":help uganda"  in Vim to read copying and usage conditions.
  6.  * Do ":help credits" in Vim to see a list of people who contributed.
  7.  */
  8.  
  9. /* ============ the header file puzzle (ca. 50-100 pieces) ========= */
  10.  
  11. #ifdef HAVE_CONFIG_H    /* GNU autoconf (or something else) was here */
  12. # include "config.h"
  13. #endif
  14.  
  15. #ifdef __EMX__            /* hand-edited config.h for OS/2 with EMX */
  16. # include "conf_os2.h"
  17. #endif
  18.  
  19. /*
  20.  * This is a bit of a wishlist.  Currently we only have the Motif and Athena
  21.  * GUI.
  22.  */
  23. #if defined(USE_GUI_MOTIF) \
  24.     || defined(USE_GUI_ATHENA) \
  25.     || defined(USE_GUI_MAC) \
  26.     || defined(USE_GUI_WINDOWS31) \
  27.     || defined(USE_GUI_WIN32) \
  28.     || defined(USE_GUI_OS2)
  29. # ifndef USE_GUI
  30. #  define USE_GUI
  31. # endif
  32. #endif
  33.  
  34. #include "feature.h"    /* #defines for optionals and features */
  35.  
  36. /*
  37.  * Find out if function definitions should include argument types
  38.  */
  39. #ifdef AZTEC_C
  40. # include <functions.h>
  41. # define __ARGS(x)    x
  42. # define __PARMS(x)    x
  43. #endif
  44.  
  45. #ifdef SASC
  46. # include <clib/exec_protos.h>
  47. # define __ARGS(x)    x
  48. # define __PARMS(x)    x
  49. #endif
  50.  
  51. #ifdef _DCC
  52. # include <clib/exec_protos.h>
  53. # define __ARGS(x)    x
  54. # define __PARMS(x)    x
  55. #endif
  56.  
  57. #ifdef __TURBOC__
  58. # define __ARGS(x) x
  59. #endif
  60.  
  61. #if defined(UNIX) || defined(__EMX__)
  62. # include "unix.h"        /* bring lots of system header files */
  63. #endif
  64.  
  65. #ifdef VMS
  66. # include "vms.h"
  67. #endif
  68.  
  69. #ifndef __ARGS
  70. # if defined(__STDC__) || defined(__GNUC__) || defined(WIN32)
  71. #  define __ARGS(x) x
  72. # else
  73. #  define __ARGS(x) ()
  74. # endif
  75. #endif
  76.  
  77. /* __ARGS and __PARMS are the same thing. */
  78. #ifndef __PARMS
  79. # define __PARMS(x) __ARGS(x)
  80. #endif
  81.  
  82. #ifdef UNIX
  83. # include "osdef.h"        /* bring missing declarations in */
  84. #endif
  85.  
  86. #ifdef __EMX__
  87. # define    getcwd    _getcwd2
  88. # define    chdir    _chdir2
  89. # undef        CHECK_INODE
  90. #endif
  91.  
  92. #ifdef AMIGA
  93. # include "amiga.h"
  94. #endif
  95.  
  96. #ifdef ARCHIE
  97. # include "archie.h"
  98. #endif
  99.  
  100. #ifdef MSDOS
  101. # include "msdos.h"
  102. #endif
  103.  
  104. #ifdef WIN32
  105. # include "win32.h"
  106. #endif
  107.  
  108. #ifdef __MINT__
  109. # include "mint.h"
  110. #endif
  111.  
  112. /*
  113.  * Maximum length of a path    (for non-unix systems) Make it a bit long, to stay
  114.  * on the safe side.  But not too long to put on the stack.
  115.  */
  116. #ifndef MAXPATHL
  117. # ifdef MAXPATHLEN
  118. #  define MAXPATHL    MAXPATHLEN
  119. # else
  120. #  define MAXPATHL    256
  121. # endif
  122. #endif
  123.  
  124. /*
  125.  * Shorthand for unsigned variables. Many systems, but not all, have u_char
  126.  * already defined, so we use char_u to avoid trouble.
  127.  */
  128. typedef unsigned char    char_u;
  129. typedef unsigned short    short_u;
  130. typedef unsigned int    int_u;
  131. typedef unsigned long    long_u;
  132.  
  133. #ifndef UNIX                /* For Unix this is included in unix.h */
  134. #include <stdio.h>
  135. #include <ctype.h>
  136. #endif
  137.  
  138. #if defined(HAVE_STRING_H)
  139. # include <string.h>
  140. #else
  141. # ifdef HAVE_STRINGS_H
  142. #  include <strings.h>
  143. # endif
  144. #endif
  145.  
  146. #include "ascii.h"
  147. #include "keymap.h"
  148. #include "term.h"
  149. #include "macros.h"
  150.  
  151. #ifdef LATTICE
  152. # include <sys/types.h>
  153. # include <sys/stat.h>
  154. #endif
  155. #ifdef _DCC
  156. # include <sys/stat.h>
  157. #endif
  158. #if defined MSDOS  ||  defined WIN32
  159. # include <sys\stat.h>
  160. #endif
  161.  
  162. /* allow other (non-unix) systems to configure themselves now */
  163. #ifndef UNIX
  164. # ifdef HAVE_STAT_H
  165. #  include <stat.h>
  166. # endif
  167. # ifdef HAVE_STDLIB_H
  168. #  include <stdlib.h>
  169. # endif
  170. #endif /* NON-UNIX */
  171.  
  172. /* ================ end of the header file puzzle =============== */
  173.  
  174. /*
  175.  * flags for updateScreen()
  176.  * The higher the value, the higher the priority
  177.  */
  178. #define VALID                    10    /* buffer not changed */
  179. #define INVERTED                20    /* redisplay inverted part */
  180. #define VALID_TO_CURSCHAR        30    /* buffer at/below cursor changed */
  181. #define NOT_VALID                40    /* buffer changed */
  182. #define CURSUPD                    50    /* buffer changed, update cursor first */
  183. #define CLEAR                    60    /* screen messed up, clear it */
  184.  
  185. /*
  186.  * Attributes for NextScreen.
  187.  */
  188. #define CHAR_NORMAL        0
  189. #define CHAR_INVERT        1
  190. #define CHAR_UNDERL        2
  191. #define CHAR_BOLD        3
  192. #define CHAR_STDOUT        4
  193. #define CHAR_ITALIC        5
  194.  
  195. /*
  196.  * values for State
  197.  *
  198.  * The lowest four bits are used to distinguish normal/visual/cmdline/
  199.  * insert+replace mode. This is used for mapping. If none of these bits are
  200.  * set, no mapping is done.
  201.  * The upper four bits are used to distinguish between other states.
  202.  */
  203. #define NORMAL                    0x01
  204. #define VISUAL                    0x02
  205. #define CMDLINE                 0x04
  206. #define INSERT                    0x08
  207. #define NORMAL_BUSY                0x11    /* busy interpreting a command */
  208. #define REPLACE                 0x28    /* replace mode */
  209. #define HITRETURN                0x61    /* waiting for a return */
  210. #define ASKMORE                    0x70    /* Asking if you want --more-- */
  211. #define SETWSIZE                0x80    /* window size has changed */
  212. #define ABBREV                    0x90    /* abbreviation instead of mapping */
  213. #define EXTERNCMD                0xa0    /* executing an external command */
  214.  
  215. /* directions */
  216. #define FORWARD                 1
  217. #define BACKWARD                (-1)
  218. #define BOTH_DIRECTIONS            2
  219.  
  220. /* return values for functions */
  221. #define OK                        1
  222. #define FAIL                    0
  223.  
  224. /*
  225.  * values for command line completion
  226.  */
  227. #define CONTEXT_UNKNOWN            (-2)
  228. #define EXPAND_UNSUCCESSFUL        (-1)
  229. #define EXPAND_NOTHING            0
  230. #define EXPAND_COMMANDS            1
  231. #define EXPAND_FILES            2
  232. #define EXPAND_DIRECTORIES        3
  233. #define EXPAND_SETTINGS            4
  234. #define EXPAND_BOOL_SETTINGS    5
  235. #define EXPAND_TAGS                6
  236. #define EXPAND_OLD_SETTING        7
  237. #define EXPAND_HELP                8
  238. #define EXPAND_BUFFERS            9
  239. #define EXPAND_EVENTS            10
  240. #define EXPAND_MENUS            11
  241.  
  242. /* Values for nextwild() and ExpandOne().  See ExpandOne() for meaning. */
  243. #define WILD_FREE                1
  244. #define WILD_EXPAND_FREE        2
  245. #define WILD_EXPAND_KEEP        3
  246. #define WILD_NEXT                4
  247. #define WILD_PREV                5
  248. #define WILD_ALL                6
  249. #define WILD_LONGEST            7
  250.  
  251. #define WILD_LIST_NOTFOUND        1
  252. #define WILD_HOME_REPLACE        2
  253.  
  254. /* Values for the find_pattern_in_path() function args 'type' and 'action': */
  255. #define FIND_ANY        1
  256. #define FIND_DEFINE        2
  257. #define CHECK_PATH        3
  258.  
  259. #define ACTION_SHOW        1
  260. #define ACTION_GOTO        2
  261. #define ACTION_SPLIT    3
  262. #define ACTION_SHOW_ALL    4
  263. #ifdef INSERT_EXPAND
  264. # define ACTION_EXPAND    5
  265. #endif
  266.  
  267. /* Values for 'options' argument in do_search() and searchit() */
  268. #define SEARCH_REV      0x01    /* go in reverse of previous dir. */
  269. #define SEARCH_ECHO      0x02    /* echo the search command and handle options */
  270. #define SEARCH_MSG      0x0c    /* give messages (yes, it's not 0x04) */
  271. #define SEARCH_NFMSG  0x08    /* give all messages except not found */
  272. #define SEARCH_OPT      0x10    /* interpret optional flags */
  273. #define SEARCH_HIS      0x20    /* put search pattern in history */
  274. #define SEARCH_END      0x40    /* put cursor at end of match */
  275. #define SEARCH_NOOF      0x80    /* don't add offset to position */
  276. #define SEARCH_START 0x100    /* start search without col offset */
  277. #define SEARCH_MARK  0x200    /* set previous context mark */
  278. #define SEARCH_KEEP  0x400    /* keep previous search pattern */
  279.  
  280. /* Values for find_ident_under_cursor() */
  281. #define FIND_IDENT    1        /* find identifier (word) */
  282. #define FIND_STRING    2        /* find any string (WORD) */
  283.  
  284. /* Values for get_file_name_in_path() */
  285. #define FNAME_MESS    1        /* give error message */
  286. #define FNAME_EXP    2        /* expand to path */
  287. #define FNAME_HYP    4        /* check for hypertext link */
  288.  
  289. /* Values for buflist_getfile() */
  290. #define GETF_SETMARK    0x01    /* set pcmark before jumping */
  291. #define GETF_ALT        0x02    /* jumping to alternate file (not buf num) */
  292.  
  293. /* Values for in_indentkeys() */
  294. #define KEY_OPEN_FORW    0x101
  295. #define KEY_OPEN_BACK    0x102
  296.  
  297. /* Values for call_shell() second argument */
  298. #define SHELL_FILTER        1        /* filtering text */
  299. #define SHELL_EXPAND        2        /* expanding wildcards */
  300. #define SHELL_COOKED        4        /* set term to cooked mode */
  301.  
  302. /* Values for change_indent() */
  303. #define INDENT_SET            1        /* set indent */
  304. #define INDENT_INC            2        /* increase indent */
  305. #define INDENT_DEC            3        /* decrease indent */
  306.  
  307. /* Values for flags argument for findmatchlimit() */
  308. #define FM_BACKWARD            0x01    /* search backwards */
  309. #define FM_FORWARD            0x02    /* search forwards */
  310. #define FM_BLOCKSTOP        0x04    /* stop at start/end of block */
  311. #define FM_SKIPCOMM            0x08    /* skip comments */
  312.  
  313. /* Values for action argument for do_buffer() */
  314. #define DOBUF_GOTO        0        /* go to specified buffer */
  315. #define DOBUF_SPLIT        1        /* split window and go to specified buffer */
  316. #define DOBUF_UNLOAD    2        /* unload specified buffer(s) */
  317. #define DOBUF_DEL        3        /* delete specified buffer(s) */
  318.  
  319. /* Values for start argument for do_buffer() */
  320. #define DOBUF_CURRENT    0        /* "count" buffer from current buffer */
  321. #define DOBUF_FIRST        1        /* "count" buffer from first buffer */
  322. #define DOBUF_LAST        2        /* "count" buffer from last buffer */
  323. #define DOBUF_MOD        3        /* "count" mod. buffer from current buffer */
  324.  
  325. /* Values for sub_cmd and which_pat argument for myregcomp() */
  326. /* Also used for which_pat argument for searchit() */
  327. #define RE_SEARCH    0            /* save/use pat in/from search_pattern */
  328. #define RE_SUBST    1            /* save/use pat in/from subst_pattern */
  329. #define RE_BOTH        2            /* save pat in both patterns */
  330. #define RE_LAST        2            /* use last used pattern if "pat" is NULL */
  331.  
  332. /* Return values for fullpathcmp() */
  333. #define FPC_SAME   1            /* both exist and are the same file. */
  334. #define FPC_DIFF   2            /* both exist and are different files. */
  335. #define FPC_NOTX   3            /* both don't exist. */
  336. #define FPC_DIFFX  4            /* one of them doesn't exist. */
  337.  
  338. /* flags for do_ecmd() */
  339. #define ECMD_HIDE        1        /* don't free the current buffer */
  340. #define ECMD_SET_HELP    2        /* set b_help flag of (new) buffer before
  341.                                    opening file */
  342. #define ECMD_OLDBUF        4        /* use existing buffer if it exists */
  343. #define ECMD_FORCEIT    8        /* ! used in Ex command */
  344.  
  345. /*
  346.  * Events for autocommands.
  347.  */
  348. enum auto_events
  349. {
  350.     EVENT_BUFENTER = 0,        /* after entering a buffer */
  351.     EVENT_BUFLEAVE,            /* before leaving a buffer */
  352.     EVENT_BUFNEWFILE,        /* when creating a buffer for a new file */
  353.     EVENT_BUFREADPOST,        /* after reading a buffer */
  354.     EVENT_BUFREADPRE,        /* before reading a buffer */
  355.     EVENT_BUFWRITEPOST,        /* after writing a buffer */
  356.     EVENT_BUFWRITEPRE,        /* before writing a buffer */
  357.     EVENT_FILEAPPENDPOST,    /* after appending to a file */
  358.     EVENT_FILEAPPENDPRE,    /* before appending to a file */
  359.     EVENT_FILEREADPOST,        /* after reading a file */
  360.     EVENT_FILEREADPRE,        /* before reading a file */
  361.     EVENT_FILEWRITEPOST,    /* after writing a file */
  362.     EVENT_FILEWRITEPRE,        /* before writing a file */
  363.     EVENT_FILTERREADPOST,    /* after reading from a filter */
  364.     EVENT_FILTERREADPRE,    /* before reading from a filter */
  365.     EVENT_FILTERWRITEPOST,    /* after writing to a filter */
  366.     EVENT_FILTERWRITEPRE,    /* before writing to a filter */
  367.     EVENT_VIMLEAVE,            /* before exiting Vim */
  368.     EVENT_WINENTER,            /* after entering a window */
  369.     EVENT_WINLEAVE,            /* before leaving a window */
  370.     NUM_EVENTS                /* MUST be the last one */
  371. };
  372.  
  373. /*
  374.  * Boolean constants
  375.  */
  376. #ifndef TRUE
  377. # define FALSE    0            /* note: this is an int, not a long! */
  378. # define TRUE    1
  379. #endif
  380.  
  381. #define MAYBE    2            /* for beginline() and the 'sol' option */
  382.  
  383. /* May be returned by add_new_completion(): */
  384. #define RET_ERROR                (-1)
  385.  
  386. /*
  387.  * jump_to_mouse() returns one of these values, possibly with
  388.  * CURSOR_MOVED added
  389.  */
  390. #define IN_UNKNOWN        1
  391. #define IN_BUFFER        2
  392. #define IN_STATUS_LINE    3            /* Or in command line */
  393. #define CURSOR_MOVED    0x100
  394.  
  395. /* flags for jump_to_mouse() */
  396. #define MOUSE_FOCUS        0x1        /* if used, need to stay in this window */
  397. #define MOUSE_MAY_VIS    0x2        /* if used, may set visual mode */ 
  398. #define MOUSE_DID_MOVE    0x4        /* if used, only act when mouse has moved */
  399. #define MOUSE_SETPOS    0x8        /* if used, only set current mouse position */
  400.  
  401. /*
  402.  * Minimum screen size
  403.  */
  404. #define MIN_COLUMNS        12        /* minimal columns for screen */
  405. #define MIN_ROWS        1        /* minimal rows for one window */
  406. #define STATUS_HEIGHT    1        /* height of a status line under a window */
  407.  
  408. /*
  409.  * Buffer sizes
  410.  */
  411. #ifndef CMDBUFFSIZE
  412. # define CMDBUFFSIZE    256        /* size of the command processing buffer */
  413. #endif
  414.  
  415. #define LSIZE        512            /* max. size of a line in the tags file */
  416.  
  417. #define IOSIZE       (1024+1)     /* file i/o and sprintf buffer size */
  418. #define MSG_BUF_LEN    80            /* length of buffer for small messages */
  419.  
  420. #define    TERMBUFSIZE    1024
  421.  
  422. #if defined(AMIGA) || defined(__linux__) || defined(__QNX__)
  423. # define TBUFSZ 2048            /* buffer size for termcap entry */
  424. #else
  425. # define TBUFSZ 1024            /* buffer size for termcap entry */
  426. #endif
  427.  
  428. /*
  429.  * Maximum length of key sequence to be mapped.
  430.  * Must be able to hold an Amiga resize report.
  431.  */
  432. #define MAXMAPLEN    50
  433.  
  434. #ifdef BINARY_FILE_IO
  435. # define WRITEBIN    "wb"        /* no CR-LF translation */
  436. # define READBIN    "rb"
  437. # define APPENDBIN    "ab"
  438. #else
  439. # define WRITEBIN    "w"
  440. # define READBIN    "r"
  441. # define APPENDBIN    "a"
  442. #endif
  443.  
  444. /*
  445.  * EMX doesn't have a global way of making open() use binary I/O.
  446.  * Use O_BINARY for all open() calls.
  447.  */
  448. #ifdef __EMX__
  449. # define O_EXTRA    O_BINARY
  450. #else
  451. # define O_EXTRA    0
  452. #endif
  453.  
  454. #define CHANGED           set_Changed()
  455. #define UNCHANGED(buf)    unset_Changed(buf)
  456.  
  457. /*
  458.  * defines to avoid typecasts from (char_u *) to (char *) and back
  459.  * (vim_strchr() and vim_strrchr() are now in alloc.c)
  460.  */
  461. #define STRLEN(s)            strlen((char *)(s))
  462. #define STRCPY(d, s)        strcpy((char *)(d), (char *)(s))
  463. #define STRNCPY(d, s, n)    strncpy((char *)(d), (char *)(s), (size_t)(n))
  464. #define STRCMP(d, s)        strcmp((char *)(d), (char *)(s))
  465. #define STRNCMP(d, s, n)    strncmp((char *)(d), (char *)(s), (size_t)(n))
  466. #define STRCAT(d, s)        strcat((char *)(d), (char *)(s))
  467. #define STRNCAT(d, s, n)    strncat((char *)(d), (char *)(s), (size_t)(n))
  468.  
  469. #define MSG(s)                msg((char_u *)(s))
  470. #define EMSG(s)                emsg((char_u *)(s))
  471. #define EMSG2(s, p)            emsg2((char_u *)(s), (char_u *)(p))
  472. #define EMSGN(s, n)            emsgn((char_u *)(s), (long)(n))
  473. #define OUTSTR(s)            outstr((char_u *)(s))
  474. #define OUTSTRN(s)            outstrn((char_u *)(s))
  475. #define MSG_OUTSTR(s)        msg_outstr((char_u *)(s))
  476.  
  477. typedef long        linenr_t;        /* line number type */
  478. typedef unsigned    colnr_t;        /* column number type */
  479.  
  480. #define MAXLNUM (0x7fffffff)        /* maximum (invalid) line number */
  481.  
  482. #if SIZEOF_INT >= 4
  483. # define MAXCOL    (0x7fffffff)        /* maximum column number, 31 bits */
  484. #else
  485. # define MAXCOL    (0x7fff)            /* maximum column number, 15 bits */
  486. #endif
  487.  
  488. #define SHOWCMD_COLS 10                /* columns needed by shown command */
  489.  
  490. /*
  491.  * Include a prototype for vim_memmove(), it may not be in alloc.pro.
  492.  */
  493. #ifdef VIM_MEMMOVE
  494. void vim_memmove __ARGS((void *, void *, size_t));
  495. #else
  496. # ifndef vim_memmove
  497. #  define vim_memmove(to, from, len) memmove(to, from, len)
  498. # endif
  499. #endif
  500.  
  501. /*
  502.  * For the Amiga we use a version of getenv that does local variables under 2.0
  503.  * For Win32 and MSDOS we also check $HOME when $VIM is used.
  504.  */
  505. #if !defined(AMIGA) && !defined(WIN32) && !defined(MSDOS) && !defined(VMS)
  506. # define vim_getenv(x) (char_u *)getenv((char *)x)
  507. #endif
  508.  
  509. /*
  510.  * fnamecmp() is used to compare filenames.
  511.  * On some systems case in a filename does not matter, on others it does.
  512.  * (this does not account for maximum name lengths and things like "../dir",
  513.  * thus it is not 100% accurate!)
  514.  */
  515. #ifdef CASE_INSENSITIVE_FILENAME
  516. # define fnamecmp(x, y) stricmp((char *)(x), (char *)(y))
  517. # define fnamencmp(x, y, n) strnicmp((char *)(x), (char *)(y), (size_t)(n))
  518. #else
  519. # define fnamecmp(x, y) strcmp((char *)(x), (char *)(y))
  520. # define fnamencmp(x, y, n) strncmp((char *)(x), (char *)(y), (size_t)(n))
  521. #endif
  522.  
  523. #ifdef HAVE_MEMSET
  524. # define vim_memset(ptr, c, size)    memset((ptr), (c), (size))
  525. #else
  526. void *vim_memset __ARGS((void *, int, size_t));
  527. #endif
  528.  
  529. /* for MS-DOS and Win32: use chdir() that also changes the default drive */
  530. #ifdef USE_VIM_CHDIR
  531. int vim_chdir __ARGS((char *));
  532. #else
  533. # define vim_chdir chdir
  534. #endif
  535.  
  536. /*
  537.  * vim_iswhite() is used for "^" and the like. It differs from isspace()
  538.  * because it doesn't include <CR> and <LF> and the like.
  539.  */
  540. #define vim_iswhite(x)    ((x) == ' ' || (x) == '\t')
  541.  
  542. /* Note that gui.h is included by structs.h */
  543.  
  544. #include "structs.h"        /* file that defines many structures */
  545.