mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
keymap: Make replace_termcodes and friends accept length and cpo_flags
Reasons: - One does not have to do `s[len] = NUL` to work with these functions if they do not need to replace the whole string: thus `s` may be const. - One does not have to save/restore p_cpo to work with them.
This commit is contained in:
@@ -116,8 +116,14 @@ String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt,
|
||||
}
|
||||
|
||||
char *ptr = NULL;
|
||||
replace_termcodes((char_u *)str.data, (char_u **)&ptr,
|
||||
from_part, do_lt, special);
|
||||
// Set 'cpoptions' the way we want it.
|
||||
// FLAG_CPO_BSLASH set - backslashes are *not* treated specially
|
||||
// FLAG_CPO_KEYCODE set - keycodes are *not* reverse-engineered
|
||||
// FLAG_CPO_SPECI unset - <Key> sequences *are* interpreted
|
||||
// The third from end parameter of replace_termcodes() is true so that the
|
||||
// <lt> sequence is recognised - needed for a real backslash.
|
||||
replace_termcodes((char_u *)str.data, str.size, (char_u **)&ptr,
|
||||
from_part, do_lt, special, CPO_TO_CPO_FLAGS);
|
||||
return cstr_as_string(ptr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user