aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 3ea7b442c8..ca903fdcf7 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -523,7 +523,7 @@ static int insert_check(VimState *state)
did_cursorhold = false;
}
- // If the cursor was moved we didn't just insert a space */
+ // If the cursor was moved we didn't just insert a space
if (arrow_used) {
s->inserted_space = false;
}
@@ -708,7 +708,7 @@ static int insert_execute(VimState *state, int key)
if (str != NULL) {
for (p = str; *p != NUL; MB_PTR_ADV(p)) {
- ins_compl_addleader(PTR2CHAR(p));
+ ins_compl_addleader(utf_ptr2char(p));
}
xfree(str);
} else {
@@ -835,7 +835,7 @@ static int insert_handle_key(InsertState *s)
case Ctrl_C: // End input mode
if (s->c == Ctrl_C && cmdwin_type != 0) {
- // Close the cmdline window. */
+ // Close the cmdline window.
cmdwin_result = K_IGNORE;
got_int = false; // don't stop executing autocommands et al
s->nomove = true;
@@ -1283,7 +1283,7 @@ normalchar:
if (*str != NUL && stop_arrow() != FAIL) {
// Insert the new value of v:char literally.
for (p = str; *p != NUL; MB_PTR_ADV(p)) {
- s->c = PTR2CHAR(p);
+ s->c = utf_ptr2char(p);
if (s->c == CAR || s->c == K_KENTER || s->c == NL) {
ins_eol(s->c);
} else {
@@ -1398,20 +1398,20 @@ bool edit(int cmdchar, bool startln, long count)
// Don't allow inserting in the sandbox.
if (sandbox != 0) {
- EMSG(_(e_sandbox));
+ emsg(_(e_sandbox));
return false;
}
// Don't allow changes in the buffer while editing the cmdline. The
// caller of getcmdline() may get confused.
if (textlock != 0) {
- EMSG(_(e_secure));
+ emsg(_(e_secure));
return false;
}
// Don't allow recursive insert mode when busy with completion.
if (compl_started || compl_busy || pum_visible()) {
- EMSG(_(e_secure));
+ emsg(_(e_secure));
return false;
}
@@ -3006,7 +3006,7 @@ static void ins_compl_files(int count, char_u **files, int thesaurus, int flags,
msg_hist_off = true; // reset in msg_trunc_attr()
vim_snprintf((char *)IObuff, IOSIZE,
_("Scanning dictionary: %s"), (char *)files[i]);
- (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R));
+ (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R));
}
if (fp == NULL) {
@@ -3330,7 +3330,7 @@ void get_complete_info(list_T *what_list, dict_T *retdict)
// Return Insert completion mode name string
static char_u *ins_compl_mode(void)
{
- if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || ctrl_x_mode == CTRL_X_SCROLL || compl_started) {
+ if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET || ctrl_x_mode == CTRL_X_SCROLL || compl_started) {
return (char_u *)ctrl_x_mode_names[ctrl_x_mode & ~CTRL_X_WANT_IDENT];
}
return (char_u *)"";
@@ -3548,7 +3548,7 @@ static void ins_compl_addfrommatch(void)
}
}
p += len;
- c = PTR2CHAR(p);
+ c = utf_ptr2char(p);
ins_compl_addleader(c);
}
@@ -3905,7 +3905,6 @@ static buf_T *ins_compl_next_buf(buf_T *buf, int flag)
assert(wp);
while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin
&& wp->w_buffer->b_scanned) {
- ;
}
buf = wp->w_buffer;
} else {
@@ -3918,7 +3917,6 @@ static buf_T *ins_compl_next_buf(buf_T *buf, int flag)
: (!buf->b_p_bl
|| (buf->b_ml.ml_mfp == NULL) != (flag == 'u')))
|| buf->b_scanned)) {
- ;
}
}
return buf;
@@ -3991,13 +3989,13 @@ static void expand_by_function(int type, char_u *base)
}
if (curwin_save != curwin || curbuf_save != curbuf) {
- EMSG(_(e_complwin));
+ emsg(_(e_complwin));
goto theend;
}
curwin->w_cursor = pos; // restore the cursor position
validate_cursor();
if (!equalpos(curwin->w_cursor, pos)) {
- EMSG(_(e_compldel));
+ emsg(_(e_compldel));
goto theend;
}
@@ -4233,7 +4231,7 @@ static int ins_compl_get_exp(pos_T *ini)
: ins_buf->b_sfname == NULL
? ins_buf->b_fname
: ins_buf->b_sfname);
- (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R));
+ (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R));
} else if (*e_cpt == NUL) {
break;
} else {
@@ -4257,7 +4255,7 @@ static int ins_compl_get_exp(pos_T *ini)
msg_hist_off = true; // reset in msg_trunc_attr()
type = CTRL_X_TAGS;
vim_snprintf((char *)IObuff, IOSIZE, "%s", _("Scanning tags."));
- (void)msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R));
+ (void)msg_trunc_attr((char *)IObuff, true, HL_ATTR(HLF_R));
} else {
type = -1;
}
@@ -4449,7 +4447,7 @@ static int ins_compl_get_exp(pos_T *ini)
// when ADDING, the text before the cursor matches, skip it
if ((compl_cont_status & CONT_ADDING) && ins_buf == curbuf
&& ini->lnum == pos->lnum
- && ini->col == pos->col) {
+ && ini->col == pos->col) {
continue;
}
ptr = ml_get_buf(ins_buf, pos->lnum, false) + pos->col;
@@ -4860,7 +4858,7 @@ static int ins_compl_next(int allow_get_expansion, int count, int insert_match,
msg_hist_off = true;
vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead,
s > compl_shown_match->cp_fname ? "<" : "", s);
- msg(IObuff);
+ msg((char *)IObuff);
msg_hist_off = false;
redraw_cmdline = false; // don't overwrite!
}
@@ -5124,7 +5122,6 @@ static int ins_complete(int c, bool enable_pum)
|| ctrl_x_mode == CTRL_X_PATH_DEFINES) {
if (!(compl_cont_status & CONT_ADDING)) {
while (--startcol >= 0 && vim_isIDc(line[startcol])) {
- ;
}
compl_col += ++startcol;
compl_length = curs_col - startcol;
@@ -5204,10 +5201,10 @@ static int ins_complete(int c, bool enable_pum)
char_u *p = line + startcol;
MB_PTR_BACK(line, p);
- while (p > line && vim_isfilec(PTR2CHAR(p))) {
+ while (p > line && vim_isfilec(utf_ptr2char(p))) {
MB_PTR_BACK(line, p);
}
- if (p == line && vim_isfilec(PTR2CHAR(p))) {
+ if (p == line && vim_isfilec(utf_ptr2char(p))) {
startcol = 0;
} else {
startcol = (int)(p - line) + 1;
@@ -5243,7 +5240,7 @@ static int ins_complete(int c, bool enable_pum)
// Call 'completefunc' or 'omnifunc' and get pattern length as a string
funcname = get_complete_funcname(ctrl_x_mode);
if (*funcname == NUL) {
- EMSG2(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION
+ semsg(_(e_notset), ctrl_x_mode == CTRL_X_FUNCTION
? "completefunc" : "omnifunc");
// restore did_ai, so that adding comment leader works
did_ai = save_did_ai;
@@ -5264,13 +5261,13 @@ static int ins_complete(int c, bool enable_pum)
State = save_State;
if (curwin_save != curwin || curbuf_save != curbuf) {
- EMSG(_(e_complwin));
+ emsg(_(e_complwin));
return FAIL;
}
curwin->w_cursor = pos; // restore the cursor position
validate_cursor();
if (!equalpos(curwin->w_cursor, pos)) {
- EMSG(_(e_compldel));
+ emsg(_(e_compldel));
return FAIL;
}
@@ -5808,7 +5805,6 @@ void insertchar(int c, int flags, int second_indent)
// Skip white space before the cursor
i = curwin->w_cursor.col;
while (--i >= 0 && ascii_iswhite(line[i])) {
- ;
}
i++;
@@ -6366,8 +6362,8 @@ void auto_format(bool trailblank, bool prev_line)
curwin->w_cursor = pos;
}
- /* With the 'c' flag in 'formatoptions' and 't' missing: only format
- * comments. */
+ // With the 'c' flag in 'formatoptions' and 't' missing: only format
+ // comments.
if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP)
&& get_leader_len(old, NULL, false, true) == 0) {
return;
@@ -7041,7 +7037,7 @@ int stuff_inserted(int c, long count, int no_esc)
ptr = get_last_insert();
if (ptr == NULL) {
- EMSG(_(e_noinstext));
+ emsg(_(e_noinstext));
return FAIL;
}
@@ -7191,7 +7187,7 @@ void replace_push(int c)
*/
int replace_push_mb(char_u *p)
{
- int l = (*mb_ptr2len)(p);
+ int l = utfc_ptr2len(p);
int j;
for (j = l - 1; j >= 0; --j) {
@@ -7347,7 +7343,7 @@ static void replace_do_bs(int limit_col)
vcol = start_vcol;
for (i = 0; i < ins_len; i++) {
vcol += win_chartabsize(curwin, p + i, vcol);
- i += (*mb_ptr2len)(p) - 1;
+ i += utfc_ptr2len(p) - 1;
}
vcol -= start_vcol;
@@ -7393,7 +7389,8 @@ void fixthisline(IndentGetter get_the_indent)
}
}
-void fix_indent(void) {
+void fix_indent(void)
+{
if (p_paste) {
return;
}
@@ -7641,7 +7638,7 @@ int hkmap(int c)
enum {
hALEF = 0, BET, GIMEL, DALET, HEI, VAV, ZAIN, HET, TET, IUD,
KAFsofit, hKAF, LAMED, MEMsofit, MEM, NUNsofit, NUN, SAMEH, AIN,
- PEIsofit, PEI, ZADIsofit, ZADI, KOF, RESH, hSHIN, TAV
+ PEIsofit, PEI, ZADIsofit, ZADI, KOF, RESH, hSHIN, TAV,
};
static char_u map[26] =
{ (char_u)hALEF /*a*/, (char_u)BET /*b*/, (char_u)hKAF /*c*/,
@@ -7989,7 +7986,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
if (reg_recording != 0 || restart_edit != NUL) {
showmode();
} else if (p_smd) {
- MSG("");
+ msg("");
}
// Exit Insert mode
return true;
@@ -8602,7 +8599,6 @@ static void ins_mousescroll(int dir)
}
-
static void ins_left(void)
{
pos_T tpos;