diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-01 14:26:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-01 14:26:37 +0200 |
commit | 11abd095210fc84e5dcee87b9baed86061caefe4 (patch) | |
tree | 5c8dcbdb357df1d9e8d2ae9142fb05f4f768151b /src/getchar.c | |
parent | 4cfde1d273ec5fca68a983805af48ea37d3d94e5 (diff) | |
download | vim-git-11abd095210fc84e5dcee87b9baed86061caefe4.tar.gz |
patch 8.2.0674: some source files are too bigv8.2.0674
Problem: Some source files are too big.
Solution: Move text formatting functions to a new file. (Yegappan
Lakshmanan, closes #6021)
Diffstat (limited to 'src/getchar.c')
-rw-r--r-- | src/getchar.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/getchar.c b/src/getchar.c index 7bbdf3583..9d8c0d4bf 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -685,6 +685,46 @@ stuffnumReadbuff(long 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(char_u *arg, int literally) +{ + int c; + char_u *start; + + 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. + start = arg; + while ((*arg >= ' ' +#ifndef EBCDIC + && *arg < DEL // EBCDIC: chars above space are normal +#endif + ) + || (*arg == K_SPECIAL && !literally)) + ++arg; + if (arg > start) + stuffReadbuffLen(start, (long)(arg - start)); + + // stuff a single special character + if (*arg != NUL) + { + if (has_mbyte) + c = mb_cptr2char_adv(&arg); + else + c = *arg++; + if (literally && ((c < ' ' && c != TAB) || c == DEL)) + stuffcharReadbuff(Ctrl_V); + stuffcharReadbuff(c); + } + } +} + +/* * Read a character from the redo buffer. Translates K_SPECIAL, CSI and * multibyte characters. * The redo buffer is left as it is. |