mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
refactor: move some mapping-related code to a separate file (#19061)
This marks the following Vim patches as ported: vim-patch:8.1.1785: map functionality mixed with character input Problem: Map functionality mixed with character input. Solution: Move the map functionality to a separate file. (Yegappan Lakshmanan, closes vim/vim#4740) Graduate the +localmap feature.b66bab381c
vim-patch:8.2.3643: header for source file is outdated Problem: Header for source file is outdated. Solution: Make the header more accurate. (closes vim/vim#9186)a3f83feb63
Also cherry-pick a change for <unique> mappings from patch 8.2.0807. Rename map_clear_mode() to do_mapclear().
This commit is contained in:
@@ -6791,57 +6791,6 @@ char **tv_to_argv(typval_T *cmd_tv, const char **cmd, bool *executable)
|
||||
return argv;
|
||||
}
|
||||
|
||||
/// Fill a dictionary with all applicable maparg() like dictionaries
|
||||
///
|
||||
/// @param dict The dictionary to be filled
|
||||
/// @param mp The maphash that contains the mapping information
|
||||
/// @param buffer_value The "buffer" value
|
||||
/// @param compatible True for compatible with old maparg() dict
|
||||
void mapblock_fill_dict(dict_T *const dict, const mapblock_T *const mp, long buffer_value,
|
||||
bool compatible)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *const lhs = str2special_save((const char *)mp->m_keys,
|
||||
compatible, !compatible);
|
||||
char *const mapmode = map_mode_to_chars(mp->m_mode);
|
||||
varnumber_T noremap_value;
|
||||
|
||||
if (compatible) {
|
||||
// Keep old compatible behavior
|
||||
// This is unable to determine whether a mapping is a <script> mapping
|
||||
noremap_value = !!mp->m_noremap;
|
||||
} else {
|
||||
// Distinguish between <script> mapping
|
||||
// If it's not a <script> mapping, check if it's a noremap
|
||||
noremap_value = mp->m_noremap == REMAP_SCRIPT ? 2 : !!mp->m_noremap;
|
||||
}
|
||||
|
||||
if (mp->m_luaref != LUA_NOREF) {
|
||||
tv_dict_add_nr(dict, S_LEN("callback"), mp->m_luaref);
|
||||
} else {
|
||||
if (compatible) {
|
||||
tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str);
|
||||
} else {
|
||||
tv_dict_add_allocated_str(dict, S_LEN("rhs"),
|
||||
str2special_save((const char *)mp->m_str, false,
|
||||
true));
|
||||
}
|
||||
}
|
||||
if (mp->m_desc != NULL) {
|
||||
tv_dict_add_allocated_str(dict, S_LEN("desc"), xstrdup(mp->m_desc));
|
||||
}
|
||||
tv_dict_add_allocated_str(dict, S_LEN("lhs"), lhs);
|
||||
tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value);
|
||||
tv_dict_add_nr(dict, S_LEN("script"), mp->m_noremap == REMAP_SCRIPT ? 1 : 0);
|
||||
tv_dict_add_nr(dict, S_LEN("expr"), mp->m_expr ? 1 : 0);
|
||||
tv_dict_add_nr(dict, S_LEN("silent"), mp->m_silent ? 1 : 0);
|
||||
tv_dict_add_nr(dict, S_LEN("sid"), (varnumber_T)mp->m_script_ctx.sc_sid);
|
||||
tv_dict_add_nr(dict, S_LEN("lnum"), (varnumber_T)mp->m_script_ctx.sc_lnum);
|
||||
tv_dict_add_nr(dict, S_LEN("buffer"), (varnumber_T)buffer_value);
|
||||
tv_dict_add_nr(dict, S_LEN("nowait"), mp->m_nowait ? 1 : 0);
|
||||
tv_dict_add_allocated_str(dict, S_LEN("mode"), mapmode);
|
||||
}
|
||||
|
||||
void return_register(int regname, typval_T *rettv)
|
||||
{
|
||||
char buf[2] = { (char)regname, 0 };
|
||||
|
Reference in New Issue
Block a user