comparison src/nv_cmds.h @ 27484:ee1019e59bef v8.2.4270

patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice Commit: https://github.com/vim/vim/commit/672776dbe8427876ef4bfce84520712df87b6eb1 Author: ichizok <gclient.gaap@gmail.com> Date: Mon Jan 31 12:27:18 2022 +0000 patch 8.2.4270: generating nv_cmdidxs.h requires building Vim twice Problem: Generating nv_cmdidxs.h requires building Vim twice. Solution: Move the table into a separate file and use a separate executable to extract the command characters. (Ozaki Kiichi, closes #9669)
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 Jan 2022 13:30:05 +0100
parents
children 50555279168b
comparison
equal deleted inserted replaced
27483:e5134251817a 27484:ee1019e59bef
1 /* vi:set ts=8 sts=4 sw=4 noet:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar et al.
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9 /*
10 * This file defines the Normal mode commands.
11 */
12
13 /*
14 * When adding a Normal/Visual mode command:
15 * 1. Add an entry in the table `nv_cmds[]` below.
16 * 2. Run "make nvcmdidxs" to re-generate nv_cmdidxs.h.
17 * 3. Add an entry in the index for Normal/Visual commands at
18 * ":help normal-index" and ":help visual-index" .
19 * 4. Add documentation in ../doc/xxx.txt. Add a tag for both the short and
20 * long name of the command.
21 */
22
23 #ifdef DO_DECLARE_NVCMD
24
25 /*
26 * Used when building Vim.
27 */
28 # define NVCMD(a, b, c, d) {a, b, c, d}
29
30 #ifdef FEAT_GUI
31 #define NV_VER_SCROLLBAR nv_ver_scrollbar
32 #define NV_HOR_SCROLLBAR nv_hor_scrollbar
33 #else
34 #define NV_VER_SCROLLBAR nv_error
35 #define NV_HOR_SCROLLBAR nv_error
36 #endif
37
38 #ifdef FEAT_GUI_TABLINE
39 #define NV_TABLINE nv_tabline
40 #define NV_TABMENU nv_tabmenu
41 #else
42 #define NV_TABLINE nv_error
43 #define NV_TABMENU nv_error
44 #endif
45
46 #ifdef FEAT_NETBEANS_INTG
47 #define NV_NBCMD nv_nbcmd
48 #else
49 #define NV_NBCMD nv_error
50 #endif
51
52 #ifdef FEAT_DND
53 #define NV_DROP nv_drop
54 #else
55 #define NV_DROP nv_error
56 #endif
57
58 /*
59 * Function to be called for a Normal or Visual mode command.
60 * The argument is a cmdarg_T.
61 */
62 typedef void (*nv_func_T)(cmdarg_T *cap);
63
64 // Values for cmd_flags.
65 #define NV_NCH 0x01 // may need to get a second char
66 #define NV_NCH_NOP (0x02|NV_NCH) // get second char when no operator pending
67 #define NV_NCH_ALW (0x04|NV_NCH) // always get a second char
68 #define NV_LANG 0x08 // second char needs language adjustment
69
70 #define NV_SS 0x10 // may start selection
71 #define NV_SSS 0x20 // may start selection with shift modifier
72 #define NV_STS 0x40 // may stop selection without shift modif.
73 #define NV_RL 0x80 // 'rightleft' modifies command
74 #define NV_KEEPREG 0x100 // don't clear regname
75 #define NV_NCW 0x200 // not allowed in command-line window
76
77 /*
78 * Generally speaking, every Normal mode command should either clear any
79 * pending operator (with *clearop*()), or set the motion type variable
80 * oap->motion_type.
81 *
82 * When a cursor motion command is made, it is marked as being a character or
83 * line oriented motion. Then, if an operator is in effect, the operation
84 * becomes character or line oriented accordingly.
85 */
86
87 /*
88 * This table contains one entry for every Normal or Visual mode command.
89 * The order doesn't matter, this will be sorted by the create_nvcmdidx.vim
90 * script to generate the nv_cmd_idx[] lookup table.
91 * It is faster when all keys from zero to '~' are present.
92 */
93 static const struct nv_cmd
94 {
95 int cmd_char; // (first) command character
96 nv_func_T cmd_func; // function for this command
97 short_u cmd_flags; // NV_ flags
98 short cmd_arg; // value for ca.arg
99 } nv_cmds[] =
100
101 #else // DO_DECLARE_NVCMD
102
103 /*
104 * Used when creating nv_cmdidxs.h.
105 */
106 # define NVCMD(a, b, c, d) a
107 static const int nv_cmds[] =
108
109 #endif // DO_DECLARE_NVCMD
110 {
111 NVCMD(NUL, nv_error, 0, 0),
112 NVCMD(Ctrl_A, nv_addsub, 0, 0),
113 NVCMD(Ctrl_B, nv_page, NV_STS, BACKWARD),
114 NVCMD(Ctrl_C, nv_esc, 0, TRUE),
115 NVCMD(Ctrl_D, nv_halfpage, 0, 0),
116 NVCMD(Ctrl_E, nv_scroll_line, 0, TRUE),
117 NVCMD(Ctrl_F, nv_page, NV_STS, FORWARD),
118 NVCMD(Ctrl_G, nv_ctrlg, 0, 0),
119 NVCMD(Ctrl_H, nv_ctrlh, 0, 0),
120 NVCMD(Ctrl_I, nv_pcmark, 0, 0),
121 NVCMD(NL, nv_down, 0, FALSE),
122 NVCMD(Ctrl_K, nv_error, 0, 0),
123 NVCMD(Ctrl_L, nv_clear, 0, 0),
124 NVCMD(CAR, nv_down, 0, TRUE),
125 NVCMD(Ctrl_N, nv_down, NV_STS, FALSE),
126 NVCMD(Ctrl_O, nv_ctrlo, 0, 0),
127 NVCMD(Ctrl_P, nv_up, NV_STS, FALSE),
128 NVCMD(Ctrl_Q, nv_visual, 0, FALSE),
129 NVCMD(Ctrl_R, nv_redo_or_register, 0, 0),
130 NVCMD(Ctrl_S, nv_ignore, 0, 0),
131 NVCMD(Ctrl_T, nv_tagpop, NV_NCW, 0),
132 NVCMD(Ctrl_U, nv_halfpage, 0, 0),
133 NVCMD(Ctrl_V, nv_visual, 0, FALSE),
134 NVCMD(Ctrl_W, nv_window, 0, 0),
135 NVCMD(Ctrl_X, nv_addsub, 0, 0),
136 NVCMD(Ctrl_Y, nv_scroll_line, 0, FALSE),
137 NVCMD(Ctrl_Z, nv_suspend, 0, 0),
138 NVCMD(ESC, nv_esc, 0, FALSE),
139 NVCMD(Ctrl_BSL, nv_normal, NV_NCH_ALW, 0),
140 NVCMD(Ctrl_RSB, nv_ident, NV_NCW, 0),
141 NVCMD(Ctrl_HAT, nv_hat, NV_NCW, 0),
142 NVCMD(Ctrl__, nv_error, 0, 0),
143 NVCMD(' ', nv_right, 0, 0),
144 NVCMD('!', nv_operator, 0, 0),
145 NVCMD('"', nv_regname, NV_NCH_NOP|NV_KEEPREG, 0),
146 NVCMD('#', nv_ident, 0, 0),
147 NVCMD('$', nv_dollar, 0, 0),
148 NVCMD('%', nv_percent, 0, 0),
149 NVCMD('&', nv_optrans, 0, 0),
150 NVCMD('\'', nv_gomark, NV_NCH_ALW, TRUE),
151 NVCMD('(', nv_brace, 0, BACKWARD),
152 NVCMD(')', nv_brace, 0, FORWARD),
153 NVCMD('*', nv_ident, 0, 0),
154 NVCMD('+', nv_down, 0, TRUE),
155 NVCMD(',', nv_csearch, 0, TRUE),
156 NVCMD('-', nv_up, 0, TRUE),
157 NVCMD('.', nv_dot, NV_KEEPREG, 0),
158 NVCMD('/', nv_search, 0, FALSE),
159 NVCMD('0', nv_beginline, 0, 0),
160 NVCMD('1', nv_ignore, 0, 0),
161 NVCMD('2', nv_ignore, 0, 0),
162 NVCMD('3', nv_ignore, 0, 0),
163 NVCMD('4', nv_ignore, 0, 0),
164 NVCMD('5', nv_ignore, 0, 0),
165 NVCMD('6', nv_ignore, 0, 0),
166 NVCMD('7', nv_ignore, 0, 0),
167 NVCMD('8', nv_ignore, 0, 0),
168 NVCMD('9', nv_ignore, 0, 0),
169 NVCMD(':', nv_colon, 0, 0),
170 NVCMD(';', nv_csearch, 0, FALSE),
171 NVCMD('<', nv_operator, NV_RL, 0),
172 NVCMD('=', nv_operator, 0, 0),
173 NVCMD('>', nv_operator, NV_RL, 0),
174 NVCMD('?', nv_search, 0, FALSE),
175 NVCMD('@', nv_at, NV_NCH_NOP, FALSE),
176 NVCMD('A', nv_edit, 0, 0),
177 NVCMD('B', nv_bck_word, 0, 1),
178 NVCMD('C', nv_abbrev, NV_KEEPREG, 0),
179 NVCMD('D', nv_abbrev, NV_KEEPREG, 0),
180 NVCMD('E', nv_wordcmd, 0, TRUE),
181 NVCMD('F', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD),
182 NVCMD('G', nv_goto, 0, TRUE),
183 NVCMD('H', nv_scroll, 0, 0),
184 NVCMD('I', nv_edit, 0, 0),
185 NVCMD('J', nv_join, 0, 0),
186 NVCMD('K', nv_ident, 0, 0),
187 NVCMD('L', nv_scroll, 0, 0),
188 NVCMD('M', nv_scroll, 0, 0),
189 NVCMD('N', nv_next, 0, SEARCH_REV),
190 NVCMD('O', nv_open, 0, 0),
191 NVCMD('P', nv_put, 0, 0),
192 NVCMD('Q', nv_exmode, NV_NCW, 0),
193 NVCMD('R', nv_Replace, 0, FALSE),
194 NVCMD('S', nv_subst, NV_KEEPREG, 0),
195 NVCMD('T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD),
196 NVCMD('U', nv_Undo, 0, 0),
197 NVCMD('V', nv_visual, 0, FALSE),
198 NVCMD('W', nv_wordcmd, 0, TRUE),
199 NVCMD('X', nv_abbrev, NV_KEEPREG, 0),
200 NVCMD('Y', nv_abbrev, NV_KEEPREG, 0),
201 NVCMD('Z', nv_Zet, NV_NCH_NOP|NV_NCW, 0),
202 NVCMD('[', nv_brackets, NV_NCH_ALW, BACKWARD),
203 NVCMD('\\', nv_error, 0, 0),
204 NVCMD(']', nv_brackets, NV_NCH_ALW, FORWARD),
205 NVCMD('^', nv_beginline, 0, BL_WHITE | BL_FIX),
206 NVCMD('_', nv_lineop, 0, 0),
207 NVCMD('`', nv_gomark, NV_NCH_ALW, FALSE),
208 NVCMD('a', nv_edit, NV_NCH, 0),
209 NVCMD('b', nv_bck_word, 0, 0),
210 NVCMD('c', nv_operator, 0, 0),
211 NVCMD('d', nv_operator, 0, 0),
212 NVCMD('e', nv_wordcmd, 0, FALSE),
213 NVCMD('f', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD),
214 NVCMD('g', nv_g_cmd, NV_NCH_ALW, FALSE),
215 NVCMD('h', nv_left, NV_RL, 0),
216 NVCMD('i', nv_edit, NV_NCH, 0),
217 NVCMD('j', nv_down, 0, FALSE),
218 NVCMD('k', nv_up, 0, FALSE),
219 NVCMD('l', nv_right, NV_RL, 0),
220 NVCMD('m', nv_mark, NV_NCH_NOP, 0),
221 NVCMD('n', nv_next, 0, 0),
222 NVCMD('o', nv_open, 0, 0),
223 NVCMD('p', nv_put, 0, 0),
224 NVCMD('q', nv_record, NV_NCH, 0),
225 NVCMD('r', nv_replace, NV_NCH_NOP|NV_LANG, 0),
226 NVCMD('s', nv_subst, NV_KEEPREG, 0),
227 NVCMD('t', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD),
228 NVCMD('u', nv_undo, 0, 0),
229 NVCMD('v', nv_visual, 0, FALSE),
230 NVCMD('w', nv_wordcmd, 0, FALSE),
231 NVCMD('x', nv_abbrev, NV_KEEPREG, 0),
232 NVCMD('y', nv_operator, 0, 0),
233 NVCMD('z', nv_zet, NV_NCH_ALW, 0),
234 NVCMD('{', nv_findpar, 0, BACKWARD),
235 NVCMD('|', nv_pipe, 0, 0),
236 NVCMD('}', nv_findpar, 0, FORWARD),
237 NVCMD('~', nv_tilde, 0, 0),
238
239 // pound sign
240 NVCMD(POUND, nv_ident, 0, 0),
241 NVCMD(K_MOUSEUP, nv_mousescroll, 0, MSCR_UP),
242 NVCMD(K_MOUSEDOWN, nv_mousescroll, 0, MSCR_DOWN),
243 NVCMD(K_MOUSELEFT, nv_mousescroll, 0, MSCR_LEFT),
244 NVCMD(K_MOUSERIGHT, nv_mousescroll, 0, MSCR_RIGHT),
245 NVCMD(K_LEFTMOUSE, nv_mouse, 0, 0),
246 NVCMD(K_LEFTMOUSE_NM, nv_mouse, 0, 0),
247 NVCMD(K_LEFTDRAG, nv_mouse, 0, 0),
248 NVCMD(K_LEFTRELEASE, nv_mouse, 0, 0),
249 NVCMD(K_LEFTRELEASE_NM, nv_mouse, 0, 0),
250 NVCMD(K_MOUSEMOVE, nv_mouse, 0, 0),
251 NVCMD(K_MIDDLEMOUSE, nv_mouse, 0, 0),
252 NVCMD(K_MIDDLEDRAG, nv_mouse, 0, 0),
253 NVCMD(K_MIDDLERELEASE, nv_mouse, 0, 0),
254 NVCMD(K_RIGHTMOUSE, nv_mouse, 0, 0),
255 NVCMD(K_RIGHTDRAG, nv_mouse, 0, 0),
256 NVCMD(K_RIGHTRELEASE, nv_mouse, 0, 0),
257 NVCMD(K_X1MOUSE, nv_mouse, 0, 0),
258 NVCMD(K_X1DRAG, nv_mouse, 0, 0),
259 NVCMD(K_X1RELEASE, nv_mouse, 0, 0),
260 NVCMD(K_X2MOUSE, nv_mouse, 0, 0),
261 NVCMD(K_X2DRAG, nv_mouse, 0, 0),
262 NVCMD(K_X2RELEASE, nv_mouse, 0, 0),
263 NVCMD(K_IGNORE, nv_ignore, NV_KEEPREG, 0),
264 NVCMD(K_NOP, nv_nop, 0, 0),
265 NVCMD(K_INS, nv_edit, 0, 0),
266 NVCMD(K_KINS, nv_edit, 0, 0),
267 NVCMD(K_BS, nv_ctrlh, 0, 0),
268 NVCMD(K_UP, nv_up, NV_SSS|NV_STS, FALSE),
269 NVCMD(K_S_UP, nv_page, NV_SS, BACKWARD),
270 NVCMD(K_DOWN, nv_down, NV_SSS|NV_STS, FALSE),
271 NVCMD(K_S_DOWN, nv_page, NV_SS, FORWARD),
272 NVCMD(K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0),
273 NVCMD(K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0),
274 NVCMD(K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1),
275 NVCMD(K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0),
276 NVCMD(K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, FALSE),
277 NVCMD(K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, TRUE),
278 NVCMD(K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD),
279 NVCMD(K_KPAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD),
280 NVCMD(K_PAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD),
281 NVCMD(K_KPAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD),
282 NVCMD(K_END, nv_end, NV_SSS|NV_STS, FALSE),
283 NVCMD(K_KEND, nv_end, NV_SSS|NV_STS, FALSE),
284 NVCMD(K_S_END, nv_end, NV_SS, FALSE),
285 NVCMD(K_C_END, nv_end, NV_SSS|NV_STS, TRUE),
286 NVCMD(K_HOME, nv_home, NV_SSS|NV_STS, 0),
287 NVCMD(K_KHOME, nv_home, NV_SSS|NV_STS, 0),
288 NVCMD(K_S_HOME, nv_home, NV_SS, 0),
289 NVCMD(K_C_HOME, nv_goto, NV_SSS|NV_STS, FALSE),
290 NVCMD(K_DEL, nv_abbrev, 0, 0),
291 NVCMD(K_KDEL, nv_abbrev, 0, 0),
292 NVCMD(K_UNDO, nv_kundo, 0, 0),
293 NVCMD(K_HELP, nv_help, NV_NCW, 0),
294 NVCMD(K_F1, nv_help, NV_NCW, 0),
295 NVCMD(K_XF1, nv_help, NV_NCW, 0),
296 NVCMD(K_SELECT, nv_select, 0, 0),
297 NVCMD(K_VER_SCROLLBAR, NV_VER_SCROLLBAR, 0, 0),
298 NVCMD(K_HOR_SCROLLBAR, NV_HOR_SCROLLBAR, 0, 0),
299 NVCMD(K_TABLINE, NV_TABLINE, 0, 0),
300 NVCMD(K_TABMENU, NV_TABMENU, 0, 0),
301 NVCMD(K_F21, NV_NBCMD, NV_NCH_ALW, 0),
302 NVCMD(K_DROP, NV_DROP, NV_STS, 0),
303 NVCMD(K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0),
304 NVCMD(K_PS, nv_edit, 0, 0),
305 NVCMD(K_COMMAND, nv_colon, 0, 0),
306 NVCMD(K_SCRIPT_COMMAND, nv_colon, 0, 0),
307 };
308
309 // Number of commands in nv_cmds[].
310 #define NV_CMDS_SIZE ARRAY_LENGTH(nv_cmds)