diff options
author | ZyX <kp-pav@yandex.ru> | 2014-07-13 11:10:27 +0400 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-04-18 02:43:43 +0300 |
commit | ebabdff5cd24f2d30ab35051d1d65f7c29fa3dd3 (patch) | |
tree | 0bae55f8b469efbef6df94dd16394ea334b22a55 /src/nvim/api/vim.c | |
parent | 83c683f5e15867c2e2889442860e91fd1074b4e1 (diff) | |
download | rneovim-ebabdff5cd24f2d30ab35051d1d65f7c29fa3dd3.tar.gz rneovim-ebabdff5cd24f2d30ab35051d1d65f7c29fa3dd3.tar.bz2 rneovim-ebabdff5cd24f2d30ab35051d1d65f7c29fa3dd3.zip |
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.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9279f6b469..1c1822aa32 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -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); } |