mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 15:58:17 +00:00
vim-patch:9.0.0449: there is no easy way to translate a key code into a string (#20168)
Problem: There is no easy way to translate a string with a key code into a readable string. Solution: Add the keytrans() function. (closes vim/vim#11114)cdc839353f
vim-patch:7b2d87220c6c Add missing part of patch7b2d87220c
This commit is contained in:
@@ -4673,6 +4673,20 @@ static void f_json_encode(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
rettv->vval.v_string = encode_tv2json(&argvars[0], NULL);
|
||||
}
|
||||
|
||||
/// "keytrans()" function
|
||||
static void f_keytrans(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
rettv->v_type = VAR_STRING;
|
||||
if (tv_check_for_string_arg(argvars, 0) == FAIL
|
||||
|| argvars[0].vval.v_string == NULL) {
|
||||
return;
|
||||
}
|
||||
// Need to escape K_SPECIAL for mb_unescape().
|
||||
char *escaped = vim_strsave_escape_ks(argvars[0].vval.v_string);
|
||||
rettv->vval.v_string = str2special_save(escaped, true, true);
|
||||
xfree(escaped);
|
||||
}
|
||||
|
||||
/// "last_buffer_nr()" function.
|
||||
static void f_last_buffer_nr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user