aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-10-11 19:00:52 +0000
committerJosh Rahm <rahm@google.com>2022-10-11 19:00:52 +0000
commit21e2e46242033c7aaa6ccfb23e256680816c063c (patch)
treef089522cfb145d6e9c8a86a01d8e454ce5501e20 /src/nvim/normal.c
parent179d3ed87b17988f5fe00d8b99f2611a28212be7 (diff)
parent760b399f6c0c6470daa0663752bd22886997f9e6 (diff)
downloadrneovim-floattitle.tar.gz
rneovim-floattitle.tar.bz2
rneovim-floattitle.zip
Merge remote-tracking branch 'upstream/master' into floattitlefloattitle
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c233
1 files changed, 113 insertions, 120 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 2c7dadad0b..e058be9135 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -65,6 +65,8 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
+#include "nvim/textformat.h"
+#include "nvim/textobject.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
@@ -523,7 +525,7 @@ static bool normal_handle_special_visual_command(NormalState *s)
&& (nv_cmds[s->idx].cmd_flags & NV_STS)
&& !(mod_mask & MOD_MASK_SHIFT)) {
end_visual_mode();
- redraw_curbuf_later(INVERTED);
+ redraw_curbuf_later(UPD_INVERTED);
}
// Keys that work different when 'keymodel' contains "startsel"
@@ -627,18 +629,18 @@ static void normal_redraw_mode_message(NormalState *s)
// If need to redraw, and there is a "keep_msg", redraw before the
// delay
if (must_redraw && keep_msg != NULL && !emsg_on_display) {
- char_u *kmsg;
+ char *kmsg;
kmsg = keep_msg;
keep_msg = NULL;
// Showmode() will clear keep_msg, but we want to use it anyway.
// First update w_topline.
setcursor();
- update_screen(0);
+ update_screen();
// now reset it, otherwise it's put in the history again
keep_msg = kmsg;
- kmsg = vim_strsave(keep_msg);
+ kmsg = xstrdup(keep_msg);
msg_attr((const char *)kmsg, keep_msg_attr);
xfree(kmsg);
}
@@ -1281,10 +1283,10 @@ static void normal_redraw(NormalState *s)
validate_cursor();
if (VIsual_active) {
- redraw_curbuf_later(INVERTED); // update inverted part
- update_screen(0);
+ redraw_curbuf_later(UPD_INVERTED); // update inverted part
+ update_screen();
} else if (must_redraw) {
- update_screen(0);
+ update_screen();
} else if (redraw_cmdline || clear_cmdline || redraw_mode) {
showmode();
}
@@ -1300,7 +1302,7 @@ static void normal_redraw(NormalState *s)
// Display message after redraw. If an external message is still visible,
// it contains the kept message already.
if (keep_msg != NULL && !msg_ext_is_visible()) {
- char_u *const p = vim_strsave(keep_msg);
+ char *const p = xstrdup(keep_msg);
// msg_start() will set keep_msg to NULL, make a copy
// first. Don't reset keep_msg, msg_attr_keep() uses it to
@@ -1738,9 +1740,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
}
// click in a tab selects that tab page
- if (is_click
- && cmdwin_type == 0
- && mouse_col < Columns) {
+ if (is_click && cmdwin_type == 0 && mouse_col < Columns) {
in_tab_line = true;
c1 = tab_page_click_defs[mouse_col].tabnr;
switch (tab_page_click_defs[mouse_col].type) {
@@ -1805,7 +1805,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
return false;
}
jump_flags = 0;
- if (STRCMP(p_mousem, "popup_setpos") == 0) {
+ if (strcmp(p_mousem, "popup_setpos") == 0) {
// First set the cursor position before showing the popup
// menu.
if (VIsual_active) {
@@ -1838,8 +1838,8 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
}
if (jump_flags) {
jump_flags = jump_to_mouse(jump_flags, NULL, which_button);
- redraw_curbuf_later(VIsual_active ? INVERTED : VALID);
- update_screen(0);
+ redraw_curbuf_later(VIsual_active ? UPD_INVERTED : UPD_VALID);
+ update_screen();
setcursor();
ui_flush(); // Update before showing popup menu
}
@@ -2178,7 +2178,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
find_start_of_word(&VIsual);
if (*p_sel == 'e' && *get_cursor_pos_ptr() != NUL) {
curwin->w_cursor.col +=
- utfc_ptr2len((char *)get_cursor_pos_ptr());
+ utfc_ptr2len(get_cursor_pos_ptr());
}
find_end_of_word(&curwin->w_cursor);
}
@@ -2186,7 +2186,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
curwin->w_set_curswant = true;
}
if (is_click) {
- redraw_curbuf_later(INVERTED); // update the inversion
+ redraw_curbuf_later(UPD_INVERTED); // update the inversion
}
} else if (VIsual_active && !old_active) {
if (mod_mask & MOD_MASK_ALT) {
@@ -2213,12 +2213,12 @@ static void find_start_of_word(pos_T *pos)
int cclass;
int col;
- line = ml_get(pos->lnum);
+ line = (char_u *)ml_get(pos->lnum);
cclass = get_mouse_class(line + pos->col);
while (pos->col > 0) {
col = pos->col - 1;
- col -= utf_head_off(line, line + col);
+ col -= utf_head_off((char *)line, (char *)line + col);
if (get_mouse_class(line + col) != cclass) {
break;
}
@@ -2234,10 +2234,10 @@ static void find_end_of_word(pos_T *pos)
int cclass;
int col;
- line = ml_get(pos->lnum);
+ line = (char_u *)ml_get(pos->lnum);
if (*p_sel == 'e' && pos->col > 0) {
pos->col--;
- pos->col -= utf_head_off(line, line + pos->col);
+ pos->col -= utf_head_off((char *)line, (char *)line + pos->col);
}
cclass = get_mouse_class(line + pos->col);
while (line[pos->col] != NUL) {
@@ -2311,7 +2311,7 @@ void reset_VIsual_and_resel(void)
{
if (VIsual_active) {
end_visual_mode();
- redraw_curbuf_later(INVERTED); // delete the inversion later
+ redraw_curbuf_later(UPD_INVERTED); // delete the inversion later
}
VIsual_reselect = false;
}
@@ -2321,7 +2321,7 @@ void reset_VIsual(void)
{
if (VIsual_active) {
end_visual_mode();
- redraw_curbuf_later(INVERTED); // delete the inversion later
+ redraw_curbuf_later(UPD_INVERTED); // delete the inversion later
VIsual_reselect = false;
}
}
@@ -2414,7 +2414,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
// if i == 0: try to find an identifier
// if i == 1: try to find any non-white text
- char_u *ptr = ml_get_buf(wp->w_buffer, lnum, false);
+ char_u *ptr = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; i++) {
// 1. skip to start of identifier/text
col = startcol;
@@ -2443,7 +2443,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
this_class = mb_get_class(ptr + col);
}
while (col > 0 && this_class != 0) {
- prevcol = col - 1 - utf_head_off(ptr, ptr + col - 1);
+ prevcol = col - 1 - utf_head_off((char *)ptr, (char *)ptr + col - 1);
prev_class = mb_get_class(ptr + prevcol);
if (this_class != prev_class
&& (i == 0
@@ -2652,8 +2652,8 @@ void clear_showcmd(void)
lines = bot - top + 1;
if (VIsual_mode == Ctrl_V) {
- char_u *const saved_sbr = p_sbr;
- char_u *const saved_w_sbr = curwin->w_p_sbr;
+ char *const saved_sbr = p_sbr;
+ char *const saved_w_sbr = curwin->w_p_sbr;
// Make 'sbr' empty for a moment to get the correct size.
p_sbr = empty_option;
@@ -2673,9 +2673,9 @@ void clear_showcmd(void)
if (cursor_bot) {
s = ml_get_pos(&VIsual);
- e = get_cursor_pos_ptr();
+ e = (char_u *)get_cursor_pos_ptr();
} else {
- s = get_cursor_pos_ptr();
+ s = (char_u *)get_cursor_pos_ptr();
e = ml_get_pos(&VIsual);
}
while ((*p_sel != 'e') ? s <= e : s < e) {
@@ -2716,8 +2716,6 @@ void clear_showcmd(void)
/// @return true if output has been written (and setcursor() has been called).
bool add_to_showcmd(int c)
{
- char_u *p;
- int i;
static int ignore[] = {
K_IGNORE,
K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE,
@@ -2740,19 +2738,19 @@ bool add_to_showcmd(int c)
// Ignore keys that are scrollbar updates and mouse clicks
if (IS_SPECIAL(c)) {
- for (i = 0; ignore[i] != 0; i++) {
+ for (int i = 0; ignore[i] != 0; i++) {
if (ignore[i] == c) {
return false;
}
}
}
- p = transchar(c);
+ char *p = (char *)transchar(c);
if (*p == ' ') {
STRCPY(p, "<20>");
}
size_t old_len = STRLEN(showcmd_buf);
- size_t extra_len = STRLEN(p);
+ size_t extra_len = strlen(p);
size_t limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS;
if (old_len + extra_len > limit) {
size_t overflow = old_len + extra_len - limit;
@@ -2817,7 +2815,8 @@ void pop_showcmd(void)
static void display_showcmd(void)
{
- if (!ui_has_messages()) {
+ if (p_ch == 0 && !ui_has(kUIMessages)) {
+ // TODO(bfredl): would be nice to show in global statusline, perhaps
return;
}
@@ -2843,12 +2842,12 @@ static void display_showcmd(void)
grid_puts_line_start(&msg_grid_adj, showcmd_row);
if (!showcmd_is_clear) {
- grid_puts(&msg_grid_adj, showcmd_buf, showcmd_row, sc_col,
+ grid_puts(&msg_grid_adj, (char *)showcmd_buf, showcmd_row, sc_col,
HL_ATTR(HLF_MSG));
}
// clear the rest of an old message by outputting up to SHOWCMD_COLS spaces
- grid_puts(&msg_grid_adj, (char_u *)" " + len, showcmd_row,
+ grid_puts(&msg_grid_adj, (char *)" " + len, showcmd_row,
sc_col + len, HL_ATTR(HLF_MSG));
grid_puts_line_flush(false);
@@ -2956,7 +2955,7 @@ void check_scrollbind(linenr_T topline_diff, long leftcol_diff)
}
}
- redraw_later(curwin, VALID);
+ redraw_later(curwin, UPD_VALID);
cursor_correct();
curwin->w_redr_status = true;
}
@@ -3134,7 +3133,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
} else {
par_pos = curwin->w_cursor;
while (curwin->w_cursor.lnum > 1
- && *skipwhite((char *)get_cursor_line_ptr()) != NUL) {
+ && *skipwhite(get_cursor_line_ptr()) != NUL) {
curwin->w_cursor.lnum--;
}
}
@@ -3171,13 +3170,13 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
}
break;
}
- if (get_leader_len((char *)get_cursor_line_ptr(), NULL, false, true) > 0) {
+ if (get_leader_len(get_cursor_line_ptr(), NULL, false, true) > 0) {
// Ignore this line, continue at start of next line.
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
continue;
}
- bool valid = is_ident(get_cursor_line_ptr(), curwin->w_cursor.col);
+ bool valid = is_ident((char_u *)get_cursor_line_ptr(), curwin->w_cursor.col);
// If the current position is not a valid identifier and a previous match is
// present, favor that one instead.
@@ -3232,7 +3231,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
/// @return true if able to move cursor, false otherwise.
static bool nv_screengo(oparg_T *oap, int dir, long dist)
{
- int linelen = linetabsize(get_cursor_line_ptr());
+ int linelen = linetabsize((char_u *)get_cursor_line_ptr());
bool retval = true;
bool atend = false;
int n;
@@ -3303,7 +3302,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
}
curwin->w_cursor.lnum--;
- linelen = linetabsize(get_cursor_line_ptr());
+ linelen = linetabsize((char_u *)get_cursor_line_ptr());
if (linelen > width1) {
int w = (((linelen - width1 - 1) / width2) + 1) * width2;
assert(curwin->w_curswant <= INT_MAX - w);
@@ -3339,7 +3338,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
if (curwin->w_curswant >= width1) {
curwin->w_curswant -= width2;
}
- linelen = linetabsize(get_cursor_line_ptr());
+ linelen = linetabsize((char_u *)get_cursor_line_ptr());
}
}
}
@@ -3361,7 +3360,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
virtcol -= vim_strsize((char *)get_showbreak_value(curwin));
}
- int c = utf_ptr2char((char *)get_cursor_pos_ptr());
+ int c = utf_ptr2char(get_cursor_pos_ptr());
if (dir == FORWARD && virtcol < curwin->w_curswant
&& (curwin->w_curswant <= (colnr_T)width1)
&& !vim_isprintc(c) && c > 255) {
@@ -3490,7 +3489,7 @@ void scroll_redraw(int up, long count)
if (moved) {
curwin->w_viewport_invalid = true;
}
- redraw_later(curwin, VALID);
+ redraw_later(curwin, UPD_VALID);
}
/// Get the count specified after a 'z' command. Only the 'z<CR>', 'zl', 'zh',
@@ -3656,7 +3655,7 @@ static void nv_zet(cmdarg_T *cap)
case 't':
scroll_cursor_top(0, true);
- redraw_later(curwin, VALID);
+ redraw_later(curwin, UPD_VALID);
set_fraction(curwin);
break;
@@ -3667,7 +3666,7 @@ static void nv_zet(cmdarg_T *cap)
case 'z':
scroll_cursor_halfway(true);
- redraw_later(curwin, VALID);
+ redraw_later(curwin, UPD_VALID);
set_fraction(curwin);
break;
@@ -3690,7 +3689,7 @@ static void nv_zet(cmdarg_T *cap)
case 'b':
scroll_cursor_bot(0, true);
- redraw_later(curwin, VALID);
+ redraw_later(curwin, UPD_VALID);
set_fraction(curwin);
break;
@@ -3742,7 +3741,7 @@ static void nv_zet(cmdarg_T *cap)
}
if (curwin->w_leftcol != col) {
curwin->w_leftcol = col;
- redraw_later(curwin, NOT_VALID);
+ redraw_later(curwin, UPD_NOT_VALID);
}
}
break;
@@ -3763,7 +3762,7 @@ static void nv_zet(cmdarg_T *cap)
}
if (curwin->w_leftcol != col) {
curwin->w_leftcol = col;
- redraw_later(curwin, NOT_VALID);
+ redraw_later(curwin, UPD_NOT_VALID);
}
}
break;
@@ -4057,7 +4056,7 @@ static void nv_colon(cmdarg_T *cap)
} else if (cap->oap->op_type != OP_NOP
&& (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
|| cap->oap->start.col >
- (colnr_T)STRLEN(ml_get(cap->oap->start.lnum))
+ (colnr_T)strlen(ml_get(cap->oap->start.lnum))
|| did_emsg)) {
// The start of the operator has become invalid by the Ex command.
clearopbeep(cap->oap);
@@ -4098,7 +4097,7 @@ static void nv_clear(cmdarg_T *cap)
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
wp->w_s->b_syn_slow = false;
}
- redraw_later(curwin, CLEAR);
+ redraw_later(curwin, UPD_CLEAR);
}
}
@@ -4164,7 +4163,7 @@ void do_nv_ident(int c1, int c2)
/// 'K' normal-mode command. Get the command to lookup the keyword under the
/// cursor.
-static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, char **ptr_arg,
+static size_t nv_K_getcmd(cmdarg_T *cap, char *kp, bool kp_help, bool kp_ex, char **ptr_arg,
size_t n, char *buf, size_t buf_size)
{
if (kp_help) {
@@ -4201,8 +4200,8 @@ static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, c
// When a count is given, turn it into a range. Is this
// really what we want?
- bool isman = (STRCMP(kp, "man") == 0);
- bool isman_s = (STRCMP(kp, "man -s") == 0);
+ bool isman = (strcmp(kp, "man") == 0);
+ bool isman_s = (strcmp(kp, "man -s") == 0);
if (cap->count0 != 0 && !(isman || isman_s)) {
snprintf(buf, buf_size, ".,.+%" PRId64, (int64_t)(cap->count0 - 1));
}
@@ -4216,7 +4215,7 @@ static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, c
}
STRCAT(buf, " ");
if (cap->count0 != 0 && (isman || isman_s)) {
- snprintf(buf + STRLEN(buf), buf_size - STRLEN(buf), "%" PRId64,
+ snprintf(buf + strlen(buf), buf_size - strlen(buf), "%" PRId64,
(int64_t)cap->count0);
STRCAT(buf, " ");
}
@@ -4234,12 +4233,12 @@ static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, c
static void nv_ident(cmdarg_T *cap)
{
char *ptr = NULL;
- char_u *p;
+ char *p;
size_t n = 0; // init for GCC
int cmdchar;
bool g_cmd; // "g" command
bool tag_cmd = false;
- char_u *aux_ptr;
+ char *aux_ptr;
if (cap->cmdchar == 'g') { // "g*", "g#", "g]" and "gCTRL-]"
cmdchar = cap->nchar;
@@ -4275,15 +4274,14 @@ static void nv_ident(cmdarg_T *cap)
// Allocate buffer to put the command in. Inserting backslashes can
// double the length of the word. p_kp / curbuf->b_p_kp could be added
// and some numbers.
- char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg'
- assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
- bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
- bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0);
+ char *kp = *curbuf->b_p_kp == NUL ? (char *)p_kp : curbuf->b_p_kp; // 'keywordprg'
+ bool kp_help = (*kp == NUL || strcmp(kp, ":he") == 0 || strcmp(kp, ":help") == 0);
if (kp_help && *skipwhite(ptr) == NUL) {
emsg(_(e_noident)); // found white space only
return;
}
- size_t buf_size = n * 2 + 30 + STRLEN(kp);
+ bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
+ size_t buf_size = n * 2 + 30 + strlen(kp);
char *buf = xmalloc(buf_size);
buf[0] = NUL;
@@ -4295,7 +4293,7 @@ static void nv_ident(cmdarg_T *cap)
// Call setpcmark() first, so "*``" puts the cursor back where
// it was.
setpcmark();
- curwin->w_cursor.col = (colnr_T)(ptr - (char *)get_cursor_line_ptr());
+ curwin->w_cursor.col = (colnr_T)(ptr - get_cursor_line_ptr());
if (!g_cmd && vim_iswordp((char_u *)ptr)) {
STRCPY(buf, "\\<");
@@ -4337,45 +4335,45 @@ static void nv_ident(cmdarg_T *cap)
ptr = xstrnsave(ptr, n);
if (kp_ex) {
// Escape the argument properly for an Ex command
- p = (char_u *)vim_strsave_fnameescape((const char *)ptr, VSE_NONE);
+ p = vim_strsave_fnameescape((const char *)ptr, VSE_NONE);
} else {
// Escape the argument properly for a shell command
- p = vim_strsave_shellescape((char_u *)ptr, true, true);
+ p = (char *)vim_strsave_shellescape((char_u *)ptr, true, true);
}
xfree(ptr);
- char *newbuf = xrealloc(buf, STRLEN(buf) + STRLEN(p) + 1);
+ char *newbuf = xrealloc(buf, strlen(buf) + strlen(p) + 1);
buf = newbuf;
STRCAT(buf, p);
xfree(p);
} else {
if (cmdchar == '*') {
- aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
+ aux_ptr = (p_magic ? "/.*~[^$\\" : "/^$\\");
} else if (cmdchar == '#') {
- aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
+ aux_ptr = (p_magic ? "/?.*~[^$\\" : "/?^$\\");
} else if (tag_cmd) {
if (curbuf->b_help) {
// ":help" handles unescaped argument
- aux_ptr = (char_u *)"";
+ aux_ptr = "";
} else {
- aux_ptr = (char_u *)"\\|\"\n[";
+ aux_ptr = "\\|\"\n[";
}
} else {
- aux_ptr = (char_u *)"\\|\"\n*?[";
+ aux_ptr = "\\|\"\n*?[";
}
- p = (char_u *)buf + STRLEN(buf);
+ p = buf + STRLEN(buf);
while (n-- > 0) {
// put a backslash before \ and some others
- if (vim_strchr((char *)aux_ptr, *ptr) != NULL) {
+ if (vim_strchr(aux_ptr, *ptr) != NULL) {
*p++ = '\\';
}
// When current byte is a part of multibyte character, copy all
// bytes of that character.
const size_t len = (size_t)(utfc_ptr2len(ptr) - 1);
for (size_t i = 0; i < len && n > 0; i++, n--) {
- *p++ = (char_u)(*ptr++);
+ *p++ = *ptr++;
}
- *p++ = (char_u)(*ptr++);
+ *p++ = *ptr++;
}
*p = NUL;
}
@@ -4383,16 +4381,15 @@ static void nv_ident(cmdarg_T *cap)
// Execute the command.
if (cmdchar == '*' || cmdchar == '#') {
if (!g_cmd
- && vim_iswordp(mb_prevptr(get_cursor_line_ptr(), (char_u *)ptr))) {
+ && vim_iswordp(mb_prevptr((char_u *)get_cursor_line_ptr(), (char_u *)ptr))) {
STRCAT(buf, "\\>");
}
// put pattern in search history
init_history();
- add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL);
+ add_to_history(HIST_SEARCH, buf, true, NUL);
- (void)normal_search(cap, cmdchar == '*' ? '/' : '?', (char_u *)buf, 0,
- NULL);
+ (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
} else {
g_tag_at_cursor = true;
do_cmdline_cmd(buf);
@@ -4427,8 +4424,8 @@ bool get_visual_text(cmdarg_T *cap, char **pp, size_t *lenp)
return false;
}
if (VIsual_mode == 'V') {
- *pp = (char *)get_cursor_line_ptr();
- *lenp = STRLEN(*pp);
+ *pp = get_cursor_line_ptr();
+ *lenp = strlen(*pp);
} else {
if (lt(curwin->w_cursor, VIsual)) {
*pp = (char *)ml_get_pos(&curwin->w_cursor);
@@ -4453,7 +4450,7 @@ bool get_visual_text(cmdarg_T *cap, char **pp, size_t *lenp)
static void nv_tagpop(cmdarg_T *cap)
{
if (!checkclearopq(cap->oap)) {
- do_tag((char_u *)"", DT_POP, (int)cap->count1, false, true);
+ do_tag("", DT_POP, (int)cap->count1, false, true);
}
}
@@ -4566,9 +4563,9 @@ static void nv_right(cmdarg_T *cap)
// <Space> wraps to next line if 'whichwrap' has 's'.
// 'l' wraps to next line if 'whichwrap' has 'l'.
// CURS_RIGHT wraps to next line if 'whichwrap' has '>'.
- if (((cap->cmdchar == ' ' && vim_strchr((char *)p_ww, 's') != NULL)
- || (cap->cmdchar == 'l' && vim_strchr((char *)p_ww, 'l') != NULL)
- || (cap->cmdchar == K_RIGHT && vim_strchr((char *)p_ww, '>') != NULL))
+ if (((cap->cmdchar == ' ' && vim_strchr(p_ww, 's') != NULL)
+ || (cap->cmdchar == 'l' && vim_strchr(p_ww, 'l') != NULL)
+ || (cap->cmdchar == K_RIGHT && vim_strchr(p_ww, '>') != NULL))
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
// When deleting we also count the NL as a character.
// Set cap->oap->inclusive when last char in the line is
@@ -4602,7 +4599,7 @@ static void nv_right(cmdarg_T *cap)
if (virtual_active()) {
oneright();
} else {
- curwin->w_cursor.col += utfc_ptr2len((char *)get_cursor_pos_ptr());
+ curwin->w_cursor.col += utfc_ptr2len(get_cursor_pos_ptr());
}
}
}
@@ -4636,9 +4633,9 @@ static void nv_left(cmdarg_T *cap)
// 'h' wraps to previous line if 'whichwrap' has 'h'.
// CURS_LEFT wraps to previous line if 'whichwrap' has '<'.
if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H)
- && vim_strchr((char *)p_ww, 'b') != NULL)
- || (cap->cmdchar == 'h' && vim_strchr((char *)p_ww, 'h') != NULL)
- || (cap->cmdchar == K_LEFT && vim_strchr((char *)p_ww, '<') != NULL))
+ && vim_strchr(p_ww, 'b') != NULL)
+ || (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL)
+ || (cap->cmdchar == K_LEFT && vim_strchr(p_ww, '<') != NULL))
&& curwin->w_cursor.lnum > 1) {
curwin->w_cursor.lnum--;
coladvance(MAXCOL);
@@ -4650,7 +4647,7 @@ static void nv_left(cmdarg_T *cap)
// Don't adjust op_end now, otherwise it won't work.
if ((cap->oap->op_type == OP_DELETE || cap->oap->op_type == OP_CHANGE)
&& !LINEEMPTY(curwin->w_cursor.lnum)) {
- char_u *cp = get_cursor_pos_ptr();
+ char_u *cp = (char_u *)get_cursor_pos_ptr();
if (*cp != NUL) {
curwin->w_cursor.col += utfc_ptr2len((char *)cp);
@@ -4805,7 +4802,7 @@ static void nv_search(cmdarg_T *cap)
// When using 'incsearch' the cursor may be moved to set a different search
// start position.
- cap->searchbuf = getcmdline(cap->cmdchar, cap->count1, 0, true);
+ cap->searchbuf = (char *)getcmdline(cap->cmdchar, cap->count1, 0, true);
if (cap->searchbuf == NULL) {
clearop(oap);
@@ -4841,9 +4838,8 @@ static void nv_next(cmdarg_T *cap)
/// @param opt extra flags for do_search()
///
/// @return 0 for failure, 1 for found, 2 for found and line offset added.
-static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrapped)
+static int normal_search(cmdarg_T *cap, int dir, char *pat, int opt, int *wrapped)
{
- int i;
searchit_arg_T sia;
cap->oap->motion_type = kMTCharWise;
@@ -4852,8 +4848,8 @@ static int normal_search(cmdarg_T *cap, int dir, char_u *pat, int opt, int *wrap
curwin->w_set_curswant = true;
CLEAR_FIELD(sia);
- i = do_search(cap->oap, dir, dir, pat, cap->count1,
- opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia);
+ int i = do_search(cap->oap, dir, dir, (char_u *)pat, cap->count1,
+ opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia);
if (wrapped != NULL) {
*wrapped = sia.sa_wrapped;
}
@@ -5363,7 +5359,7 @@ static void nv_replace(cmdarg_T *cap)
}
// Abort if not enough characters to replace.
- ptr = get_cursor_pos_ptr();
+ ptr = (char_u *)get_cursor_pos_ptr();
if (STRLEN(ptr) < (unsigned)cap->count1
|| (mb_charlen(ptr) < cap->count1)) {
clearopbeep(cap->oap);
@@ -5552,7 +5548,7 @@ static void n_swapchar(cmdarg_T *cap)
return;
}
- if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr((char *)p_ww, '~') == NULL) {
+ if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL) {
clearopbeep(cap->oap);
return;
}
@@ -5568,7 +5564,7 @@ static void n_swapchar(cmdarg_T *cap)
did_change |= swapchar(cap->oap->op_type, &curwin->w_cursor);
inc_cursor();
if (gchar_cursor() == NUL) {
- if (vim_strchr((char *)p_ww, '~') != NULL
+ if (vim_strchr(p_ww, '~') != NULL
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
@@ -5624,7 +5620,7 @@ static MarkMoveRes nv_mark_move_to(cmdarg_T *cap, MarkMove flags, fmark_T *fm)
/// Handle commands that are operators in Visual mode.
static void v_visop(cmdarg_T *cap)
{
- static char_u trans[] = "YyDdCcxdXdAAIIrr";
+ static char trans[] = "YyDdCcxdXdAAIIrr";
// Uppercase means linewise, except in block mode, then "D" deletes till
// the end of the line, and "C" replaces till EOL
@@ -5636,7 +5632,7 @@ static void v_visop(cmdarg_T *cap)
curwin->w_curswant = MAXCOL;
}
}
- cap->cmdchar = (uint8_t)(*(vim_strchr((char *)trans, cap->cmdchar) + 1));
+ cap->cmdchar = (uint8_t)(*(vim_strchr(trans, cap->cmdchar) + 1));
nv_operator(cap);
}
@@ -5819,7 +5815,7 @@ static void nv_visual(cmdarg_T *cap)
showmode();
may_trigger_modechanged();
}
- redraw_curbuf_later(INVERTED); // update the inversion
+ redraw_curbuf_later(UPD_INVERTED); // update the inversion
} else { // start Visual mode
if (cap->count0 > 0 && resel_VIsual_mode != NUL) {
// use previously selected part
@@ -5865,7 +5861,7 @@ static void nv_visual(cmdarg_T *cap)
} else {
curwin->w_set_curswant = true;
}
- redraw_curbuf_later(INVERTED); // show the inversion
+ redraw_curbuf_later(UPD_INVERTED); // show the inversion
} else {
if (!cap->arg) {
// start Select mode when 'selectmode' contains "cmd"
@@ -5900,7 +5896,7 @@ void start_selection(void)
void may_start_select(int c)
{
VIsual_select = (c == 'o' || (stuff_empty() && typebuf_typed()))
- && vim_strchr((char *)p_slm, c) != NULL;
+ && vim_strchr(p_slm, c) != NULL;
}
/// Start Visual mode "c".
@@ -5931,7 +5927,7 @@ static void n_start_visual_mode(int c)
}
// Only need to redraw this line, unless still need to redraw an old
// Visual area (when 'lazyredraw' is set).
- if (curwin->w_redr_type < INVERTED) {
+ if (curwin->w_redr_type < UPD_INVERTED) {
curwin->w_old_cursor_lnum = curwin->w_cursor.lnum;
curwin->w_old_visual_lnum = curwin->w_cursor.lnum;
}
@@ -6018,7 +6014,7 @@ static void nv_gv_cmd(cmdarg_T *cap)
may_start_select('c');
}
setmouse();
- redraw_curbuf_later(INVERTED);
+ redraw_curbuf_later(UPD_INVERTED);
showmode();
}
@@ -6071,7 +6067,7 @@ static void nv_g_underscore_cmd(cmdarg_T *cap)
return;
}
- char_u *ptr = get_cursor_line_ptr();
+ char_u *ptr = (char_u *)get_cursor_line_ptr();
// In Visual mode we may end up after the line.
if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) {
@@ -6154,7 +6150,7 @@ static void nv_gi_cmd(cmdarg_T *cap)
if (curbuf->b_last_insert.mark.lnum != 0) {
curwin->w_cursor = curbuf->b_last_insert.mark;
check_cursor_lnum();
- int i = (int)STRLEN(get_cursor_line_ptr());
+ int i = (int)strlen(get_cursor_line_ptr());
if (curwin->w_cursor.col > (colnr_T)i) {
if (virtual_active()) {
curwin->w_cursor.coladd += curwin->w_cursor.col - i;
@@ -6282,7 +6278,7 @@ static void nv_g_cmd(cmdarg_T *cap)
case 'M':
oap->motion_type = kMTCharWise;
oap->inclusive = false;
- i = linetabsize(get_cursor_line_ptr());
+ i = linetabsize((char_u *)get_cursor_line_ptr());
if (cap->count0 > 0 && cap->count0 <= 100) {
coladvance((colnr_T)(i * cap->count0 / 100));
} else {
@@ -6837,7 +6833,7 @@ bool unadjust_for_sel(void)
mark_mb_adjustpos(curbuf, pp);
} else if (pp->lnum > 1) {
pp->lnum--;
- pp->col = (colnr_T)STRLEN(ml_get(pp->lnum));
+ pp->col = (colnr_T)strlen(ml_get(pp->lnum));
return true;
}
}
@@ -6901,7 +6897,7 @@ static void nv_normal(cmdarg_T *cap)
}
if (VIsual_active) {
end_visual_mode(); // stop Visual
- redraw_curbuf_later(INVERTED);
+ redraw_curbuf_later(UPD_INVERTED);
}
} else {
clearopbeep(cap->oap);
@@ -6920,10 +6916,7 @@ static void nv_esc(cmdarg_T *cap)
&& cap->oap->regname == 0);
if (cap->arg) { // true for CTRL-C
- if (restart_edit == 0
- && cmdwin_type == 0
- && !VIsual_active
- && no_reason) {
+ if (restart_edit == 0 && cmdwin_type == 0 && !VIsual_active && no_reason) {
if (anyBufIsChanged()) {
msg(_("Type :qa! and press <Enter> to abandon all changes"
" and exit Nvim"));
@@ -6955,7 +6948,7 @@ static void nv_esc(cmdarg_T *cap)
end_visual_mode(); // stop Visual
check_cursor_col(); // make sure cursor is not beyond EOL
curwin->w_set_curswant = true;
- redraw_curbuf_later(INVERTED);
+ redraw_curbuf_later(UPD_INVERTED);
} else if (no_reason) {
vim_beep(BO_ESC);
}
@@ -6974,7 +6967,7 @@ void set_cursor_for_append_to_line(void)
coladvance(MAXCOL);
State = save_State;
} else {
- curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
+ curwin->w_cursor.col += (colnr_T)strlen(get_cursor_pos_ptr());
}
}
@@ -7075,8 +7068,8 @@ static void nv_object(cmdarg_T *cap)
include = true; // "ax" = an object: include white space
}
// Make sure (), [], {} and <> are in 'matchpairs'
- mps_save = curbuf->b_p_mps;
- curbuf->b_p_mps = (char_u *)"(:),{:},[:],<:>";
+ mps_save = (char_u *)curbuf->b_p_mps;
+ curbuf->b_p_mps = "(:),{:},[:],<:>";
switch (cap->nchar) {
case 'w': // "aw" = a word
@@ -7130,7 +7123,7 @@ static void nv_object(cmdarg_T *cap)
break;
}
- curbuf->b_p_mps = mps_save;
+ curbuf->b_p_mps = (char *)mps_save;
if (!flag) {
clearopbeep(cap->oap);
}