vim.h
Go to the documentation of this file.
1 #ifndef NVIM_VIM_H
2 #define NVIM_VIM_H
3 
4 #include "nvim/types.h"
5 #include "nvim/pos.h" // for linenr_T, MAXCOL, etc...
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/keymap.h"
34 #include "nvim/macros.h"
35 
36 #include "nvim/gettext.h"
37 
38 // special attribute addition: Put message in history
39 #define MSG_HIST 0x1000
40 
41 
42 // values for State
43 //
44 // The lower bits up to 0x20 are used to distinguish normal/visual/op_pending
45 // and cmdline/insert+replace mode. This is used for mapping. If none of
46 // these bits are set, no mapping is done.
47 // The upper bits are used to distinguish between other states.
48 
49 #define NORMAL 0x01 // Normal mode, command expected
50 #define VISUAL 0x02 // Visual mode - use get_real_state()
51 #define OP_PENDING 0x04 // Normal mode, operator is pending - use
52  // get_real_state()
53 #define CMDLINE 0x08 // Editing command line
54 #define INSERT 0x10 // Insert mode
55 #define LANGMAP 0x20 // Language mapping, can be combined with
56  // INSERT and CMDLINE
57 
58 #define REPLACE_FLAG 0x40 // Replace mode flag
59 #define REPLACE (REPLACE_FLAG + INSERT)
60 # define VREPLACE_FLAG 0x80 // Virtual-replace mode flag
61 # define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
62 #define LREPLACE (REPLACE_FLAG + LANGMAP)
63 
64 #define NORMAL_BUSY (0x100 + NORMAL) // Normal mode, busy with a command
65 #define HITRETURN (0x200 + NORMAL) // waiting for return or command
66 #define ASKMORE 0x300 // Asking if you want --more--
67 #define SETWSIZE 0x400 // window size has changed
68 #define ABBREV 0x500 // abbreviation instead of mapping
69 #define EXTERNCMD 0x600 // executing an external command
70 #define SHOWMATCH (0x700 + INSERT) // show matching paren
71 #define CONFIRM 0x800 // ":confirm" prompt
72 #define SELECTMODE 0x1000 // Select mode, only for mappings
73 #define TERM_FOCUS 0x2000 // Terminal focus mode
74 #define CMDPREVIEW 0x4000 // Showing 'inccommand' command "live" preview.
75 
76 // all mode bits used for mapping
77 #define MAP_ALL_MODES (0x3f | SELECTMODE | TERM_FOCUS)
78 
80 typedef enum {
82  FORWARD = 1,
83  BACKWARD = (-1),
85  BACKWARD_FILE = (-3),
86 } Direction;
87 
88 // return values for functions
89 #if !(defined(OK) && (OK == 1))
90 // OK already defined to 1 in MacOS X curses, skip this
91 # define OK 1
92 #endif
93 #define FAIL 0
94 #define NOTDONE 2 // not OK or FAIL but skipped
95 
96 // Type values for type().
97 #define VAR_TYPE_NUMBER 0
98 #define VAR_TYPE_STRING 1
99 #define VAR_TYPE_FUNC 2
100 #define VAR_TYPE_LIST 3
101 #define VAR_TYPE_DICT 4
102 #define VAR_TYPE_FLOAT 5
103 #define VAR_TYPE_BOOL 6
104 
105 
106 // values for xp_context when doing command line completion
107 
108 enum {
110  EXPAND_OK = -1,
161 };
162 
163 
164 
165 
166 // Minimal size for block 0 of a swap file.
167 // NOTE: This depends on size of struct block0! It's not done with a sizeof(),
168 // because struct block0 is defined in memline.c (Sorry).
169 // The maximal block size is arbitrary.
170 
171 #define MIN_SWAP_PAGE_SIZE 1048
172 #define MAX_SWAP_PAGE_SIZE 50000
173 
174 
175 
176 // Boolean constants
177 
178 #ifndef TRUE
179 # define FALSE 0 // note: this is an int, not a long!
180 # define TRUE 1
181 #endif
182 
183 #define MAYBE 2 // sometimes used for a variant on TRUE
184 
185 #define STATUS_HEIGHT 1 // height of a status line under a window
186 #define QF_WINHEIGHT 10 // default height for quickfix window
187 
188 
189 // Buffer sizes
190 
191 #ifndef CMDBUFFSIZE
192 # define CMDBUFFSIZE 256 // size of the command processing buffer
193 #endif
194 
195 #define LSIZE 512 // max. size of a line in the tags file
196 
197 #define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg()
198 
199 enum { FOLD_TEXT_LEN = 51 };
200 
201 
202 // Maximum length of key sequence to be mapped.
203 // Must be able to hold an Amiga resize report.
204 
205 #define MAXMAPLEN 50
206 
207 // Size in bytes of the hash used in the undo file.
208 #define UNDO_HASH_SIZE 32
209 
210 
211 // defines to avoid typecasts from (char_u *) to (char *) and back
212 // (vim_strchr() is now in strings.c)
213 
214 #define STRLEN(s) strlen((char *)(s))
215 #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
216 #define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n))
217 #define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))
218 #define STRCMP(d, s) strcmp((char *)(d), (char *)(s))
219 #define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
220 #ifdef HAVE_STRCASECMP
221 # define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
222 #else
223 # ifdef HAVE_STRICMP
224 # define STRICMP(d, s) stricmp((char *)(d), (char *)(s))
225 # else
226 # define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s))
227 # endif
228 #endif
229 
230 // Like strcpy() but allows overlapped source and destination.
231 #define STRMOVE(d, s) memmove((d), (s), STRLEN(s) + 1)
232 
233 #ifdef HAVE_STRNCASECMP
234 # define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
235 #else
236 # ifdef HAVE_STRNICMP
237 # define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n))
238 # else
239 # define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
240 # endif
241 #endif
242 
243 #define STRRCHR(s, c) (char_u *)strrchr((const char *)(s), (c))
244 
245 #define STRCAT(d, s) strcat((char *)(d), (char *)(s))
246 #define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
247 #define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
248 
249 # define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
250 
251 #include "nvim/message.h"
252 
253 // Prefer using emsgf(), because perror() may send the output to the wrong
254 // destination and mess up the screen.
255 #define PERROR(msg) (void) emsgf("%s: %s", msg, strerror(errno))
256 
257 #define SHOWCMD_COLS 10 // columns needed by shown command
258 #define STL_MAX_ITEM 80 // max nr of %<flag> in statusline
259 
272 #define fnamecmp(x, y) path_fnamecmp((const char *)(x), (const char *)(y))
273 #define fnamencmp(x, y, n) path_fnamencmp((const char *)(x), \
274  (const char *)(y), \
275  (size_t)(n))
276 
277 
278 // Enums need a typecast to be used as array index (for Ultrix).
279 #define HL_ATTR(n) highlight_attr[(int)(n)]
280 
284 #define MB_MAXBYTES 21
285 
286 // This has to go after the include of proto.h, as proto/gui.pro declares
287 // functions of these names. The declarations would break if the defines had
288 // been seen at that stage. But it must be before globals.h, where error_ga
289 // is declared.
290 #ifndef WIN32
291 # define mch_errmsg(str) fprintf(stderr, "%s", (str))
292 # define mch_msg(str) printf("%s", (str))
293 #endif
294 
295 #include "nvim/globals.h" // global variables and messages
296 #include "nvim/buffer_defs.h" // buffer and windows
297 #include "nvim/ex_cmds_defs.h" // Ex command defines
298 
299 # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr( \
300  VV_HLSEARCH, !no_hlsearch && p_hls)
301 
302 // Used for flags in do_in_path()
303 #define DIP_ALL 0x01 // all matches, not just the first one
304 #define DIP_DIR 0x02 // find directories instead of files
305 #define DIP_ERR 0x04 // give an error message when none found
306 #define DIP_START 0x08 // also use "start" directory in 'packpath'
307 #define DIP_OPT 0x10 // also use "opt" directory in 'packpath'
308 #define DIP_NORTP 0x20 // do not use 'runtimepath'
309 #define DIP_NOAFTER 0x40 // skip "after" directories
310 #define DIP_AFTER 0x80 // only use "after" directories
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__)) && defined(S_ISCHR)
317 # define OPEN_CHR_FILES
318 #endif
319 
320 // Replacement for nchar used by nv_replace().
321 #define REPLACE_CR_NCHAR -1
322 #define REPLACE_NL_NCHAR -2
323 
324 #endif // NVIM_VIM_H
Definition: vim.h:152
Definition: vim.h:112
Definition: vim.h:120
Definition: vim.h:134
Definition: vim.h:139
Definition: vim.h:128
Definition: vim.h:27
Definition: vim.h:136
Definition: vim.h:123
Definition: vim.h:143
Definition: vim.h:135
Definition: vim.h:146
Definition: vim.h:132
Definition: vim.h:125
Definition: vim.h:159
Definition: vim.h:156
Definition: vim.h:137
Definition: vim.h:151
Definition: vim.h:118
Definition: vim.h:149
Definition: vim.h:160
Definition: vim.h:127
Definition: vim.h:142
Definition: vim.h:155
Definition: vim.h:158
Definition: vim.h:157
Definition: vim.h:114
Definition: vim.h:141
Definition: vim.h:199
Definition: vim.h:129
Definition: vim.h:117
Definition: vim.h:130
Definition: vim.h:122
Definition: vim.h:124
Definition: vim.h:150
Definition: vim.h:148
Definition: vim.h:133
Definition: vim.h:144
Definition: vim.h:153
Definition: vim.h:115
Definition: vim.h:110
Definition: vim.h:113
Definition: vim.h:121
Definition: vim.h:81
Definition: vim.h:140
Definition: vim.h:145
Definition: vim.h:116
Definition: vim.h:84
Direction
Directions.
Definition: vim.h:80
Definition: vim.h:109
Definition: vim.h:82
Definition: vim.h:138
Definition: vim.h:147
Definition: vim.h:154
Definition: vim.h:83
Definition: vim.h:119
Definition: vim.h:126
Definition: vim.h:111
Definition: vim.h:85
Definition: vim.h:131