diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-26 22:37:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 22:37:20 +0800 |
commit | 0b72e23bf13ade1e76d11eae6990014098b3928d (patch) | |
tree | fa9ebbdd2d80d604cb67a952bdfedc26d038cb99 /src/nvim/getchar.c | |
parent | 2ecb4076dfa2236f6610449bbcb3f887f1c4f9f1 (diff) | |
download | rneovim-0b72e23bf13ade1e76d11eae6990014098b3928d.tar.gz rneovim-0b72e23bf13ade1e76d11eae6990014098b3928d.tar.bz2 rneovim-0b72e23bf13ade1e76d11eae6990014098b3928d.zip |
vim-patch:8.2.0674: some source files are too big (#19959)
Problem: Some source files are too big.
Solution: Move text formatting functions to a new file. (Yegappan
Lakshmanan, closes vim/vim#6021)
https://github.com/vim/vim/commit/11abd095210fc84e5dcee87b9baed86061caefe4
Cherry-pick set_can_cindent() from patch 8.1.2062.
Cherry-pick global old_indent from patch 8.2.2127.
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index f5f09f1394..c1c5680cb0 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -623,6 +623,34 @@ void stuffnumReadbuff(long n) add_num_buff(&readbuf1, n); } +/// Stuff a string into the typeahead buffer, such that edit() will insert it +/// literally ("literally" true) or interpret is as typed characters. +void stuffescaped(const char *arg, bool literally) +{ + while (*arg != NUL) { + // Stuff a sequence of normal ASCII characters, that's fast. Also + // stuff K_SPECIAL to get the effect of a special key when "literally" + // is true. + const char *const start = arg; + while ((*arg >= ' ' && *arg < DEL) || ((uint8_t)(*arg) == K_SPECIAL + && !literally)) { + arg++; + } + if (arg > start) { + stuffReadbuffLen(start, (arg - start)); + } + + // stuff a single special character + if (*arg != NUL) { + const int c = mb_cptr2char_adv((const char_u **)&arg); + if (literally && ((c < ' ' && c != TAB) || c == DEL)) { + stuffcharReadbuff(Ctrl_V); + } + stuffcharReadbuff(c); + } + } +} + /// Read a character from the redo buffer. Translates K_SPECIAL and /// multibyte characters. /// The redo buffer is left as it is. |