mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
move ins_char
This commit is contained in:
@@ -502,16 +502,16 @@ void ins_bytes_len(char_u *p, size_t len)
|
|||||||
/// convert bytes to a character.
|
/// convert bytes to a character.
|
||||||
void ins_char(int c)
|
void ins_char(int c)
|
||||||
{
|
{
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
char_u buf[MB_MAXBYTES + 1];
|
||||||
int n = (*mb_char2bytes)(c, buf);
|
size_t n = (size_t)utf_char2bytes(c, buf);
|
||||||
|
|
||||||
// When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte.
|
// When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte.
|
||||||
// Happens for CTRL-Vu9900.
|
// Happens for CTRL-Vu9900.
|
||||||
if (buf[0] == 0) {
|
if (buf[0] == 0) {
|
||||||
buf[0] = '\n';
|
buf[0] = '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
ins_char_bytes(buf, n);
|
ins_char_bytes(buf, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ins_char_bytes(char_u *buf, size_t charlen)
|
void ins_char_bytes(char_u *buf, size_t charlen)
|
||||||
|
@@ -507,24 +507,6 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert or replace a single character at the cursor position.
|
|
||||||
/// When in REPLACE or VREPLACE mode, replace any existing character.
|
|
||||||
/// Caller must have prepared for undo.
|
|
||||||
/// For multi-byte characters we get the whole character, the caller must
|
|
||||||
/// convert bytes to a character.
|
|
||||||
void ins_char(int c)
|
|
||||||
{
|
|
||||||
char_u buf[MB_MAXBYTES + 1];
|
|
||||||
size_t n = (size_t)utf_char2bytes(c, buf);
|
|
||||||
|
|
||||||
// When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte.
|
|
||||||
// Happens for CTRL-Vu9900.
|
|
||||||
if (buf[0] == 0) {
|
|
||||||
buf[0] = '\n';
|
|
||||||
}
|
|
||||||
ins_char_bytes(buf, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
int gchar_pos(pos_T *pos)
|
int gchar_pos(pos_T *pos)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user