ex_cmds_defs.h
Go to the documentation of this file.
1 #ifndef NVIM_EX_CMDS_DEFS_H
2 #define NVIM_EX_CMDS_DEFS_H
3 
4 #include <stdbool.h>
5 #include <stdint.h>
6 
7 #include "nvim/pos.h" // for linenr_T
8 #include "nvim/normal.h"
9 #include "nvim/regexp_defs.h"
10 
11 #ifdef INCLUDE_GENERATED_DECLARATIONS
12 # include "ex_cmds_enum.generated.h"
13 #endif
14 
15 /*
16  * When adding an Ex command:
17  * 1. Add an entry to the table in src/nvim/ex_cmds.lua. Keep it sorted on the
18  * shortest version of the command name that works. If it doesn't start with
19  * a lower case letter, add it at the end.
20  *
21  * Each table entry is a table with the following keys:
22  *
23  * Key | Description
24  * ------- | -------------------------------------------------------------
25  * command | Name of the command. Required.
26  * enum | Name of the enum entry. If not set defaults to CMD_{command}.
27  * flags | A set of the flags from below list joined by bitwise or.
28  * func | Name of the function containing the implementation.
29  *
30  * Referenced function should be either non-static one or defined in
31  * ex_docmd.c and be coercible to ex_func_T type from below.
32  *
33  * All keys not described in the above table are reserved for future use.
34  *
35  * 2. Add a "case: CMD_xxx" in the big switch in ex_docmd.c.
36  * 3. Add an entry in the index for Ex commands at ":help ex-cmd-index".
37  * 4. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
38  * long name of the command.
39  */
40 
41 #define RANGE 0x001 /* allow a linespecs */
42 #define BANG 0x002 /* allow a ! after the command name */
43 #define EXTRA 0x004 /* allow extra args after command name */
44 #define XFILE 0x008 /* expand wildcards in extra part */
45 #define NOSPC 0x010 /* no spaces allowed in the extra part */
46 #define DFLALL 0x020 /* default file range is 1,$ */
47 #define WHOLEFOLD 0x040 /* extend range to include whole fold also
48  when less than two numbers given */
49 #define NEEDARG 0x080 /* argument required */
50 #define TRLBAR 0x100 /* check for trailing vertical bar */
51 #define REGSTR 0x200 /* allow "x for register designation */
52 #define COUNT 0x400 /* allow count in argument, after command */
53 #define NOTRLCOM 0x800 /* no trailing comment allowed */
54 #define ZEROR 0x1000 /* zero line number allowed */
55 #define USECTRLV 0x2000 /* do not remove CTRL-V from argument */
56 #define NOTADR 0x4000 /* number before command is not an address */
57 #define EDITCMD 0x8000 /* allow "+command" argument */
58 #define BUFNAME 0x10000 /* accepts buffer name */
59 #define BUFUNL 0x20000 /* accepts unlisted buffer too */
60 #define ARGOPT 0x40000 /* allow "++opt=val" argument */
61 #define SBOXOK 0x80000 /* allowed in the sandbox */
62 #define CMDWIN 0x100000 /* allowed in cmdline window; when missing
63  * disallows editing another buffer when
64  * curbuf_lock is set */
65 #define MODIFY 0x200000 /* forbidden in non-'modifiable' buffer */
66 #define EXFLAGS 0x400000 /* allow flags after count in argument */
67 #define FILES (XFILE | EXTRA) /* multiple extra files allowed */
68 #define WORD1 (EXTRA | NOSPC) /* one extra word allowed */
69 #define FILE1 (FILES | NOSPC) /* 1 file allowed, defaults to current file */
70 
71 // values for cmd_addr_type
72 #define ADDR_LINES 0
73 #define ADDR_WINDOWS 1
74 #define ADDR_ARGUMENTS 2
75 #define ADDR_LOADED_BUFFERS 3
76 #define ADDR_BUFFERS 4
77 #define ADDR_TABS 5
78 #define ADDR_TABS_RELATIVE 6 // Tab page that only relative
79 #define ADDR_QUICKFIX 7
80 #define ADDR_OTHER 99
81 
82 typedef struct exarg exarg_T;
83 
84 /* behavior for bad character, "++bad=" argument */
85 #define BAD_REPLACE '?' /* replace it with '?' (default) */
86 #define BAD_KEEP -1 /* leave it */
87 #define BAD_DROP -2 /* erase it */
88 
89 typedef void (*ex_func_T)(exarg_T *eap);
90 
91 typedef char_u *(*LineGetter)(int, void *, int, bool);
92 
94 typedef struct cmdname {
97  uint32_t cmd_argt;
100 
102 struct exarg {
107  cmdidx_T cmdidx;
108  uint32_t argt;
109  int skip;
110  int forceit;
114  int addr_type;
115  int flags;
118  int append;
119  int usefilter;
120  int amount;
121  int regname;
122  int force_bin;
123  int read_edit;
124  int force_ff;
125  int force_enc;
126  int bad_char;
127  int useridx;
130  void *cookie;
131  struct condstack *cstack;
132 };
133 
134 #define FORCE_BIN 1 // ":edit ++bin file"
135 #define FORCE_NOBIN 2 // ":edit ++nobin file"
136 
137 // Values for "flags"
138 #define EXFLAG_LIST 0x01 // 'l': list
139 #define EXFLAG_NR 0x02 // '#': number
140 #define EXFLAG_PRINT 0x04 // 'p': print
141 
142 // used for completion on the command line
143 struct expand {
144  int xp_context; // type of expansion
145  char_u *xp_pattern; // start of item to expand
146  size_t xp_pattern_len; // bytes in xp_pattern before cursor
147  char_u *xp_arg; // completion function
148  sctx_T xp_script_ctx; // SCTX for completion function
149  int xp_backslash; // one of the XP_BS_ values
150 #ifndef BACKSLASH_IN_FILENAME
151  int xp_shell; // TRUE for a shell command, more
152  // characters need to be escaped
153 #endif
154  int xp_numfiles; // number of files found by file name completion
155  char_u **xp_files; // list of files
156  char_u *xp_line; // text being completed
157  int xp_col; // cursor position in line
158 };
159 
160 // values for xp_backslash
161 #define XP_BS_NONE 0 // nothing special for backslashes
162 #define XP_BS_ONE 1 // uses one backslash before a space
163 #define XP_BS_THREE 2 // uses three backslashes before a space
164 
168 typedef struct {
169  int split;
170  int tab;
171  bool browse;
172  bool confirm;
173  bool hide;
174  bool keepalt;
175  bool keepjumps;
176  bool keepmarks;
178  bool lockmarks;
179  bool noswapfile;
183 } cmdmod_T;
184 
185 #endif // NVIM_EX_CMDS_DEFS_H
char_u * xp_arg
Definition: ex_cmds_defs.h:147
Definition: ex_eval.h:25
int xp_numfiles
Definition: ex_cmds_defs.h:154
char_u * save_ei
saved value of &#39;eventignore&#39;
Definition: ex_cmds_defs.h:180
LineGetter getline
Function used to get the next line.
Definition: ex_cmds_defs.h:129
char_u * cmd_name
Name of the command.
Definition: ex_cmds_defs.h:95
bool lockmarks
true when ":lockmarks" was used
Definition: ex_cmds_defs.h:178
int split
flags for win_split()
Definition: ex_cmds_defs.h:169
linenr_T do_ecmd_lnum
the line number in an edited file
Definition: ex_cmds_defs.h:117
char_u ** cmdlinep
pointer to pointer of allocated cmdline
Definition: ex_cmds_defs.h:106
char_u ** xp_files
Definition: ex_cmds_defs.h:155
bool keepalt
true when ":keepalt" was used
Definition: ex_cmds_defs.h:174
int amount
number of &#39;>&#39; or &#39;<&#39; for shift command
Definition: ex_cmds_defs.h:120
uint32_t argt
flags for the command
Definition: ex_cmds_defs.h:108
int force_bin
0, FORCE_BIN or FORCE_NOBIN
Definition: ex_cmds_defs.h:122
Structure for command definition.
Definition: ex_cmds_defs.h:94
char_u * arg
argument of the command
Definition: ex_cmds_defs.h:103
int xp_shell
Definition: ex_cmds_defs.h:151
int regname
register name (NUL if none)
Definition: ex_cmds_defs.h:121
char_u * do_ecmd_cmd
+command arg to be used in edited file
Definition: ex_cmds_defs.h:116
int force_enc
++enc= argument (index in cmd[])
Definition: ex_cmds_defs.h:125
char_u * errmsg
returned error message
Definition: ex_cmds_defs.h:128
struct condstack * cstack
condition stack for ":if" etc.
Definition: ex_cmds_defs.h:131
linenr_T line2
the second line number or count
Definition: ex_cmds_defs.h:113
Definition: regexp_defs.h:139
bool keepmarks
true when ":keepmarks" was used
Definition: ex_cmds_defs.h:176
int useridx
user command index
Definition: ex_cmds_defs.h:127
void(* ex_func_T)(exarg_T *eap)
Definition: ex_cmds_defs.h:89
int xp_col
Definition: ex_cmds_defs.h:157
int tab
0 when ":tab" was used
Definition: ex_cmds_defs.h:170
size_t xp_pattern_len
Definition: ex_cmds_defs.h:146
char_u * xp_line
Definition: ex_cmds_defs.h:156
int read_edit
++edit argument
Definition: ex_cmds_defs.h:123
int bad_char
BAD_KEEP, BAD_DROP or replacement byte.
Definition: ex_cmds_defs.h:126
sctx_T xp_script_ctx
Definition: ex_cmds_defs.h:148
int xp_context
Definition: ex_cmds_defs.h:144
struct cmdname CommandDefinition
Structure for command definition.
ex_func_T cmd_func
Function with implementation of this command.
Definition: ex_cmds_defs.h:96
cmdidx_T cmdidx
the index for the command
Definition: ex_cmds_defs.h:107
int addr_count
the number of addresses given
Definition: ex_cmds_defs.h:111
Definition: ex_cmds_defs.h:168
bool keeppatterns
true when ":keeppatterns" was used
Definition: ex_cmds_defs.h:177
int addr_type
type of the count/range
Definition: ex_cmds_defs.h:114
uint32_t cmd_argt
Relevant flags from the declared above.
Definition: ex_cmds_defs.h:97
void * cookie
argument for getline()
Definition: ex_cmds_defs.h:130
int append
TRUE with ":w >>file" command.
Definition: ex_cmds_defs.h:118
char_u * xp_pattern
Definition: ex_cmds_defs.h:145
Arguments used for Ex commands.
Definition: ex_cmds_defs.h:102
int cmd_addr_type
Flag for address type.
Definition: ex_cmds_defs.h:98
int flags
extra flags after count: EXFLAG_
Definition: ex_cmds_defs.h:115
long linenr_T
Definition: pos.h:4
int usefilter
TRUE with ":w !command" and ":r!command".
Definition: ex_cmds_defs.h:119
bool filter_force
set for :filter!
Definition: ex_cmds_defs.h:182
unsigned char char_u
Definition: types.h:11
bool keepjumps
true when ":keepjumps" was used
Definition: ex_cmds_defs.h:175
regmatch_T filter_regmatch
set by :filter /pat/
Definition: ex_cmds_defs.h:181
char_u *(* LineGetter)(int, void *, int, bool)
Definition: ex_cmds_defs.h:91
int skip
don&#39;t execute the command, only parse it
Definition: ex_cmds_defs.h:109
int force_ff
++ff= argument (index in cmd[])
Definition: ex_cmds_defs.h:124
bool hide
true when ":hide" was used
Definition: ex_cmds_defs.h:173
Definition: typval.h:255
char_u * nextcmd
next command (NULL if none)
Definition: ex_cmds_defs.h:104
bool browse
true to invoke file dialog
Definition: ex_cmds_defs.h:171
char_u * cmd
the name of the command (except for :make)
Definition: ex_cmds_defs.h:105
Definition: ex_cmds_defs.h:143
int xp_backslash
Definition: ex_cmds_defs.h:149
bool confirm
true to invoke yes/no dialog
Definition: ex_cmds_defs.h:172
bool noswapfile
true when ":noswapfile" was used
Definition: ex_cmds_defs.h:179
linenr_T line1
the first line number
Definition: ex_cmds_defs.h:112
int forceit
TRUE if ! present.
Definition: ex_cmds_defs.h:110