vim.h
Go to the documentation of this file.
1 #ifndef NVIM_VIM_H
2 #define NVIM_VIM_H
3 
4 #include "nvim/pos.h" // for linenr_T, MAXCOL, etc...
5 #include "nvim/types.h"
6 
7 // Some defines from the old feature.h
8 #define SESSION_FILE "Session.vim"
9 #define MAX_MSG_HIST_LEN 200
10 #define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
11 #define RUNTIME_DIRNAME "runtime"
12 
13 
14 #include "auto/config.h"
15 #define HAVE_PATHDEF
16 
17 // Check if configure correctly managed to find sizeof(int). If this failed,
18 // it becomes zero. This is likely a problem of not being able to run the
19 // test program. Other items from configure may also be wrong then!
20 #if (SIZEOF_INT == 0)
21 # error Configure did not run properly.
22 #endif
23 
24 #include "nvim/os/os_defs.h" // bring lots of system header files
25 
27 enum { NUMBUFLEN = 65, };
28 
29 #define MAX_TYPENR 65535
30 
31 #define ROOT_UID 0
32 
33 #include "nvim/gettext.h"
34 #include "nvim/keymap.h"
35 #include "nvim/macros.h"
36 
37 // special attribute addition: Put message in history
38 #define MSG_HIST 0x1000
39 
40 
41 // values for State
42 //
43 // The lower bits up to 0x20 are used to distinguish normal/visual/op_pending
44 // and cmdline/insert+replace mode. This is used for mapping. If none of
45 // these bits are set, no mapping is done.
46 // The upper bits are used to distinguish between other states.
47 
48 #define NORMAL 0x01 // Normal mode, command expected
49 #define VISUAL 0x02 // Visual mode - use get_real_state()
50 #define OP_PENDING 0x04 // Normal mode, operator is pending - use
51  // get_real_state()
52 #define CMDLINE 0x08 // Editing command line
53 #define INSERT 0x10 // Insert mode
54 #define LANGMAP 0x20 // Language mapping, can be combined with
55  // INSERT and CMDLINE
56 
57 #define REPLACE_FLAG 0x40 // Replace mode flag
58 #define REPLACE (REPLACE_FLAG + INSERT)
59 #define VREPLACE_FLAG 0x80 // Virtual-replace mode flag
60 #define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
61 #define LREPLACE (REPLACE_FLAG + LANGMAP)
62 
63 #define NORMAL_BUSY (0x100 + NORMAL) // Normal mode, busy with a command
64 #define HITRETURN (0x200 + NORMAL) // waiting for return or command
65 #define ASKMORE 0x300 // Asking if you want --more--
66 #define SETWSIZE 0x400 // window size has changed
67 #define ABBREV 0x500 // abbreviation instead of mapping
68 #define EXTERNCMD 0x600 // executing an external command
69 #define SHOWMATCH (0x700 + INSERT) // show matching paren
70 #define CONFIRM 0x800 // ":confirm" prompt
71 #define SELECTMODE 0x1000 // Select mode, only for mappings
72 #define TERM_FOCUS 0x2000 // Terminal focus mode
73 #define CMDPREVIEW 0x4000 // Showing 'inccommand' command "live" preview.
74 
75 #define MODE_MAX_LENGTH 4 // max mode length returned in mode()
76 
77 // all mode bits used for mapping
78 #define MAP_ALL_MODES (0x3f | SELECTMODE | TERM_FOCUS)
79 
81 typedef enum {
83  FORWARD = 1,
84  BACKWARD = (-1),
86  BACKWARD_FILE = (-3),
87 } Direction;
88 
89 // return values for functions
90 #if !(defined(OK) && (OK == 1))
91 // OK already defined to 1 in MacOS X curses, skip this
92 # define OK 1
93 #endif
94 #define FAIL 0
95 #define NOTDONE 2 // not OK or FAIL but skipped
96 
97 // Type values for type().
98 #define VAR_TYPE_NUMBER 0
99 #define VAR_TYPE_STRING 1
100 #define VAR_TYPE_FUNC 2
101 #define VAR_TYPE_LIST 3
102 #define VAR_TYPE_DICT 4
103 #define VAR_TYPE_FLOAT 5
104 #define VAR_TYPE_BOOL 6
105 #define VAR_TYPE_SPECIAL 7
106 #define VAR_TYPE_BLOB 10
107 
108 
109 // values for xp_context when doing command line completion
110 
111 enum {
113  EXPAND_OK = -1,
167 };
168 
169 
170 // Minimal size for block 0 of a swap file.
171 // NOTE: This depends on size of struct block0! It's not done with a sizeof(),
172 // because struct block0 is defined in memline.c (Sorry).
173 // The maximal block size is arbitrary.
174 
175 #define MIN_SWAP_PAGE_SIZE 1048
176 #define MAX_SWAP_PAGE_SIZE 50000
177 
178 
179 // Boolean constants
180 
181 #ifndef TRUE
182 # define FALSE 0 // note: this is an int, not a long!
183 # define TRUE 1
184 #endif
185 
186 #define MAYBE 2 // sometimes used for a variant on TRUE
187 
188 #define STATUS_HEIGHT 1 // height of a status line under a window
189 #define QF_WINHEIGHT 10 // default height for quickfix window
190 
191 
192 // Buffer sizes
193 
194 #ifndef CMDBUFFSIZE
195 # define CMDBUFFSIZE 256 // size of the command processing buffer
196 #endif
197 
198 #define LSIZE 512 // max. size of a line in the tags file
199 
200 #define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg()
201 
202 enum { FOLD_TEXT_LEN = 51, };
203 
204 
205 // Maximum length of key sequence to be mapped.
206 // Must be able to hold an Amiga resize report.
207 
208 #define MAXMAPLEN 50
209 
210 // Size in bytes of the hash used in the undo file.
211 #define UNDO_HASH_SIZE 32
212 
213 #define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr)))
214 
215 // defines to avoid typecasts from (char_u *) to (char *) and back
216 // (vim_strchr() is now in strings.c)
217 
218 #define STRLEN(s) strlen((char *)(s))
219 #ifdef HAVE_STRNLEN
220 # define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n))
221 #else
222 # define STRNLEN(s, n) xstrnlen((char *)(s), (size_t)(n))
223 #endif
224 #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
225 #define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n))
226 #define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))
227 #define STRCMP(d, s) strcmp((char *)(d), (char *)(s))
228 #define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
229 #ifdef HAVE_STRCASECMP
230 # define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
231 #else
232 # ifdef HAVE_STRICMP
233 # define STRICMP(d, s) stricmp((char *)(d), (char *)(s))
234 # else
235 # define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s))
236 # endif
237 #endif
238 
239 // Like strcpy() but allows overlapped source and destination.
240 #define STRMOVE(d, s) memmove((d), (s), STRLEN(s) + 1)
241 
242 #ifdef HAVE_STRNCASECMP
243 # define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
244 #else
245 # ifdef HAVE_STRNICMP
246 # define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n))
247 # else
248 # define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
249 # endif
250 #endif
251 
252 #define STRRCHR(s, c) (char_u *)strrchr((const char *)(s), (c))
253 
254 #define STRCAT(d, s) strcat((char *)(d), (char *)(s))
255 #define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
256 #define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
257 
258 #define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
259 
260 // Character used as separated in autoload function/variable names.
261 #define AUTOLOAD_CHAR '#'
262 
263 #include "nvim/message.h"
264 
265 // Prefer using semsg(), because perror() may send the output to the wrong
266 // destination and mess up the screen.
267 #define PERROR(msg) (void)semsg("%s: %s", msg, strerror(errno))
268 
269 #define SHOWCMD_COLS 10 // columns needed by shown command
270 
271 #include "nvim/path.h"
272 
285 #define fnamecmp(x, y) path_fnamecmp((const char *)(x), (const char *)(y))
286 #define fnamencmp(x, y, n) path_fnamencmp((const char *)(x), \
287  (const char *)(y), \
288  (size_t)(n))
289 
290 
291 // Enums need a typecast to be used as array index (for Ultrix).
292 #define HL_ATTR(n) highlight_attr[(int)(n)]
293 
297 #define MB_MAXBYTES 21
298 
299 // This has to go after the include of proto.h, as proto/gui.pro declares
300 // functions of these names. The declarations would break if the defines had
301 // been seen at that stage. But it must be before globals.h, where error_ga
302 // is declared.
303 #ifndef WIN32
304 # define mch_errmsg(str) fprintf(stderr, "%s", (str))
305 # define mch_msg(str) printf("%s", (str))
306 #endif
307 
308 #include "nvim/buffer_defs.h" // buffer and windows
309 #include "nvim/ex_cmds_defs.h" // Ex command defines
310 #include "nvim/globals.h" // global variables and messages
311 
312 // Lowest number used for window ID. Cannot have this many windows per tab.
313 #define LOWEST_WIN_ID 1000
314 
315 // BSD is supposed to cover FreeBSD and similar systems.
316 #if (defined(BSD) || defined(__FreeBSD_kernel__)) \
317  && (defined(S_ISCHR) || defined(S_IFCHR))
318 # define OPEN_CHR_FILES
319 #endif
320 
321 // Replacement for nchar used by nv_replace().
322 #define REPLACE_CR_NCHAR -1
323 #define REPLACE_NL_NCHAR -2
324 
325 #endif // NVIM_VIM_H
EXPAND_BOOL_SETTINGS
@ EXPAND_BOOL_SETTINGS
Definition: vim.h:119
EXPAND_USER_CMD_FLAGS
@ EXPAND_USER_CMD_FLAGS
Definition: vim.h:137
path.h
EXPAND_USER_VARS
@ EXPAND_USER_VARS
Definition: vim.h:129
EXPAND_TAGS
@ EXPAND_TAGS
Definition: vim.h:120
EXPAND_EVENTS
@ EXPAND_EVENTS
Definition: vim.h:124
EXPAND_OWNSYNTAX
@ EXPAND_OWNSYNTAX
Definition: vim.h:154
BACKWARD
@ BACKWARD
Definition: vim.h:84
types.h
EXPAND_COMPILER
@ EXPAND_COMPILER
Definition: vim.h:143
EXPAND_MENUNAMES
@ EXPAND_MENUNAMES
Definition: vim.h:135
EXPAND_COLORS
@ EXPAND_COLORS
Definition: vim.h:142
EXPAND_MENUS
@ EXPAND_MENUS
Definition: vim.h:125
Direction
Direction
Directions.
Definition: vim.h:81
EXPAND_HIGHLIGHT
@ EXPAND_HIGHLIGHT
Definition: vim.h:127
EXPAND_SYNTIME
@ EXPAND_SYNTIME
Definition: vim.h:158
macros.h
EXPAND_AUGROUP
@ EXPAND_AUGROUP
Definition: vim.h:128
EXPAND_USER_LUA
@ EXPAND_USER_LUA
Definition: vim.h:146
EXPAND_SYNTAX
@ EXPAND_SYNTAX
Definition: vim.h:126
EXPAND_PACKADD
@ EXPAND_PACKADD
Definition: vim.h:160
EXPAND_LOCALES
@ EXPAND_LOCALES
Definition: vim.h:155
EXPAND_USER_DEFINED
@ EXPAND_USER_DEFINED
Definition: vim.h:144
EXPAND_OK
@ EXPAND_OK
Definition: vim.h:113
EXPAND_FILES
@ EXPAND_FILES
Definition: vim.h:116
EXPAND_FUNCTIONS
@ EXPAND_FUNCTIONS
Definition: vim.h:132
EXPAND_USER_LIST
@ EXPAND_USER_LIST
Definition: vim.h:145
globals.h
EXPAND_LUA
@ EXPAND_LUA
Definition: vim.h:166
message.h
keymap.h
EXPAND_BEHAVE
@ EXPAND_BEHAVE
Definition: vim.h:151
EXPAND_PROFILE
@ EXPAND_PROFILE
Definition: vim.h:150
EXPAND_USER_NARGS
@ EXPAND_USER_NARGS
Definition: vim.h:138
gettext.h
NUMBUFLEN
@ NUMBUFLEN
Definition: vim.h:27
EXPAND_UNSUCCESSFUL
@ EXPAND_UNSUCCESSFUL
Definition: vim.h:112
EXPAND_USER_FUNC
@ EXPAND_USER_FUNC
Definition: vim.h:133
FORWARD
@ FORWARD
Definition: vim.h:83
EXPAND_SIGN
@ EXPAND_SIGN
Definition: vim.h:149
EXPAND_USER_COMPLETE
@ EXPAND_USER_COMPLETE
Definition: vim.h:139
EXPAND_EXPRESSION
@ EXPAND_EXPRESSION
Definition: vim.h:134
EXPAND_FILES_IN_PATH
@ EXPAND_FILES_IN_PATH
Definition: vim.h:153
kDirectionNotSet
@ kDirectionNotSet
Definition: vim.h:82
BACKWARD_FILE
@ BACKWARD_FILE
Definition: vim.h:86
FOLD_TEXT_LEN
@ FOLD_TEXT_LEN
Definition: vim.h:202
EXPAND_SETTINGS
@ EXPAND_SETTINGS
Definition: vim.h:118
EXPAND_NOTHING
@ EXPAND_NOTHING
Definition: vim.h:114
EXPAND_HELP
@ EXPAND_HELP
Definition: vim.h:122
EXPAND_OLD_SETTING
@ EXPAND_OLD_SETTING
Definition: vim.h:121
EXPAND_DIFF_BUFFERS
@ EXPAND_DIFF_BUFFERS
Definition: vim.h:164
EXPAND_HISTORY
@ EXPAND_HISTORY
Definition: vim.h:156
EXPAND_COMMANDS
@ EXPAND_COMMANDS
Definition: vim.h:115
os_defs.h
EXPAND_BUFFERS
@ EXPAND_BUFFERS
Definition: vim.h:123
FORWARD_FILE
@ FORWARD_FILE
Definition: vim.h:85
EXPAND_SHELLCMD
@ EXPAND_SHELLCMD
Definition: vim.h:147
EXPAND_ARGLIST
@ EXPAND_ARGLIST
Definition: vim.h:163
ex_cmds_defs.h
buffer_defs.h
EXPAND_USER
@ EXPAND_USER
Definition: vim.h:157
EXPAND_MAPCLEAR
@ EXPAND_MAPCLEAR
Definition: vim.h:162
EXPAND_MESSAGES
@ EXPAND_MESSAGES
Definition: vim.h:161
EXPAND_USER_COMMANDS
@ EXPAND_USER_COMMANDS
Definition: vim.h:136
EXPAND_LANGUAGE
@ EXPAND_LANGUAGE
Definition: vim.h:141
EXPAND_CHECKHEALTH
@ EXPAND_CHECKHEALTH
Definition: vim.h:165
EXPAND_FILETYPE
@ EXPAND_FILETYPE
Definition: vim.h:152
EXPAND_DIRECTORIES
@ EXPAND_DIRECTORIES
Definition: vim.h:117
EXPAND_MAPPINGS
@ EXPAND_MAPPINGS
Definition: vim.h:130
EXPAND_USER_ADDR_TYPE
@ EXPAND_USER_ADDR_TYPE
Definition: vim.h:159
EXPAND_TAGS_LISTFILES
@ EXPAND_TAGS_LISTFILES
Definition: vim.h:131
pos.h
EXPAND_CSCOPE
@ EXPAND_CSCOPE
Definition: vim.h:148
EXPAND_ENV_VARS
@ EXPAND_ENV_VARS
Definition: vim.h:140