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 / structs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-05-26  |  57.6 KB  |  1,844 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. /*
  10.  * This file contains various definitions of structures that are used by Vim
  11.  */
  12.  
  13. /*
  14.  * There is something wrong in the SAS compiler that makes typedefs not
  15.  * valid in include files.  Has been fixed in version 6.58.
  16.  */
  17. #if defined(SASC) && SASC < 658
  18. typedef long        linenr_T;
  19. typedef unsigned    colnr_T;
  20. typedef unsigned short    short_u;
  21. #endif
  22.  
  23. /*
  24.  * position in file or buffer
  25.  */
  26. typedef struct
  27. {
  28.     linenr_T    lnum;    /* line number */
  29.     colnr_T    col;    /* column number */
  30. #ifdef FEAT_VIRTUALEDIT
  31.     colnr_T    coladd;
  32. #endif
  33. } pos_T;
  34.  
  35. /*
  36.  * Same, but without coladd.
  37.  */
  38. typedef struct
  39. {
  40.     linenr_T    lnum;    /* line number */
  41.     colnr_T    col;    /* column number */
  42. } lpos_T;
  43.  
  44. /*
  45.  * Structure used for growing arrays.
  46.  * This is used to store information that only grows, is deleted all at
  47.  * once, and needs to be accessed by index.  See ga_clear() and ga_grow().
  48.  */
  49. typedef struct growarray
  50. {
  51.     int        ga_len;            /* current number of items used */
  52.     int        ga_room;            /* number of unused items at the end */
  53.     int        ga_itemsize;        /* sizeof one item */
  54.     int        ga_growsize;        /* number of items to grow each time */
  55.     void    *ga_data;            /* pointer to the first item */
  56. } garray_T;
  57.  
  58. /*
  59.  * This is here because regexp.h needs pos_T and below regprog_T is used.
  60.  */
  61. #include "regexp.h"
  62.  
  63. typedef struct window    win_T;
  64. typedef struct wininfo    wininfo_T;
  65. typedef struct frame    frame_T;
  66. typedef int        scid_T;        /* script ID */
  67.  
  68. /*
  69.  * This is here because gui.h needs the pos_T and win_T, and win_T needs gui.h
  70.  * for scrollbar_T.
  71.  */
  72. #ifdef FEAT_GUI
  73. # include "gui.h"
  74. #else
  75. # ifdef FEAT_XCLIPBOARD
  76. #  include <X11/Intrinsic.h>
  77. # endif
  78. # define guicolor_T int        /* avoid error in prototypes */
  79. #endif
  80.  
  81. /*
  82.  * marks: positions in a file
  83.  * (a normal mark is a lnum/col pair, the same as a file position)
  84.  */
  85.  
  86. /* (Note: for EBCDIC there are more than 26, because there are gaps in the
  87.  * alphabet coding.  To minimize changes to the code, I decided to just
  88.  * increase the number of possible marks. */
  89. #define NMARKS        ('z' - 'a' + 1)    /* max. # of named marks */
  90. #define JUMPLISTSIZE    100        /* max. # of marks in jump list */
  91. #define TAGSTACKSIZE    20        /* max. # of tags in tag stack */
  92.  
  93. typedef struct filemark
  94. {
  95.     pos_T    mark;        /* cursor position */
  96.     int        fnum;        /* file number */
  97. } fmark_T;
  98.  
  99. /* Xtended file mark: also has a file name */
  100. typedef struct xfilemark
  101. {
  102.     fmark_T    fmark;
  103.     char_u    *fname;        /* file name, used when fnum == 0 */
  104. } xfmark_T;
  105.  
  106. /*
  107.  * The taggy struct is used to store the information about a :tag command.
  108.  */
  109. typedef struct taggy
  110. {
  111.     char_u    *tagname;    /* tag name */
  112.     fmark_T    fmark;        /* cursor position BEFORE ":tag" */
  113.     int        cur_match;    /* match number */
  114. } taggy_T;
  115.  
  116. /*
  117.  * Structure that contains all options that are local to a window.
  118.  * Used twice in a window: for the current buffer and for all buffers.
  119.  * Also used in wininfo_T.
  120.  */
  121. typedef struct
  122. {
  123. #ifdef FEAT_ARABIC
  124.     int        wo_arab;
  125. # define w_p_arab w_onebuf_opt.wo_arab    /* 'arabic' */
  126. #endif
  127. #ifdef FEAT_DIFF
  128.     int        wo_diff;
  129. # define w_p_diff w_onebuf_opt.wo_diff    /* 'diff' */
  130. #endif
  131. #ifdef FEAT_FOLDING
  132.     long    wo_fdc;
  133. # define w_p_fdc w_onebuf_opt.wo_fdc    /* 'foldcolumn' */
  134.     int        wo_fen;
  135. # define w_p_fen w_onebuf_opt.wo_fen    /* 'foldenable' */
  136.     char_u    *wo_fdi;
  137. # define w_p_fdi w_onebuf_opt.wo_fdi    /* 'foldignore' */
  138.     long    wo_fdl;
  139. # define w_p_fdl w_onebuf_opt.wo_fdl    /* 'foldlevel' */
  140.     char_u    *wo_fdm;
  141. # define w_p_fdm w_onebuf_opt.wo_fdm    /* 'foldmethod' */
  142.     long    wo_fml;
  143. # define w_p_fml w_onebuf_opt.wo_fml    /* 'foldminlines' */
  144.     long    wo_fdn;
  145. # define w_p_fdn w_onebuf_opt.wo_fdn    /* 'foldnextmax' */
  146. # ifdef FEAT_EVAL
  147.     char_u    *wo_fde;
  148. # define w_p_fde w_onebuf_opt.wo_fde    /* 'foldexpr' */
  149.     char_u    *wo_fdt;
  150. #  define w_p_fdt w_onebuf_opt.wo_fdt    /* 'foldtext' */
  151. # endif
  152.     char_u    *wo_fmr;
  153. # define w_p_fmr w_onebuf_opt.wo_fmr    /* 'foldmarker' */
  154. #endif
  155. #ifdef FEAT_LINEBREAK
  156.     int        wo_lbr;
  157. # define w_p_lbr w_onebuf_opt.wo_lbr    /* 'linebreak' */
  158. #endif
  159.     int        wo_list;
  160. #define w_p_list w_onebuf_opt.wo_list    /* 'list' */
  161.     int        wo_nu;
  162. #define w_p_nu w_onebuf_opt.wo_nu    /* 'number' */
  163. #if defined(FEAT_WINDOWS)
  164.     int        wo_wfh;
  165. # define w_p_wfh w_onebuf_opt.wo_wfh    /* 'winfixheight' */
  166. #endif
  167. #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
  168.     int        wo_pvw;
  169. # define w_p_pvw w_onebuf_opt.wo_pvw    /* 'previewwindow' */
  170. #endif
  171. #ifdef FEAT_RIGHTLEFT
  172.     int        wo_rl;
  173. # define w_p_rl w_onebuf_opt.wo_rl    /* 'rightleft' */
  174.     char_u    *wo_rlc;
  175. # define w_p_rlc w_onebuf_opt.wo_rlc    /* 'rightleftcmd' */
  176. #endif
  177.     long    wo_scr;
  178. #define w_p_scr w_onebuf_opt.wo_scr    /* 'scroll' */
  179. #ifdef FEAT_SCROLLBIND
  180.     int        wo_scb;
  181. # define w_p_scb w_onebuf_opt.wo_scb    /* 'scrollbind' */
  182. #endif
  183.     int        wo_wrap;
  184. #define w_p_wrap w_onebuf_opt.wo_wrap    /* 'wrap' */
  185. } winopt_T;
  186.  
  187. /*
  188.  * Window info stored with a buffer.
  189.  *
  190.  * Two types of info are kept for a buffer which are associated with a
  191.  * specific window:
  192.  * 1. Each window can have a different line number associated with a buffer.
  193.  * 2. The window-local options for a buffer work in a similar way.
  194.  * The window-info is kept in a list at b_wininfo.  It is kept in
  195.  * most-recently-used order.
  196.  */
  197. struct wininfo
  198. {
  199.     wininfo_T    *wi_next;    /* next entry or NULL for last entry */
  200.     wininfo_T    *wi_prev;    /* previous entry or NULL for first entry */
  201.     win_T    *wi_win;    /* pointer to window that did set wi_lnum */
  202.     pos_T    wi_fpos;    /* last cursor position in the file */
  203.     int        wi_optset;    /* TRUE when wi_opt has useful values */
  204.     winopt_T    wi_opt;        /* local window options */
  205. #ifdef FEAT_FOLDING
  206.     int        wi_fold_manual;    /* copy of w_fold_manual */
  207.     garray_T    wi_folds;    /* clone of w_folds */
  208. #endif
  209. };
  210.  
  211. /*
  212.  * Info used to pass info about a fold from the fold-detection code to the
  213.  * code that displays the foldcolumn.
  214.  */
  215. typedef struct foldinfo
  216. {
  217.     int        fi_level;    /* level of the fold; when this is zero the
  218.                    other fields are invalid */
  219.     int        fi_lnum;    /* line number where fold starts */
  220.     int        fi_low_level;    /* lowest fold level that starts in the same
  221.                    line */
  222. } foldinfo_T;
  223.  
  224. /*
  225.  * stuctures used for undo
  226.  */
  227.  
  228. typedef struct u_entry u_entry_T;
  229. typedef struct u_header u_header_T;
  230. struct u_entry
  231. {
  232.     u_entry_T    *ue_next;    /* pointer to next entry in list */
  233.     linenr_T    ue_top;        /* number of line above undo block */
  234.     linenr_T    ue_bot;        /* number of line below undo block */
  235.     linenr_T    ue_lcount;    /* linecount when u_save called */
  236.     char_u    **ue_array;    /* array of lines in undo block */
  237.     long    ue_size;    /* number of lines in ue_array */
  238. };
  239.  
  240. struct u_header
  241. {
  242.     u_header_T    *uh_next;    /* pointer to next header in list */
  243.     u_header_T    *uh_prev;    /* pointer to previous header in list */
  244.     u_entry_T    *uh_entry;    /* pointer to first entry */
  245.     u_entry_T    *uh_getbot_entry; /* pointer to where ue_bot must be set */
  246.     pos_T    uh_cursor;    /* cursor position before saving */
  247. #ifdef FEAT_VIRTUALEDIT
  248.     long    uh_cursor_vcol;
  249. #endif
  250.     int        uh_flags;    /* see below */
  251.     pos_T    uh_namedm[NMARKS];    /* marks before undo/after redo */
  252. };
  253.  
  254. /* values for uh_flags */
  255. #define UH_CHANGED  0x01    /* b_changed flag before undo/after redo */
  256. #define UH_EMPTYBUF 0x02    /* buffer was empty */
  257.  
  258. /*
  259.  * stuctures used in undo.c
  260.  */
  261. #if SIZEOF_INT > 2
  262. # define ALIGN_LONG    /* longword alignment and use filler byte */
  263. # define ALIGN_SIZE (sizeof(long))
  264. #else
  265. # define ALIGN_SIZE (sizeof(short))
  266. #endif
  267.  
  268. #define ALIGN_MASK (ALIGN_SIZE - 1)
  269.  
  270. typedef struct m_info minfo_T;
  271.  
  272. /*
  273.  * stucture used to link chunks in one of the free chunk lists.
  274.  */
  275. struct m_info
  276. {
  277. #ifdef ALIGN_LONG
  278.     long_u    m_size;        /* size of the chunk (including m_info) */
  279. #else
  280.     short_u    m_size;        /* size of the chunk (including m_info) */
  281. #endif
  282.     minfo_T    *m_next;    /* pointer to next free chunk in the list */
  283. };
  284.  
  285. /*
  286.  * structure used to link blocks in the list of allocated blocks.
  287.  */
  288. typedef struct m_block mblock_T;
  289. struct m_block
  290. {
  291.     mblock_T    *mb_next;    /* pointer to next allocated block */
  292.     size_t    mb_size;    /* total size of all chunks in this block */
  293.     minfo_T    mb_info;    /* head of free chuck list for this block */
  294. };
  295.  
  296. /*
  297.  * things used in memfile.c
  298.  */
  299.  
  300. typedef struct block_hdr    bhdr_T;
  301. typedef struct memfile        memfile_T;
  302. typedef long            blocknr_T;
  303.  
  304. /*
  305.  * for each (previously) used block in the memfile there is one block header.
  306.  *
  307.  * The block may be linked in the used list OR in the free list.
  308.  * The used blocks are also kept in hash lists.
  309.  *
  310.  * The used list is a doubly linked list, most recently used block first.
  311.  *    The blocks in the used list have a block of memory allocated.
  312.  *    mf_used_count is the number of pages in the used list.
  313.  * The hash lists are used to quickly find a block in the used list.
  314.  * The free list is a single linked list, not sorted.
  315.  *    The blocks in the free list have no block of memory allocated and
  316.  *    the contents of the block in the file (if any) is irrelevant.
  317.  */
  318.  
  319. struct block_hdr
  320. {
  321.     bhdr_T    *bh_next;        /* next block_hdr in free or used list */
  322.     bhdr_T    *bh_prev;        /* previous block_hdr in used list */
  323.     bhdr_T    *bh_hash_next;        /* next block_hdr in hash list */
  324.     bhdr_T    *bh_hash_prev;        /* previous block_hdr in hash list */
  325.     blocknr_T    bh_bnum;        /* block number */
  326.     char_u    *bh_data;        /* pointer to memory (for used block) */
  327.     int        bh_page_count;        /* number of pages in this block */
  328.  
  329. #define BH_DIRTY    1
  330. #define BH_LOCKED   2
  331.     char    bh_flags;        /* BH_DIRTY or BH_LOCKED */
  332. };
  333.  
  334. /*
  335.  * when a block with a negative number is flushed to the file, it gets
  336.  * a positive number. Because the reference to the block is still the negative
  337.  * number, we remember the translation to the new positive number in the
  338.  * double linked trans lists. The structure is the same as the hash lists.
  339.  */
  340. typedef struct nr_trans NR_TRANS;
  341.  
  342. struct nr_trans
  343. {
  344.     NR_TRANS    *nt_next;        /* next nr_trans in hash list */
  345.     NR_TRANS    *nt_prev;        /* previous nr_trans in hash list */
  346.     blocknr_T    nt_old_bnum;        /* old, negative, number */
  347.     blocknr_T    nt_new_bnum;        /* new, positive, number */
  348. };
  349.  
  350. /*
  351.  * structure used to store one block of the stuff/redo/recording buffers
  352.  */
  353. struct buffblock
  354. {
  355.     struct buffblock    *b_next;    /* pointer to next buffblock */
  356.     char_u        b_str[1];    /* contents (actually longer) */
  357. };
  358.  
  359. /*
  360.  * header used for the stuff buffer and the redo buffer
  361.  */
  362. struct buffheader
  363. {
  364.     struct buffblock    bh_first;    /* first (dummy) block of list */
  365.     struct buffblock    *bh_curr;    /* buffblock for appending */
  366.     int            bh_index;    /* index for reading */
  367.     int            bh_space;    /* space in bh_curr for appending */
  368. };
  369.  
  370. /*
  371.  * used for completion on the command line
  372.  */
  373. typedef struct expand
  374. {
  375.     int        xp_context;        /* type of expansion */
  376.     char_u    *xp_pattern;        /* start of item to expand */
  377.     char_u    *xp_arg;        /* generic expansion argument */
  378.     int        xp_backslash;        /* one of the XP_BS_ values */
  379. } expand_T;
  380.  
  381. /* values for xp_backslash */
  382. #define XP_BS_NONE    0    /* nothing special for backslashes */
  383. #define XP_BS_ONE    1    /* uses one backslash before a space */
  384. #define XP_BS_THREE    2    /* uses three backslashes before a space */
  385.  
  386. /*
  387.  * Command modifiers ":vertical", ":browse", ":confirm" and ":hide" set a flag.
  388.  * This needs to be saved for recursive commands, put them in a structure for
  389.  * easy manipulation.
  390.  */
  391. typedef struct
  392. {
  393.     int        hide;            /* TRUE when ":hide" was used */
  394. # ifdef FEAT_BROWSE
  395.     int        browse;            /* TRUE to invoke file dialog */
  396. # endif
  397. # ifdef FEAT_WINDOWS
  398.     int        split;            /* flags for win_split() */
  399. # endif
  400. # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
  401.     int        confirm;        /* TRUE to invoke yes/no dialog */
  402. # endif
  403. } cmdmod_T;
  404.  
  405. /*
  406.  * Simplistic hashing scheme to quickly locate the blocks in the used list.
  407.  * 64 blocks are found directly (64 * 4K = 256K, most files are smaller).
  408.  */
  409. #define MEMHASHSIZE    64
  410. #define MEMHASH(nr)    ((nr) & (MEMHASHSIZE - 1))
  411.  
  412. struct memfile
  413. {
  414.     char_u    *mf_fname;        /* name of the file */
  415.     char_u    *mf_ffname;        /* idem, full path */
  416.     int        mf_fd;            /* file descriptor */
  417.     bhdr_T    *mf_free_first;        /* first block_hdr in free list */
  418.     bhdr_T    *mf_used_first;        /* mru block_hdr in used list */
  419.     bhdr_T    *mf_used_last;        /* lru block_hdr in used list */
  420.     unsigned    mf_used_count;        /* number of pages in used list */
  421.     unsigned    mf_used_count_max;    /* maximum number of pages in memory */
  422.     bhdr_T    *mf_hash[MEMHASHSIZE];    /* array of hash lists */
  423.     NR_TRANS    *mf_trans[MEMHASHSIZE];    /* array of trans lists */
  424.     blocknr_T    mf_blocknr_max;        /* highest positive block number + 1*/
  425.     blocknr_T    mf_blocknr_min;        /* lowest negative block number - 1 */
  426.     blocknr_T    mf_neg_count;        /* number of negative blocks numbers */
  427.     blocknr_T    mf_infile_count;    /* number of pages in the file */
  428.     unsigned    mf_page_size;        /* number of bytes in a page */
  429.     int        mf_dirty;        /* TRUE if there are dirty blocks */
  430. };
  431.  
  432. /*
  433.  * things used in memline.c
  434.  */
  435. /*
  436.  * When searching for a specific line, we remember what blocks in the tree
  437.  * are the branches leading to that block. This is stored in ml_stack.  Each
  438.  * entry is a pointer to info in a block (may be data block or pointer block)
  439.  */
  440. typedef struct info_pointer
  441. {
  442.     blocknr_T    ip_bnum;    /* block number */
  443.     linenr_T    ip_low;        /* lowest lnum in this block */
  444.     linenr_T    ip_high;    /* highest lnum in this block */
  445.     int        ip_index;    /* index for block with current lnum */
  446. } infoptr_T;    /* block/index pair */
  447.  
  448. #ifdef FEAT_BYTEOFF
  449. typedef struct ml_chunksize
  450. {
  451.     int        mlcs_numlines;
  452.     long    mlcs_totalsize;
  453. } chunksize_T;
  454.  
  455.  /* Flags when calling ml_updatechunk() */
  456.  
  457. #define ML_CHNK_ADDLINE 1
  458. #define ML_CHNK_DELLINE 2
  459. #define ML_CHNK_UPDLINE 3
  460. #endif
  461.  
  462. /*
  463.  * the memline structure holds all the information about a memline
  464.  */
  465. typedef struct memline
  466. {
  467.     linenr_T    ml_line_count;    /* number of lines in the buffer */
  468.  
  469.     memfile_T    *ml_mfp;    /* pointer to associated memfile */
  470.  
  471. #define ML_EMPTY    1    /* empty buffer */
  472. #define ML_LINE_DIRTY    2    /* cached line was changed and allocated */
  473. #define ML_LOCKED_DIRTY    4    /* ml_locked was changed */
  474. #define ML_LOCKED_POS    8    /* ml_locked needs positive block number */
  475.     int        ml_flags;
  476.  
  477.     infoptr_T    *ml_stack;    /* stack of pointer blocks (array of IPTRs) */
  478.     int        ml_stack_top;    /* current top if ml_stack */
  479.     int        ml_stack_size;    /* total number of entries in ml_stack */
  480.  
  481.     linenr_T    ml_line_lnum;    /* line number of cached line, 0 if not valid */
  482.     char_u    *ml_line_ptr;    /* pointer to cached line */
  483.  
  484.     bhdr_T    *ml_locked;    /* block used by last ml_get */
  485.     linenr_T    ml_locked_low;    /* first line in ml_locked */
  486.     linenr_T    ml_locked_high;    /* last line in ml_locked */
  487.     int        ml_locked_lineadd;  /* number of lines inserted in ml_locked */
  488. #ifdef FEAT_BYTEOFF
  489.     chunksize_T *ml_chunksize;
  490.     int        ml_numchunks;
  491.     int        ml_usedchunks;
  492. #endif
  493. } memline_T;
  494.  
  495. #if defined(FEAT_SIGNS) || defined(PROTO)
  496. typedef struct signlist signlist_T;
  497.  
  498. struct signlist
  499. {
  500.     int        id;        /* unique identifier for each placed sign */
  501.     linenr_T    lnum;        /* line number which has this sign */
  502.     int        typenr;        /* typenr of sign */
  503.     signlist_T    *next;        /* next signlist entry */
  504. # ifdef FEAT_NETBEANS_INTG
  505.     signlist_T  *prev;        /* previous entry -- for easy reordering */
  506. # endif
  507. };
  508.  
  509. /* type argument for buf_getsigntype() */
  510. #define SIGN_ANY    0
  511. #define SIGN_LINEHL    1
  512. #define SIGN_ICON    2
  513. #define SIGN_TEXT    3
  514. #endif
  515.  
  516. /*
  517.  * Argument list: Array of file names.
  518.  * Used for the global argument list and the argument lists local to a window.
  519.  */
  520. typedef struct arglist
  521. {
  522.     garray_T    al_ga;        /* growarray with the array of file names */
  523.     int        al_refcount;    /* number of windows using this arglist */
  524. } alist_T;
  525.  
  526. /*
  527.  * For each argument remember the file name as it was given, and the buffer
  528.  * number that contains the expanded file name (required for when ":cd" is
  529.  * used.
  530.  */
  531. typedef struct argentry
  532. {
  533.     char_u    *ae_fname;    /* file name as specified */
  534.     int        ae_fnum;    /* buffer number with expanded file name */
  535. } aentry_T;
  536.  
  537. #ifdef FEAT_WINDOWS
  538. # define ALIST(win) (win)->w_alist
  539. #else
  540. # define ALIST(win) (&global_alist)
  541. #endif
  542. #define GARGLIST    ((aentry_T *)global_alist.al_ga.ga_data)
  543. #define ARGLIST        ((aentry_T *)ALIST(curwin)->al_ga.ga_data)
  544. #define WARGLIST(wp)    ((aentry_T *)ALIST(wp)->al_ga.ga_data)
  545. #define AARGLIST(al)    ((aentry_T *)((al)->al_ga.ga_data))
  546. #define GARGCOUNT    (global_alist.al_ga.ga_len)
  547. #define ARGCOUNT    (ALIST(curwin)->al_ga.ga_len)
  548. #define WARGCOUNT(wp)    (ALIST(wp)->al_ga.ga_len)
  549.  
  550. /*
  551.  * A list used for saving values of "emsg_silent".  Used by ex_try() to save the
  552.  * value of "emsg_silent" if it was non-zero.  When this is done, the CSF_SILENT
  553.  * flag below is set.
  554.  */
  555.  
  556. typedef struct eslist_elem eslist_T;
  557. struct eslist_elem
  558. {
  559.     int        saved_emsg_silent;    /* saved value of "emsg_silent" */
  560.     eslist_T    *next;            /* next element on the list */
  561. };
  562.  
  563. /*
  564.  * For conditional commands a stack is kept of nested conditionals.
  565.  * When cs_idx < 0, there is no conditional command.
  566.  */
  567. #define CSTACK_LEN    50
  568.  
  569. struct condstack
  570. {
  571.     char    cs_flags[CSTACK_LEN];    /* CSF_ flags */
  572.     char    cs_pending[CSTACK_LEN];    /* CSTP_: what's pending in ":finally"*/
  573.     union {
  574.     void   *cs_pend_rv[CSTACK_LEN];    /* returnval for pending return */
  575.     void   *cs_pend_ex[CSTACK_LEN];    /* exception for pending throw */
  576.     }        cs_pend;
  577.     int        cs_line[CSTACK_LEN];    /* line number of ":while" line */
  578.     int        cs_idx;            /* current entry, or -1 if none */
  579.     int        cs_whilelevel;        /* number of nested ":while"s */
  580.     int        cs_trylevel;        /* number of nested ":try"s */
  581.     eslist_T    *cs_emsg_silent_list;    /* saved values of "emsg_silent" */
  582.     char    cs_had_while;        /* just found ":while" */
  583.     char    cs_had_continue;    /* just found ":continue" */
  584.     char    cs_had_endwhile;    /* just found ":endwhile" */
  585.     char    cs_had_finally;        /* just found ":finally" */
  586. };
  587. # define cs_retvar    cs_pend.cs_pend_rv
  588. # define cs_exception    cs_pend.cs_pend_ex
  589.  
  590. # define CSF_TRUE    1    /* condition was TRUE */
  591. # define CSF_ACTIVE    2    /* current state is active */
  592. # define CSF_ELSE    4    /* ":else" has been passed */
  593. # define CSF_WHILE    8    /* is a ":while" */
  594. # define CSF_TRY    16    /* is a ":try" */
  595. # define CSF_FINALLY    32    /* ":finally" has been passed */
  596. # define CSF_THROWN    64    /* exception thrown to this try conditional */
  597. # define CSF_CAUGHT    128    /* exception caught by this try conditional */
  598. # define CSF_SILENT    4    /* "emsg_silent" reset by ":try" */
  599. /* Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
  600.  * (an ":if"), and CSF_SILENT is only used when CSF_TRY is set. */
  601.  
  602. /*
  603.  * What's pending for being reactivated at the ":endtry" of this try
  604.  * conditional:
  605.  */
  606. # define CSTP_NONE    0    /* nothing pending in ":finally" clause */
  607. # define CSTP_ERROR    1    /* an error is pending */
  608. # define CSTP_INTERRUPT    2    /* an interrupt is pending */
  609. # define CSTP_THROW    4    /* a throw is pending */
  610. # define CSTP_BREAK    8    /* ":break" is pending */
  611. # define CSTP_CONTINUE    16    /* ":continue" is pending */
  612. # define CSTP_RETURN    24    /* ":return" is pending */
  613. # define CSTP_FINISH    32    /* ":finish" is pending */
  614.  
  615. /*
  616.  * A list of error messages that can be converted to an exception.  "throw_msg"
  617.  * is only set in the first element of the list.  Usually, it points to the
  618.  * original message stored in that element, but sometimes it points to a later
  619.  * message in the list.  See cause_errthrow() below.
  620.  */
  621. struct msglist
  622. {
  623.     char_u        *msg;        /* original message */
  624.     char_u        *throw_msg;    /* msg to throw: usually original one */
  625.     struct msglist    *next;        /* next of several messages in a row */
  626. };
  627.  
  628. /*
  629.  * Structure describing an exception.
  630.  * (don't use "struct exception", it's used by the math library).
  631.  */
  632. typedef struct vim_exception except_T;
  633. struct vim_exception
  634. {
  635.     int            type;        /* exception type */
  636.     char_u        *value;        /* exception value */
  637.     struct msglist    *messages;    /* message(s) causing error exception */
  638.     char_u        *throw_name;    /* name of the throw point */
  639.     linenr_T        throw_lnum;    /* line number of the throw point */
  640.     except_T        *caught;    /* next exception on the caught stack */
  641. };
  642.  
  643. /*
  644.  * The exception types.
  645.  */
  646. #define ET_USER        0    /* exception caused by ":throw" command */
  647. #define ET_ERROR    1    /* error exception */
  648. #define ET_INTERRUPT    2    /* interrupt exception triggered by Ctrl-C */
  649.  
  650.  
  651. #ifdef FEAT_SYN_HL
  652. /* struct passed to in_id_list() */
  653. struct sp_syn
  654. {
  655.     int        inc_tag;    /* ":syn include" unique tag */
  656.     short    id;        /* highlight group ID of item */
  657.     short    *cont_in_list;    /* cont.in group IDs, if non-zero */
  658. };
  659.  
  660. /*
  661.  * Each keyword has one keyentry, which is linked in a hash list.
  662.  */
  663. typedef struct keyentry keyentry_T;
  664.  
  665. struct keyentry
  666. {
  667.     keyentry_T    *next;        /* next keyword in the hash list */
  668.     struct sp_syn k_syn;    /* struct passed to in_id_list() */
  669.     short    *next_list;    /* ID list for next match (if non-zero) */
  670.     short    flags;        /* see syntax.c */
  671.     char_u    keyword[1];    /* actually longer */
  672. };
  673.  
  674. /*
  675.  * Struct used to store one state of the state stack.
  676.  */
  677. typedef struct buf_state
  678. {
  679.     int            bs_idx;     /* index of pattern */
  680.     long        bs_flags;     /* flags for pattern */
  681.     reg_extmatch_T *bs_extmatch; /* external matches from start pattern */
  682. } bufstate_T;
  683.  
  684. /*
  685.  * syn_state contains the syntax state stack for the start of one line.
  686.  * Used by b_sst_array[].
  687.  */
  688. typedef struct syn_state synstate_T;
  689.  
  690. struct syn_state
  691. {
  692.     synstate_T    *sst_next;    /* next entry in used or free list */
  693.     linenr_T    sst_lnum;    /* line number for this state */
  694.     union
  695.     {
  696.     bufstate_T    sst_stack[SST_FIX_STATES]; /* short state stack */
  697.     garray_T    sst_ga;    /* growarray for long state stack */
  698.     } sst_union;
  699.     int        sst_next_flags;    /* flags for sst_next_list */
  700.     short    *sst_next_list;    /* "nextgroup" list in this state
  701.                  * (this is a copy, don't free it! */
  702.     short    sst_stacksize;    /* number of states on the stack */
  703.     disptick_T    sst_tick;    /* tick when last displayed */
  704.     linenr_T    sst_change_lnum;/* when non-zero, change in this line
  705.                  * may have made the state invalid */
  706. };
  707. #endif /* FEAT_SYN_HL */
  708.  
  709. /*
  710.  * Structure shared between syntax.c, screen.c and gui_x11.c.
  711.  */
  712. typedef struct attr_entry
  713. {
  714.     short        ae_attr;        /* HL_BOLD, etc. */
  715.     union
  716.     {
  717.     struct
  718.     {
  719.         char_u        *start;    /* start escape sequence */
  720.         char_u        *stop;    /* stop escape sequence */
  721.     } term;
  722.     struct
  723.     {
  724.         char_u        fg_color;    /* foreground color number */
  725.         char_u        bg_color;    /* background color number */
  726.     } cterm;
  727. # ifdef FEAT_GUI
  728.     struct
  729.     {
  730.         guicolor_T        fg_color;    /* foreground color handle */
  731.         guicolor_T        bg_color;    /* background color handle */
  732.         GuiFont        font;    /* font handle */
  733. #  ifdef FEAT_XFONTSET
  734.         GuiFontset        fontset;    /* fontset handle */
  735. #  endif
  736.     } gui;
  737. # endif
  738.     } ae_u;
  739. } attrentry_T;
  740.  
  741. #ifdef USE_ICONV
  742. # ifdef HAVE_ICONV_H
  743. #  include <iconv.h>
  744. # else
  745. #  if defined(MACOS_X)
  746. #   include <sys/errno.h>
  747. #   define EILSEQ ENOENT /* MacOS X does not have EILSEQ */
  748. typedef struct _iconv_t *iconv_t;
  749. #  else
  750. #   if defined(MACOS_CLASSIC)
  751. typedef struct _iconv_t *iconv_t;
  752. #    define EINVAL    22
  753. #    define E2BIG    7
  754. #    define ENOENT    2
  755. #    define EFAULT    14
  756. #    define EILSEQ    123
  757. #   else
  758. #    include <errno.h>
  759. #   endif
  760. #  endif
  761. typedef void *iconv_t;
  762. # endif
  763. #endif
  764.  
  765. /*
  766.  * Used for the typeahead buffer: typebuf.
  767.  */
  768. typedef struct
  769. {
  770.     char_u    *tb_buf;    /* buffer for typed characters */
  771.     char_u    *tb_noremap;    /* mapping flags for characters in tb_buf[] */
  772.     int        tb_buflen;    /* size of tb_buf[] */
  773.     int        tb_off;        /* current position in tb_buf[] */
  774.     int        tb_len;        /* number of valid chars in tb_buf[] */
  775.     int        tb_maplen;    /* nr of mapped characters in tb_buf[] */
  776.     int        tb_silent;    /* nr of silently mapped chars in tb_buf[] */
  777.     int        tb_no_abbr_cnt; /* nr of chars without abbrev. in tb_buf[] */
  778. } typebuf_T;
  779.  
  780. /* Struct to hold the saved typeahead for save_typeahead(). */
  781. typedef struct
  782. {
  783.     typebuf_T        save_typebuf;
  784.     int            typebuf_valid;        /* TRUE when save_typebuf valid */
  785.     struct buffheader    save_stuffbuff;
  786. #ifdef USE_INPUT_BUF
  787.     char_u        *save_inputbuf;
  788. #endif
  789. } tasave_T;
  790.  
  791. /*
  792.  * Used for conversion of terminal I/O and script files.
  793.  */
  794. typedef struct
  795. {
  796.     int        vc_type;    /* zero or one of the CONV_ values */
  797.     int        vc_factor;    /* max. expansion factor */
  798. # ifdef WIN3264
  799.     int        vc_cpfrom;    /* codepage to convert from (CONV_CODEPAGE) */
  800.     int        vc_cpto;    /* codepage to convert to (CONV_CODEPAGE) */
  801. # endif
  802. # ifdef USE_ICONV
  803.     iconv_t    vc_fd;        /* for CONV_ICONV */
  804. # endif
  805. } vimconv_T;
  806.  
  807. /*
  808.  * Structure used for reading from the viminfo file.
  809.  */
  810. typedef struct
  811. {
  812.     char_u    *vir_line;    /* text of the current line */
  813.     FILE    *vir_fd;    /* file descriptor */
  814. #ifdef FEAT_MBYTE
  815.     vimconv_T    vir_conv;    /* encoding conversion */
  816. #endif
  817. } vir_T;
  818.  
  819. #define CONV_NONE        0
  820. #define CONV_TO_UTF8        1
  821. #define CONV_TO_LATIN1        2
  822. #define CONV_ICONV        3
  823. #ifdef WIN3264
  824. # define CONV_CODEPAGE        4    /* codepage -> codepage */
  825. #endif
  826.  
  827. /*
  828.  * Structure used for mappings and abbreviations.
  829.  */
  830. typedef struct mapblock mapblock_T;
  831. struct mapblock
  832. {
  833.     mapblock_T    *m_next;    /* next mapblock in list */
  834.     char_u    *m_keys;    /* mapped from */
  835.     int        m_keylen;    /* strlen(m_keys) */
  836.     char_u    *m_str;        /* mapped to */
  837.     int        m_mode;        /* valid mode */
  838.     int        m_noremap;    /* if non-zero no re-mapping for m_str */
  839.     char    m_silent;    /* <silent> used, don't echo commands */
  840. #if 0  /* Not used yet */
  841.     scid_T    m_script_ID;    /* ID of script where map was defined,
  842.                    used for s: variables and functions */
  843. #endif
  844. };
  845.  
  846. /*
  847.  * Used for highlighting in the status line.
  848.  */
  849. struct stl_hlrec
  850. {
  851.     char_u    *start;
  852.     int        userhl;
  853. };
  854.  
  855. /*
  856.  * buffer: structure that holds information about one file
  857.  *
  858.  * Several windows can share a single Buffer
  859.  * A buffer is unallocated if there is no memfile for it.
  860.  * A buffer is new if the associated file has never been loaded yet.
  861.  */
  862.  
  863. typedef struct file_buffer buf_T;
  864.  
  865. struct file_buffer
  866. {
  867.     memline_T    b_ml;        /* associated memline (also contains line
  868.                    count) */
  869.  
  870.     buf_T    *b_next;    /* links in list of buffers */
  871.     buf_T    *b_prev;
  872.  
  873.     int        b_nwindows;    /* nr of windows open on this buffer */
  874.  
  875.     int        b_flags;    /* various BF_ flags */
  876.  
  877.     /*
  878.      * b_ffname has the full path of the file (NULL for no name).
  879.      * b_sfname is the name as the user typed it (or NULL).
  880.      * b_fname is the same as b_sfname, unless ":cd" has been done,
  881.      *        then it is the same as b_ffname (NULL for no name).
  882.      */
  883.     char_u    *b_ffname;    /* full path file name */
  884.     char_u    *b_sfname;    /* short file name */
  885.     char_u    *b_fname;    /* current file name */
  886.  
  887. #ifdef UNIX
  888.     int        b_dev;        /* device number (-1 if not set) */
  889.     ino_t    b_ino;        /* inode number */
  890. #endif
  891. #ifdef MACOS
  892.     FSSpec    b_FSSpec;    /* MacOS File Identification */
  893. #endif
  894. #ifdef VMS
  895.     char    b_fab_rfm;    /* Record format */
  896. #endif
  897. #ifdef FEAT_SNIFF
  898.     int        b_sniff;    /* file was loaded through Sniff */
  899. #endif
  900.  
  901.     int        b_fnum;        /* buffer number for this file. */
  902.  
  903.     int        b_changed;    /* 'modified': Set to TRUE if something in the
  904.                    file has been changed and not written out. */
  905.     int        b_changedtick;    /* incremented for each change, also for undo */
  906.  
  907.     int        b_saving;    /* Set to TRUE if we are in the middle of
  908.                    saving the buffer. */
  909.  
  910.     /*
  911.      * Changes to a buffer require updating of the display.  To minimize the
  912.      * work, remember changes made and update everything at once.
  913.      */
  914.     int        b_mod_set;    /* TRUE when there are changes since the last
  915.                    time the display was updated */
  916.     linenr_T    b_mod_top;    /* topmost lnum that was changed */
  917.     linenr_T    b_mod_bot;    /* lnum below last changed line, AFTER the
  918.                    change */
  919.     long    b_mod_xlines;    /* number of extra buffer lines inserted;
  920.                    negative when lines were deleted */
  921.  
  922.     wininfo_T    *b_wininfo;    /* list of last used info for each window */
  923.  
  924.     long    b_mtime;    /* last change time of original file */
  925.     long    b_mtime_read;    /* last change time when reading */
  926.     size_t    b_orig_size;    /* size of original file in bytes */
  927.     int        b_orig_mode;    /* mode of original file */
  928.  
  929.     pos_T    b_namedm[NMARKS]; /* current named marks (mark.c) */
  930.  
  931. #ifdef FEAT_VISUAL
  932.     /* These variables are set when VIsual_active becomes FALSE */
  933.     pos_T    b_visual_start;    /* start pos of last VIsual */
  934.     pos_T    b_visual_end;    /* end position of last VIsual */
  935.     int        b_visual_mode;    /* VIsual_mode of last VIsual */
  936. # ifdef FEAT_EVAL
  937.     int        b_visual_mode_eval;  /* b_visual_mode for visualmode() */
  938. # endif
  939.     colnr_T    b_visual_curswant;   /* MAXCOL from w_curswant */
  940. #endif
  941.  
  942.     pos_T    b_last_cursor;    /* cursor position when last unloading this
  943.                    buffer */
  944.     pos_T    b_last_insert;    /* where Insert mode was left */
  945.     pos_T    b_last_change;    /* position of last change: '. mark */
  946.  
  947.     /*
  948.      * Character table, only used in charset.c for 'iskeyword'
  949.      * 32 bytes of 8 bits: 1 bit per character 0-255.
  950.      */
  951.     char_u    b_chartab[32];
  952.  
  953. #ifdef FEAT_LOCALMAP
  954.     /* Table used for mappings local to a buffer. */
  955.     mapblock_T    *(b_maphash[256]);
  956.  
  957.     /* First abbreviation local to a buffer. */
  958.     mapblock_T    *b_first_abbr;
  959. #endif
  960. #ifdef FEAT_USR_CMDS
  961.     /* User commands local to the buffer. */
  962.     garray_T    b_ucmds;
  963. #endif
  964.     /*
  965.      * start and end of an operator, also used for '[ and ']
  966.      */
  967.     pos_T    b_op_start;
  968.     pos_T    b_op_end;
  969.  
  970. #ifdef FEAT_VIMINFO
  971.     int        b_marks_read;    /* Have we read viminfo marks yet? */
  972. #endif
  973.  
  974.     /*
  975.      * The following only used in undo.c.
  976.      */
  977.     u_header_T    *b_u_oldhead;    /* pointer to oldest header */
  978.     u_header_T    *b_u_newhead;    /* pointer to newest header */
  979.     u_header_T    *b_u_curhead;    /* pointer to current header */
  980.     int        b_u_numhead;    /* current number of headers */
  981.     int        b_u_synced;    /* entry lists are synced */
  982.  
  983.     /*
  984.      * variables for "U" command in undo.c
  985.      */
  986.     char_u    *b_u_line_ptr;    /* saved line for "U" command */
  987.     linenr_T    b_u_line_lnum;    /* line number of line in u_line */
  988.     colnr_T    b_u_line_colnr;    /* optional column number */
  989.  
  990.     /*
  991.      * The following only used in undo.c
  992.      */
  993.     mblock_T    b_block_head;    /* head of allocated memory block list */
  994.     minfo_T    *b_m_search;    /* pointer to chunk before previously
  995.                    allocated/freed chunk */
  996.     mblock_T    *b_mb_current;    /* block where m_search points in */
  997. #ifdef FEAT_INS_EXPAND
  998.     int        b_scanned;    /* ^N/^P have scanned this buffer */
  999. #endif
  1000.  
  1001.     /* flags for use of ":lmap" and IM control */
  1002.     long    b_p_iminsert;    /* input mode for insert */
  1003.     long    b_p_imsearch;    /* input mode for search */
  1004. #define B_IMODE_USE_INSERT -1    /*    Use b_p_iminsert value for search */
  1005. #define B_IMODE_NONE 0        /*    Input via none */
  1006. #define B_IMODE_LMAP 1        /*    Input via langmap */
  1007. #ifndef USE_IM_CONTROL
  1008. # define B_IMODE_LAST 1
  1009. #else
  1010. # define B_IMODE_IM 2        /*    Input via input method */
  1011. # define B_IMODE_LAST 2
  1012. #endif
  1013.  
  1014. #ifdef FEAT_KEYMAP
  1015.     short    b_kmap_state;    /* using "lmap" mappings */
  1016. # define KEYMAP_INIT    1    /* 'keymap' was set, call keymap_init() */
  1017. # define KEYMAP_LOADED    2    /* 'keymap' mappings have been loaded */
  1018.     garray_T    b_kmap_ga;    /* the keymap table */
  1019. #endif
  1020.  
  1021.     /*
  1022.      * Options local to a buffer.
  1023.      * They are here because their value depends on the type of file
  1024.      * or contents of the file being edited.
  1025.      */
  1026.     int        b_p_initialized;    /* set when options initialized */
  1027.  
  1028.     int        b_p_ai;        /* 'autoindent' */
  1029.     int        b_p_ai_nopaste;    /* b_p_ai saved for paste mode */
  1030.     int        b_p_ci;        /* 'copyindent' */
  1031.     int        b_p_bin;    /* 'binary' */
  1032. #ifdef FEAT_MBYTE
  1033.     int        b_p_bomb;    /* 'bomb' */
  1034. #endif
  1035. #if defined(FEAT_QUICKFIX)
  1036.     char_u    *b_p_bh;    /* 'bufhidden' */
  1037.     char_u    *b_p_bt;    /* 'buftype' */
  1038. #endif
  1039.     int        b_p_bl;        /* 'buflisted' */
  1040. #ifdef FEAT_CINDENT
  1041.     int        b_p_cin;    /* 'cindent' */
  1042.     char_u    *b_p_cino;    /* 'cinoptions' */
  1043.     char_u    *b_p_cink;    /* 'cinkeys' */
  1044. #endif
  1045. #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
  1046.     char_u    *b_p_cinw;    /* 'cinwords' */
  1047. #endif
  1048. #ifdef FEAT_COMMENTS
  1049.     char_u    *b_p_com;    /* 'comments' */
  1050. #endif
  1051. #ifdef FEAT_FOLDING
  1052.     char_u    *b_p_cms;    /* 'commentstring' */
  1053. #endif
  1054. #ifdef FEAT_INS_EXPAND
  1055.     char_u    *b_p_cpt;    /* 'complete' */
  1056. #endif
  1057.     int        b_p_eol;    /* 'endofline' */
  1058.     int        b_p_et;        /* 'expandtab' */
  1059.     int        b_p_et_nobin;    /* b_p_et saved for binary mode */
  1060. #ifdef FEAT_MBYTE
  1061.     char_u    *b_p_fenc;    /* 'fileencoding' */
  1062. #endif
  1063.     char_u    *b_p_ff;    /* 'fileformat' */
  1064. #ifdef FEAT_AUTOCMD
  1065.     char_u    *b_p_ft;    /* 'filetype' */
  1066. #endif
  1067.     char_u    *b_p_fo;    /* 'formatoptions' */
  1068.     int        b_p_inf;    /* 'infercase' */
  1069.     char_u    *b_p_isk;    /* 'iskeyword' */
  1070. #ifdef FEAT_FIND_ID
  1071.     char_u    *b_p_def;    /* 'define' local value */
  1072.     char_u    *b_p_inc;    /* 'include' */
  1073. # ifdef FEAT_EVAL
  1074.     char_u    *b_p_inex;    /* 'includeexpr' */
  1075. # endif
  1076. #endif
  1077. #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
  1078.     char_u    *b_p_inde;    /* 'indentexpr' */
  1079.     char_u    *b_p_indk;    /* 'indentkeys' */
  1080. #endif
  1081. #ifdef FEAT_CRYPT
  1082.     char_u    *b_p_key;    /* 'key' */
  1083. #endif
  1084.     char_u    *b_p_kp;    /* 'keywordprg' */
  1085. #ifdef FEAT_LISP
  1086.     int        b_p_lisp;    /* 'lisp' */
  1087. #endif
  1088.     char_u    *b_p_mps;    /* 'matchpairs' */
  1089.     int        b_p_ml;        /* 'modeline' */
  1090.     int        b_p_ml_nobin;    /* b_p_ml saved for binary mode */
  1091.     int        b_p_ma;        /* 'modifiable' */
  1092.     char_u    *b_p_nf;    /* 'nrformats' */
  1093. #ifdef FEAT_OSFILETYPE
  1094.     char_u    *b_p_oft;    /* 'osfiletype' */
  1095. #endif
  1096.     int        b_p_pi;        /* 'preserveindent' */
  1097.     int        b_p_ro;        /* 'readonly' */
  1098.     long    b_p_sw;        /* 'shiftwidth' */
  1099. #ifndef SHORT_FNAME
  1100.     int        b_p_sn;        /* 'shortname' */
  1101. #endif
  1102. #ifdef FEAT_SMARTINDENT
  1103.     int        b_p_si;        /* 'smartindent' */
  1104. #endif
  1105.     long    b_p_sts;    /* 'softtabstop' */
  1106.     long    b_p_sts_nopaste; /* b_p_sts saved for paste mode */
  1107. #ifdef FEAT_SEARCHPATH
  1108.     char_u    *b_p_sua;    /* 'suffixesadd' */
  1109. #endif
  1110.     int        b_p_swf;    /* 'swapfile' */
  1111. #ifdef FEAT_SYN_HL
  1112.     char_u    *b_p_syn;    /* 'syntax' */
  1113. #endif
  1114.     long    b_p_ts;        /* 'tabstop' */
  1115.     int        b_p_tx;        /* 'textmode' */
  1116.     long    b_p_tw;        /* 'textwidth' */
  1117.     long    b_p_tw_nobin;    /* b_p_tw saved for binary mode */
  1118.     long    b_p_tw_nopaste;    /* b_p_tw saved for paste mode */
  1119.     long    b_p_wm;        /* 'wrapmargin' */
  1120.     long    b_p_wm_nobin;    /* b_p_wm saved for binary mode */
  1121.     long    b_p_wm_nopaste;    /* b_p_wm saved for paste mode */
  1122. #ifdef FEAT_KEYMAP
  1123.     char_u    *b_p_keymap;    /* 'keymap' */
  1124. #endif
  1125.  
  1126.     /* local values for options which are normally global */
  1127. #ifdef FEAT_QUICKFIX
  1128.     char_u    *b_p_gp;    /* 'grepprg' local value */
  1129.     char_u    *b_p_mp;    /* 'makeprg' local value */
  1130.     char_u    *b_p_efm;    /* 'errorformat' local value */
  1131. #endif
  1132.     char_u    *b_p_ep;    /* 'equalprg' local value */
  1133.     char_u    *b_p_path;    /* 'path' local value */
  1134.     int        b_p_ar;        /* 'autoread' local value */
  1135.     char_u    *b_p_tags;    /* 'tags' local value */
  1136. #ifdef FEAT_INS_EXPAND
  1137.     char_u    *b_p_dict;    /* 'dictionary' local value */
  1138.     char_u    *b_p_tsr;    /* 'thesaurus' local value */
  1139. #endif
  1140.  
  1141.     /* end of buffer options */
  1142.  
  1143.     int        b_start_eol;    /* last line had eol when it was read */
  1144.     int        b_start_ffc;    /* first char of 'ff' when edit started */
  1145. #ifdef FEAT_MBYTE
  1146.     char_u    *b_start_fenc;    /* 'fileencoding' when edit started or NULL */
  1147. #endif
  1148.  
  1149. #ifdef FEAT_EVAL
  1150.     garray_T    b_vars;        /* internal variables, local to buffer */
  1151. #endif
  1152.  
  1153.     /* When a buffer is created, it starts without a swap file.  b_may_swap is
  1154.      * then set to indicate that a swap file may be opened later.  It is reset
  1155.      * if a swap file could not be opened.
  1156.      */
  1157.     int        b_may_swap;
  1158.     int        b_did_warn;    /* Set to 1 if user has been warned on first
  1159.                    change of a read-only file */
  1160.     int        b_help;        /* buffer for help file (when set b_p_bt is
  1161.                    "help") */
  1162.  
  1163. #ifndef SHORT_FNAME
  1164.     int        b_shortname;    /* this file has an 8.3 file name */
  1165. #endif
  1166.  
  1167. #ifdef FEAT_PERL
  1168.     void    *perl_private;
  1169. #endif
  1170.  
  1171. #ifdef FEAT_PYTHON
  1172.     void    *python_ref;    /* The Python value referring to this buffer */
  1173. #endif
  1174.  
  1175. #ifdef FEAT_TCL
  1176.     void    *tcl_ref;
  1177. #endif
  1178.  
  1179. #ifdef FEAT_RUBY
  1180.     void    *ruby_ref;
  1181. #endif
  1182.  
  1183. #ifdef FEAT_SYN_HL
  1184.     keyentry_T    **b_keywtab;        /* syntax keywords hash table */
  1185.     keyentry_T    **b_keywtab_ic;        /* idem, ignore case */
  1186.     int        b_syn_ic;        /* ignore case for :syn cmds */
  1187.     garray_T    b_syn_patterns;        /* table for syntax patterns */
  1188.     garray_T    b_syn_clusters;        /* table for syntax clusters */
  1189.     int        b_syn_containedin;    /* TRUE when there is an item with a
  1190.                        "containedin" argument */
  1191.     int        b_syn_sync_flags;    /* flags about how to sync */
  1192.     short    b_syn_sync_id;        /* group to sync on */
  1193.     long    b_syn_sync_minlines;    /* minimal sync lines offset */
  1194.     long    b_syn_sync_maxlines;    /* maximal sync lines offset */
  1195.     long    b_syn_sync_linebreaks;    /* offset for multi-line pattern */
  1196.     char_u    *b_syn_linecont_pat;    /* line continuation pattern */
  1197.     regprog_T    *b_syn_linecont_prog;    /* line continuation program */
  1198.     int        b_syn_linecont_ic;    /* ignore-case flag for above */
  1199.     int        b_syn_topgrp;        /* for ":syntax include" */
  1200. # ifdef FEAT_FOLDING
  1201.     int        b_syn_folditems;    /* number of patterns with the HL_FOLD
  1202.                        flag set */
  1203. # endif
  1204. /*
  1205.  * b_sst_array[] contains the state stack for a number of lines, for the start
  1206.  * of that line (col == 0).  This avoids having to recompute the syntax state
  1207.  * too often.
  1208.  * b_sst_array[] is allocated to hold the state for all displayed lines, and
  1209.  * states for 1 out of about 20 other lines.
  1210.  * b_sst_array        pointer to an array of synstate_T
  1211.  * b_sst_len        number of entries in b_sst_array[]
  1212.  * b_sst_first        pointer to first used entry in b_sst_array[] or NULL
  1213.  * b_sst_firstfree    pointer to first free entry in b_sst_array[] or NULL
  1214.  * b_sst_freecount    number of free entries in b_sst_array[]
  1215.  * b_sst_check_lnum    entries after this lnum need to be checked for
  1216.  *            validity (MAXLNUM means no check needed)
  1217.  */
  1218.     synstate_T    *b_sst_array;
  1219.     int        b_sst_len;
  1220.     synstate_T    *b_sst_first;
  1221.     synstate_T    *b_sst_firstfree;
  1222.     int        b_sst_freecount;
  1223.     linenr_T    b_sst_check_lnum;
  1224.     short_u    b_sst_lasttick;    /* last display tick */
  1225. #endif /* FEAT_SYN_HL */
  1226.  
  1227. #ifdef FEAT_SIGNS
  1228.     signlist_T    *b_signlist;    /* list of signs to draw */
  1229. #endif
  1230.  
  1231. };
  1232.  
  1233. /*
  1234.  * Structure to cache info for displayed lines in w_lines[].
  1235.  * Each logical line has one entry.
  1236.  * The entry tells how the logical line is currently displayed in the window.
  1237.  * This is updated when displaying the window.
  1238.  * When the display is changed (e.g., when clearing the screen) w_lines_valid
  1239.  * is changed to exclude invalid entries.
  1240.  * When making changes to the buffer, wl_valid is reset to indicate wl_size
  1241.  * may not reflect what is actually in the buffer.  When wl_valid is FALSE,
  1242.  * the entries can only be used to count the number of displayed lines used.
  1243.  * wl_lnum and wl_lastlnum are invalid too.
  1244.  */
  1245. typedef struct w_line
  1246. {
  1247.     linenr_T    wl_lnum;    /* buffer line number for logical line */
  1248.     short_u    wl_size;    /* height in screen lines */
  1249.     char    wl_valid;    /* TRUE values are valid for text in buffer */
  1250. #ifdef FEAT_FOLDING
  1251.     char    wl_folded;    /* TRUE when this is a range of folded lines */
  1252.     linenr_T    wl_lastlnum;    /* last buffer line number for logical line */
  1253. #endif
  1254. } wline_T;
  1255.  
  1256. /*
  1257.  * Windows are kept in a tree of frames.  Each frame has a column (FR_COL)
  1258.  * or row (FR_ROW) layout or is a leaf, which has a window.
  1259.  */
  1260. struct frame
  1261. {
  1262.     char    fr_layout;    /* FR_LEAF, FR_COL or FR_ROW */
  1263. #ifdef FEAT_VERTSPLIT
  1264.     int        fr_width;
  1265. #endif
  1266.     int        fr_height;
  1267.     int        fr_newheight;    /* new height used in win_equal_rec() */
  1268.     frame_T    *fr_parent;    /* containing frame or NULL */
  1269.     frame_T    *fr_next;    /* frame right or below in same parent, NULL
  1270.                    for first */
  1271.     frame_T    *fr_prev;    /* frame left or above in same parent, NULL
  1272.                    for last */
  1273.     /* fr_child and fr_win are mutually exclusive */
  1274.     frame_T    *fr_child;    /* first contained frame */
  1275.     win_T    *fr_win;    /* window that fills this frame */
  1276. };
  1277.  
  1278. #define FR_LEAF    0    /* frame is a leaf */
  1279. #define FR_ROW    1    /* frame with a row of windows */
  1280. #define FR_COL    2    /* frame with a column of windows */
  1281.  
  1282. /*
  1283.  * Structure which contains all information that belongs to a window
  1284.  *
  1285.  * All row numbers are relative to the start of the window, except w_winrow.
  1286.  */
  1287. struct window
  1288. {
  1289.     buf_T    *w_buffer;        /* buffer we are a window into (used
  1290.                        often, keep it the first item!) */
  1291.  
  1292. #ifdef FEAT_WINDOWS
  1293.     win_T    *w_prev;        /* link to previous window */
  1294.     win_T    *w_next;        /* link to next window */
  1295. #endif
  1296.  
  1297.     frame_T    *w_frame;        /* frame containing this window */
  1298.  
  1299.     pos_T    w_cursor;        /* cursor position in buffer */
  1300.  
  1301.     colnr_T    w_curswant;        /* The column we'd like to be at.  This is
  1302.                        used to try to stay in the same column
  1303.                        for up/down cursor motions. */
  1304.  
  1305.     int        w_set_curswant;        /* If set, then update w_curswant the next
  1306.                        time through cursupdate() to the
  1307.                        current virtual column */
  1308.  
  1309. #ifdef FEAT_VISUAL
  1310.     /*
  1311.      * the next six are used to update the visual part
  1312.      */
  1313.     char    w_old_visual_mode;  /* last known VIsual_mode */
  1314.     linenr_T    w_old_cursor_lnum;  /* last known end of visual part */
  1315.     colnr_T    w_old_cursor_fcol;  /* first column for block visual part */
  1316.     colnr_T    w_old_cursor_lcol;  /* last column for block visual part */
  1317.     linenr_T    w_old_visual_lnum;  /* last known start of visual part */
  1318.     colnr_T    w_old_curswant;        /* last known value of Curswant */
  1319. #endif
  1320.  
  1321.     /*
  1322.      * The next three specify the offsets for displaying the buffer:
  1323.      */
  1324.     linenr_T    w_topline;        /* buffer line number of the line at the
  1325.                        top of the window */
  1326. #ifdef FEAT_DIFF
  1327.     int        w_topfill;        /* number of filler lines above w_topline */
  1328.     int        w_old_topfill;        /* w_topfill at last redraw */
  1329.     int        w_botfill;        /* TRUE when filler lines are actually
  1330.                        below w_topline (at end of file) */
  1331.     int        w_old_botfill;        /* w_botfill at last redraw */
  1332. #endif
  1333.     colnr_T    w_leftcol;        /* window column number of the left most
  1334.                        character in the window; used when
  1335.                        'wrap' is off */
  1336.     colnr_T    w_skipcol;        /* starting column when a single line
  1337.                        doesn't fit in the window */
  1338.  
  1339.     /*
  1340.      * Layout of the window in the screen.
  1341.      * May need to add "msg_scrolled" to "w_winrow" in rare situations.
  1342.      */
  1343. #ifdef FEAT_WINDOWS
  1344.     int        w_winrow;        /* first row of window in screen */
  1345. #endif
  1346.     int        w_height;        /* number of rows in window, excluding
  1347.                        status/command line(s) */
  1348. #ifdef FEAT_WINDOWS
  1349.     int        w_status_height;    /* number of status lines (0 or 1) */
  1350. #endif
  1351. #ifdef FEAT_VERTSPLIT
  1352.     int        w_wincol;        /* Leftmost column of window in screen.
  1353.                        use W_WINCOL() */
  1354.     int        w_width;        /* Width of window, excluding separation.
  1355.                        use W_WIDTH() */
  1356.     int        w_vsep_width;        /* Number of separator columns (0 or 1).
  1357.                        use W_VSEP_WIDTH() */
  1358. #endif
  1359.  
  1360.     /*
  1361.      * === start of cached values ====
  1362.      */
  1363.     /*
  1364.      * Recomputing is minimized by storing the result of computations.
  1365.      * Use functions in screen.c to check if they are valid and to update.
  1366.      * w_valid is a bitfield of flags, which indicate if specific values are
  1367.      * valid or need to be recomputed.    See screen.c for values.
  1368.      */
  1369.     int        w_valid;
  1370.     pos_T    w_valid_cursor;        /* last known position of w_cursor, used
  1371.                        to adjust w_valid */
  1372.     colnr_T    w_valid_leftcol;    /* last known w_leftcol */
  1373.  
  1374.     /*
  1375.      * w_cline_height is the number of physical lines taken by the buffer line
  1376.      * that the cursor is on.  We use this to avoid extra calls to plines().
  1377.      */
  1378.     int        w_cline_height;        /* current size of cursor line */
  1379. #ifdef FEAT_FOLDING
  1380.     int        w_cline_folded;        /* cursor line is folded */
  1381. #endif
  1382.  
  1383.     int        w_cline_row;        /* starting row of the cursor line */
  1384.  
  1385.     colnr_T    w_virtcol;        /* column number of the cursor in the
  1386.                        buffer line, as opposed to the column
  1387.                        number we're at on the screen.  This
  1388.                        makes a difference on lines which span
  1389.                        more than one screen line or when
  1390.                        w_leftcol is non-zero */
  1391.  
  1392.     /*
  1393.      * w_wrow and w_wcol specify the cursor position in the window.
  1394.      * This is related to positions in the window, not in the display or
  1395.      * buffer, thus w_wrow is relative to w_winrow.
  1396.      */
  1397.     int        w_wrow, w_wcol;        /* cursor position in window */
  1398.  
  1399.     linenr_T    w_botline;        /* number of the line below the bottom of
  1400.                        the screen */
  1401.     int        w_empty_rows;        /* number of ~ rows in window */
  1402. #ifdef FEAT_DIFF
  1403.     int        w_filler_rows;        /* number of filler rows at the end of the
  1404.                        window */
  1405. #endif
  1406.  
  1407.     /*
  1408.      * Info about the lines currently in the window is remembered to avoid
  1409.      * recomputing it every time.  The allocated size of w_lines[] is Rows.
  1410.      * Only the w_lines_valid entries are actually valid.
  1411.      * When the display is up-to-date w_lines[0].wl_lnum is equal to w_topline
  1412.      * and w_lines[w_lines_valid - 1].wl_lnum is equal to w_botline.
  1413.      * Between changing text and updating the display w_lines[] represents
  1414.      * what is currently displayed.  wl_valid is reset to indicated this.
  1415.      * This is used for efficient redrawing.
  1416.      */
  1417.     int        w_lines_valid;        /* number of valid entries */
  1418.     wline_T    *w_lines;
  1419.  
  1420. #ifdef FEAT_FOLDING
  1421.     garray_T    w_folds;        /* array of nested folds */
  1422.     char    w_fold_manual;        /* when TRUE: some folds are opened/closed
  1423.                        manually */
  1424.     char    w_foldinvalid;        /* when TRUE: folding needs to be
  1425.                        recomputed */
  1426. #endif
  1427.  
  1428.     /*
  1429.      * === end of cached values ===
  1430.      */
  1431.  
  1432.     int        w_redr_type;        /* type of redraw to be performed on win */
  1433.     int        w_upd_rows;        /* number of window lines to update when
  1434.                        w_redr_type is REDRAW_TOP */
  1435.     linenr_T    w_redraw_top;        /* when != 0: first line needing redraw */
  1436.     linenr_T    w_redraw_bot;        /* when != 0: last line needing redraw */
  1437. #ifdef FEAT_WINDOWS
  1438.     int        w_redr_status;        /* if TRUE status line must be redrawn */
  1439. #endif
  1440.  
  1441. #ifdef FEAT_CMDL_INFO
  1442.     /* remember what is shown in the ruler for this window (if 'ruler' set) */
  1443.     pos_T    w_ru_cursor;        /* cursor position shown in ruler */
  1444.     colnr_T    w_ru_virtcol;        /* virtcol shown in ruler */
  1445.     linenr_T    w_ru_topline;        /* topline shown in ruler */
  1446. # ifdef FEAT_DIFF
  1447.     int        w_ru_topfill;        /* topfill shown in ruler */
  1448. # endif
  1449.     char    w_ru_empty;        /* TRUE if ruler shows 0-1 (empty line) */
  1450. #endif
  1451.  
  1452.     int        w_alt_fnum;        /* alternate file (for # and CTRL-^) */
  1453.  
  1454. #ifdef FEAT_WINDOWS
  1455.     alist_T    *w_alist;        /* pointer to arglist for this window */
  1456. #endif
  1457.     int        w_arg_idx;        /* current index in argument list (can be
  1458.                        out of range!) */
  1459.     int        w_arg_idx_invalid;  /* editing another file then w_arg_idx */
  1460.  
  1461.     char_u    *w_localdir;        /* absolute path of local directory or
  1462.                        NULL */
  1463.     /*
  1464.      * Options local to a window.
  1465.      * They are local because they influence the layout of the window or
  1466.      * depend on the window layout.
  1467.      * There are two values: w_onebuf_opt is local to the buffer currently in
  1468.      * this window, w_allbuf_opt is for all buffers in this window.
  1469.      */
  1470.     winopt_T    w_onebuf_opt;
  1471.     winopt_T    w_allbuf_opt;
  1472.  
  1473.     /* transfor a pointer to a "onebuf" option to a "allbuf" option */
  1474. #define GLOBAL_WO(p)    ((char *)p + sizeof(winopt_T))
  1475.  
  1476. #ifdef FEAT_SCROLLBIND
  1477.     long    w_scbind_pos;
  1478. #endif
  1479.  
  1480. #ifdef FEAT_EVAL
  1481.     garray_T    w_vars;        /* internal variables, local to window */
  1482. #endif
  1483.  
  1484. #if defined(FEAT_RIGHTLEFT) && defined(FEAT_FKMAP)
  1485.     int        w_farsi;    /* for the window dependent Farsi functions */
  1486. #endif
  1487.  
  1488.     /*
  1489.      * The w_prev_pcmark field is used to check whether we really did jump to
  1490.      * a new line after setting the w_pcmark.  If not, then we revert to
  1491.      * using the previous w_pcmark.
  1492.      */
  1493.     pos_T    w_pcmark;    /* previous context mark */
  1494.     pos_T    w_prev_pcmark;    /* previous w_pcmark */
  1495.  
  1496. #ifdef FEAT_JUMPLIST
  1497.     /*
  1498.      * the jumplist contains old cursor positions
  1499.      */
  1500.     xfmark_T    w_jumplist[JUMPLISTSIZE];
  1501.     int        w_jumplistlen;        /* number of active entries */
  1502.     int        w_jumplistidx;        /* current position */
  1503. #endif
  1504.  
  1505. #ifdef FEAT_SEARCH_EXTRA
  1506.     regmmatch_T    w_match;    /* regexp program for ":match" */
  1507.     int        w_match_id;    /* highlight ID for ":match" */
  1508. #endif
  1509.  
  1510.     /*
  1511.      * the tagstack grows from 0 upwards:
  1512.      * entry 0: older
  1513.      * entry 1: newer
  1514.      * entry 2: newest
  1515.      */
  1516.     taggy_T    w_tagstack[TAGSTACKSIZE];    /* the tag stack */
  1517.     int        w_tagstackidx;        /* idx just below activ entry */
  1518.     int        w_tagstacklen;        /* number of tags on stack */
  1519.  
  1520.     /*
  1521.      * w_fraction is the fractional row of the cursor within the window, from
  1522.      * 0 at the top row to FRACTION_MULT at the last row.
  1523.      * w_prev_fraction_row was the actual cursor row when w_fraction was last
  1524.      * calculated.
  1525.      */
  1526.     int        w_fraction;
  1527.     int        w_prev_fraction_row;
  1528.  
  1529. #ifdef FEAT_GUI
  1530.     scrollbar_T    w_scrollbars[2];    /* vert. Scrollbars for this window */
  1531. #endif
  1532.  
  1533. #ifdef FEAT_PERL
  1534.     void    *perl_private;
  1535. #endif
  1536.  
  1537. #ifdef FEAT_PYTHON
  1538.     void    *python_ref;    /* The Python value referring to this
  1539.                        window */
  1540. #endif
  1541.  
  1542. #ifdef FEAT_TCL
  1543.     void    *tcl_ref;
  1544. #endif
  1545.  
  1546. #ifdef FEAT_RUBY
  1547.     void    *ruby_ref;
  1548. #endif
  1549. };
  1550.  
  1551. /*
  1552.  * Arguments for operators.
  1553.  */
  1554. typedef struct oparg
  1555. {
  1556.     int        op_type;    /* current pending operator type */
  1557.     int        regname;    /* register to use for the operator */
  1558.     int        motion_type;    /* type of the current cursor motion */
  1559.     int        motion_force;    /* force motion type: 'v', 'V' or CTRL-V */
  1560.     int        use_reg_one;    /* TRUE if delete uses reg 1 even when not
  1561.                    linewise */
  1562.     int        inclusive;    /* TRUE if char motion is inclusive (only
  1563.                    valid when motion_type is MCHAR */
  1564.     int        end_adjusted;    /* backuped b_op_end one char (only used by
  1565.                    do_format()) */
  1566.     pos_T    start;        /* start of the operator */
  1567.     pos_T    end;        /* end of the operator */
  1568.  
  1569.     long    line_count;    /* number of lines from op_start to op_end
  1570.                    (inclusive) */
  1571.     int        empty;        /* op_start and op_end the same (only used by
  1572.                    do_change()) */
  1573. #ifdef FEAT_VISUAL
  1574.     int        is_VIsual;    /* operator on Visual area */
  1575.     int        block_mode;    /* current operator is Visual block mode */
  1576. #endif
  1577.     colnr_T    start_vcol;    /* start col for block mode operator */
  1578.     colnr_T    end_vcol;    /* end col for block mode operator */
  1579. } oparg_T;
  1580.  
  1581. /*
  1582.  * Arguments for Normal mode commands.
  1583.  */
  1584. typedef struct cmdarg
  1585. {
  1586.     oparg_T    *oap;        /* Operator arguments */
  1587.     int        prechar;    /* prefix character (optional, always 'g') */
  1588.     int        cmdchar;    /* command character */
  1589.     int        nchar;        /* next command character (optional) */
  1590. #ifdef FEAT_MBYTE
  1591.     int        ncharC1;    /* first composing character (optional) */
  1592.     int        ncharC2;    /* second composing character (optional) */
  1593. #endif
  1594.     int        extra_char;    /* yet another character (optional) */
  1595.     long    opcount;    /* count before an operator */
  1596.     long    count0;        /* count before command, default 0 */
  1597.     long    count1;        /* count before command, default 1 */
  1598.     int        arg;        /* extra argument from nv_cmds[] */
  1599.     int        retval;        /* return: CA_* values */
  1600.     char_u    *searchbuf;    /* return: pointer to search pattern or NULL */
  1601. } cmdarg_T;
  1602.  
  1603. /* values for retval: */
  1604. #define CA_COMMAND_BUSY        1    /* skip restarting edit() once */
  1605. #define CA_NO_ADJ_OP_END    2    /* don't adjust operator end */
  1606.  
  1607. #ifdef CURSOR_SHAPE
  1608. /*
  1609.  * struct to store values from 'guicursor' and 'mouseshape'
  1610.  */
  1611. /* Indexes in shape_table[] */
  1612. #define SHAPE_IDX_N    0    /* Normal mode */
  1613. #define SHAPE_IDX_V    1    /* Visual mode */
  1614. #define SHAPE_IDX_I    2    /* Insert mode */
  1615. #define SHAPE_IDX_R    3    /* Replace mode */
  1616. #define SHAPE_IDX_C    4    /* Command line Normal mode */
  1617. #define SHAPE_IDX_CI    5    /* Command line Insert mode */
  1618. #define SHAPE_IDX_CR    6    /* Command line Replace mode */
  1619. #define SHAPE_IDX_O    7    /* Operator-pending mode */
  1620. #define SHAPE_IDX_VE    8    /* Visual mode with 'seleciton' exclusive */
  1621. #define SHAPE_IDX_CLINE    9    /* On command line */
  1622. #define SHAPE_IDX_STATUS 10    /* A status line */
  1623. #define SHAPE_IDX_SDRAG 11    /* dragging a status line */
  1624. #define SHAPE_IDX_VSEP    12    /* A vertical separator line */
  1625. #define SHAPE_IDX_VDRAG 13    /* dragging a vertical separator line */
  1626. #define SHAPE_IDX_MORE    14    /* Hit-return or More */
  1627. #define SHAPE_IDX_MOREL    15    /* Hit-return or More in last line */
  1628. #define SHAPE_IDX_SM    16    /* showing matching paren */
  1629. #define SHAPE_IDX_COUNT    17
  1630.  
  1631. #define SHAPE_BLOCK    0    /* block cursor */
  1632. #define SHAPE_HOR    1    /* horizontal bar cursor */
  1633. #define SHAPE_VER    2    /* vertical bar cursor */
  1634.  
  1635. #define MSHAPE_NUMBERED    1000    /* offset for shapes identified by number */
  1636. #define MSHAPE_HIDE    1    /* hide mouse pointer */
  1637.  
  1638. #define SHAPE_MOUSE    1    /* used for mouse pointer shape */
  1639. #define SHAPE_CURSOR    2    /* used for text cursor shape */
  1640.  
  1641. typedef struct cursor_entry
  1642. {
  1643.     int        shape;        /* one of the SHAPE_ defines */
  1644.     int        mshape;        /* one of the MSHAPE defines */
  1645.     int        percentage;    /* percentage of cell for bar */
  1646.     long    blinkwait;    /* blinking, wait time before blinking starts */
  1647.     long    blinkon;    /* blinking, on time */
  1648.     long    blinkoff;    /* blinking, off time */
  1649.     int        id;        /* highlight group ID */
  1650.     int        id_lm;        /* highlight group ID for :lmap mode */
  1651.     char    *name;        /* mode name (fixed) */
  1652.     char    used_for;    /* SHAPE_MOUSE and/or SHAPE_CURSOR */
  1653. } cursorentry_T;
  1654. #endif /* CURSOR_SHAPE */
  1655.  
  1656. #ifdef FEAT_MENU
  1657.  
  1658. /* Indices into vimmenu_T->strings[] and vimmenu_T->noremap[] for each mode */
  1659. #define MENU_INDEX_INVALID    -1
  1660. #define MENU_INDEX_NORMAL    0
  1661. #define MENU_INDEX_VISUAL    1
  1662. #define MENU_INDEX_OP_PENDING    2
  1663. #define MENU_INDEX_INSERT    3
  1664. #define MENU_INDEX_CMDLINE    4
  1665. #define MENU_INDEX_TIP        5
  1666. #define MENU_MODES        6
  1667.  
  1668. /* Menu modes */
  1669. #define MENU_NORMAL_MODE    (1 << MENU_INDEX_NORMAL)
  1670. #define MENU_VISUAL_MODE    (1 << MENU_INDEX_VISUAL)
  1671. #define MENU_OP_PENDING_MODE    (1 << MENU_INDEX_OP_PENDING)
  1672. #define MENU_INSERT_MODE    (1 << MENU_INDEX_INSERT)
  1673. #define MENU_CMDLINE_MODE    (1 << MENU_INDEX_CMDLINE)
  1674. #define MENU_TIP_MODE        (1 << MENU_INDEX_TIP)
  1675. #define MENU_ALL_MODES        ((1 << MENU_INDEX_TIP) - 1)
  1676. /*note MENU_INDEX_TIP is not a 'real' mode*/
  1677.  
  1678. /* Start a menu name with this to not include it on the main menu bar */
  1679. #define MNU_HIDDEN_CHAR        ']'
  1680.  
  1681. typedef struct VimMenu vimmenu_T;
  1682.  
  1683. struct VimMenu
  1684. {
  1685.     int        modes;            /* Which modes is this menu visible for? */
  1686.     int        enabled;        /* for which modes the menu is enabled */
  1687.     char_u    *name;            /* Name of menu */
  1688.     char_u    *dname;            /* Displayed Name (without '&') */
  1689.     int        mnemonic;        /* mnemonic key (after '&') */
  1690.     char_u    *actext;        /* accelerator text (after TAB) */
  1691.     int        priority;        /* Menu order priority */
  1692. #ifdef FEAT_GUI
  1693.     void    (*cb)();        /* Call-back routine */
  1694. #endif
  1695. #ifdef FEAT_TOOLBAR
  1696.     char_u    *iconfile;        /* name of file for icon or NULL */
  1697.     int        iconidx;        /* icon index (-1 if not set) */
  1698.     int        icon_builtin;        /* icon names is BuiltIn{nr} */
  1699. #endif
  1700.     char_u    *strings[MENU_MODES]; /* Mapped string for each mode */
  1701.     int        noremap[MENU_MODES]; /* A REMAP_ flag for each mode */
  1702.     char    silent[MENU_MODES]; /* A silent flag for each mode */
  1703.     vimmenu_T    *children;        /* Children of sub-menu */
  1704.     vimmenu_T    *parent;        /* Parent of menu */
  1705.     vimmenu_T    *next;            /* Next item in menu */
  1706. #ifdef FEAT_GUI_X11
  1707.     Widget    id;            /* Manage this to enable item */
  1708.     Widget    submenu_id;        /* If this is submenu, add children here */
  1709. #endif
  1710. #ifdef FEAT_GUI_GTK
  1711.     GtkWidget    *id;            /* Manage this to enable item */
  1712.     GtkWidget    *submenu_id;        /* If this is submenu, add children here */
  1713.     GtkWidget    *tearoff_handle;
  1714.     GtkWidget   *label;            /* Used by "set wak=" code. */
  1715. #endif
  1716. #ifdef FEAT_GUI_MOTIF
  1717.     int        sensitive;        /* turn button on/off */
  1718. #endif
  1719. #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF)
  1720.     Pixmap    image;            /* Toolbar image */
  1721. #endif
  1722. #ifdef FEAT_GUI_MOTIF
  1723.     Pixmap    image_ins;        /* Toolbar image insensitive */
  1724. #endif
  1725. #ifdef FEAT_BEVAL_TIP
  1726.     BalloonEval *tip;            /* tooltip for this menu item */
  1727. #endif
  1728. #ifdef FEAT_GUI_W16
  1729.     UINT    id;            /* Id of menu item */
  1730.     HMENU    submenu_id;        /* If this is submenu, add children here */
  1731. #endif
  1732. #ifdef FEAT_GUI_W32
  1733.     UINT    id;            /* Id of menu item */
  1734.     HMENU    submenu_id;        /* If this is submenu, add children here */
  1735.     HWND    tearoff_handle;        /* hWnd of tearoff if created */
  1736. #endif
  1737. #if FEAT_GUI_BEOS
  1738.     BMenuItem    *id;            /* Id of menu item */
  1739.     BMenu    *submenu_id;        /* If this is submenu, add children here */
  1740. #endif
  1741. #ifdef FEAT_GUI_MAC
  1742. /*  MenuHandle    id; */
  1743. /*  short    index;    */        /* the item index within the father menu */
  1744.     short    menu_id;        /* the menu id to which this item belong */
  1745.     short    submenu_id;        /* the menu id of the children (could be
  1746.                        get throught some tricks) */
  1747.     MenuHandle    menu_handle;
  1748.     MenuHandle    submenu_handle;
  1749. #endif
  1750. #if defined(FEAT_GUI_AMIGA)
  1751.                     /* only one of these will ever be set, but
  1752.                      * they are used to allow the menu routine
  1753.                      * to easily get a hold of the parent menu
  1754.                      * pointer which is needed by all items to
  1755.                      * form the chain correctly */
  1756.     int            id;            /* unused by the amiga, but used in the
  1757.                      * code kept for compatibility */
  1758.     struct Menu        *menuPtr;
  1759.     struct MenuItem *menuItemPtr;
  1760. #endif
  1761. #ifdef RISCOS
  1762.     int        *id;            /* Not used, but gui.c needs it */
  1763.     int        greyed_out;        /* Flag */
  1764.     int        hidden;
  1765. #endif
  1766. #ifdef FEAT_GUI_PHOTON
  1767.     PtWidget_t    *id;
  1768.     PtWidget_t    *submenu_id;
  1769. #endif
  1770. };
  1771. #else
  1772. /* For generating prototypes when FEAT_MENU isn't defined. */
  1773. typedef int vimmenu_T;
  1774.  
  1775. #endif /* FEAT_MENU */
  1776.  
  1777. /*
  1778.  * Struct to save values in before executing autocommands for a buffer that is
  1779.  * not the current buffer.
  1780.  */
  1781. typedef struct
  1782. {
  1783.     buf_T    *save_buf;    /* saved curbuf */
  1784.     buf_T    *new_curbuf;    /* buffer to be used */
  1785.     win_T    *save_curwin;    /* saved curwin, NULL if it didn't change */
  1786.     win_T    *new_curwin;    /* new curwin if save_curwin != NULL */
  1787.     pos_T    save_cursor;    /* saved cursor pos of save_curwin */
  1788.     linenr_T    save_topline;    /* saved topline of save_curwin */
  1789. #ifdef FEAT_DIFF
  1790.     int        save_topfill;    /* saved topfill of save_curwin */
  1791. #endif
  1792. } aco_save_T;
  1793.  
  1794. /*
  1795.  * Generic option table item, only used for printer at the moment.
  1796.  */
  1797. typedef struct
  1798. {
  1799.     const char    *name;
  1800.     int        hasnum;
  1801.     long    number;
  1802.     char_u    *string;    /* points into option string */
  1803.     int        strlen;
  1804.     int        present;
  1805. } option_table_T;
  1806.  
  1807. /*
  1808.  * Structure to hold printing color and font attributes.
  1809.  */
  1810. typedef struct
  1811. {
  1812.     long_u    fg_color;
  1813.     long_u    bg_color;
  1814.     int        bold;
  1815.     int        italic;
  1816.     int        underline;
  1817. } prt_text_attr_T;
  1818.  
  1819. /*
  1820.  * Structure passed back to the generic printer code.
  1821.  */
  1822. typedef struct
  1823. {
  1824.     int        n_collated_copies;
  1825.     int        n_uncollated_copies;
  1826.     int        duplex;
  1827.     int        chars_per_line;
  1828.     int        lines_per_page;
  1829.     int        has_color;
  1830.     prt_text_attr_T number;
  1831. #ifdef FEAT_SYN_HL
  1832.     int        modec;
  1833.     int        do_syntax;
  1834. #endif
  1835.     int        user_abort;
  1836.     char_u    *jobname;
  1837. #ifdef FEAT_POSTSCRIPT
  1838.     char_u    *outfile;
  1839.     char_u    *arguments;
  1840. #endif
  1841. } prt_settings_T;
  1842.  
  1843. #define PRINT_NUMBER_WIDTH 8
  1844.