mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
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)
This commit is contained in:
315
src/normal.c
315
src/normal.c
@@ -1,6 +1,6 @@
|
||||
/* vi:set ts=8 sts=4 sw=4 noet:
|
||||
*
|
||||
* VIM - Vi IMproved by Bram Moolenaar
|
||||
* VIM - Vi IMproved by Bram Moolenaar et al.
|
||||
*
|
||||
* Do ":help uganda" in Vim to read copying and usage conditions.
|
||||
* Do ":help credits" in Vim to see a list of people who contributed.
|
||||
@@ -127,320 +127,13 @@ static void nv_drop(cmdarg_T *cap);
|
||||
#endif
|
||||
static void nv_cursorhold(cmdarg_T *cap);
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
#define NV_VER_SCROLLBAR nv_ver_scrollbar
|
||||
#define NV_HOR_SCROLLBAR nv_hor_scrollbar
|
||||
#else
|
||||
#define NV_VER_SCROLLBAR nv_error
|
||||
#define NV_HOR_SCROLLBAR nv_error
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_GUI_TABLINE
|
||||
#define NV_TABLINE nv_tabline
|
||||
#define NV_TABMENU nv_tabmenu
|
||||
#else
|
||||
#define NV_TABLINE nv_error
|
||||
#define NV_TABMENU nv_error
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_NETBEANS_INTG
|
||||
#define NV_NBCMD nv_nbcmd
|
||||
#else
|
||||
#define NV_NBCMD nv_error
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_DND
|
||||
#define NV_DROP nv_drop
|
||||
#else
|
||||
#define NV_DROP nv_error
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function to be called for a Normal or Visual mode command.
|
||||
* The argument is a cmdarg_T.
|
||||
*/
|
||||
typedef void (*nv_func_T)(cmdarg_T *cap);
|
||||
|
||||
// Values for cmd_flags.
|
||||
#define NV_NCH 0x01 // may need to get a second char
|
||||
#define NV_NCH_NOP (0x02|NV_NCH) // get second char when no operator pending
|
||||
#define NV_NCH_ALW (0x04|NV_NCH) // always get a second char
|
||||
#define NV_LANG 0x08 // second char needs language adjustment
|
||||
|
||||
#define NV_SS 0x10 // may start selection
|
||||
#define NV_SSS 0x20 // may start selection with shift modifier
|
||||
#define NV_STS 0x40 // may stop selection without shift modif.
|
||||
#define NV_RL 0x80 // 'rightleft' modifies command
|
||||
#define NV_KEEPREG 0x100 // don't clear regname
|
||||
#define NV_NCW 0x200 // not allowed in command-line window
|
||||
|
||||
/*
|
||||
* Generally speaking, every Normal mode command should either clear any
|
||||
* pending operator (with *clearop*()), or set the motion type variable
|
||||
* oap->motion_type.
|
||||
*
|
||||
* When a cursor motion command is made, it is marked as being a character or
|
||||
* line oriented motion. Then, if an operator is in effect, the operation
|
||||
* becomes character or line oriented accordingly.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This table contains one entry for every Normal or Visual mode command.
|
||||
* The order doesn't matter, this will be sorted by the create_nvcmdidx.vim
|
||||
* script to generate the nv_cmd_idx[] lookup table.
|
||||
* It is faster when all keys from zero to '~' are present.
|
||||
*
|
||||
* After changing the "nv_cmds" table:
|
||||
* 1. Build Vim with "make"
|
||||
* 2. Run "make nvcmdidxs" to re-generate the nv_cmdidxs.h file.
|
||||
* 3. Build Vim with "make" to use the newly generated index table.
|
||||
*/
|
||||
static const struct nv_cmd
|
||||
{
|
||||
int cmd_char; // (first) command character
|
||||
nv_func_T cmd_func; // function for this command
|
||||
short_u cmd_flags; // NV_ flags
|
||||
short cmd_arg; // value for ca.arg
|
||||
} nv_cmds[] =
|
||||
{
|
||||
{NUL, nv_error, 0, 0},
|
||||
{Ctrl_A, nv_addsub, 0, 0},
|
||||
{Ctrl_B, nv_page, NV_STS, BACKWARD},
|
||||
{Ctrl_C, nv_esc, 0, TRUE},
|
||||
{Ctrl_D, nv_halfpage, 0, 0},
|
||||
{Ctrl_E, nv_scroll_line, 0, TRUE},
|
||||
{Ctrl_F, nv_page, NV_STS, FORWARD},
|
||||
{Ctrl_G, nv_ctrlg, 0, 0},
|
||||
{Ctrl_H, nv_ctrlh, 0, 0},
|
||||
{Ctrl_I, nv_pcmark, 0, 0},
|
||||
{NL, nv_down, 0, FALSE},
|
||||
{Ctrl_K, nv_error, 0, 0},
|
||||
{Ctrl_L, nv_clear, 0, 0},
|
||||
{CAR, nv_down, 0, TRUE},
|
||||
{Ctrl_N, nv_down, NV_STS, FALSE},
|
||||
{Ctrl_O, nv_ctrlo, 0, 0},
|
||||
{Ctrl_P, nv_up, NV_STS, FALSE},
|
||||
{Ctrl_Q, nv_visual, 0, FALSE},
|
||||
{Ctrl_R, nv_redo_or_register, 0, 0},
|
||||
{Ctrl_S, nv_ignore, 0, 0},
|
||||
{Ctrl_T, nv_tagpop, NV_NCW, 0},
|
||||
{Ctrl_U, nv_halfpage, 0, 0},
|
||||
{Ctrl_V, nv_visual, 0, FALSE},
|
||||
{Ctrl_W, nv_window, 0, 0},
|
||||
{Ctrl_X, nv_addsub, 0, 0},
|
||||
{Ctrl_Y, nv_scroll_line, 0, FALSE},
|
||||
{Ctrl_Z, nv_suspend, 0, 0},
|
||||
{ESC, nv_esc, 0, FALSE},
|
||||
{Ctrl_BSL, nv_normal, NV_NCH_ALW, 0},
|
||||
{Ctrl_RSB, nv_ident, NV_NCW, 0},
|
||||
{Ctrl_HAT, nv_hat, NV_NCW, 0},
|
||||
{Ctrl__, nv_error, 0, 0},
|
||||
{' ', nv_right, 0, 0},
|
||||
{'!', nv_operator, 0, 0},
|
||||
{'"', nv_regname, NV_NCH_NOP|NV_KEEPREG, 0},
|
||||
{'#', nv_ident, 0, 0},
|
||||
{'$', nv_dollar, 0, 0},
|
||||
{'%', nv_percent, 0, 0},
|
||||
{'&', nv_optrans, 0, 0},
|
||||
{'\'', nv_gomark, NV_NCH_ALW, TRUE},
|
||||
{'(', nv_brace, 0, BACKWARD},
|
||||
{')', nv_brace, 0, FORWARD},
|
||||
{'*', nv_ident, 0, 0},
|
||||
{'+', nv_down, 0, TRUE},
|
||||
{',', nv_csearch, 0, TRUE},
|
||||
{'-', nv_up, 0, TRUE},
|
||||
{'.', nv_dot, NV_KEEPREG, 0},
|
||||
{'/', nv_search, 0, FALSE},
|
||||
{'0', nv_beginline, 0, 0},
|
||||
{'1', nv_ignore, 0, 0},
|
||||
{'2', nv_ignore, 0, 0},
|
||||
{'3', nv_ignore, 0, 0},
|
||||
{'4', nv_ignore, 0, 0},
|
||||
{'5', nv_ignore, 0, 0},
|
||||
{'6', nv_ignore, 0, 0},
|
||||
{'7', nv_ignore, 0, 0},
|
||||
{'8', nv_ignore, 0, 0},
|
||||
{'9', nv_ignore, 0, 0},
|
||||
{':', nv_colon, 0, 0},
|
||||
{';', nv_csearch, 0, FALSE},
|
||||
{'<', nv_operator, NV_RL, 0},
|
||||
{'=', nv_operator, 0, 0},
|
||||
{'>', nv_operator, NV_RL, 0},
|
||||
{'?', nv_search, 0, FALSE},
|
||||
{'@', nv_at, NV_NCH_NOP, FALSE},
|
||||
{'A', nv_edit, 0, 0},
|
||||
{'B', nv_bck_word, 0, 1},
|
||||
{'C', nv_abbrev, NV_KEEPREG, 0},
|
||||
{'D', nv_abbrev, NV_KEEPREG, 0},
|
||||
{'E', nv_wordcmd, 0, TRUE},
|
||||
{'F', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD},
|
||||
{'G', nv_goto, 0, TRUE},
|
||||
{'H', nv_scroll, 0, 0},
|
||||
{'I', nv_edit, 0, 0},
|
||||
{'J', nv_join, 0, 0},
|
||||
{'K', nv_ident, 0, 0},
|
||||
{'L', nv_scroll, 0, 0},
|
||||
{'M', nv_scroll, 0, 0},
|
||||
{'N', nv_next, 0, SEARCH_REV},
|
||||
{'O', nv_open, 0, 0},
|
||||
{'P', nv_put, 0, 0},
|
||||
{'Q', nv_exmode, NV_NCW, 0},
|
||||
{'R', nv_Replace, 0, FALSE},
|
||||
{'S', nv_subst, NV_KEEPREG, 0},
|
||||
{'T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD},
|
||||
{'U', nv_Undo, 0, 0},
|
||||
{'V', nv_visual, 0, FALSE},
|
||||
{'W', nv_wordcmd, 0, TRUE},
|
||||
{'X', nv_abbrev, NV_KEEPREG, 0},
|
||||
{'Y', nv_abbrev, NV_KEEPREG, 0},
|
||||
{'Z', nv_Zet, NV_NCH_NOP|NV_NCW, 0},
|
||||
{'[', nv_brackets, NV_NCH_ALW, BACKWARD},
|
||||
{'\\', nv_error, 0, 0},
|
||||
{']', nv_brackets, NV_NCH_ALW, FORWARD},
|
||||
{'^', nv_beginline, 0, BL_WHITE | BL_FIX},
|
||||
{'_', nv_lineop, 0, 0},
|
||||
{'`', nv_gomark, NV_NCH_ALW, FALSE},
|
||||
{'a', nv_edit, NV_NCH, 0},
|
||||
{'b', nv_bck_word, 0, 0},
|
||||
{'c', nv_operator, 0, 0},
|
||||
{'d', nv_operator, 0, 0},
|
||||
{'e', nv_wordcmd, 0, FALSE},
|
||||
{'f', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD},
|
||||
{'g', nv_g_cmd, NV_NCH_ALW, FALSE},
|
||||
{'h', nv_left, NV_RL, 0},
|
||||
{'i', nv_edit, NV_NCH, 0},
|
||||
{'j', nv_down, 0, FALSE},
|
||||
{'k', nv_up, 0, FALSE},
|
||||
{'l', nv_right, NV_RL, 0},
|
||||
{'m', nv_mark, NV_NCH_NOP, 0},
|
||||
{'n', nv_next, 0, 0},
|
||||
{'o', nv_open, 0, 0},
|
||||
{'p', nv_put, 0, 0},
|
||||
{'q', nv_record, NV_NCH, 0},
|
||||
{'r', nv_replace, NV_NCH_NOP|NV_LANG, 0},
|
||||
{'s', nv_subst, NV_KEEPREG, 0},
|
||||
{'t', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD},
|
||||
{'u', nv_undo, 0, 0},
|
||||
{'v', nv_visual, 0, FALSE},
|
||||
{'w', nv_wordcmd, 0, FALSE},
|
||||
{'x', nv_abbrev, NV_KEEPREG, 0},
|
||||
{'y', nv_operator, 0, 0},
|
||||
{'z', nv_zet, NV_NCH_ALW, 0},
|
||||
{'{', nv_findpar, 0, BACKWARD},
|
||||
{'|', nv_pipe, 0, 0},
|
||||
{'}', nv_findpar, 0, FORWARD},
|
||||
{'~', nv_tilde, 0, 0},
|
||||
|
||||
// pound sign
|
||||
{POUND, nv_ident, 0, 0},
|
||||
{K_MOUSEUP, nv_mousescroll, 0, MSCR_UP},
|
||||
{K_MOUSEDOWN, nv_mousescroll, 0, MSCR_DOWN},
|
||||
{K_MOUSELEFT, nv_mousescroll, 0, MSCR_LEFT},
|
||||
{K_MOUSERIGHT, nv_mousescroll, 0, MSCR_RIGHT},
|
||||
{K_LEFTMOUSE, nv_mouse, 0, 0},
|
||||
{K_LEFTMOUSE_NM, nv_mouse, 0, 0},
|
||||
{K_LEFTDRAG, nv_mouse, 0, 0},
|
||||
{K_LEFTRELEASE, nv_mouse, 0, 0},
|
||||
{K_LEFTRELEASE_NM, nv_mouse, 0, 0},
|
||||
{K_MOUSEMOVE, nv_mouse, 0, 0},
|
||||
{K_MIDDLEMOUSE, nv_mouse, 0, 0},
|
||||
{K_MIDDLEDRAG, nv_mouse, 0, 0},
|
||||
{K_MIDDLERELEASE, nv_mouse, 0, 0},
|
||||
{K_RIGHTMOUSE, nv_mouse, 0, 0},
|
||||
{K_RIGHTDRAG, nv_mouse, 0, 0},
|
||||
{K_RIGHTRELEASE, nv_mouse, 0, 0},
|
||||
{K_X1MOUSE, nv_mouse, 0, 0},
|
||||
{K_X1DRAG, nv_mouse, 0, 0},
|
||||
{K_X1RELEASE, nv_mouse, 0, 0},
|
||||
{K_X2MOUSE, nv_mouse, 0, 0},
|
||||
{K_X2DRAG, nv_mouse, 0, 0},
|
||||
{K_X2RELEASE, nv_mouse, 0, 0},
|
||||
{K_IGNORE, nv_ignore, NV_KEEPREG, 0},
|
||||
{K_NOP, nv_nop, 0, 0},
|
||||
{K_INS, nv_edit, 0, 0},
|
||||
{K_KINS, nv_edit, 0, 0},
|
||||
{K_BS, nv_ctrlh, 0, 0},
|
||||
{K_UP, nv_up, NV_SSS|NV_STS, FALSE},
|
||||
{K_S_UP, nv_page, NV_SS, BACKWARD},
|
||||
{K_DOWN, nv_down, NV_SSS|NV_STS, FALSE},
|
||||
{K_S_DOWN, nv_page, NV_SS, FORWARD},
|
||||
{K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0},
|
||||
{K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0},
|
||||
{K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1},
|
||||
{K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0},
|
||||
{K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, FALSE},
|
||||
{K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, TRUE},
|
||||
{K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD},
|
||||
{K_KPAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD},
|
||||
{K_PAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD},
|
||||
{K_KPAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD},
|
||||
{K_END, nv_end, NV_SSS|NV_STS, FALSE},
|
||||
{K_KEND, nv_end, NV_SSS|NV_STS, FALSE},
|
||||
{K_S_END, nv_end, NV_SS, FALSE},
|
||||
{K_C_END, nv_end, NV_SSS|NV_STS, TRUE},
|
||||
{K_HOME, nv_home, NV_SSS|NV_STS, 0},
|
||||
{K_KHOME, nv_home, NV_SSS|NV_STS, 0},
|
||||
{K_S_HOME, nv_home, NV_SS, 0},
|
||||
{K_C_HOME, nv_goto, NV_SSS|NV_STS, FALSE},
|
||||
{K_DEL, nv_abbrev, 0, 0},
|
||||
{K_KDEL, nv_abbrev, 0, 0},
|
||||
{K_UNDO, nv_kundo, 0, 0},
|
||||
{K_HELP, nv_help, NV_NCW, 0},
|
||||
{K_F1, nv_help, NV_NCW, 0},
|
||||
{K_XF1, nv_help, NV_NCW, 0},
|
||||
{K_SELECT, nv_select, 0, 0},
|
||||
{K_VER_SCROLLBAR, NV_VER_SCROLLBAR, 0, 0},
|
||||
{K_HOR_SCROLLBAR, NV_HOR_SCROLLBAR, 0, 0},
|
||||
{K_TABLINE, NV_TABLINE, 0, 0},
|
||||
{K_TABMENU, NV_TABMENU, 0, 0},
|
||||
{K_F21, NV_NBCMD, NV_NCH_ALW, 0},
|
||||
{K_DROP, NV_DROP, NV_STS, 0},
|
||||
{K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0},
|
||||
{K_PS, nv_edit, 0, 0},
|
||||
{K_COMMAND, nv_colon, 0, 0},
|
||||
{K_SCRIPT_COMMAND, nv_colon, 0, 0},
|
||||
};
|
||||
|
||||
// Number of commands in nv_cmds[].
|
||||
#define NV_CMDS_SIZE ARRAY_LENGTH(nv_cmds)
|
||||
// Declare nv_cmds[].
|
||||
#define DO_DECLARE_NVCMD
|
||||
#include "nv_cmds.h"
|
||||
|
||||
// Include the lookuptable generated by create_nvcmdidx.vim.
|
||||
#include "nv_cmdidxs.h"
|
||||
|
||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||
/*
|
||||
* Return the command character for the given command index. This function is
|
||||
* used to auto-generate nv_cmd_idx[].
|
||||
*/
|
||||
void
|
||||
f_internal_get_nv_cmdchar(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
int idx;
|
||||
int cmd_char;
|
||||
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
if (check_for_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
idx = tv_get_number(&argvars[0]);
|
||||
if (idx < 0 || idx >= (int)NV_CMDS_SIZE)
|
||||
return;
|
||||
|
||||
cmd_char = nv_cmds[idx].cmd_char;
|
||||
|
||||
// We use the absolute value of the character. Special keys have a
|
||||
// negative value, but are sorted on their absolute value.
|
||||
if (cmd_char < 0)
|
||||
cmd_char = -cmd_char;
|
||||
|
||||
rettv->vval.v_number = cmd_char;
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Search for a command in the commands table.
|
||||
* Returns -1 for invalid command.
|
||||
|
Reference in New Issue
Block a user