diff options
author | Daniel Hahler <git@thequod.de> | 2019-06-09 19:11:37 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-08-07 14:21:23 +0200 |
commit | 0b3ee2e8ac81ce1ddde9075b488760c24c110795 (patch) | |
tree | 1ab3634a25bdbddf658618779072af7e442df61a /src | |
parent | 75598927f2856d0df13abb7d939ecc5c96d0ddc6 (diff) | |
download | rneovim-0b3ee2e8ac81ce1ddde9075b488760c24c110795.tar.gz rneovim-0b3ee2e8ac81ce1ddde9075b488760c24c110795.tar.bz2 rneovim-0b3ee2e8ac81ce1ddde9075b488760c24c110795.zip |
move del_char, del_chars
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/change.c | 60 | ||||
-rw-r--r-- | src/nvim/misc1.c | 36 |
2 files changed, 27 insertions, 69 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index 21d944fd96..206599f8e6 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -672,46 +672,40 @@ void ins_str(char_u *s) curwin->w_cursor.col += newlen; } -/* - * Delete one character under the cursor. - * If "fixpos" is TRUE, don't leave the cursor on the NUL after the line. - * Caller must have prepared for undo. - * - * return FAIL for failure, OK otherwise - */ - int -del_char(int fixpos) +// Delete one character under the cursor. +// If "fixpos" is true, don't leave the cursor on the NUL after the line. +// Caller must have prepared for undo. +// +// return FAIL for failure, OK otherwise +int del_char(bool fixpos) { - if (has_mbyte) - { - // Make sure the cursor is at the start of a character. - mb_adjust_cursor(); - if (*ml_get_cursor() == NUL) - return FAIL; - return del_chars(1L, fixpos); - } - return del_bytes(1L, fixpos, TRUE); + if (has_mbyte) { + // Make sure the cursor is at the start of a character. + mb_adjust_cursor(); + if (*get_cursor_pos_ptr() == NUL) + return FAIL; + return del_chars(1L, fixpos); + } + return del_bytes(1, fixpos, true); } /* * Like del_bytes(), but delete characters instead of bytes. */ - int -del_chars(long count, int fixpos) +int del_chars(long count, int fixpos) { - long bytes = 0; - long i; - char_u *p; - int l; - - p = ml_get_cursor(); - for (i = 0; i < count && *p != NUL; ++i) - { - l = (*mb_ptr2len)(p); - bytes += l; - p += l; - } - return del_bytes(bytes, fixpos, TRUE); + int bytes = 0; + long i; + char_u *p; + int l; + + p = get_cursor_pos_ptr(); + for (i = 0; i < count && *p != NUL; ++i) { + l = (*mb_ptr2len)(p); + bytes += l; + p += l; + } + return del_bytes(bytes, fixpos, TRUE); } /* diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index cfcbfdb003..786fbb6678 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -1398,42 +1398,6 @@ void ins_char(int c) ins_char_bytes(buf, n); } -// Delete one character under the cursor. -// If "fixpos" is true, don't leave the cursor on the NUL after the line. -// Caller must have prepared for undo. -// -// return FAIL for failure, OK otherwise -int del_char(bool fixpos) -{ - if (has_mbyte) { - /* Make sure the cursor is at the start of a character. */ - mb_adjust_cursor(); - if (*get_cursor_pos_ptr() == NUL) - return FAIL; - return del_chars(1L, fixpos); - } - return del_bytes(1, fixpos, true); -} - -/* - * Like del_bytes(), but delete characters instead of bytes. - */ -int del_chars(long count, int fixpos) -{ - int bytes = 0; - long i; - char_u *p; - int l; - - p = get_cursor_pos_ptr(); - for (i = 0; i < count && *p != NUL; ++i) { - l = (*mb_ptr2len)(p); - bytes += l; - p += l; - } - return del_bytes(bytes, fixpos, TRUE); -} - /// Delete "count" bytes under the cursor. /// If "fixpos" is true, don't leave the cursor on the NUL after the line. /// Caller must have prepared for undo. |