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 / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / src / vim.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-05-29  |  53.5 KB  |  1,705 lines

  1. /* vi:set ts=8 sts=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. #ifndef VIM__H
  10. # define VIM__H
  11.  
  12. /* use fastcall for Borland, when compiling for Win32 (not for DOS16) */
  13. #if defined(__BORLANDC__) && defined(WIN32) && !defined(DEBUG)
  14. #if defined(FEAT_PERL) || \
  15.     defined(FEAT_PYTHON) || \
  16.     defined(FEAT_RUBY) || \
  17.     defined(FEAT_TCL) || \
  18.     defined(DYNAMIC_GETTEXT) || \
  19.     defined(DYNAMIC_ICONV) || \
  20.     defined(DYNAMIC_IME)
  21. #  pragma option -pc
  22. # else
  23. #  pragma option -pr
  24. # endif
  25. #endif
  26.  
  27. /* ============ the header file puzzle (ca. 50-100 pieces) ========= */
  28.  
  29. #ifdef HAVE_CONFIG_H    /* GNU autoconf (or something else) was here */
  30. # include "auto/config.h"
  31. # define HAVE_PATHDEF
  32.  
  33. /*
  34.  * Check if configure correcly managed to find sizeof(int).  If this failed,
  35.  * it becomes zero.  This is likely a problem of not being able to run the
  36.  * test program.  Other items from configure may also be wrong then!
  37.  */
  38. # if (SIZEOF_INT == 0)
  39.     Error: configure did not run properly.  Check auto/config.log.
  40. # endif
  41.  
  42. /*
  43.  * Cygwin may have fchdir() in a newer rleease, but in most versions it
  44.  * doesn't work well and avoiding it keeps the binary backward compatible.
  45.  */
  46. # if defined(__CYGWIN32__) && defined(HAVE_FCHDIR)
  47. #  undef HAVE_FCHDIR
  48. # endif
  49. #endif
  50.  
  51. #ifdef __EMX__        /* hand-edited config.h for OS/2 with EMX */
  52. # include "os_os2_cfg.h"
  53. #endif
  54.  
  55. /*
  56.  * MACOS_CLASSIC compiling for MacOS prior to MacOS X
  57.  * MACOS_X_UNIX  compiling for MacOS X (using os_unix.c)
  58.  * MACOS_X       compiling for MacOS X (using os_unix.c or os_mac.c)
  59.  * MACOS     compiling for either one
  60.  */
  61. #if defined(macintosh) && !defined(MACOS_CLASSIC)
  62. #  define MACOS_CLASSIC
  63. #endif
  64. #if defined(MACOS_X_UNIX)
  65. #  define MACOS_X
  66. #  define UNIX
  67. #endif
  68. #if defined(MACOS_X) || defined(MACOS_CLASSIC)
  69. #  define MACOS
  70. #endif
  71. #if defined(MACOS_X) && defined(MACOS_CLASSIC)
  72.     Error: To compile for both MACOS X and Classic use a Classic Carbon
  73. #endif
  74.  
  75.  
  76. #if defined(MACOS)
  77. # define FEAT_GUI_MAC
  78. #endif
  79. #if defined(FEAT_GUI_MOTIF) \
  80.     || defined(FEAT_GUI_GTK) \
  81.     || defined(FEAT_GUI_ATHENA) \
  82.     || defined(FEAT_GUI_MAC) \
  83.     || defined(FEAT_GUI_W32) \
  84.     || defined(FEAT_GUI_W16) \
  85.     || defined(FEAT_GUI_BEOS) \
  86.     || defined(FEAT_GUI_AMIGA) \
  87.     || defined(FEAT_GUI_PHOTON)
  88. # ifndef FEAT_GUI
  89. #  define FEAT_GUI
  90. # endif
  91. #endif
  92.  
  93. #if defined(FEAT_GUI_W32) || defined(FEAT_GUI_W16)
  94. # define FEAT_GUI_MSWIN
  95. #endif
  96. #if defined(WIN16) || defined(WIN32) || defined(_WIN64)
  97. # define MSWIN
  98. #endif
  99. /* Practically everything is common to both Win32 and Win64 */
  100. #if defined(WIN32) || defined(_WIN64)
  101. # define WIN3264
  102. #endif
  103.  
  104. /*
  105.  * SIZEOF_INT is used in feature.h, and the system-specific included files
  106.  * need items from feature.h.  Therefore define SIZEOF_INT here.
  107.  */
  108. #ifdef WIN3264
  109. # define SIZEOF_INT 4
  110. #endif
  111. #ifdef MSDOS
  112. # ifdef DJGPP
  113. #  ifndef FEAT_GUI_GTK        /* avoid problems when generating prototypes */
  114. #   define SIZEOF_INT 4        /* 32 bit ints */
  115. #  endif
  116. #  define DOS32
  117. #  define FEAT_CLIPBOARD
  118. # else
  119. #  ifndef FEAT_GUI_GTK        /* avoid problems when generating prototypes */
  120. #   define SIZEOF_INT 2        /* 16 bit ints */
  121. #  endif
  122. #  define SMALL_MALLOC        /* 16 bit storage allocation */
  123. #  define DOS16
  124. # endif
  125. #endif
  126.  
  127. #ifdef AMIGA
  128.   /* Be conservative about sizeof(int). It could be 4 too. */
  129. # ifndef FEAT_GUI_GTK    /* avoid problems when generating prototypes */
  130. #  define SIZEOF_INT    2
  131. # endif
  132. #endif
  133. #ifdef MACOS
  134. # if defined(__POWERPC__) || defined(__fourbyteints__) \
  135.   || defined(__MRC__) || defined(__SC__) || defined(__APPLE_CC__)/* MPW Compilers */
  136. #  define SIZEOF_INT 4
  137. # else
  138. #  define SIZEOF_INT 2
  139. # endif
  140. #endif
  141. #ifdef RISCOS
  142. # define SIZEOF_INT 4
  143. #endif
  144.  
  145.  
  146. #include "feature.h"    /* #defines for optionals and features */
  147.  
  148. /* +x11 is only enabled when it's both available and wanted. */
  149. #if defined(HAVE_X11) && defined(WANT_X11)
  150. # define FEAT_X11
  151. #endif
  152.  
  153. /* Can't use "PACKAGE" here, conflicts with a Perl include file. */
  154. #ifndef VIMPACKAGE
  155. # define VIMPACKAGE    "vim"
  156. #endif
  157.  
  158. /*
  159.  * Find out if function definitions should include argument types
  160.  */
  161. #ifdef AZTEC_C
  162. # include <functions.h>
  163. # define __ARGS(x)  x
  164. #endif
  165.  
  166. #ifdef SASC
  167. # include <clib/exec_protos.h>
  168. # define __ARGS(x)  x
  169. #endif
  170.  
  171. #ifdef _DCC
  172. # include <clib/exec_protos.h>
  173. # define __ARGS(x)  x
  174. #endif
  175.  
  176. #ifdef __TURBOC__
  177. # define __ARGS(x) x
  178. #endif
  179.  
  180. #ifdef __BEOS__
  181. # include "os_beos.h"
  182. # define __ARGS(x)  x
  183. #endif
  184.  
  185. #if (defined(UNIX) || defined(__EMX__) || defined(VMS)) && !defined(MACOS_X)
  186. # include "os_unix.h"        /* bring lots of system header files */
  187. #endif
  188.  
  189. #if defined(MACOS) && (defined(__MRC__) || defined(__SC__))
  190.    /* Apple's Compilers support prototypes */
  191. # define __ARGS(x) x
  192. #endif
  193. #ifndef __ARGS
  194. # if defined(__STDC__) || defined(__GNUC__) || defined(WIN3264)
  195. #  define __ARGS(x) x
  196. # else
  197. #  define __ARGS(x) ()
  198. # endif
  199. #endif
  200.  
  201. /* __ARGS and __PARMS are the same thing. */
  202. #ifndef __PARMS
  203. # define __PARMS(x) __ARGS(x)
  204. #endif
  205.  
  206. #if defined(UNIX) && !defined(MACOS_X) /* MACOS_X doesn't yet support osdef.h */
  207. # include "auto/osdef.h"    /* bring missing declarations in */
  208. #endif
  209.  
  210. #ifdef __EMX__
  211. # define    getcwd  _getcwd2
  212. # define    chdir   _chdir2
  213. # undef        CHECK_INODE
  214. #endif
  215.  
  216. #ifdef AMIGA
  217. # include "os_amiga.h"
  218. #endif
  219.  
  220. #ifdef MSDOS
  221. # include "os_msdos.h"
  222. #endif
  223.  
  224. #ifdef WIN16
  225. # include "os_win16.h"
  226. #endif
  227.  
  228. #ifdef WIN3264
  229. # include "os_win32.h"
  230. #endif
  231.  
  232. #ifdef __MINT__
  233. # include "os_mint.h"
  234. #endif
  235.  
  236. #if defined(MACOS)
  237. # if defined(__MRC__) || defined(__SC__) /* MPW Compilers */
  238. #  define HAVE_SETENV
  239. # endif
  240. # include "os_mac.h"
  241. #endif
  242.  
  243. #ifdef RISCOS
  244. # include "os_riscos.h"
  245. #endif
  246.  
  247. #ifdef __QNX__
  248. # include "os_qnx.h"
  249. #endif
  250.  
  251. #ifdef FEAT_SUN_WORKSHOP
  252. # include "workshop.h"
  253. #endif
  254.  
  255. #ifdef X_LOCALE
  256. # include <X11/Xlocale.h>
  257. #else
  258. # ifdef HAVE_LOCALE_H
  259. #  include <locale.h>
  260. # endif
  261. #endif
  262.  
  263. /*
  264.  * Maximum length of a path (for non-unix systems) Make it a bit long, to stay
  265.  * on the safe side.  But not too long to put on the stack.
  266.  */
  267. #ifndef MAXPATHL
  268. # ifdef MAXPATHLEN
  269. #  define MAXPATHL  MAXPATHLEN
  270. # else
  271. #  define MAXPATHL  256
  272. # endif
  273. #endif
  274. #ifdef BACKSLASH_IN_FILENAME
  275. # define PATH_ESC_CHARS ((char_u *)" *?[{`%#")
  276. #else
  277. # ifdef COLON_AS_PATHSEP
  278. #  define PATH_ESC_CHARS ((char_u *)" *?[{`$%#/")
  279. # else
  280. #  define PATH_ESC_CHARS ((char_u *)" *?[{`$\\%#'\"|")
  281. # endif
  282. #endif
  283.  
  284. #define NUMBUFLEN 30        /* length of a buffer to store a number in ASCII */
  285.  
  286. /*
  287.  * Shorthand for unsigned variables. Many systems, but not all, have u_char
  288.  * already defined, so we use char_u to avoid trouble.
  289.  */
  290. typedef unsigned char    char_u;
  291. typedef unsigned short    short_u;
  292. typedef unsigned int    int_u;
  293. /* Make sure long_u is big enough to hold a pointer.  On Win64 longs are 32
  294.  * bit and pointers 64 bit. */
  295. #ifdef _WIN64
  296. typedef unsigned __int64 long_u;
  297. #else
  298. typedef unsigned long    long_u;
  299. #endif
  300.  
  301. /*
  302.  * The characters and attributes cached for the screen.
  303.  * Currently a single byte.  The attributes may become larger some day.
  304.  */
  305. #define schar_T    char_u
  306. #define sattr_T    char_u
  307.  
  308. /*
  309.  * The u8char_T can hold one decoded UTF-8 character.
  310.  * Vim always use an int (32 bits) for characters most places, so that we can
  311.  * handle 32 bit characters in the file.  u8char_T is only used for
  312.  * displaying.  That should be enough, because there is no font for > 16 bits.
  313.  */
  314. #ifdef FEAT_MBYTE
  315. typedef unsigned short u8char_T;
  316. #endif
  317.  
  318. #ifndef UNIX            /* For Unix this is included in os_unix.h */
  319. # include <stdio.h>
  320. # include <ctype.h>
  321. #endif
  322.  
  323. #include "ascii.h"
  324. #include "keymap.h"
  325. #include "term.h"
  326. #include "macros.h"
  327.  
  328. #ifdef LATTICE
  329. # include <sys/types.h>
  330. # include <sys/stat.h>
  331. #endif
  332. #ifdef _DCC
  333. # include <sys/stat.h>
  334. #endif
  335. #if defined(MSDOS) || defined(MSWIN)
  336. # include <sys/stat.h>
  337. #endif
  338.  
  339. /*
  340.  * Allow other (non-unix) systems to configure themselves now
  341.  * These are also in os_unix.h, because osdef.sh needs them there.
  342.  */
  343. #ifndef UNIX
  344. /* Note: Some systems need both string.h and strings.h (Savage).  If the
  345.  * system can't handle this, define NO_STRINGS_WITH_STRING_H. */
  346. # ifdef HAVE_STRING_H
  347. #  include <string.h>
  348. # endif
  349. # if defined(HAVE_STRINGS_H) && !defined(NO_STRINGS_WITH_STRING_H)
  350. #   include <strings.h>
  351. # endif
  352. # ifdef HAVE_STAT_H
  353. #  include <stat.h>
  354. # endif
  355. # ifdef HAVE_STDLIB_H
  356. #  include <stdlib.h>
  357. # endif
  358. #endif /* NON-UNIX */
  359.  
  360. #include <assert.h>
  361.  
  362. /* ================ end of the header file puzzle =============== */
  363.  
  364. /*
  365.  * For dynamically loaded imm library. Currently, only for Win32.
  366.  */
  367. #ifdef DYNAMIC_IME
  368. # ifndef FEAT_MBYTE_IME
  369. #  define FEAT_MBYTE_IME
  370. # endif
  371. #endif
  372.  
  373. /*
  374.  * Check input method control.
  375.  */
  376. #if defined(FEAT_XIM) || \
  377.     (defined(FEAT_GUI) && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)))
  378. # define USE_IM_CONTROL
  379. #endif
  380.  
  381. /*
  382.  * For dynamically loaded gettext library.  Currently, only for Win32.
  383.  */
  384. #ifdef DYNAMIC_GETTEXT
  385. # ifndef FEAT_GETTEXT
  386. #  define FEAT_GETTEXT
  387. # endif
  388. /* These are in os_win32.c */
  389. extern char* (*dyn_libintl_gettext)(const char* msgid);
  390. extern char* (*dyn_libintl_bindtextdomain)(const char* domainname, const char* dirname);
  391. extern char* (*dyn_libintl_textdomain)(const char* domainname);
  392. #endif
  393.  
  394.  
  395. /*
  396.  * The _() stuff is for using gettext().  It is a no-op when libintl.h is not
  397.  * found or the +multilang feature is disabled.
  398.  */
  399. #ifdef FEAT_GETTEXT
  400. # ifdef DYNAMIC_GETTEXT
  401. #  define _(x) (*dyn_libintl_gettext)((char *)(x))
  402. #  define N_(x) x
  403. #  define bindtextdomain(domain,dir) (*dyn_libintl_bindtextdomain)(domain,dir)
  404. #  define textdomain(domain) (*dyn_libintl_textdomain)(domain)
  405. # else
  406. #  include <libintl.h>
  407. #  define _(x) gettext((char *)(x))
  408. #  ifdef gettext_noop
  409. #   define N_(x) gettext_noop(x)
  410. #  else
  411. #   define N_(x) x
  412. #  endif
  413. # endif
  414. #else
  415. # define _(x) ((char *)(x))
  416. # define N_(x) x
  417. # ifdef bindtextdomain
  418. #  undef bindtextdomain
  419. # endif
  420. # define bindtextdomain(x, y) /* empty */
  421. # ifdef textdomain
  422. #  undef textdomain
  423. # endif
  424. # define textdomain(x) /* empty */
  425. #endif
  426.  
  427. /*
  428.  * flags for update_screen()
  429.  * The higher the value, the higher the priority
  430.  */
  431. #define VALID            10  /* buffer not changed, or changes marked
  432.                        with b_mod_* */
  433. #define INVERTED        20  /* redisplay inverted part that changed */
  434. #define INVERTED_ALL        25  /* redisplay whole inverted part */
  435. #define REDRAW_TOP        30  /* display first w_upd_rows screen lines */
  436. #define NOT_VALID        40  /* buffer needs complete redraw */
  437. #define CLEAR            50  /* screen messed up, clear it */
  438.  
  439. /*
  440.  * Hints used to optimize screen updating.
  441.  */
  442. #define HINT_NONE    0        /* no current hint */
  443. #define HINT_DEL_CHAR    1        /* delete character */
  444. #define HINT_INS_CHAR    2        /* insert character */
  445.  
  446. /*
  447.  * Flags for w_valid.
  448.  * These are set when something in a window structure becomes invalid, except
  449.  * when the cursor is moved.  Call check_cursor_moved() before testing one of
  450.  * the flags.
  451.  * These are reset when that thing has been updated and is valid again.
  452.  *
  453.  * Every function that invalidates one of these must call one of the
  454.  * invalidate_* functions.
  455.  *
  456.  * w_valid is supposed to be used only in screen.c.  From other files, use the
  457.  * functions that set or reset the flags.
  458.  *
  459.  * VALID_BOTLINE    VALID_BOTLINE_AP
  460.  *     on        on        w_botline valid
  461.  *     off        on        w_botline approximated
  462.  *     off        off        w_botline not valid
  463.  *     on        off        not possible
  464.  */
  465. #define VALID_WROW    0x01    /* w_wrow (window row) is valid */
  466. #define VALID_WCOL    0x02    /* w_wcol (window col) is valid */
  467. #define VALID_VIRTCOL    0x04    /* w_virtcol (file col) is valid */
  468. #define VALID_CHEIGHT    0x08    /* w_cline_height and w_cline_folded valid */
  469. #define VALID_CROW    0x10    /* w_cline_row is valid */
  470. #define VALID_BOTLINE    0x20    /* w_botine and w_empty_rows are valid */
  471. #define VALID_BOTLINE_AP 0x40    /* w_botine is approximated */
  472. #define VALID_TOPLINE    0x80    /* w_topline is valid (for cursor position) */
  473.  
  474. /*
  475.  * Terminal highlighting attribute bits.
  476.  * Attibutes above HL_ALL are used for syntax highlighting.
  477.  */
  478. #define HL_NORMAL        0x00
  479. #define HL_INVERSE        0x01
  480. #define HL_BOLD            0x02
  481. #define HL_ITALIC        0x04
  482. #define HL_UNDERLINE        0x08
  483. #define HL_STANDOUT        0x10
  484. #define HL_ALL            0x1f
  485.  
  486. /* special attribute addition: Put message in history */
  487. #define MSG_HIST        0x1000
  488.  
  489. /*
  490.  * values for State
  491.  *
  492.  * The lower bits up to 0x20 are used to distinguish normal/visual/op_pending
  493.  * and cmdline/insert+replace mode.  This is used for mapping.  If none of
  494.  * these bits are set, no mapping is done.
  495.  * The upper bits are used to distinguish between other states.
  496.  */
  497. #define NORMAL        0x01    /* Normal mode, command expected */
  498. #define VISUAL        0x02    /* Visual mode - use get_real_state() */
  499. #define OP_PENDING    0x04    /* Normal mode, operator is pending - use
  500.                    get_real_state() */
  501. #define CMDLINE        0x08    /* Editing command line */
  502. #define INSERT        0x10    /* Insert mode */
  503. #define LANGMAP        0x20    /* Language mapping, can be combined with
  504.                    INSERT and CMDLINE */
  505. #define MAP_ALL_MODES    0x3f    /* all mode bits used for mapping */
  506.  
  507. #define REPLACE_FLAG    0x40    /* Replace mode flag */
  508. #define REPLACE        (REPLACE_FLAG + INSERT)
  509. #ifdef FEAT_VREPLACE
  510. # define VREPLACE_FLAG    0x80    /* Virtual-replace mode flag */
  511. # define VREPLACE    (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
  512. #endif
  513. #define LREPLACE    (REPLACE_FLAG + LANGMAP)
  514.  
  515. #define NORMAL_BUSY    (0x100 + NORMAL) /* Normal mode, busy with a command */
  516. #define HITRETURN    (0x200 + NORMAL) /* waiting for return or command */
  517. #define ASKMORE        0x300    /* Asking if you want --more-- */
  518. #define SETWSIZE    0x400    /* window size has changed */
  519. #define ABBREV        0x500    /* abbreviation instead of mapping */
  520. #define EXTERNCMD    0x600    /* executing an external command */
  521. #define SHOWMATCH    (0x700 + INSERT) /* show matching paren */
  522. #define CONFIRM        0x800    /* ":confirm" prompt */
  523.  
  524. /* directions */
  525. #define FORWARD            1
  526. #define BACKWARD        (-1)
  527. #define FORWARD_FILE        3
  528.  
  529. /* return values for functions */
  530. #if !(defined(OK) && (OK == 1))
  531. /* OK already defined to 1 in MacOS X curses, skip this */
  532. /* OK defined to 0 in MacOS X 10.2 curses!  redefine it */
  533. # if defined(OK) && defined(MACOS_X_UNIX)
  534. #  undef OK
  535. # endif
  536. # define OK            1
  537. #endif
  538. #define FAIL            0
  539.  
  540. /* flags for b_flags */
  541. #define BF_RECOVERED    0x01    /* buffer has been recovered */
  542. #define BF_CHECK_RO    0x02    /* need to check readonly when loading file
  543.                    into buffer (set by ":e", may be reset by
  544.                    ":buf" */
  545. #define BF_NEVERLOADED    0x04    /* file has never been loaded into buffer,
  546.                    many variables still need to be set */
  547. #define BF_NOTEDITED    0x08    /* Set when file name is changed after
  548.                    starting to edit, reset when file is
  549.                    written out. */
  550. #define BF_NEW        0x10    /* file didn't exist when editing started */
  551. #define BF_NEW_W    0x20    /* Warned for BF_NEW and file created */
  552. #define BF_READERR    0x40    /* got errors while reading the file */
  553.  
  554. /* Mask to check for flags that prevent normal writing */
  555. #define BF_WRITE_MASK    (BF_NOTEDITED + BF_NEW + BF_READERR)
  556.  
  557. /*
  558.  * values for xp_context when doing command line completion
  559.  */
  560. #define CONTEXT_UNKNOWN        (-3)
  561. #define EXPAND_UNSUCCESSFUL    (-2)
  562. #define EXPAND_OK        (-1)
  563. #define EXPAND_NOTHING        0
  564. #define EXPAND_COMMANDS        1
  565. #define EXPAND_FILES        2
  566. #define EXPAND_DIRECTORIES    3
  567. #define EXPAND_SETTINGS        4
  568. #define EXPAND_BOOL_SETTINGS    5
  569. #define EXPAND_TAGS        6
  570. #define EXPAND_OLD_SETTING    7
  571. #define EXPAND_HELP        8
  572. #define EXPAND_BUFFERS        9
  573. #define EXPAND_EVENTS        10
  574. #define EXPAND_MENUS        11
  575. #define EXPAND_SYNTAX        12
  576. #define EXPAND_HIGHLIGHT    13
  577. #define EXPAND_AUGROUP        14
  578. #define EXPAND_USER_VARS    15
  579. #define EXPAND_MAPPINGS        16
  580. #define EXPAND_TAGS_LISTFILES    17
  581. #define EXPAND_FUNCTIONS    18
  582. #define EXPAND_USER_FUNC    19
  583. #define EXPAND_EXPRESSION    20
  584. #define EXPAND_MENUNAMES    21
  585. #define EXPAND_USER_COMMANDS    22
  586. #define EXPAND_USER_CMD_FLAGS    23
  587. #define EXPAND_USER_NARGS    24
  588. #define EXPAND_USER_COMPLETE    25
  589. #define EXPAND_ENV_VARS        26
  590. #define EXPAND_LANGUAGE        27
  591. #define EXPAND_COLORS        28
  592. #define EXPAND_COMPILER        29
  593. #define EXPAND_USER_DEFINED    30
  594.  
  595. /* Values for exmode_active (0 is no exmode) */
  596. #define EXMODE_NORMAL        1
  597. #define EXMODE_VIM        2
  598.  
  599. /* Values for nextwild() and ExpandOne().  See ExpandOne() for meaning. */
  600. #define WILD_FREE        1
  601. #define WILD_EXPAND_FREE    2
  602. #define WILD_EXPAND_KEEP    3
  603. #define WILD_NEXT        4
  604. #define WILD_PREV        5
  605. #define WILD_ALL        6
  606. #define WILD_LONGEST        7
  607.  
  608. #define WILD_LIST_NOTFOUND    1
  609. #define WILD_HOME_REPLACE    2
  610. #define WILD_USE_NL        4
  611. #define WILD_NO_BEEP        8
  612. #define WILD_ADD_SLASH        16
  613. #define WILD_KEEP_ALL        32
  614. #define WILD_SILENT        64
  615. #define WILD_ESCAPE        128
  616.  
  617. /* Flags for expand_wildcards() */
  618. #define EW_DIR        1    /* include directory names */
  619. #define EW_FILE        2    /* include file names */
  620. #define EW_NOTFOUND    4    /* include not found names */
  621. #define EW_ADDSLASH    8    /* append slash to directory name */
  622. #define EW_KEEPALL    16    /* keep all matches */
  623. #define EW_SILENT    32    /* don't print "1 returned" from shell */
  624. /* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND
  625.  * is used when executing commands and EW_SILENT for interactive expanding. */
  626.  
  627. #ifdef FEAT_VERTSPLIT
  628. # define W_WINCOL(wp)    (wp->w_wincol)
  629. # define W_WIDTH(wp)    (wp->w_width)
  630. # define W_ENDCOL(wp)    (wp->w_wincol + wp->w_width)
  631. # define W_VSEP_WIDTH(wp) (wp->w_vsep_width)
  632. #else
  633. # define W_WINCOL(wp)    0
  634. # define W_WIDTH(wp)    Columns
  635. # define W_ENDCOL(wp)    Columns
  636. # define W_VSEP_WIDTH(wp) 0
  637. #endif
  638. #ifdef FEAT_WINDOWS
  639. # define W_STATUS_HEIGHT(wp) (wp->w_status_height)
  640. # define W_WINROW(wp)    (wp->w_winrow)
  641. #else
  642. # define W_STATUS_HEIGHT(wp) 0
  643. # define W_WINROW(wp)    0
  644. #endif
  645.  
  646. #ifdef NO_EXPANDPATH
  647. # define gen_expand_wildcards mch_expand_wildcards
  648. #endif
  649.  
  650. /* Values for the find_pattern_in_path() function args 'type' and 'action': */
  651. #define FIND_ANY    1
  652. #define FIND_DEFINE    2
  653. #define CHECK_PATH    3
  654.  
  655. #define ACTION_SHOW    1
  656. #define ACTION_GOTO    2
  657. #define ACTION_SPLIT    3
  658. #define ACTION_SHOW_ALL    4
  659. #ifdef FEAT_INS_EXPAND
  660. # define ACTION_EXPAND    5
  661. #endif
  662.  
  663. #ifdef FEAT_SYN_HL
  664. # define SST_MIN_ENTRIES 150    /* minimal size for state stack array */
  665. # ifdef FEAT_GUI_W16
  666. #  define SST_MAX_ENTRIES 500    /* (only up to 64K blocks) */
  667. # else
  668. #  define SST_MAX_ENTRIES 1000    /* maximal size for state stack array */
  669. # endif
  670. # define SST_FIX_STATES     7    /* size of sst_stack[]. */
  671. # define SST_DIST     16    /* normal distance between entries */
  672. # define SST_INVALID    (synstate_T *)-1    /* invalid syn_state pointer */
  673. #endif
  674.  
  675. /* Values for 'options' argument in do_search() and searchit() */
  676. #define SEARCH_REV    0x01  /* go in reverse of previous dir. */
  677. #define SEARCH_ECHO   0x02  /* echo the search command and handle options */
  678. #define SEARCH_MSG    0x0c  /* give messages (yes, it's not 0x04) */
  679. #define SEARCH_NFMSG  0x08  /* give all messages except not found */
  680. #define SEARCH_OPT    0x10  /* interpret optional flags */
  681. #define SEARCH_HIS    0x20  /* put search pattern in history */
  682. #define SEARCH_END    0x40  /* put cursor at end of match */
  683. #define SEARCH_NOOF   0x80  /* don't add offset to position */
  684. #define SEARCH_START 0x100  /* start search without col offset */
  685. #define SEARCH_MARK  0x200  /* set previous context mark */
  686. #define SEARCH_KEEP  0x400  /* keep previous search pattern */
  687. #define SEARCH_PEEK  0x800  /* peek for typed char, cancel search */
  688.  
  689. /* Values for find_ident_under_cursor() */
  690. #define FIND_IDENT    1    /* find identifier (word) */
  691. #define FIND_STRING    2    /* find any string (WORD) */
  692.  
  693. /* Values for file_name_in_line() */
  694. #define FNAME_MESS    1    /* give error message */
  695. #define FNAME_EXP    2    /* expand to path */
  696. #define FNAME_HYP    4    /* check for hypertext link */
  697. #define FNAME_INCL    8    /* apply 'includeexpr' */
  698. #define FNAME_REL    16    /* ".." and "./" are relative to the (current)
  699.                    file instead of the current directory */
  700.  
  701. /* Values for buflist_getfile() */
  702. #define GETF_SETMARK    0x01    /* set pcmark before jumping */
  703. #define GETF_ALT    0x02    /* jumping to alternate file (not buf num) */
  704. #define GETF_SWITCH    0x04    /* respect 'switchbuf' settings when jumping */
  705.  
  706. /* Values for buflist_new() flags */
  707. #define BLN_CURBUF    1    /* May re-use curbuf for new buffer */
  708. #define BLN_LISTED    2    /* Put new buffer in buffer list */
  709. #define BLN_DUMMY    4    /* Allocating dummy buffer */
  710.  
  711. /* Values for in_cinkeys() */
  712. #define KEY_OPEN_FORW    0x101
  713. #define KEY_OPEN_BACK    0x102
  714. #define KEY_COMPLETE    0x103    /* end of completion */
  715.  
  716. /* Values for "noremap" argument of ins_typebuf().  Also used for
  717.  * map->m_noremap and menu->noremap[]. */
  718. #define REMAP_YES    0    /* allow remapping */
  719. #define REMAP_NONE    -1    /* no remapping */
  720. #define REMAP_SCRIPT    -2    /* remap script-local mappings only */
  721.  
  722. /* Values for mch_call_shell() second argument */
  723. #define SHELL_FILTER    1    /* filtering text */
  724. #define SHELL_EXPAND    2    /* expanding wildcards */
  725. #define SHELL_COOKED    4    /* set term to cooked mode */
  726. #define SHELL_DOOUT    8    /* redirecting output */
  727. #define SHELL_SILENT    16    /* don't print error returned by command */
  728.  
  729. /* Values returned by mch_nodetype() */
  730. #define NODE_NORMAL    0    /* file or directory, check with mch_isdir()*/
  731. #define NODE_WRITABLE    1    /* something we can write to (character
  732.                    device, fifo, socket, ..) */
  733. #define NODE_OTHER    2    /* non-writable thing (e.g., block device) */
  734.  
  735. /* Values for readfile() flags */
  736. #define READ_NEW    0x01    /* read a file into a new buffer */
  737. #define READ_FILTER    0x02    /* read filter output */
  738. #define READ_STDIN    0x04    /* read from stdin */
  739. #define READ_BUFFER    0x08    /* read from curbuf (converting stdin) */
  740. #define READ_DUMMY    0x10    /* reading into a dummy buffer */
  741.  
  742. /* Values for change_indent() */
  743. #define INDENT_SET    1    /* set indent */
  744. #define INDENT_INC    2    /* increase indent */
  745. #define INDENT_DEC    3    /* decrease indent */
  746.  
  747. /* Values for flags argument for findmatchlimit() */
  748. #define FM_BACKWARD    0x01    /* search backwards */
  749. #define FM_FORWARD    0x02    /* search forwards */
  750. #define FM_BLOCKSTOP    0x04    /* stop at start/end of block */
  751. #define FM_SKIPCOMM    0x08    /* skip comments */
  752.  
  753. /* Values for action argument for do_buffer() */
  754. #define DOBUF_GOTO    0    /* go to specified buffer */
  755. #define DOBUF_SPLIT    1    /* split window and go to specified buffer */
  756. #define DOBUF_UNLOAD    2    /* unload specified buffer(s) */
  757. #define DOBUF_DEL    3    /* delete specified buffer(s) from buflist */
  758. #define DOBUF_WIPE    4    /* delete specified buffer(s) really */
  759.  
  760. /* Values for start argument for do_buffer() */
  761. #define DOBUF_CURRENT    0    /* "count" buffer from current buffer */
  762. #define DOBUF_FIRST    1    /* "count" buffer from first buffer */
  763. #define DOBUF_LAST    2    /* "count" buffer from last buffer */
  764. #define DOBUF_MOD    3    /* "count" mod. buffer from current buffer */
  765.  
  766. /* Values for sub_cmd and which_pat argument for search_regcomp() */
  767. /* Also used for which_pat argument for searchit() */
  768. #define RE_SEARCH    0    /* save/use pat in/from search_pattern */
  769. #define RE_SUBST    1    /* save/use pat in/from subst_pattern */
  770. #define RE_BOTH        2    /* save pat in both patterns */
  771. #define RE_LAST        2    /* use last used pattern if "pat" is NULL */
  772.  
  773. /* Second argument for vim_regcomp(). */
  774. #define RE_MAGIC    1    /* 'magic' option */
  775. #define RE_STRING    2    /* match in string instead of buffer text */
  776.  
  777. #ifdef FEAT_SYN_HL
  778. /* values for reg_do_extmatch */
  779. # define REX_SET    1    /* to allow \z\(...\), */
  780. # define REX_USE    2    /* to allow \z\1 et al. */
  781. #endif
  782.  
  783. /* Return values for fullpathcmp() */
  784. /* Note: can use (fullpathcmp() & FPC_SAME) to check for equal files */
  785. #define FPC_SAME    1    /* both exist and are the same file. */
  786. #define FPC_DIFF    2    /* both exist and are different files. */
  787. #define FPC_NOTX    4    /* both don't exist. */
  788. #define FPC_DIFFX    6    /* one of them doesn't exist. */
  789. #define FPC_SAMEX    7    /* both don't exist and file names are same. */
  790.  
  791. /* flags for do_ecmd() */
  792. #define ECMD_HIDE    0x01    /* don't free the current buffer */
  793. #define ECMD_SET_HELP    0x02    /* set b_help flag of (new) buffer before
  794.                    opening file */
  795. #define ECMD_OLDBUF    0x04    /* use existing buffer if it exists */
  796. #define ECMD_FORCEIT    0x08    /* ! used in Ex command */
  797. #define ECMD_ADDBUF    0x10    /* don't edit, just add to buffer list */
  798.  
  799. /* for lnum argument in do_ecmd() */
  800. #define ECMD_LASTL    (linenr_T)0    /* use last position in loaded file */
  801. #define ECMD_LAST    (linenr_T)-1    /* use last position in all files */
  802. #define ECMD_ONE    (linenr_T)1    /* use first line */
  803.  
  804. /* flags for do_cmdline() */
  805. #define DOCMD_VERBOSE    0x01    /* included command in error message */
  806. #define DOCMD_NOWAIT    0x02    /* don't call wait_return() and friends */
  807. #define DOCMD_REPEAT    0x04    /* repeat exec. until getline() returns NULL */
  808. #define DOCMD_KEYTYPED    0x08    /* don't reset KeyTyped */
  809. #define DOCMD_EXCRESET    0x10    /* reset exception environment (for debugging)*/
  810.  
  811. /* flags for beginline() */
  812. #define BL_WHITE    1    /* cursor on first non-white in the line */
  813. #define BL_SOL        2    /* use 'sol' option */
  814. #define BL_FIX        4    /* don't leave cursor on a NUL */
  815.  
  816. /* flags for mf_sync() */
  817. #define MFS_ALL        1    /* also sync blocks with negative numbers */
  818. #define MFS_STOP    2    /* stop syncing when a character is available */
  819. #define MFS_FLUSH    4    /* flushed file to disk */
  820. #define MFS_ZERO    8    /* only write block 0 */
  821.  
  822. /* flags for buf_copy_options() */
  823. #define BCO_ENTER    1    /* going to enter the buffer */
  824. #define BCO_ALWAYS    2    /* always copy the options */
  825. #define BCO_NOHELP    4    /* don't touch the help related options */
  826.  
  827. /* flags for do_put() */
  828. #define PUT_FIXINDENT    1    /* make indent look nice */
  829. #define PUT_CURSEND    2    /* leave cursor after end of new text */
  830. #define PUT_LINE    4    /* put register as lines */
  831. #define PUT_LINE_SPLIT    8    /* split line for linewise register */
  832. #define PUT_LINE_FORWARD 16    /* put linewise register below Visual sel. */
  833.  
  834. /* flags for set_indent() */
  835. #define SIN_CHANGED    1    /* call changed_bytes() when line changed */
  836. #define SIN_INSERT    2    /* insert indent before existing text */
  837. #define SIN_UNDO    4    /* save line for undo before changing it */
  838.  
  839. /* flags for insertchar() */
  840. #define INSCHAR_FORMAT    1    /* force formatting */
  841. #define INSCHAR_DO_COM    2    /* format comments */
  842. #define INSCHAR_CTRLV    4    /* char typed just after CTRL-V */
  843.  
  844. /* flags for open_line() */
  845. #define OPENLINE_DELSPACES  1    /* delete spaces after cursor */
  846. #define OPENLINE_DO_COM        2    /* format comments */
  847. #define OPENLINE_KEEPTRAIL  4    /* keep trailing spaces */
  848.  
  849. /*
  850.  * There are four history tables:
  851.  */
  852. #define HIST_CMD    0    /* colon commands */
  853. #define HIST_SEARCH    1    /* search commands */
  854. #define HIST_EXPR    2    /* expressions (from entering = register) */
  855. #define HIST_INPUT    3    /* input() lines */
  856. #define HIST_DEBUG    4    /* debug commands */
  857. #define HIST_COUNT    5    /* number of history tables */
  858.  
  859. /*
  860.  * Flags for chartab[].
  861.  */
  862. #define CT_CELL_MASK    0x07    /* mask: nr of display cells (1, 2 or 4) */
  863. #define CT_PRINT_CHAR    0x10    /* flag: set for printable chars */
  864. #define CT_ID_CHAR    0x20    /* flag: set for ID chars */
  865. #define CT_FNAME_CHAR    0x40    /* flag: set for file name chars */
  866.  
  867. /*
  868.  * Values for do_tag().
  869.  */
  870. #define DT_TAG        1    /* jump to newer position or same tag again */
  871. #define DT_POP        2    /* jump to older position */
  872. #define DT_NEXT        3    /* jump to next match of same tag */
  873. #define DT_PREV        4    /* jump to previous match of same tag */
  874. #define DT_FIRST    5    /* jump to first match of same tag */
  875. #define DT_LAST        6    /* jump to first match of same tag */
  876. #define DT_SELECT    7    /* jump to selection from list */
  877. #define DT_HELP        8    /* like DT_TAG, but no wildcards */
  878. #define DT_JUMP        9    /* jump to new tag or selection from list */
  879. #define DT_CSCOPE    10    /* cscope find command (like tjump) */
  880.  
  881. /*
  882.  * flags for find_tags().
  883.  */
  884. #define TAG_HELP    1    /* only search for help tags */
  885. #define TAG_NAMES    2    /* only return name of tag */
  886. #define    TAG_REGEXP    4    /* use tag pattern as regexp */
  887. #define    TAG_NOIC    8    /* don't always ignore case */
  888. #ifdef FEAT_CSCOPE
  889. # define TAG_CSCOPE    16    /* cscope tag */
  890. #endif
  891. #define TAG_VERBOSE    32    /* message verbosity */
  892. #define TAG_INS_COMP    64    /* Currently doing insert completion */
  893. #define TAG_MANY    200    /* When finding many tags (for completion),
  894.                    find up to this many tags */
  895.  
  896. /*
  897.  * Types of dialogs passed to do_vim_dialog().
  898.  */
  899. #define VIM_GENERIC    0
  900. #define VIM_ERROR    1
  901. #define VIM_WARNING    2
  902. #define VIM_INFO    3
  903. #define VIM_QUESTION    4
  904. #define VIM_LAST_TYPE    4    /* sentinel value */
  905.  
  906. /*
  907.  * Return values for functions like gui_yesnocancel()
  908.  */
  909. #define VIM_OK        1
  910. #define VIM_YES        2
  911. #define VIM_NO        3
  912. #define VIM_CANCEL    4
  913. #define VIM_ALL        5
  914. #define VIM_DISCARDALL  6
  915.  
  916. /*
  917.  * arguments for win_split()
  918.  */
  919. #define WSP_ROOM    1    /* require enough room */
  920. #define WSP_VERT    2    /* split vertically */
  921. #define WSP_TOP        4    /* window at top-left of shell */
  922. #define WSP_BOT        8    /* window at bottom-right of shell */
  923. #define WSP_HELP    16    /* creating the help window */
  924. #define WSP_BELOW    32    /* put new window below/right */
  925. #define WSP_ABOVE    64    /* put new window above/left */
  926.  
  927. /*
  928.  * "flags" values for option-setting functions.
  929.  * When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
  930.  * values, get local value.
  931.  */
  932. #define OPT_FREE    1    /* free old value if it was allocated */
  933. #define OPT_GLOBAL    2    /* use global value */
  934. #define OPT_LOCAL    4    /* use local value */
  935. #define OPT_MODELINE    8    /* option in modeline */
  936.  
  937. /* Magic chars used in confirm dialog strings */
  938. #define DLG_BUTTON_SEP    '\n'
  939. #define DLG_HOTKEY_CHAR    '&'
  940.  
  941. /* Values for "starting" */
  942. #define NO_SCREEN    2    /* no screen updating yet */
  943. #define NO_BUFFERS    1    /* not all buffers loaded yet */
  944. /*            0       not starting anymore */
  945.  
  946. /* Values for swap_exists_action: what to do when swap file already exists */
  947. #define SEA_NONE    0    /* don't use dialog */
  948. #define SEA_DIALOG    1    /* use dialog when */
  949. #define SEA_QUIT    2    /* quit editing the file */
  950. #define SEA_RECOVER    3    /* recover the file */
  951.  
  952. /*
  953.  * Minimal size for block 0 of a swap file.
  954.  * NOTE: This depends on size of struct block0! It's not done with a sizeof(),
  955.  * because struct block0 is defined in memline.c (Sorry).
  956.  * The maximal block size is arbitrary.
  957.  */
  958. #define MIN_SWAP_PAGE_SIZE 1048
  959. #define MAX_SWAP_PAGE_SIZE 50000
  960.  
  961. #define SID_MODELINE    -1    /* script ID when using a modeline */
  962.  
  963. /*
  964.  * Events for autocommands.
  965.  */
  966. enum auto_event
  967. {
  968.     EVENT_BUFADD = 0,        /* after adding a buffer to the buffer list */
  969.     EVENT_BUFNEW,        /* after creating any buffer */
  970.     EVENT_BUFDELETE,        /* deleting a buffer from the buffer list */
  971.     EVENT_BUFWIPEOUT,        /* just before really deleting a buffer */
  972.     EVENT_BUFENTER,        /* after entering a buffer */
  973.     EVENT_BUFFILEPOST,        /* after renaming a buffer */
  974.     EVENT_BUFFILEPRE,        /* before renaming a buffer */
  975.     EVENT_BUFLEAVE,        /* before leaving a buffer */
  976.     EVENT_BUFNEWFILE,        /* when creating a buffer for a new file */
  977.     EVENT_BUFREADPOST,        /* after reading a buffer */
  978.     EVENT_BUFREADPRE,        /* before reading a buffer */
  979.     EVENT_BUFREADCMD,        /* read buffer using command */
  980.     EVENT_BUFUNLOAD,        /* just before unloading a buffer */
  981.     EVENT_BUFHIDDEN,        /* just after buffer becomes hidden */
  982.     EVENT_BUFWINENTER,        /* after showing a buffer in a window */
  983.     EVENT_BUFWINLEAVE,        /* just after buffer removed from window */
  984.     EVENT_BUFWRITEPOST,        /* after writing a buffer */
  985.     EVENT_BUFWRITEPRE,        /* before writing a buffer */
  986.     EVENT_BUFWRITECMD,        /* write buffer using command */
  987.     EVENT_CMDWINENTER,        /* after entering the cmdline window */
  988.     EVENT_CMDWINLEAVE,        /* before leaving the cmdline window */
  989.     EVENT_FILEAPPENDPOST,    /* after appending to a file */
  990.     EVENT_FILEAPPENDPRE,    /* before appending to a file */
  991.     EVENT_FILEAPPENDCMD,    /* appende to a file using command */
  992.     EVENT_FILECHANGEDSHELL,    /* after shell command that changed file */
  993.     EVENT_FILECHANGEDRO,    /* before first change to read-only file */
  994.     EVENT_FILEREADPOST,        /* after reading a file */
  995.     EVENT_FILEREADPRE,        /* before reading a file */
  996.     EVENT_FILEREADCMD,        /* read from a file using command */
  997.     EVENT_FILETYPE,        /* new file type detected (user defined) */
  998.     EVENT_FILEWRITEPOST,    /* after writing a file */
  999.     EVENT_FILEWRITEPRE,        /* before writing a file */
  1000.     EVENT_FILEWRITECMD,        /* write to a file using command */
  1001.     EVENT_FILTERREADPOST,    /* after reading from a filter */
  1002.     EVENT_FILTERREADPRE,    /* before reading from a filter */
  1003.     EVENT_FILTERWRITEPOST,    /* after writing to a filter */
  1004.     EVENT_FILTERWRITEPRE,    /* before writing to a filter */
  1005.     EVENT_FOCUSGAINED,        /* got the focus */
  1006.     EVENT_FOCUSLOST,        /* lost the focus to another app */
  1007.     EVENT_GUIENTER,        /* after starting the GUI */
  1008.     EVENT_STDINREADPOST,    /* after reading from stdin */
  1009.     EVENT_STDINREADPRE,        /* before reading from stdin */
  1010.     EVENT_SYNTAX,        /* syntax selected */
  1011.     EVENT_TERMCHANGED,        /* after changing 'term' */
  1012.     EVENT_TERMRESPONSE,        /* after setting "v:termresponse" */
  1013.     EVENT_USER,            /* user defined autocommand */
  1014.     EVENT_VIMENTER,        /* after starting Vim */
  1015.     EVENT_VIMLEAVE,        /* before exiting Vim */
  1016.     EVENT_VIMLEAVEPRE,        /* before exiting Vim and writing .viminfo */
  1017.     EVENT_WINENTER,        /* after entering a window */
  1018.     EVENT_WINLEAVE,        /* before leaving a window */
  1019.     EVENT_ENCODINGCHANGED,    /* after changing the 'encoding' option */
  1020.     EVENT_CURSORHOLD,        /* cursor in same position for a while */
  1021.     EVENT_FUNCUNDEFINED,    /* if calling a function which doesn't exist */
  1022.     EVENT_REMOTEREPLY,        /* upon string reception from a remote vim */
  1023.     NUM_EVENTS            /* MUST be the last one */
  1024. };
  1025.  
  1026. typedef enum auto_event EVENT_T;
  1027.  
  1028. /*
  1029.  * Values for index in highlight_attr[].
  1030.  * When making changes, also update HL_FLAGS below!  And update the default
  1031.  * value of 'highlight' in option.c.
  1032.  */
  1033. enum hlf_value
  1034. {
  1035.     HLF_8 = 0        /* Meta & special keys listed with ":map", text that is
  1036.                displayed different from what it is */
  1037.     , HLF_AT        /* @ and ~ characters at end of screen, characters that
  1038.                don't really exist in the text */
  1039.     , HLF_D        /* directories in CTRL-D listing */
  1040.     , HLF_E        /* error messages */
  1041.     , HLF_H        /* obsolete, ignored */
  1042.     , HLF_I        /* incremental search */
  1043.     , HLF_L        /* last search string */
  1044.     , HLF_M        /* "--More--" message */
  1045.     , HLF_CM        /* Mode (e.g., "-- INSERT --") */
  1046.     , HLF_N        /* line number for ":number" and ":#" commands */
  1047.     , HLF_R        /* return to continue message and yes/no questions */
  1048.     , HLF_S        /* status lines */
  1049.     , HLF_SNC        /* status lines of not-current windows */
  1050.     , HLF_C        /* column to separate vertically split windows */
  1051.     , HLF_T        /* Titles for output from ":set all", ":autocmd" etc. */
  1052.     , HLF_V        /* Visual mode */
  1053.     , HLF_VNC        /* Visual mode, autoselecting and not clipboard owner */
  1054.     , HLF_W        /* warning messages */
  1055.     , HLF_WM        /* Wildmenu highlight */
  1056.     , HLF_FL        /* Folded line */
  1057.     , HLF_FC        /* Fold column */
  1058.     , HLF_ADD        /* Added diff line */
  1059.     , HLF_CHD        /* Changed diff line */
  1060.     , HLF_DED        /* Deleted diff line */
  1061.     , HLF_TXD        /* Text Changed in diff line */
  1062.     , HLF_COUNT        /* MUST be the last one */
  1063. };
  1064.  
  1065. /* the HL_FLAGS must be in the same order as the HLF_ enums! */
  1066. #define HL_FLAGS {'8', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \
  1067.           'n', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
  1068.           'f', 'F', 'A', 'C', 'D', 'T'}
  1069.  
  1070. /*
  1071.  * Boolean constants
  1072.  */
  1073. #ifndef TRUE
  1074. # define FALSE    0        /* note: this is an int, not a long! */
  1075. # define TRUE    1
  1076. #endif
  1077.  
  1078. #define MAYBE    2        /* sometimes used for a variant on TRUE */
  1079.  
  1080. /* May be returned by add_new_completion(): */
  1081. #define RET_ERROR        (-1)
  1082.  
  1083. /*
  1084.  * Operator IDs; The order must correspond to opchars[] in ops.c!
  1085.  */
  1086. #define OP_NOP        0    /* no pending operation */
  1087. #define OP_DELETE    1    /* "d"  delete operator */
  1088. #define OP_YANK        2    /* "y"  yank operator */
  1089. #define OP_CHANGE    3    /* "c"  change operator */
  1090. #define OP_LSHIFT    4    /* "<"  left shift operator */
  1091. #define OP_RSHIFT    5    /* ">"  right shift operator */
  1092. #define OP_FILTER    6    /* "!"  filter operator */
  1093. #define OP_TILDE    7    /* "g~" switch case operator */
  1094. #define OP_INDENT    8    /* "="  indent operator */
  1095. #define OP_FORMAT    9    /* "gq" format operator */
  1096. #define OP_COLON    10    /* ":"  colon operator */
  1097. #define OP_UPPER    11    /* "gU" make upper case operator */
  1098. #define OP_LOWER    12    /* "gu" make lower case operator */
  1099. #define OP_JOIN        13    /* "J"  join operator, only for Visual mode */
  1100. #define OP_JOIN_NS    14    /* "gJ"  join operator, only for Visual mode */
  1101. #define OP_ROT13    15    /* "g?" rot-13 encoding */
  1102. #define OP_REPLACE    16    /* "r"  replace chars, only for Visual mode */
  1103. #define OP_INSERT    17    /* "I"  Insert column, only for Visual mode */
  1104. #define OP_APPEND    18    /* "A"  Append column, only for Visual mode */
  1105. #define OP_FOLD        19    /* "zf" define a fold */
  1106. #define OP_FOLDOPEN    20    /* "zo" open folds */
  1107. #define OP_FOLDOPENREC    21    /* "zO" open folds recursively */
  1108. #define OP_FOLDCLOSE    22    /* "zc" close folds */
  1109. #define OP_FOLDCLOSEREC    23    /* "zC" close folds recursively */
  1110. #define OP_FOLDDEL    24    /* "zd" delete folds */
  1111. #define OP_FOLDDELREC    25    /* "zD" delete folds recursively */
  1112.  
  1113. /*
  1114.  * Motion types, used for operators and for yank/delete registers.
  1115.  */
  1116. #define MCHAR    0        /* character-wise movement/register */
  1117. #define MLINE    1        /* line-wise movement/register */
  1118. #define MBLOCK    2        /* block-wise register */
  1119.  
  1120. #define MAUTO    0xff        /* Decide between MLINE/MCHAR */
  1121.  
  1122. /*
  1123.  * Minimum screen size
  1124.  */
  1125. #define MIN_COLUMNS    12    /* minimal columns for screen */
  1126. #define MIN_LINES    2    /* minimal lines for screen */
  1127. #define STATUS_HEIGHT    1    /* height of a status line under a window */
  1128. #define QF_WINHEIGHT    10    /* default height for quickfix window */
  1129.  
  1130. /*
  1131.  * Buffer sizes
  1132.  */
  1133. #ifndef CMDBUFFSIZE
  1134. # define CMDBUFFSIZE    256    /* size of the command processing buffer */
  1135. #endif
  1136.  
  1137. #define LSIZE        512        /* max. size of a line in the tags file */
  1138.  
  1139. #define IOSIZE       (1024+1)    /* file i/o and sprintf buffer size */
  1140. #define MSG_BUF_LEN 80        /* length of buffer for small messages */
  1141.  
  1142. #if defined(AMIGA) || defined(__linux__) || defined(__QNX__) || defined(__CYGWIN32__) || defined(_AIX)
  1143. # define TBUFSZ 2048        /* buffer size for termcap entry */
  1144. #else
  1145. # define TBUFSZ 1024        /* buffer size for termcap entry */
  1146. #endif
  1147.  
  1148. /*
  1149.  * Maximum length of key sequence to be mapped.
  1150.  * Must be able to hold an Amiga resize report.
  1151.  */
  1152. #define MAXMAPLEN   50
  1153.  
  1154. #ifdef BINARY_FILE_IO
  1155. # define WRITEBIN   "wb"    /* no CR-LF translation */
  1156. # define READBIN    "rb"
  1157. # define APPENDBIN  "ab"
  1158. #else
  1159. # define WRITEBIN   "w"
  1160. # define READBIN    "r"
  1161. # define APPENDBIN  "a"
  1162. #endif
  1163.  
  1164. /*
  1165.  * EMX doesn't have a global way of making open() use binary I/O.
  1166.  * Use O_BINARY for all open() calls.
  1167.  */
  1168. #if defined(__EMX__) || defined(__CYGWIN32__)
  1169. # define O_EXTRA    O_BINARY
  1170. #else
  1171. # define O_EXTRA    0
  1172. #endif
  1173.  
  1174. #ifndef W_OK
  1175. # define W_OK 2        /* for systems that don't have W_OK in unistd.h */
  1176. #endif
  1177. #ifndef R_OK
  1178. # define R_OK 4        /* for systems that don't have R_OK in unistd.h */
  1179. #endif
  1180.  
  1181. /*
  1182.  * defines to avoid typecasts from (char_u *) to (char *) and back
  1183.  * (vim_strchr() and vim_strrchr() are now in alloc.c)
  1184.  */
  1185. #define STRLEN(s)        strlen((char *)(s))
  1186. #define STRCPY(d, s)        strcpy((char *)(d), (char *)(s))
  1187. #define STRNCPY(d, s, n)    strncpy((char *)(d), (char *)(s), (size_t)(n))
  1188. #define STRCMP(d, s)        strcmp((char *)(d), (char *)(s))
  1189. #define STRNCMP(d, s, n)    strncmp((char *)(d), (char *)(s), (size_t)(n))
  1190. #ifdef HAVE_STRCASECMP
  1191. # define STRICMP(d, s)        strcasecmp((char *)(d), (char *)(s))
  1192. #else
  1193. # ifdef HAVE_STRICMP
  1194. #  define STRICMP(d, s)        stricmp((char *)(d), (char *)(s))
  1195. # else
  1196. #  define STRICMP(d, s)        vim_stricmp((char *)(d), (char *)(s))
  1197. # endif
  1198. #endif
  1199.  
  1200. #ifdef HAVE_STRNCASECMP
  1201. # define STRNICMP(d, s, n)  strncasecmp((char *)(d), (char *)(s), (size_t)(n))
  1202. #else
  1203. # ifdef HAVE_STRNICMP
  1204. #  define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n))
  1205. # else
  1206. #  define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
  1207. # endif
  1208. #endif
  1209.  
  1210. #ifdef FEAT_MBYTE
  1211. # define MB_STRICMP(d, s)    (has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL) : STRICMP((d), (s)))
  1212. # define MB_STRNICMP(d, s, n)    (has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n)) : STRNICMP((d), (s), (n)))
  1213. #else
  1214. # define MB_STRICMP(d, s)    STRICMP((d), (s))
  1215. # define MB_STRNICMP(d, s, n)    STRNICMP((d), (s), (n))
  1216. # define transchar_byte(c)    transchar(c)
  1217. #endif
  1218.  
  1219. #define STRCAT(d, s)        strcat((char *)(d), (char *)(s))
  1220. #define STRNCAT(d, s, n)    strncat((char *)(d), (char *)(s), (size_t)(n))
  1221.  
  1222. #ifdef HAVE_STRPBRK
  1223. # define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
  1224. #endif
  1225.  
  1226. #define MSG(s)                msg((char_u *)(s))
  1227. #define MSG_ATTR(s, attr)        msg_attr((char_u *)(s), (attr))
  1228. #define EMSG(s)                emsg((char_u *)(s))
  1229. #define EMSG2(s, p)            emsg2((char_u *)(s), (char_u *)(p))
  1230. #define EMSGN(s, n)            emsgn((char_u *)(s), (long)(n))
  1231. #define OUT_STR(s)            out_str((char_u *)(s))
  1232. #define OUT_STR_NF(s)            out_str_nf((char_u *)(s))
  1233. #define MSG_PUTS(s)            msg_puts((char_u *)(s))
  1234. #define MSG_PUTS_ATTR(s, a)        msg_puts_attr((char_u *)(s), (a))
  1235. #define MSG_PUTS_TITLE(s)        msg_puts_title((char_u *)(s))
  1236. #define MSG_PUTS_LONG(s)        msg_puts_long((char_u *)(s))
  1237. #define MSG_PUTS_LONG_ATTR(s, a)    msg_puts_long_attr((char_u *)(s), (a))
  1238.  
  1239. typedef long        linenr_T;        /* line number type */
  1240. typedef unsigned    colnr_T;        /* column number type */
  1241. typedef unsigned short disptick_T;    /* display tick type */
  1242.  
  1243. #define MAXLNUM (0x7fffffffL)        /* maximum (invalid) line number */
  1244.  
  1245. /*
  1246.  * Well, you won't believe it, but some S/390 machines ("host", now also known
  1247.  * as zServer) us 31 bit pointers. There are also some newer machines, that
  1248.  * use 64 bit pointers. I don't know how to distinguish between 31 and 64 bit
  1249.  * machines, so the best way is to assume 31 bits whenever we detect OS/390
  1250.  * Unix.
  1251.  * With this we restrict the maximum line length to 1073741823. I guess this is
  1252.  * not a real problem. BTW:  Longer lines are split.
  1253.  */
  1254. #if SIZEOF_INT >= 4
  1255. # ifdef __MVS__
  1256. #  define MAXCOL (0x3fffffffL)        /* maximum column number, 30 bits */
  1257. # else
  1258. #  define MAXCOL (0x7fffffffL)        /* maximum column number, 31 bits */
  1259. # endif
  1260. #else
  1261. # define MAXCOL    (0x7fff)        /* maximum column number, 15 bits */
  1262. #endif
  1263.  
  1264. #define SHOWCMD_COLS 10            /* columns needed by shown command */
  1265. #define STL_MAX_ITEM 50            /* max count of %<flag> in statusline*/
  1266.  
  1267. typedef void        *vim_acl_T;        /* dummy to pass an ACL to a function */
  1268.  
  1269. /*
  1270.  * Include a prototype for mch_memmove(), it may not be in alloc.pro.
  1271.  */
  1272. #ifdef VIM_MEMMOVE
  1273. void mch_memmove __ARGS((void *, void *, size_t));
  1274. #else
  1275. # ifndef mch_memmove
  1276. #  define mch_memmove(to, from, len) memmove(to, from, len)
  1277. # endif
  1278. #endif
  1279.  
  1280. /*
  1281.  * fnamecmp() is used to compare file names.
  1282.  * On some systems case in a file name does not matter, on others it does.
  1283.  * (this does not account for maximum name lengths and things like "../dir",
  1284.  * thus it is not 100% accurate!)
  1285.  */
  1286. #ifdef CASE_INSENSITIVE_FILENAME
  1287. # ifdef BACKSLASH_IN_FILENAME
  1288. #  define fnamecmp(x, y) vim_fnamecmp((x), (y))
  1289. #  define fnamencmp(x, y, n) vim_fnamencmp((x), (y), (size_t)(n))
  1290. # else
  1291. #  define fnamecmp(x, y) MB_STRICMP((x), (y))
  1292. #  define fnamencmp(x, y, n) MB_STRNICMP((x), (y), (n))
  1293. # endif
  1294. #else
  1295. # define fnamecmp(x, y) strcmp((char *)(x), (char *)(y))
  1296. # define fnamencmp(x, y, n) strncmp((char *)(x), (char *)(y), (size_t)(n))
  1297. #endif
  1298.  
  1299. #ifdef HAVE_MEMSET
  1300. # define vim_memset(ptr, c, size)   memset((ptr), (c), (size))
  1301. #else
  1302. void *vim_memset __ARGS((void *, int, size_t));
  1303. #endif
  1304.  
  1305. #ifdef HAVE_MEMCMP
  1306. # define vim_memcmp(p1, p2, len)   memcmp((p1), (p2), (len))
  1307. #else
  1308. # ifdef HAVE_BCMP
  1309. #  define vim_memcmp(p1, p2, len)   bcmp((p1), (p2), (len))
  1310. # else
  1311. int vim_memcmp __ARGS((void *, void *, size_t));
  1312. #  define VIM_MEMCMP
  1313. # endif
  1314. #endif
  1315.  
  1316. #if defined(UNIX) || defined(FEAT_GUI) || defined(OS2) || defined(VMS) \
  1317.     || defined(FEAT_CLIENTSERVER)
  1318. # define USE_INPUT_BUF
  1319. #endif
  1320.  
  1321. #ifdef MSWIN
  1322. /* On MS-Windows the third argument isn't size_t.  This matters for Win64,
  1323.  * where sizeof(size_t)==8, not 4 */
  1324. # define vim_read(fd, buf, count)   read((fd), (char *)(buf), (unsigned int)(count))
  1325. # define vim_write(fd, buf, count)  write((fd), (char *)(buf), (unsigned int)(count))
  1326. #else
  1327. # define vim_read(fd, buf, count)   read((fd), (char *)(buf), (size_t) (count))
  1328. # define vim_write(fd, buf, count)  write((fd), (char *)(buf), (size_t) (count))
  1329. #endif
  1330.  
  1331. /*
  1332.  * Enums need a typecast to be used as array index (for Ultrix).
  1333.  */
  1334. #define hl_attr(n)    highlight_attr[(int)(n)]
  1335. #define term_str(n)    term_strings[(int)(n)]
  1336.  
  1337. /*
  1338.  * vim_iswhite() is used for "^" and the like. It differs from isspace()
  1339.  * because it doesn't include <CR> and <LF> and the like.
  1340.  */
  1341. #define vim_iswhite(x)    ((x) == ' ' || (x) == '\t')
  1342.  
  1343. /* Note that gui.h is included by structs.h */
  1344.  
  1345. #include "structs.h"        /* file that defines many structures */
  1346.  
  1347. #ifdef FEAT_MOUSE
  1348.  
  1349. /* Codes for mouse button events in lower three bits: */
  1350. # define MOUSE_LEFT    0x00
  1351. # define MOUSE_MIDDLE    0x01
  1352. # define MOUSE_RIGHT    0x02
  1353. # define MOUSE_RELEASE    0x03
  1354.  
  1355. /* bit masks for modifiers: */
  1356. # define MOUSE_SHIFT    0x04
  1357. # define MOUSE_ALT    0x08
  1358. # define MOUSE_CTRL    0x10
  1359.  
  1360. /* mouse buttons that are handled like a key press (GUI only) */
  1361. # define MOUSE_4    0x100    /* scroll wheel down */
  1362. # define MOUSE_5    0x200    /* scroll wheel up */
  1363.  
  1364. # define MOUSE_X1    0x300 /* Mouse-button X1 (6th) */
  1365. # define MOUSE_X2    0x400 /* Mouse-button X2 */
  1366.  
  1367. /* 0x20 is reserved by xterm */
  1368. # define MOUSE_DRAG_XTERM   0x40
  1369.  
  1370. # define MOUSE_DRAG    (0x40 | MOUSE_RELEASE)
  1371.  
  1372. /* Lowest button code for using the mouse wheel (xterm only) */
  1373. # define MOUSEWHEEL_LOW        0x60
  1374.  
  1375. # define MOUSE_CLICK_MASK    0x03
  1376.  
  1377. # define NUM_MOUSE_CLICKS(code) \
  1378.     (((unsigned)((code) & 0xC0) >> 6) + 1)
  1379.  
  1380. # define SET_NUM_MOUSE_CLICKS(code, num) \
  1381.     (code) = ((code) & 0x3f) | ((((num) - 1) & 3) << 6)
  1382.  
  1383. /*
  1384.  * jump_to_mouse() returns one of first four these values, possibly with
  1385.  * some of the other three added.
  1386.  */
  1387. # define IN_UNKNOWN        0
  1388. # define IN_BUFFER        1
  1389. # define IN_STATUS_LINE        2    /* on status or command line */
  1390. # define IN_SEP_LINE        4    /* on vertical separator line */
  1391. # define IN_OTHER_WIN        8    /* in other window but can't go there */
  1392. # define CURSOR_MOVED        0x100
  1393. # define MOUSE_FOLD_CLOSE    0x200    /* clicked on '-' in fold column */
  1394. # define MOUSE_FOLD_OPEN    0x400    /* clicked on '+' in fold column */
  1395.  
  1396. /* flags for jump_to_mouse() */
  1397. # define MOUSE_FOCUS        0x01    /* need to stay in this window */
  1398. # define MOUSE_MAY_VIS        0x02    /* may start Visual mode */
  1399. # define MOUSE_DID_MOVE        0x04    /* only act when mouse has moved */
  1400. # define MOUSE_SETPOS        0x08    /* only set current mouse position */
  1401. # define MOUSE_MAY_STOP_VIS    0x10    /* may stop Visual mode */
  1402. # define MOUSE_RELEASED        0x20    /* button was released */
  1403.  
  1404. # if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
  1405. #  define CHECK_DOUBLE_CLICK 1    /* Checking for double clicks ourselves. */
  1406. # endif
  1407.  
  1408. #endif /* FEAT_MOUSE */
  1409.  
  1410. /* defines for eval_vars() */
  1411. #define VALID_PATH        1
  1412. #define VALID_HEAD        2
  1413.  
  1414. /* Defines for Vim variables.  These must match vimvars[] in eval.c! */
  1415. #define VV_COUNT    0
  1416. #define VV_COUNT1    1
  1417. #define VV_PREVCOUNT    2
  1418. #define VV_ERRMSG    3
  1419. #define VV_WARNINGMSG    4
  1420. #define VV_STATUSMSG    5
  1421. #define VV_SHELL_ERROR    6
  1422. #define VV_THIS_SESSION    7
  1423. #define VV_VERSION    8
  1424. #define VV_LNUM        9
  1425. #define VV_TERMRESPONSE    10
  1426. #define VV_FNAME    11
  1427. #define VV_LANG        12
  1428. #define VV_LC_TIME    13
  1429. #define VV_CTYPE    14
  1430. #define VV_CC_FROM    15
  1431. #define VV_CC_TO    16
  1432. #define VV_FNAME_IN    17
  1433. #define VV_FNAME_OUT    18
  1434. #define VV_FNAME_NEW    19
  1435. #define VV_FNAME_DIFF    20
  1436. #define VV_CMDARG    21
  1437. #define VV_FOLDSTART    22
  1438. #define VV_FOLDEND    23
  1439. #define VV_FOLDDASHES    24
  1440. #define VV_FOLDLEVEL    25
  1441. #define VV_PROGNAME    26
  1442. #define VV_SEND_SERVER    27
  1443. #define VV_DYING    28
  1444. #define VV_EXCEPTION    29
  1445. #define VV_THROWPOINT    30
  1446. #define VV_REG        31
  1447. #define VV_LEN        32    /* number of v: vars */
  1448.  
  1449. #ifdef FEAT_CLIPBOARD
  1450.  
  1451. /* Vim-specific selection type for X11 */
  1452. #define VIM_ATOM_NAME "_VIM_TEXT"
  1453.  
  1454. /* Selection states for modeless selection */
  1455. # define SELECT_CLEARED        0
  1456. # define SELECT_IN_PROGRESS    1
  1457. # define SELECT_DONE        2
  1458.  
  1459. # define SELECT_MODE_CHAR    0
  1460. # define SELECT_MODE_WORD    1
  1461. # define SELECT_MODE_LINE    2
  1462.  
  1463. # ifdef FEAT_GUI_W32
  1464. #  ifdef FEAT_OLE
  1465. #   define WM_OLE (WM_APP+0)
  1466. #  endif
  1467. # endif
  1468.  
  1469. /* Info about selected text */
  1470. typedef struct VimClipboard
  1471. {
  1472.     int        available;    /* Is clipboard available? */
  1473.     int        owned;        /* Flag: do we own the selection? */
  1474.     pos_T    start;        /* Start of selected area */
  1475.     pos_T    end;        /* End of selected area */
  1476.     int        vmode;        /* Visual mode character */
  1477.  
  1478.     /* Fields for selection that doesn't use Visual mode */
  1479.     short_u    origin_row;
  1480.     short_u    origin_start_col;
  1481.     short_u    origin_end_col;
  1482.     short_u    word_start_col;
  1483.     short_u    word_end_col;
  1484.  
  1485.     pos_T    prev;        /* Previous position */
  1486.     short_u    state;        /* Current selection state */
  1487.     short_u    mode;        /* Select by char, word, or line. */
  1488.  
  1489. # if defined(FEAT_GUI_X11) || defined(FEAT_XCLIPBOARD)
  1490.     Atom    sel_atom;    /* PRIMARY/CLIPBOARD selection ID */
  1491. # endif
  1492.  
  1493. # ifdef FEAT_GUI_GTK
  1494.     GdkAtom     gtk_sel_atom;    /* PRIMARY/CLIPBOARD selection ID */
  1495. # endif
  1496.  
  1497. # ifdef MSWIN
  1498.     int_u    format;        /* Vim's own special clipboard format */
  1499. # endif
  1500. # ifdef FEAT_GUI_BEOS
  1501.                 /* no clipboard at the moment */
  1502. # endif
  1503. } VimClipboard;
  1504. #else
  1505. typedef int VimClipboard;    /* This is required for the prototypes. */
  1506. #endif
  1507.  
  1508. #ifdef __BORLANDC__
  1509. /* work around a bug in the Borland 'stat' function: */
  1510. # include <io.h>        /* for access() */
  1511.  
  1512. # define stat(a,b) (access(a,0) ? -1 : stat(a,b))
  1513. #endif
  1514.  
  1515. /*
  1516.  * EXTERN is only defined in main.c.  That's where global variables are
  1517.  * actually defined and initialized.
  1518.  */
  1519. #ifndef EXTERN
  1520. # define EXTERN extern
  1521. # define INIT(x)
  1522. #else
  1523. # ifndef INIT
  1524. #  define INIT(x) x
  1525. #  define DO_INIT
  1526. # endif
  1527. #endif
  1528.  
  1529. #include "option.h"        /* option variables and defines */
  1530. #include "ex_cmds.h"        /* Ex command defines */
  1531. #include "proto.h"        /* function prototypes */
  1532.  
  1533. /* This has to go after the include of proto.h, as proto/gui.pro declares
  1534.  * functions of these names. The declarations would break if the defines had
  1535.  * been seen at that stage.  But it must be before globals.h, where error_ga
  1536.  * is declared. */
  1537. #if !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_X11) \
  1538.     && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC)
  1539. # define mch_errmsg(str)    fprintf(stderr, "%s", (str))
  1540. # define display_errors()    fflush(stderr)
  1541. # define mch_msg(str)        printf("%s", (str))
  1542. #else
  1543. # define USE_MCH_ERRMSG
  1544. #endif
  1545.  
  1546. #include "globals.h"        /* global variables and messages */
  1547.  
  1548. #ifdef FEAT_SNIFF
  1549. # include "if_sniff.h"
  1550. #endif
  1551.  
  1552. #ifndef FEAT_VIRTUALEDIT
  1553. # define getvvcol(w, p, s, c, e) getvcol(w, p, s, c, e)
  1554. # define virtual_active() 0
  1555. # define virtual_op FALSE
  1556. #endif
  1557.  
  1558. /*
  1559.  * If console dialog not supported, but GUI dialog is, use the GUI one.
  1560.  */
  1561. #if defined(FEAT_GUI_DIALOG) && !defined(FEAT_CON_DIALOG)
  1562. # define do_dialog gui_mch_dialog
  1563. #endif
  1564.  
  1565. /*
  1566.  * Default filters for gui_mch_browse().
  1567.  * The filters are almost system independent.  Except for the difference
  1568.  * between "*" and "*.*" for MSDOS-like systems.
  1569.  * NOTE: Motif only uses the very first pattern.  Therefore
  1570.  * BROWSE_FILTER_DEFAULT should start with a "*" pattern.
  1571.  */
  1572. #ifdef FEAT_BROWSE
  1573. # ifdef BACKSLASH_IN_FILENAME
  1574. #  define BROWSE_FILTER_MACROS \
  1575.     (char_u *)"Vim macro files (*.vim)\t*.vim\nAll Files (*.*)\t*.*\n"
  1576. #  define BROWSE_FILTER_ALL_FILES (char_u *)"All Files (*.*)\t*.*\n"
  1577. #  define BROWSE_FILTER_DEFAULT \
  1578.     (char_u *)"All Files (*.*)\t*.*\nC source (*.c, *.h)\t*.c;*.h\nC++ source (*.cpp, *.hpp)\t*.cpp;*.hpp\nVB code (*.bas, *.frm)\t*.bas;*.frm\nVim files (*.vim, _vimrc, _gvimrc)\t*.vim;_vimrc;_gvimrc\n"
  1579. # else
  1580. #  define BROWSE_FILTER_MACROS \
  1581.     (char_u *)"Vim macro files (*.vim)\t*.vim\nAll Files (*)\t*\n"
  1582. #  define BROWSE_FILTER_ALL_FILES (char_u *)"All Files (*)\t*\n"
  1583. #  define BROWSE_FILTER_DEFAULT \
  1584.     (char_u *)"All Files (*)\t*\nC source (*.c, *.h)\t*.c;*.h\nC++ source (*.cpp, *.hpp)\t*.cpp;*.hpp\nVim files (*.vim, _vimrc, _gvimrc)\t*.vim;_vimrc;_gvimrc\n"
  1585. # endif
  1586. #endif
  1587.  
  1588. /* stop using fastcall for Borland */
  1589. #if defined(__BORLANDC__) && defined(WIN32) && !defined(DEBUG)
  1590. # pragma option -p.
  1591. #endif
  1592.  
  1593. #if defined(MEM_PROFILE)
  1594. # define vim_realloc(ptr, size)  mem_realloc((ptr), (size))
  1595. #else
  1596. # define vim_realloc(ptr, size)  realloc((ptr), (size))
  1597. #endif
  1598.  
  1599. /*
  1600.  * The following macros stop displat/event loop nesting at the wrong time.
  1601.  */
  1602. #ifdef ALT_X_INPUT
  1603. # define ALT_INPUT_LOCK_OFF    suppress_alternate_input = FALSE
  1604. # define ALT_INPUT_LOCK_ON    suppress_alternate_input = TRUE
  1605. #endif
  1606.  
  1607. #ifdef FEAT_MBYTE
  1608. /* Maximum number of bytes in a multi-byte character.  It can be one 32-bit
  1609.  * character of up to 6 bytes, or one 16-bit character of up to three bytes
  1610.  * plus two following composing characters of three bytes each. */
  1611. # define MB_MAXBYTES    9
  1612.  
  1613. /*
  1614.  * Return byte length of character that starts with byte "b".
  1615.  * Returns 1 for a single-byte character.
  1616.  * MB_BYTE2LEN_CHECK() can be used to count a special key as one byte.
  1617.  * Don't call MB_BYTE2LEN(b) with b < 0 or b > 255!
  1618.  */
  1619. # define MB_BYTE2LEN(b)        mb_bytelen_tab[b]
  1620. # define MB_BYTE2LEN_CHECK(b)    (((b) < 0 || (b) > 255) ? 1 : mb_bytelen_tab[b])
  1621. #endif
  1622.  
  1623. #if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
  1624. /* properties used in enc_canon_table[] (first three mutually exclusive) */
  1625. # define ENC_8BIT    0x01
  1626. # define ENC_DBCS    0x02
  1627. # define ENC_UNICODE    0x04
  1628.  
  1629. # define ENC_ENDIAN_B    0x10        /* Unicode: Big endian */
  1630. # define ENC_ENDIAN_L    0x20        /* Unicode: Little endian */
  1631.  
  1632. # define ENC_2BYTE    0x40        /* Unicode: UCS-2 */
  1633. # define ENC_4BYTE    0x80        /* Unicode: UCS-4 */
  1634. # define ENC_2WORD    0x100        /* Unicode: UTF-16 */
  1635.  
  1636. # define ENC_LATIN1    0x200        /* Latin1 */
  1637. #endif
  1638.  
  1639. #ifdef FEAT_MBYTE
  1640. # ifdef USE_ICONV
  1641. #  ifndef EILSEQ
  1642. #   define EILSEQ 123
  1643. #  endif
  1644. #  ifdef DYNAMIC_ICONV
  1645. /* On Win32 iconv.dll is dynamically loaded. */
  1646. #   define ICONV_ERRNO (*iconv_errno())
  1647. #   define ICONV_E2BIG  7
  1648. #   define ICONV_EINVAL 22
  1649. #   define ICONV_EILSEQ 42
  1650. #  else
  1651. #   define ICONV_ERRNO errno
  1652. #   define ICONV_E2BIG  E2BIG
  1653. #   define ICONV_EINVAL EINVAL
  1654. #   define ICONV_EILSEQ EILSEQ
  1655. #  endif
  1656. # endif
  1657.  
  1658. #endif
  1659.  
  1660. /* ISSYMLINK(mode) tests if a file is a symbolic link. */
  1661. #if (defined(S_IFMT) && defined(S_IFLNK)) || defined(S_ISLNK)
  1662. # define HAVE_ISSYMLINK
  1663. # if defined(S_IFMT) && defined(S_IFLNK)
  1664. #  define ISSYMLINK(mode) (((mode) & S_IFMT) == S_IFLNK)
  1665. # else
  1666. #  define ISSYMLINK(mode) S_ISLNK(mode)
  1667. # endif
  1668. #endif
  1669.  
  1670. #define SIGN_BYTE 1        /* byte value used where sign is displayed;
  1671.                    attribute value is sign type */
  1672.  
  1673. #ifdef FEAT_NETBEANS_INTG
  1674. # define MULTISIGN_BYTE 2   /* byte value used where sign is displayed if
  1675.                    multiple signs exist on the line */
  1676. #endif
  1677.  
  1678. #if defined(FEAT_GUI) && defined(FEAT_XCLIPBOARD)
  1679. # ifdef FEAT_GUI_GTK
  1680.    /* Avoid using a global variable for the X display.  It's ugly
  1681.     * and is likely to cause trouble in multihead environments. */
  1682. #  define X_DISPLAY    ((gui.in_use) ? gui_mch_get_display() : xterm_dpy)
  1683. # else
  1684. #  define X_DISPLAY    (gui.in_use ? gui.dpy : xterm_dpy)
  1685. # endif
  1686. #else
  1687. # ifdef FEAT_GUI
  1688. #  ifdef FEAT_GUI_GTK
  1689. #   define X_DISPLAY    ((gui.in_use) ? gui_mch_get_display() : (Display *)NULL)
  1690. #  else
  1691. #   define X_DISPLAY    gui.dpy
  1692. #  endif
  1693. # else
  1694. #  define X_DISPLAY    xterm_dpy
  1695. # endif
  1696. #endif
  1697.  
  1698. #ifdef NBDEBUG /* Netbeans debugging. */
  1699. # include "nbdebug.h"
  1700. #else
  1701. # define nbdebug(a)
  1702. #endif
  1703.  
  1704. #endif /* VIM__H */
  1705.