mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 21:18:34 +00:00
move ins_bytes, ins_bytes_len
This commit is contained in:
@@ -477,35 +477,31 @@ unchanged(buf_T *buf, int ff)
|
|||||||
* Insert string "p" at the cursor position. Stops at a NUL byte.
|
* Insert string "p" at the cursor position. Stops at a NUL byte.
|
||||||
* Handles Replace mode and multi-byte characters.
|
* Handles Replace mode and multi-byte characters.
|
||||||
*/
|
*/
|
||||||
void
|
void ins_bytes(char_u *p)
|
||||||
ins_bytes(char_u *p)
|
|
||||||
{
|
{
|
||||||
ins_bytes_len(p, (int)STRLEN(p));
|
ins_bytes_len(p, STRLEN(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Insert string "p" with length "len" at the cursor position.
|
||||||
* Insert string "p" with length "len" at the cursor position.
|
/// Handles Replace mode and multi-byte characters.
|
||||||
* Handles Replace mode and multi-byte characters.
|
void ins_bytes_len(char_u *p, size_t len)
|
||||||
*/
|
|
||||||
void
|
|
||||||
ins_bytes_len(char_u *p, int len)
|
|
||||||
{
|
{
|
||||||
int i;
|
if (has_mbyte) {
|
||||||
int n;
|
size_t n;
|
||||||
|
for (size_t i = 0; i < len; i += n) {
|
||||||
if (has_mbyte)
|
if (enc_utf8) {
|
||||||
for (i = 0; i < len; i += n)
|
// avoid reading past p[len]
|
||||||
{
|
n = (size_t)utfc_ptr2len_len(p + i, (int)(len - i));
|
||||||
if (enc_utf8)
|
} else {
|
||||||
// avoid reading past p[len]
|
n = (size_t)(*mb_ptr2len)(p + i);
|
||||||
n = utfc_ptr2len_len(p + i, len - i);
|
}
|
||||||
else
|
ins_char_bytes(p + i, n);
|
||||||
n = (*mb_ptr2len)(p + i);
|
}
|
||||||
ins_char_bytes(p + i, n);
|
} else {
|
||||||
}
|
for (size_t i = 0; i < len; i++) {
|
||||||
else
|
ins_char(p[i]);
|
||||||
for (i = 0; i < len; ++i)
|
}
|
||||||
ins_char(p[i]);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1380,37 +1380,6 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Insert string "p" at the cursor position. Stops at a NUL byte.
|
|
||||||
* Handles Replace mode and multi-byte characters.
|
|
||||||
*/
|
|
||||||
void ins_bytes(char_u *p)
|
|
||||||
{
|
|
||||||
ins_bytes_len(p, STRLEN(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Insert string "p" with length "len" at the cursor position.
|
|
||||||
/// Handles Replace mode and multi-byte characters.
|
|
||||||
void ins_bytes_len(char_u *p, size_t len)
|
|
||||||
{
|
|
||||||
if (has_mbyte) {
|
|
||||||
size_t n;
|
|
||||||
for (size_t i = 0; i < len; i += n) {
|
|
||||||
if (enc_utf8) {
|
|
||||||
// avoid reading past p[len]
|
|
||||||
n = (size_t)utfc_ptr2len_len(p + i, (int)(len - i));
|
|
||||||
} else {
|
|
||||||
n = (size_t)(*mb_ptr2len)(p + i);
|
|
||||||
}
|
|
||||||
ins_char_bytes(p + i, n);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
ins_char(p[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Insert or replace a single character at the cursor position.
|
/// Insert or replace a single character at the cursor position.
|
||||||
/// When in REPLACE or VREPLACE mode, replace any existing character.
|
/// When in REPLACE or VREPLACE mode, replace any existing character.
|
||||||
/// Caller must have prepared for undo.
|
/// Caller must have prepared for undo.
|
||||||
|
Reference in New Issue
Block a user