diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-03-04 10:59:44 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-03-16 19:53:21 +0100 |
commit | be8ebba325451b387c0aedacfcda6c53e6c51188 (patch) | |
tree | 6ee90da21194166b5163fa6375e4f50ab1813626 /src/nvim/mbyte.c | |
parent | 175398f21645552b708a7626309b826ae0f3d8a8 (diff) | |
download | rneovim-be8ebba325451b387c0aedacfcda6c53e6c51188.tar.gz rneovim-be8ebba325451b387c0aedacfcda6c53e6c51188.tar.bz2 rneovim-be8ebba325451b387c0aedacfcda6c53e6c51188.zip |
Allow using internal popupmenu or ext_popupmenu for wildmenu
Deprecate ext_wildmenu. ext_popupmenu already contains more state (anchor
position), and will allow further expansion (info about items).
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 5ed2b4c564..6c34cacb8d 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -555,6 +555,24 @@ size_t mb_string2cells(const char_u *str) return clen; } +/// Get the number of cells occupied by string `str` with maximum length `size` +/// +/// @param str The source string, may not be NULL, must be a NUL-terminated +/// string. +/// @param size maximum length of string. It will terminate on earlier NUL. +/// @return The number of cells occupied by string `str` +size_t mb_string2cells_len(const char_u *str, size_t size) +{ + size_t clen = 0; + + for (const char_u *p = str; *p != NUL && p < str+size; + p += utf_ptr2len_len(p, size+(p-str))) { + clen += utf_ptr2cells(p); + } + + return clen; +} + /// Convert a UTF-8 byte sequence to a wide character /// /// If the sequence is illegal or truncated by a NUL then the first byte is |