robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
31.7 KiB718 linesraw
1#pragma once
2
3#include <inttypes.h>
4#include <stdbool.h>
5
6#include "nvim/arglist_defs.h"
7#include "nvim/ascii_defs.h"
8#include "nvim/event/loop.h"
9#include "nvim/ex_cmds_defs.h"
10#include "nvim/ex_eval_defs.h"
11#include "nvim/iconv_defs.h"
12#include "nvim/input_defs.h"
13#include "nvim/insert_defs.h"
14#include "nvim/macros_defs.h"
15#include "nvim/menu_defs.h"
16#include "nvim/normal_defs.h"
17#include "nvim/os/os_defs.h"
18#include "nvim/runtime_defs.h"
19#include "nvim/search_defs.h"
20#include "nvim/state_defs.h"
21#include "nvim/syntax_defs.h"
22#include "nvim/types_defs.h"
23
24#define IOSIZE         (1024 + 1)          // file I/O and sprintf buffer size
25
26#define MSG_BUF_LEN 480                 // length of buffer for small messages
27#define MSG_BUF_CLEN  (MSG_BUF_LEN / 6)  // cell length (worst case: utf-8
28                                         // takes 6 bytes for one cell)
29
30// FILETYPE_FILE        used for file type detection
31// FTPLUGIN_FILE        used for loading filetype plugin files
32// INDENT_FILE          used for loading indent files
33// FTOFF_FILE           used for file type detection
34// FTPLUGOF_FILE        used for loading settings files
35// INDOFF_FILE          used for loading indent files
36
37#ifndef FILETYPE_FILE
38# define FILETYPE_FILE  "filetype.lua filetype.vim"
39#endif
40
41#ifndef FTPLUGIN_FILE
42# define FTPLUGIN_FILE  "ftplugin.vim"
43#endif
44
45#ifndef INDENT_FILE
46# define INDENT_FILE    "indent.vim"
47#endif
48
49#ifndef FTOFF_FILE
50# define FTOFF_FILE     "ftoff.vim"
51#endif
52
53#ifndef FTPLUGOF_FILE
54# define FTPLUGOF_FILE  "ftplugof.vim"
55#endif
56
57#ifndef INDOFF_FILE
58# define INDOFF_FILE    "indoff.vim"
59#endif
60
61#define DFLT_ERRORFILE  "errors.err"
62
63#ifndef SYS_VIMRC_FILE
64# define SYS_VIMRC_FILE "$VIM/sysinit.vim"
65#endif
66
67#ifndef DFLT_HELPFILE
68# define DFLT_HELPFILE  "$VIMRUNTIME/doc/help.txt"
69#endif
70
71#ifndef SYNTAX_FNAME
72# define SYNTAX_FNAME   "$VIMRUNTIME/syntax/%s.vim"
73#endif
74
75#ifndef EXRC_FILE
76# define EXRC_FILE      ".exrc"
77#endif
78
79#ifndef VIMRC_FILE
80# define VIMRC_FILE     ".nvimrc"
81#endif
82
83#ifndef VIMRC_LUA_FILE
84# define VIMRC_LUA_FILE ".nvim.lua"
85#endif
86
87EXTERN struct nvim_stats_s {
88  int64_t fsync;
89  int64_t redraw;
90  int16_t log_skip;  // How many logs were tried and skipped before log_init.
91} g_stats INIT( = { 0, 0, 0 });
92
93// Values for "starting".
94#define NO_SCREEN       2       // no screen updating yet
95#define NO_BUFFERS      1       // not all buffers loaded yet
96//                      0          not starting anymore
97
98// Number of Rows and Columns in the screen.
99// Note: Use default_grid.rows and default_grid.cols to access items in
100// default_grid.chars[]. They may have different values when the screen
101// wasn't (re)allocated yet after setting Rows or Columns (e.g., when starting
102// up).
103#define DFLT_COLS       80              // default value for 'columns'
104#define DFLT_ROWS       24              // default value for 'lines'
105EXTERN int Rows INIT( = DFLT_ROWS);     // nr of rows in the screen
106EXTERN int Columns INIT( = DFLT_COLS);  // nr of columns in the screen
107
108// When vgetc() is called, it sets mod_mask to the set of modifiers that are
109// held down based on the MOD_MASK_* symbols that are read first.
110EXTERN int mod_mask INIT( = 0);  // current key modifiers
111
112// The value of "mod_mask" and the unmodified character in vgetc() after it has
113// called vgetorpeek() enough times.
114EXTERN int vgetc_mod_mask INIT( = 0);
115EXTERN int vgetc_char INIT( = 0);
116
117// Cmdline_row is the row where the command line starts, just below the
118// last window.
119// When the cmdline gets longer than the available space the screen gets
120// scrolled up. After a CTRL-D (show matches), after hitting ':' after
121// "hit return", and for the :global command, the command line is
122// temporarily moved.  The old position is restored with the next call to
123// update_screen().
124EXTERN int cmdline_row;
125
126EXTERN bool redraw_cmdline INIT( = false);          // cmdline must be redrawn
127EXTERN bool redraw_mode INIT( = false);             // mode must be redrawn
128EXTERN bool clear_cmdline INIT( = false);           // cmdline must be cleared
129EXTERN bool mode_displayed INIT( = false);          // mode is being displayed
130EXTERN int cmdline_star INIT( = 0);                 // cmdline is encrypted
131EXTERN bool redrawing_cmdline INIT( = false);       // cmdline is being redrawn
132EXTERN bool cmdline_was_last_drawn INIT( = false);  // cmdline was last drawn
133
134EXTERN bool exec_from_reg INIT( = false);         // executing register
135
136// When '$' is included in 'cpoptions' option set:
137// When a change command is given that deletes only part of a line, a dollar
138// is put at the end of the changed text. dollar_vcol is set to the virtual
139// column of this '$'.  -1 is used to indicate no $ is being displayed.
140EXTERN colnr_T dollar_vcol INIT( = -1);
141
142// Variables for Insert mode completion.
143
144EXTERN char *edit_submode INIT( = NULL);         // msg for CTRL-X submode
145EXTERN char *edit_submode_pre INIT( = NULL);     // prepended to edit_submode
146EXTERN char *edit_submode_extra INIT( = NULL);   // appended to edit_submode
147EXTERN hlf_T edit_submode_highl;                // highl. method for extra info
148
149// state for putting characters in the message area
150EXTERN bool cmdmsg_rl INIT( = false);  // cmdline is drawn right to left
151EXTERN int msg_col;
152EXTERN int msg_row;
153EXTERN int msg_scrolled;  ///< Number of screen lines that messages have scrolled.
154// when true don't set need_wait_return in msg_puts_attr()
155// when msg_scrolled is non-zero
156EXTERN bool msg_scrolled_ign INIT( = false);
157// Whether the screen is damaged due to scrolling. Sometimes msg_scrolled
158// is reset before the screen is redrawn, so we need to keep track of this.
159EXTERN bool msg_did_scroll INIT( = false);
160
161EXTERN char *keep_msg INIT( = NULL);         // msg to be shown after redraw
162EXTERN int keep_msg_hl_id INIT( = 0);        // highlight id for keep_msg
163EXTERN bool need_fileinfo INIT( = false);    // do fileinfo() after redraw
164EXTERN int msg_scroll INIT( = false);        // msg_start() will scroll
165EXTERN bool msg_didout INIT( = false);       // msg_outstr() was used in line
166EXTERN bool msg_didany INIT( = false);       // msg_outstr() was used at all
167EXTERN bool msg_nowait INIT( = false);       // don't wait for this msg
168EXTERN int emsg_off INIT( = 0);              // don't display errors for now,
169                                             // unless 'debug' is set.
170EXTERN bool info_message INIT( = false);     // printing informative message
171EXTERN bool msg_hist_off INIT( = false);     // don't add messages to history
172EXTERN bool need_clr_eos INIT( = false);     // need to clear text before
173                                             // displaying a message.
174EXTERN int emsg_skip INIT( = 0);             // don't display errors for
175                                             // expression that is skipped
176EXTERN bool emsg_severe INIT( = false);      // use message of next of several
177                                             //  emsg() calls for throw
178// used by assert_fails()
179EXTERN char *emsg_assert_fails_msg INIT( = NULL);
180EXTERN long emsg_assert_fails_lnum INIT( = 0);
181EXTERN char *emsg_assert_fails_context INIT( = NULL);
182
183EXTERN bool did_endif INIT( = false);        // just had ":endif"
184EXTERN int did_emsg;                        // incremented by emsg() when a
185                                            // message is displayed or thrown
186EXTERN uint64_t did_beep;                   // Incremented by vim_beep(), if not silenced.
187EXTERN uint64_t did_beep_silent;            // Incremented by vim_beep(), if silenced (emsg_silent).
188EXTERN bool did_emsg_syntax;                // did_emsg set because of a
189                                            // syntax error
190EXTERN int called_emsg;                     // always incremented by emsg()
191EXTERN int ex_exitval INIT( = 0);            // exit value for ex mode
192EXTERN bool emsg_on_display INIT( = false);  // there is an error message
193EXTERN bool rc_did_emsg INIT( = false);      // vim_regcomp() called emsg()
194
195EXTERN int no_wait_return INIT( = 0);         // don't wait for return for now
196EXTERN bool need_wait_return INIT( = false);  // need to wait for return later
197EXTERN bool did_wait_return INIT( = false);   // wait_return() was used and
198                                              // nothing written since then
199EXTERN bool need_maketitle INIT( = true);     // call maketitle() soon
200
201EXTERN bool quit_more INIT( = false);        // 'q' hit at "--more--" msg
202EXTERN int vgetc_busy INIT( = 0);            // when inside vgetc() then > 0
203
204EXTERN bool didset_vim INIT( = false);         // did set $VIM ourselves
205EXTERN bool didset_vimruntime INIT( = false);  // idem for $VIMRUNTIME
206
207/// Lines left before a "more" message.  Ex mode needs to be able to reset this
208/// after you type something.
209EXTERN int lines_left INIT( = -1);           // lines left for listing
210EXTERN bool msg_no_more INIT( = false);      // don't use more prompt, truncate
211                                             // messages
212
213EXTERN int ex_nesting_level INIT( = 0);          // nesting level
214EXTERN int debug_break_level INIT( = -1);        // break below this level
215EXTERN bool debug_did_msg INIT( = false);        // did "debug mode" message
216EXTERN int debug_tick INIT( = 0);                // breakpoint change count
217EXTERN int debug_backtrace_level INIT( = 0);     // breakpoint backtrace level
218
219// Values for "do_profiling".
220#define PROF_NONE       0       ///< profiling not started
221#define PROF_YES        1       ///< profiling busy
222#define PROF_PAUSED     2       ///< profiling paused
223EXTERN int do_profiling INIT( = PROF_NONE);      ///< PROF_ values
224
225/// Exception currently being thrown.  Used to pass an exception to a different
226/// cstack.  Also used for discarding an exception before it is caught or made
227/// pending.  Only valid when did_throw is true.
228EXTERN except_T *current_exception;
229
230/// An exception is being thrown.  Reset when the exception is caught or as
231/// long as it is pending in a finally clause.
232EXTERN bool did_throw INIT( = false);
233
234/// Set when a throw that cannot be handled in do_cmdline() must be propagated
235/// to the cstack of the previously called do_cmdline().
236EXTERN bool need_rethrow INIT( = false);
237
238/// Set when a ":finish" or ":return" that cannot be handled in do_cmdline()
239/// must be propagated to the cstack of the previously called do_cmdline().
240EXTERN bool check_cstack INIT( = false);
241
242/// Number of nested try conditionals (across function calls and ":source"
243/// commands).
244EXTERN int trylevel INIT( = 0);
245
246/// When "force_abort" is true, always skip commands after an error message,
247/// even after the outermost ":endif", ":endwhile" or ":endfor" or for a
248/// function without the "abort" flag.  It is set to true when "trylevel" is
249/// non-zero (and ":silent!" was not used) or an exception is being thrown at
250/// the time an error is detected.  It is set to false when "trylevel" gets
251/// zero again and there was no error or interrupt or throw.
252EXTERN bool force_abort INIT( = false);
253
254/// "msg_list" points to a variable in the stack of do_cmdline() which keeps
255/// the list of arguments of several emsg() calls, one of which is to be
256/// converted to an error exception immediately after the failing command
257/// returns.  The message to be used for the exception value is pointed to by
258/// the "throw_msg" field of the first element in the list.  It is usually the
259/// same as the "msg" field of that element, but can be identical to the "msg"
260/// field of a later list element, when the "emsg_severe" flag was set when the
261/// emsg() call was made.
262EXTERN msglist_T **msg_list INIT( = NULL);
263
264/// When set, don't convert an error to an exception.  Used when displaying the
265/// interrupt message or reporting an exception that is still uncaught at the
266/// top level (which has already been discarded then).  Also used for the error
267/// message when no exception can be thrown.
268EXTERN bool suppress_errthrow INIT( = false);
269
270/// The stack of all caught and not finished exceptions.  The exception on the
271/// top of the stack is the one got by evaluation of v:exception.  The complete
272/// stack of all caught and pending exceptions is embedded in the various
273/// cstacks; the pending exceptions, however, are not on the caught stack.
274EXTERN except_T *caught_stack INIT( = NULL);
275
276///
277/// Garbage collection can only take place when we are sure there are no Lists
278/// or Dictionaries being used internally.  This is flagged with
279/// "may_garbage_collect" when we are at the toplevel.
280/// "want_garbage_collect" is set by the garbagecollect() function, which means
281/// we do garbage collection before waiting for a char at the toplevel.
282/// "garbage_collect_at_exit" indicates garbagecollect(1) was called.
283///
284EXTERN bool may_garbage_collect INIT( = false);
285EXTERN bool want_garbage_collect INIT( = false);
286EXTERN bool garbage_collect_at_exit INIT( = false);
287
288// Special values for current_SID.
289#define SID_MODELINE    (-1)      // when using a modeline
290#define SID_CMDARG      (-2)      // for "--cmd" argument
291#define SID_CARG        (-3)      // for "-c" argument
292#define SID_ENV         (-4)      // for sourcing environment variable
293#define SID_ERROR       (-5)      // option was reset because of an error
294#define SID_NONE        (-6)      // don't set scriptID
295#define SID_WINLAYOUT   (-7)      // changing window size
296#define SID_LUA         (-8)      // for Lua scripts/chunks
297#define SID_API_CLIENT  (-9)      // for API clients
298#define SID_STR         (-10)     // for sourcing a string with no script item
299
300// Script CTX being sourced or was sourced to define the current function.
301EXTERN sctx_T current_sctx INIT( = { 0, 0, 0, 0 });
302/// Last channel that invoked 'nvim_input` or got FocusGained.
303EXTERN uint64_t current_ui INIT( = 0);
304
305EXTERN bool did_source_packages INIT( = false);
306
307// Scope information for the code that indirectly triggered the current
308// provider function call
309EXTERN struct caller_scope {
310  sctx_T script_ctx;
311  estack_T es_entry;
312  char *autocmd_fname, *autocmd_match;
313  bool autocmd_fname_full;
314  int autocmd_bufnr;
315  void *funccalp;
316} provider_caller_scope;
317EXTERN int provider_call_nesting INIT( = 0);
318
319EXTERN int t_colors INIT( = 256);                // int value of T_CCO
320
321// Flags to indicate an additional string for highlight name completion.
322EXTERN int include_none INIT( = 0);     // when 1 include "None"
323EXTERN int include_default INIT( = 0);  // when 1 include "default"
324EXTERN int include_link INIT( = 0);     // when 2 include "link" and "clear"
325
326/// Per-subsystem state for the search/highlight engine; see search_defs.h.
327EXTERN SearchState Search INIT( = { .last_line = MAXLNUM });
328
329EXTERN bool need_check_timestamps INIT( = false);  // need to check file
330                                                   // timestamps asap
331EXTERN bool did_check_timestamps INIT( = false);   // did check timestamps
332                                                   // recently
333EXTERN int no_check_timestamps INIT( = 0);         // Don't check timestamps
334
335// Mouse coordinates, set by handle_mouse_event()
336EXTERN int mouse_grid;
337EXTERN int mouse_row;
338EXTERN int mouse_col;
339EXTERN bool mouse_past_bottom INIT( = false);  // mouse below last line
340EXTERN bool mouse_past_eol INIT( = false);     // mouse right of line
341EXTERN int mouse_dragging INIT( = 0);          // extending Visual area with
342                                               // mouse dragging
343
344// The root of the menu hierarchy.
345EXTERN vimmenu_T *root_menu INIT( = NULL);
346// While defining the system menu, sys_menu is true.  This avoids
347// overruling of menus that the user already defined.
348EXTERN bool sys_menu INIT( = false);
349
350// All windows are linked in a list. firstwin points to the first entry,
351// lastwin to the last entry (can be the same as firstwin) and curwin to the
352// currently active window.
353EXTERN win_T *firstwin;              // first window
354EXTERN win_T *lastwin;               // last window
355EXTERN win_T *prevwin INIT( = NULL);  // previous window (may equal curwin)
356#define ONE_WINDOW (firstwin == lastwin)
357#define FOR_ALL_FRAMES(frp, first_frame) \
358  for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
359
360// When using this macro "break" only breaks out of the inner loop. Use "goto"
361// to break out of the tabpage loop.
362#define FOR_ALL_TAB_WINDOWS(tp, wp) \
363  FOR_ALL_TABS(tp) \
364  FOR_ALL_WINDOWS_IN_TAB(wp, tp)
365
366#define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \
367  for (win_T *wp = ((tp) == curtab) ? firstwin : (tp)->tp_firstwin; \
368       wp != NULL; wp = wp->w_next)
369
370EXTERN win_T *curwin;        // currently active window
371
372// The window layout is kept in a tree of frames.  topframe points to the top
373// of the tree.
374EXTERN frame_T *topframe;      // top of the window frame tree
375
376// Tab pages are alternative topframes.  "first_tabpage" points to the first
377// one in the list, "curtab" is the current one. "lastused_tabpage" is the
378// last used one.
379EXTERN tabpage_T *first_tabpage;
380EXTERN tabpage_T *curtab;
381EXTERN tabpage_T *lastused_tabpage;
382EXTERN bool redraw_tabline INIT( = false);  // need to redraw tabline
383
384// Iterates over all tabs in the tab list
385#define FOR_ALL_TABS(tp) for (tabpage_T *(tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
386
387// All buffers are linked in a list. 'firstbuf' points to the first entry,
388// 'lastbuf' to the last entry and 'curbuf' to the currently active buffer.
389EXTERN buf_T    *firstbuf INIT( = NULL);  // first buffer
390EXTERN buf_T *lastbuf INIT( = NULL);   // last buffer
391EXTERN buf_T *curbuf INIT( = NULL);    // currently active buffer
392
393// Iterates over all buffers in the buffer list.
394#define FOR_ALL_BUFFERS(buf) \
395  for (buf_T *buf = firstbuf; buf != NULL; buf = buf->b_next)
396#define FOR_ALL_BUFFERS_BACKWARDS(buf) \
397  for (buf_T *buf = lastbuf; buf != NULL; buf = buf->b_prev)
398
399// List of files being edited (global argument list).  curwin->w_alist points
400// to this when the window is using the global argument list.
401EXTERN alist_T global_alist;    // global argument list
402EXTERN int max_alist_id INIT( = 0);     ///< the previous argument list id
403EXTERN bool arg_had_last INIT( = false);     // accessed last file in
404                                             // global_alist
405
406EXTERN int ru_col;              // column for ruler
407EXTERN int ru_wid;              // 'rulerfmt' width of ruler when non-zero
408EXTERN int sc_col;              // column for shown command
409
410// When starting or exiting some things are done differently (e.g. screen
411// updating).
412
413// First NO_SCREEN, then NO_BUFFERS, then 0 when startup finished.
414EXTERN int starting INIT( = NO_SCREEN);
415// Planning to exit. Might keep running if there is a changed buffer.
416EXTERN bool exiting INIT( = false);
417// Internal value of v:dying
418EXTERN int v_dying INIT( = 0);
419// Is stdin a terminal?
420EXTERN bool stdin_isatty INIT( = true);
421// Is stdout a terminal?
422EXTERN bool stdout_isatty INIT( = true);
423// Is stderr a terminal?
424EXTERN bool stderr_isatty INIT( = true);
425
426/// Filedesc set by embedder for reading first buffer like `cmd | nvim -`.
427EXTERN int stdin_fd INIT( = -1);
428
429// true when doing full-screen output, otherwise only writing some messages.
430EXTERN bool full_screen INIT( = false);
431
432/// Non-zero when only "safe" commands are allowed
433EXTERN int secure INIT( = 0);
434
435/// Non-zero when changing text and jumping to another window or editing another buffer is not
436/// allowed.
437EXTERN int textlock INIT( = 0);
438
439/// Non-zero when no buffer name can be changed, no buffer can be deleted and
440/// current directory can't be changed. Used for SwapExists et al.
441EXTERN int allbuf_lock INIT( = 0);
442
443/// Non-zero when evaluating an expression in a "sandbox".  Several things are
444/// not allowed then.
445EXTERN int sandbox INIT( = 0);
446
447/// Batch-mode: "-es", "-Es", "-l" commandline argument was given.
448EXTERN bool silent_mode INIT( = false);
449/// Non-interactive Ex mode ("-es"): stdin is executed as Ex commands. mode() returns "cv".
450EXTERN bool exmode_active INIT( = false);
451
452/// Per-subsystem state for Visual/Select mode; see normal_defs.h.
453EXTERN VisualState Visual INIT( = { .mode = 'v' });
454
455/// When pasting text with the middle mouse button in visual mode with
456/// restart_edit set, remember where it started so we can set Ins.start.
457EXTERN pos_T where_paste_started;
458
459// This flag is set after a ":syncbind" to let the check_scrollbind() function
460// know that it should not attempt to perform scrollbinding due to the scroll
461// that was a result of the ":syncbind." (Otherwise, check_scrollbind() will
462// undo some of the work done by ":syncbind.")  -ralston
463EXTERN bool did_syncbind INIT( = false);
464
465EXTERN int old_indent INIT( = 0);  ///< for ^^D command in insert mode
466
467// w_cursor before formatting text.
468EXTERN pos_T saved_cursor INIT( = { 0, 0, 0 });
469
470// Stuff for insert mode: the current insert session.
471EXTERN InsState Ins;
472
473// Stuff for MODE_VREPLACE state.
474EXTERN linenr_T orig_line_count INIT( = 0);       // Line count when "gR" started
475EXTERN int vr_lines_changed INIT( = 0);      // #Lines changed by "gR" so far
476
477// increase around internal delete/replace
478EXTERN int inhibit_delete_count INIT( = 0);
479
480// These flags are set based upon 'fileencoding'.
481// The characters are internally stored as UTF-8
482// to avoid trouble with NUL bytes.
483#define DBCS_JPN       932     // japan
484#define DBCS_JPNU      9932    // euc-jp
485#define DBCS_KOR       949     // korea
486#define DBCS_KORU      9949    // euc-kr
487#define DBCS_CHS       936     // chinese
488#define DBCS_CHSU      9936    // euc-cn
489#define DBCS_CHT       950     // taiwan
490#define DBCS_CHTU      9950    // euc-tw
491#define DBCS_2BYTE     1       // 2byte-
492#define DBCS_DEBUG     (-1)
493
494/// Encoding used when 'fencs' is set to "default"
495EXTERN char *fenc_default INIT( = NULL);
496
497/// "State" is the main state (editor-mode) of Vim.
498/// There are other variables that modify the state:
499///    Visual_mode:    When State is MODE_NORMAL or MODE_INSERT.
500///    finish_op  :    When State is MODE_NORMAL, after typing the operator and
501///                    before typing the motion command.
502///    motion_force:   Last motion_force from do_pending_operator()
503///    debug_mode:     Debug mode
504EXTERN int State INIT( = MODE_NORMAL);
505
506EXTERN bool debug_mode INIT( = false);
507EXTERN bool finish_op INIT( = false);    // true while an operator is pending
508EXTERN int opcount INIT( = 0);           // count for pending operator
509EXTERN int motion_force INIT( = 0);      // motion force for pending operator
510
511// 'inccommand' command preview state
512EXTERN bool cmdpreview INIT( = false);
513
514EXTERN int reg_recording INIT( = 0);     // register for recording  or zero
515EXTERN int reg_executing INIT( = 0);     // register being executed or zero
516// Flag set when peeking a character and found the end of executed register
517EXTERN bool pending_end_reg_executing INIT( = false);
518EXTERN int reg_recorded INIT( = 0);      // last recorded register or zero
519
520EXTERN int no_mapping INIT( = 0);        // currently no mapping allowed
521EXTERN int no_zero_mapping INIT( = 0);   // mapping zero not allowed
522EXTERN int allow_keys INIT( = 0);        // allow key codes when no_mapping is set
523EXTERN int no_u_sync INIT( = 0);         // Don't call u_sync()
524EXTERN int u_sync_once INIT( = 0);       // Call u_sync() once when evaluating
525                                         // an expression.
526
527EXTERN bool force_restart_edit INIT( = false);  // force restart_edit after
528                                                // ex_normal returns
529EXTERN int restart_edit INIT( = 0);      // call edit when next cmd finished
530EXTERN bool ins_at_eol INIT( = false);   // put cursor after eol when
531                                         // restarting edit after CTRL-O
532
533EXTERN bool no_abbr INIT( = true);       // true when no abbreviations loaded
534
535EXTERN int mapped_ctrl_c INIT( = 0);  // Modes where CTRL-C is mapped.
536EXTERN bool ctrl_c_interrupts INIT( = true);  // CTRL-C sets got_int
537
538EXTERN cmdmod_T cmdmod;                 // Ex command modifiers
539
540EXTERN int msg_silent INIT( = 0);         // don't print messages
541EXTERN int emsg_silent INIT( = 0);        // don't print error messages
542EXTERN bool emsg_noredir INIT( = false);  // don't redirect error messages
543EXTERN bool cmd_silent INIT( = false);    // don't echo the command line
544
545EXTERN bool in_assert_fails INIT( = false);  // assert_fails() active
546
547// Values for swap_exists_action: what to do when swap file already exists
548#define SEA_NONE        0       // don't use dialog
549#define SEA_DIALOG      1       // use dialog when possible
550#define SEA_QUIT        2       // quit editing the file
551#define SEA_RECOVER     3       // recover the file
552#define SEA_READONLY    4       // no dialog, mark buffer as read-only
553
554EXTERN int swap_exists_action INIT( = SEA_NONE);  ///< For dialog when swap file already exists.
555EXTERN bool swap_exists_did_quit INIT( = false);  ///< Selected "quit" at the dialog.
556
557EXTERN char IObuff[IOSIZE];                 ///< Buffer for sprintf, I/O, etc.
558EXTERN char NameBuff[MAXPATHL];             ///< Buffer for expanding file names
559EXTERN char msg_buf[MSG_BUF_LEN];           ///< Small buffer for messages
560EXTERN char os_buf[                         ///< Buffer for the os/ layer
561#if MAXPATHL > IOSIZE
562                                            MAXPATHL
563#else
564                                            IOSIZE
565#endif
566];
567
568// When non-zero, postpone redrawing.
569EXTERN int RedrawingDisabled INIT( = 0);
570
571EXTERN bool readonlymode INIT( = false);      // Set to true for "view"
572EXTERN bool recoverymode INIT( = false);      // Set to true for "-r" option
573
574// typeahead buffer
575EXTERN typebuf_T typebuf INIT( = { NULL, NULL, 0, 0, 0, 0, 0, 0, 0 });
576
577/// Flag used to indicate that vgetorpeek() returned a char like Esc when the
578/// :normal argument was exhausted.
579EXTERN bool typebuf_was_empty INIT( = false);
580
581EXTERN int ex_normal_busy INIT( = 0);      // recursiveness of ex_normal()
582EXTERN int expr_map_lock INIT( = 0);       // running expr mapping, prevent use of ex_normal() and text changes
583EXTERN bool ignore_script INIT( = false);  // ignore script input
584EXTERN bool KeyTyped;                      // true if user typed current char
585EXTERN int KeyStuffed;                     // true if current char from stuffbuf
586EXTERN int maptick INIT( = 0);             // tick for each non-mapped char
587
588EXTERN int must_redraw INIT( = 0);           // type of redraw necessary
589EXTERN bool skip_redraw INIT( = false);      // skip redraw once
590EXTERN bool do_redraw INIT( = false);        // extra redraw once
591EXTERN bool must_redraw_pum INIT( = false);  // redraw pum. NB: must_redraw
592                                             // should also be set.
593
594EXTERN bool need_highlight_changed INIT( = true);
595
596EXTERN FILE *scriptout INIT( = NULL);  ///< Write input to this file ("nvim -w").
597
598// Note that even when handling SIGINT, volatile is not necessary because the
599// callback is not called directly from the signal handlers.
600EXTERN bool got_int INIT( = false);          // set to true when interrupt signal occurred
601EXTERN bool bangredo INIT( = false);         // set to true with ! command
602EXTERN int reg_do_extmatch INIT( = 0);       // Used when compiling regexp:
603                                             // REX_SET to allow \z\(...\),
604                                             // REX_USE to allow \z\1 et al.
605// Used by vim_regexec(): strings for \z\1...\z\9
606EXTERN reg_extmatch_T *re_extmatch_in INIT( = NULL);
607// Set by vim_regexec() to store \z\(...\) matches
608EXTERN reg_extmatch_T *re_extmatch_out INIT( = NULL);
609
610EXTERN bool did_outofmem_msg INIT( = false);  ///< set after out of memory msg
611EXTERN bool did_swapwrite_msg INIT( = false);  ///< set after swap write error msg
612EXTERN int global_busy INIT( = 0);           ///< set when :global is executing
613EXTERN bool listcmd_busy INIT( = false);     ///< set when :argdo, :windo or :bufdo is executing
614EXTERN bool need_start_insertmode INIT( = false);  ///< start insert mode soon
615
616#define MODE_MAX_LENGTH 4       // max mode length returned in get_mode(),
617                                // including the terminating NUL
618
619EXTERN char last_mode[MODE_MAX_LENGTH] INIT( = "n");
620EXTERN char *last_cmdline INIT( = NULL);        // last command line (for ":)
621EXTERN char *repeat_cmdline INIT( = NULL);      // command line for "."
622EXTERN char *new_last_cmdline INIT( = NULL);    // new value for last_cmdline
623
624EXTERN int postponed_split INIT( = 0);        // for CTRL-W CTRL-] command
625EXTERN int postponed_split_flags INIT( = 0);  // args for win_split()
626EXTERN int postponed_split_tab INIT( = 0);    // cmdmod.cmod_tab
627EXTERN int g_do_tagpreview INIT( = 0);  // for tag preview commands:
628                                        // height of preview window
629EXTERN bool g_tag_at_cursor INIT( = false);  // whether the tag command comes
630                                             // from the command line (0) or was
631                                             // invoked as a normal command (1)
632
633EXTERN int replace_offset INIT( = 0);        // offset for replace_push()
634
635EXTERN char *escape_chars INIT( = " \t\\\"|");  // need backslash in cmd line
636
637EXTERN bool keep_help_flag INIT( = false);  // doing :ta from help file
638
639EXTERN bool redir_off INIT( = false);        // no redirection for a moment
640EXTERN FILE *redir_fd INIT( = NULL);         // message redirection file
641EXTERN int redir_reg INIT( = 0);             // message redirection register
642EXTERN bool redir_vname INIT( = false);      // message redirection variable
643EXTERN garray_T *capture_ga INIT( = NULL);   // captured output for execute()
644
645EXTERN uint8_t langmap_mapchar[256];     // mapping for language keys
646
647EXTERN int save_p_ls INIT( = -1);        // Save 'laststatus' setting
648EXTERN int save_p_wmh INIT( = -1);       // Save 'winminheight' setting
649EXTERN int wild_menu_showing INIT( = 0);
650enum {
651  WM_SHOWN = 1,     ///< wildmenu showing
652  WM_SCROLLED = 2,  ///< wildmenu showing with scroll
653};
654
655// When a window has a local directory, the absolute path of the global
656// current directory is stored here (in allocated memory).  If the current
657// directory is not a local directory, globaldir is NULL.
658EXTERN char *globaldir INIT( = NULL);
659
660EXTERN char *last_chdir_reason INIT( = NULL);
661
662// Whether 'keymodel' contains "stopsel" and "startsel".
663EXTERN bool km_stopsel INIT( = false);
664EXTERN bool km_startsel INIT( = false);
665
666EXTERN int cmdwin_type INIT( = 0);  ///< |cmdwin| type (':', '/', '?') or 0.
667EXTERN buf_T *cmdwin_buf INIT( = NULL);  ///< |cmdwin| scratch buffer, or NULL.
668EXTERN win_T *cmdline_win INIT( = NULL);  ///< window in use by ext_cmdline
669
670EXTERN char no_lines_msg[] INIT( = N_("--No lines in buffer--"));
671
672// When ":global" is used to number of substitutions and changed lines is
673// accumulated until it's finished.
674// Also used for ":spellrepall".
675EXTERN int sub_nsubs;        // total number of substitutions
676EXTERN linenr_T sub_nlines;  // total number of lines changed
677
678// table to store parsed 'wildmode'
679EXTERN uint8_t wim_flags[4];
680
681// whether titlestring and iconstring contains statusline syntax
682#define STL_IN_ICON    1
683#define STL_IN_TITLE   2
684EXTERN int stl_syntax INIT( = 0);
685
686EXTERN bool typebuf_was_filled INIT( = false);     // received text from client
687                                                   // or from feedkeys()
688
689// Set to kTrue when an operator is being executed with virtual editing
690// kNone when no operator is being executed, kFalse otherwise.
691EXTERN TriState virtual_op INIT( = kNone);
692
693// Display tick, incremented for each call to update_screen()
694EXTERN disptick_T display_tick INIT( = 0);
695
696// Line in which spell checking wasn't highlighted because it touched the
697// cursor position in Insert mode.
698EXTERN linenr_T spell_redraw_lnum INIT( = 0);
699
700EXTERN FILE *time_fd INIT( = NULL);  // Where to write --startuptime report.
701
702// Some compilers warn for not using a return value, but in some situations we
703// can't do anything useful with the value.  Assign to this variable to avoid
704// the warning.
705EXTERN int vim_ignored;
706
707// stdio is an RPC channel (--embed).
708EXTERN bool embedded_mode INIT( = false);
709// Do not start UI (--headless, -l) nor read/write to stdio (unless embedding).
710EXTERN bool headless_mode INIT( = false);
711
712/// Only filled for Win32.
713EXTERN char windowsVersion[20] INIT( = { 0 });
714
715/// Skip win_fix_scroll() call for 'splitkeep' when closing tab page.
716EXTERN bool skip_win_fix_scroll INIT( = false);
717/// Skip update_topline() call while executing win_fix_scroll().
718EXTERN bool skip_update_topline INIT( = false);