aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/globals.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/globals.h')
-rw-r--r--src/nvim/globals.h237
1 files changed, 125 insertions, 112 deletions
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index dafb75ca87..baa85c01f8 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -409,12 +409,8 @@ EXTERN struct caller_scope {
} provider_caller_scope;
EXTERN int provider_call_nesting INIT(= 0);
-/* Magic number used for hashitem "hi_key" value indicating a deleted item.
- * Only the address is used. */
-EXTERN char_u hash_removed;
-
-EXTERN int t_colors INIT(= 0); /* int value of T_CCO */
+EXTERN int t_colors INIT(= 256); // int value of T_CCO
/*
* When highlight_match is TRUE, highlight a match, starting at the cursor
@@ -442,59 +438,60 @@ EXTERN int no_check_timestamps INIT(= 0); /* Don't check timestamps */
typedef enum {
HLF_8 = 0 /* Meta & special keys listed with ":map", text that is
displayed different from what it is */
- , HLF_EOB //< after the last line in the buffer
- , HLF_TERM //< terminal cursor focused
- , HLF_TERMNC //< terminal cursor unfocused
- , HLF_AT /* @ characters at end of screen, characters that
- don't really exist in the text */
- , HLF_D /* directories in CTRL-D listing */
- , HLF_E /* error messages */
- , HLF_I /* incremental search */
- , HLF_L /* last search string */
- , HLF_M /* "--More--" message */
- , HLF_CM /* Mode (e.g., "-- INSERT --") */
- , HLF_N /* line number for ":number" and ":#" commands */
- , HLF_CLN /* current line number */
- , HLF_R /* return to continue message and yes/no questions */
- , HLF_S /* status lines */
- , HLF_SNC /* status lines of not-current windows */
- , HLF_C /* column to separate vertically split windows */
- , HLF_T /* Titles for output from ":set all", ":autocmd" etc. */
- , HLF_V /* Visual mode */
- , HLF_VNC /* Visual mode, autoselecting and not clipboard owner */
- , HLF_W /* warning messages */
- , HLF_WM /* Wildmenu highlight */
- , HLF_FL /* Folded line */
- , HLF_FC /* Fold column */
- , HLF_ADD /* Added diff line */
- , HLF_CHD /* Changed diff line */
- , HLF_DED /* Deleted diff line */
- , HLF_TXD /* Text Changed in diff line */
- , HLF_CONCEAL /* Concealed text */
- , HLF_SC /* Sign column */
- , HLF_SPB /* SpellBad */
- , HLF_SPC /* SpellCap */
- , HLF_SPR /* SpellRare */
- , HLF_SPL /* SpellLocal */
- , HLF_PNI /* popup menu normal item */
- , HLF_PSI /* popup menu selected item */
- , HLF_PSB /* popup menu scrollbar */
- , HLF_PST /* popup menu scrollbar thumb */
- , HLF_TP /* tabpage line */
- , HLF_TPS /* tabpage line selected */
- , HLF_TPF /* tabpage line filler */
- , HLF_CUC /* 'cursurcolumn' */
- , HLF_CUL /* 'cursurline' */
- , HLF_MC /* 'colorcolumn' */
- , HLF_COUNT /* MUST be the last one */
+ , HLF_EOB // after the last line in the buffer
+ , HLF_TERM // terminal cursor focused
+ , HLF_TERMNC // terminal cursor unfocused
+ , HLF_AT // @ characters at end of screen, characters that
+ // don't really exist in the text
+ , HLF_D // directories in CTRL-D listing
+ , HLF_E // error messages
+ , HLF_I // incremental search
+ , HLF_L // last search string
+ , HLF_M // "--More--" message
+ , HLF_CM // Mode (e.g., "-- INSERT --")
+ , HLF_N // line number for ":number" and ":#" commands
+ , HLF_CLN // current line number
+ , HLF_R // return to continue message and yes/no questions
+ , HLF_S // status lines
+ , HLF_SNC // status lines of not-current windows
+ , HLF_C // column to separate vertically split windows
+ , HLF_T // Titles for output from ":set all", ":autocmd" etc.
+ , HLF_V // Visual mode
+ , HLF_VNC // Visual mode, autoselecting and not clipboard owner
+ , HLF_W // warning messages
+ , HLF_WM // Wildmenu highlight
+ , HLF_FL // Folded line
+ , HLF_FC // Fold column
+ , HLF_ADD // Added diff line
+ , HLF_CHD // Changed diff line
+ , HLF_DED // Deleted diff line
+ , HLF_TXD // Text Changed in diff line
+ , HLF_CONCEAL // Concealed text
+ , HLF_SC // Sign column
+ , HLF_SPB // SpellBad
+ , HLF_SPC // SpellCap
+ , HLF_SPR // SpellRare
+ , HLF_SPL // SpellLocal
+ , HLF_PNI // popup menu normal item
+ , HLF_PSI // popup menu selected item
+ , HLF_PSB // popup menu scrollbar
+ , HLF_PST // popup menu scrollbar thumb
+ , HLF_TP // tabpage line
+ , HLF_TPS // tabpage line selected
+ , HLF_TPF // tabpage line filler
+ , HLF_CUC // 'cursurcolumn'
+ , HLF_CUL // 'cursurline'
+ , HLF_MC // 'colorcolumn'
+ , HLF_QFL // selected quickfix line
+ , HLF_COUNT // MUST be the last one
} hlf_T;
/* The HL_FLAGS must be in the same order as the HLF_ enums!
* When changing this also adjust the default for 'highlight'. */
-#define HL_FLAGS {'8', '~', 'z', 'Z', '@', 'd', 'e', 'i', 'l', 'm', 'M', 'n', \
- 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', 'f', 'F', \
- 'A', 'C', 'D', 'T', '-', '>', 'B', 'P', 'R', 'L', '+', '=', \
- 'x', 'X', '*', '#', '_', '!', '.', 'o'}
+#define HL_FLAGS { '8', '~', 'z', 'Z', '@', 'd', 'e', 'i', 'l', 'm', 'M', 'n', \
+ 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', 'f', 'F', \
+ 'A', 'C', 'D', 'T', '-', '>', 'B', 'P', 'R', 'L', '+', '=', \
+ 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q' }
EXTERN int highlight_attr[HLF_COUNT]; /* Highl. attr for each context. */
EXTERN int highlight_user[9]; /* User[1-9] attributes */
@@ -569,6 +566,7 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */
FOR_ALL_TABS(tp) \
FOR_ALL_WINDOWS_IN_TAB(wp, tp)
+# define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_next)
# define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \
for (win_T *wp = ((tp) == curtab) \
? firstwin : (tp)->tp_firstwin; wp != NULL; wp = wp->w_next)
@@ -599,9 +597,9 @@ EXTERN int redraw_tabline INIT(= FALSE); /* need to redraw tabline */
* All buffers are linked in a list. 'firstbuf' points to the first entry,
* 'lastbuf' to the last entry and 'curbuf' to the currently active buffer.
*/
-EXTERN buf_T *firstbuf INIT(= NULL); /* first buffer */
-EXTERN buf_T *lastbuf INIT(= NULL); /* last buffer */
-EXTERN buf_T *curbuf INIT(= NULL); /* currently active buffer */
+EXTERN buf_T *firstbuf INIT(= NULL); // first buffer
+EXTERN buf_T *lastbuf INIT(= NULL); // last buffer
+EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer
// Iterates over all buffers in the buffer list.
# define FOR_ALL_BUFFERS(buf) for (buf_T *buf = firstbuf; buf != NULL; buf = buf->b_next)
@@ -634,10 +632,10 @@ EXTERN int exiting INIT(= FALSE);
/* TRUE when planning to exit Vim. Might
* still keep on running if there is a changed
* buffer. */
-/* volatile because it is used in signal handler deathtrap(). */
-EXTERN volatile int full_screen INIT(= FALSE);
-/* TRUE when doing full-screen output
- * otherwise only writing some messages */
+// volatile because it is used in signal handler deathtrap().
+EXTERN volatile int full_screen INIT(= false);
+// TRUE when doing full-screen output
+// otherwise only writing some messages
EXTERN int restricted INIT(= FALSE);
// TRUE when started in restricted mode (-Z)
@@ -777,44 +775,38 @@ EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */
# define DBCS_2BYTE 1 /* 2byte- */
# define DBCS_DEBUG -1
-EXTERN int enc_dbcs INIT(= 0); /* One of DBCS_xxx values if
- DBCS encoding */
-EXTERN int enc_unicode INIT(= 0); /* 2: UCS-2 or UTF-16, 4: UCS-4 */
-EXTERN bool enc_utf8 INIT(= false); /* UTF-8 encoded Unicode */
-EXTERN int enc_latin1like INIT(= TRUE); /* 'encoding' is latin1 comp. */
-EXTERN int has_mbyte INIT(= 0); /* any multi-byte encoding */
+// mbyte flags that used to depend on 'encoding'. These are now deprecated, as
+// 'encoding' is always "utf-8". Code that use them can be refactored to
+// remove dead code.
+#define enc_dbcs false
+#define enc_utf8 true
+#define has_mbyte true
/// Encoding used when 'fencs' is set to "default"
EXTERN char_u *fenc_default INIT(= NULL);
-/*
- * To speed up BYTELEN() we fill a table with the byte lengths whenever
- * enc_utf8 or enc_dbcs changes.
- */
-EXTERN char mb_bytelen_tab[256];
-
-/*
- * Function pointers, used to quickly get to the right function. Each has
- * three possible values: latin_ (8-bit), utfc_ or utf_ (utf-8) and dbcs_
- * (DBCS).
- * The value is set in mb_init();
- */
-/* length of char in bytes, including following composing chars */
-EXTERN int (*mb_ptr2len)(const char_u *p) INIT(= latin_ptr2len);
-/* idem, with limit on string length */
-EXTERN int (*mb_ptr2len_len)(const char_u *p, int size) INIT(= latin_ptr2len_len);
-/* byte length of char */
-EXTERN int (*mb_char2len)(int c) INIT(= latin_char2len);
-/* convert char to bytes, return the length */
-EXTERN int (*mb_char2bytes)(int c, char_u *buf) INIT(= latin_char2bytes);
-EXTERN int (*mb_ptr2cells)(const char_u *p) INIT(= latin_ptr2cells);
-EXTERN int (*mb_ptr2cells_len)(const char_u *p, int size) INIT(
- = latin_ptr2cells_len);
-EXTERN int (*mb_char2cells)(int c) INIT(= latin_char2cells);
-EXTERN int (*mb_off2cells)(unsigned off, unsigned max_off) INIT(
- = latin_off2cells);
-EXTERN int (*mb_ptr2char)(const char_u *p) INIT(= latin_ptr2char);
-EXTERN int (*mb_head_off)(const char_u *base, const char_u *p) INIT(= latin_head_off);
+// To speed up BYTELEN(); keep a lookup table to quickly get the length in
+// bytes of a UTF-8 character from the first byte of a UTF-8 string. Bytes
+// which are illegal when used as the first byte have a 1. The NUL byte has
+// length 1.
+EXTERN char utf8len_tab[256] INIT(= {
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1,
+});
# if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
/* Pointers to functions and variables to be loaded at runtime */
@@ -836,8 +828,8 @@ EXTERN int* (*iconv_errno)(void);
EXTERN int State INIT(= NORMAL); /* This is the current state of the
* command interpreter. */
-EXTERN int finish_op INIT(= FALSE); /* TRUE while an operator is pending */
-EXTERN long opcount INIT(= 0); /* count for pending operator */
+EXTERN bool finish_op INIT(= false); // true while an operator is pending
+EXTERN long opcount INIT(= 0); // count for pending operator
/*
* ex mode (Q) state
@@ -877,9 +869,10 @@ EXTERN int mapped_ctrl_c INIT(= 0); // Modes where CTRL-C is mapped.
EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
-EXTERN int msg_silent INIT(= 0); /* don't print messages */
-EXTERN int emsg_silent INIT(= 0); /* don't print error messages */
-EXTERN int cmd_silent INIT(= FALSE); /* don't echo the command line */
+EXTERN int msg_silent INIT(= 0); // don't print messages
+EXTERN int emsg_silent INIT(= 0); // don't print error messages
+EXTERN bool emsg_noredir INIT(= false); // don't redirect error messages
+EXTERN int cmd_silent INIT(= false); // don't echo the command line
/* Values for swap_exists_action: what to do when swap file already exists */
#define SEA_NONE 0 /* don't use dialog */
@@ -914,9 +907,6 @@ EXTERN int KeyTyped; // TRUE if user typed current char
EXTERN int KeyStuffed; // TRUE if current char from stuffbuf
EXTERN int maptick INIT(= 0); // tick for each non-mapped char
-EXTERN uint8_t chartab[256]; // table used in charset.c; See
- // init_chartab() for explanation
-
EXTERN int must_redraw INIT(= 0); /* type of redraw necessary */
EXTERN int skip_redraw INIT(= FALSE); /* skip redraw once */
EXTERN int do_redraw INIT(= FALSE); /* extra redraw once */
@@ -929,9 +919,9 @@ EXTERN FILE *scriptin[NSCRIPT]; /* streams to read script from */
EXTERN int curscript INIT(= 0); /* index in scriptin[] */
EXTERN FILE *scriptout INIT(= NULL); /* stream to write script to */
-/* volatile because it is used in signal handler catch_sigint(). */
-EXTERN volatile int got_int INIT(= FALSE); /* set to TRUE when interrupt
- signal occurred */
+// volatile because it is used in a signal handler.
+EXTERN volatile int got_int INIT(= false); // set to true when interrupt
+ // signal occurred
EXTERN int bangredo INIT(= FALSE); /* set to TRUE with ! command */
EXTERN int searchcmdlen; /* length of previous search cmd */
EXTERN int reg_do_extmatch INIT(= 0); /* Used when compiling regexp:
@@ -985,10 +975,11 @@ EXTERN int keep_help_flag INIT(= FALSE); /* doing :ta from help file */
*/
EXTERN char_u *empty_option INIT(= (char_u *)"");
-EXTERN int redir_off INIT(= FALSE); /* no redirection for a moment */
-EXTERN FILE *redir_fd INIT(= NULL); /* message redirection file */
-EXTERN int redir_reg INIT(= 0); /* message redirection register */
-EXTERN int redir_vname INIT(= 0); /* message redirection variable */
+EXTERN int redir_off INIT(= false); // no redirection for a moment
+EXTERN FILE *redir_fd INIT(= NULL); // message redirection file
+EXTERN int redir_reg INIT(= 0); // message redirection register
+EXTERN int redir_vname INIT(= 0); // message redirection variable
+EXTERN garray_T *capture_ga INIT(= NULL); // captured output for execute()
EXTERN char_u langmap_mapchar[256]; /* mapping for language keys */
@@ -1132,7 +1123,6 @@ EXTERN char_u e_invcmd[] INIT(= N_("E476: Invalid command"));
EXTERN char_u e_isadir2[] INIT(= N_("E17: \"%s\" is a directory"));
EXTERN char_u e_invjob[] INIT(= N_("E900: Invalid job id"));
EXTERN char_u e_jobtblfull[] INIT(= N_("E901: Job table is full"));
-EXTERN char_u e_jobexe[] INIT(= N_("E902: \"%s\" is not an executable"));
EXTERN char_u e_jobspawn[] INIT(= N_(
"E903: Process for command \"%s\" could not be spawned"));
EXTERN char_u e_jobnotpty[] INIT(= N_("E904: Job is not connected to a pty"));
@@ -1222,7 +1212,10 @@ EXTERN char_u e_invalpat[] INIT(= N_(
EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer"));
EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set"));
EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
+EXTERN char_u e_dirnotf[] INIT(= N_(
+ "E919: Directory not found in '%s': \"%s\""));
EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
+EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long"));
EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));
@@ -1241,9 +1234,13 @@ EXTERN FILE *time_fd INIT(= NULL); /* where to write startup timing */
EXTERN int ignored;
EXTERN char *ignoredp;
+EXTERN bool in_free_unref_items INIT(= false);
+
// If a msgpack-rpc channel should be started over stdin/stdout
EXTERN bool embedded_mode INIT(= false);
-EXTERN Loop loop;
+
+/// next free id for a job or rpc channel
+EXTERN uint64_t next_chan_id INIT(= 1);
/// Used to track the status of external functions.
/// Currently only used for iconv().
@@ -1253,4 +1250,20 @@ typedef enum {
kBroken
} WorkingStatus;
+/// The scope of a working-directory command like `:cd`.
+///
+/// Scopes are enumerated from lowest to highest. When adding a scope make sure
+/// to update all functions using scopes as well, such as the implementation of
+/// `getcwd()`. When using scopes as limits (e.g. in loops) don't use the scopes
+/// directly, use `MIN_CD_SCOPE` and `MAX_CD_SCOPE` instead.
+typedef enum {
+ kCdScopeInvalid = -1,
+ kCdScopeWindow, ///< Affects one window.
+ kCdScopeTab, ///< Affects one tab page.
+ kCdScopeGlobal, ///< Affects the entire instance of Neovim.
+} CdScope;
+
+#define MIN_CD_SCOPE kCdScopeWindow
+#define MAX_CD_SCOPE kCdScopeGlobal
+
#endif /* NVIM_GLOBALS_H */