1
0
forked from aniani/vim

patch 8.2.4911: the mode #defines are not clearly named

Problem:    The mode #defines are not clearly named.
Solution:   Prepend MODE_.  Renumber them to put the mapped modes first.
This commit is contained in:
Bram Moolenaar
2022-05-07 20:01:16 +01:00
parent 9ff7d717aa
commit 249591057b
49 changed files with 514 additions and 490 deletions

View File

@@ -988,7 +988,7 @@ ins_bytes_len(char_u *p, int len)
/*
* Insert or replace a single character at the cursor position.
* When in REPLACE or VREPLACE mode, replace any existing character.
* When in MODE_REPLACE or MODE_VREPLACE state, 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.
@@ -1119,7 +1119,7 @@ ins_char_bytes(char_u *buf, int charlen)
// If we're in Insert or Replace mode and 'showmatch' is set, then briefly
// show the match for right parens and braces.
if (p_sm && (State & INSERT)
if (p_sm && (State & MODE_INSERT)
&& msg_silent == 0
&& !ins_compl_active())
{
@@ -1342,10 +1342,10 @@ del_bytes(
/*
* open_line: Add a new line below or above the current line.
*
* For VREPLACE mode, we only add a new line when we get to the end of the
* file, otherwise we just start replacing the next line.
* For MODE_VREPLACE state, we only add a new line when we get to the end of
* the file, otherwise we just start replacing the next line.
*
* Caller must take care of undo. Since VREPLACE may affect any number of
* Caller must take care of undo. Since MODE_VREPLACE may affect any number of
* lines however, it may call u_save_cursor() again when starting to change a
* new line.
* "flags": OPENLINE_DELSPACES delete spaces after cursor
@@ -1416,7 +1416,7 @@ open_line(
if (State & VREPLACE_FLAG)
{
// With VREPLACE we make a copy of the next line, which we will be
// With MODE_VREPLACE we make a copy of the next line, which we will be
// starting to replace. First make the new line empty and let vim play
// with the indenting and comment leader to its heart's content. Then
// we grab what it ended up putting on the new line, put back the
@@ -1430,11 +1430,11 @@ open_line(
if (next_line == NULL) // out of memory!
goto theend;
// In VREPLACE mode, a NL replaces the rest of the line, and starts
// replacing the next line, so push all of the characters left on the
// line onto the replace stack. We'll push any other characters that
// might be replaced at the start of the next line (due to autoindent
// etc) a bit later.
// In MODE_VREPLACE state, a NL replaces the rest of the line, and
// starts replacing the next line, so push all of the characters left
// on the line onto the replace stack. We'll push any other characters
// that might be replaced at the start of the next line (due to
// autoindent etc) a bit later.
replace_push(NUL); // Call twice because BS over NL expects it
replace_push(NUL);
p = saved_line + curwin->w_cursor.col;
@@ -1448,7 +1448,7 @@ open_line(
saved_line[curwin->w_cursor.col] = NUL;
}
if ((State & INSERT) && !(State & VREPLACE_FLAG))
if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
{
p_extra = saved_line + curwin->w_cursor.col;
#ifdef FEAT_SMARTINDENT
@@ -2077,7 +2077,7 @@ open_line(
}
}
// (State == INSERT || State == REPLACE), only when dir == FORWARD
// (State == MODE_INSERT || State == MODE_REPLACE), only when dir == FORWARD
if (p_extra != NULL)
{
*p_extra = saved_char; // restore char that NUL replaced
@@ -2085,8 +2085,9 @@ open_line(
// When 'ai' set or "flags" has OPENLINE_DELSPACES, skip to the first
// non-blank.
//
// When in REPLACE mode, put the deleted blanks on the replace stack,
// preceded by a NUL, so they can be put back when a BS is entered.
// When in MODE_REPLACE state, put the deleted blanks on the replace
// stack, preceded by a NUL, so they can be put back when a BS is
// entered.
if (REPLACE_NORMAL(State))
replace_push(NUL); // end of extra blanks
if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES))
@@ -2156,7 +2157,7 @@ open_line(
mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
did_append = TRUE;
#ifdef FEAT_PROP_POPUP
if ((State & INSERT) && !(State & VREPLACE_FLAG))
if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
// properties after the split move to the next line
adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum,
curwin->w_cursor.col + 1, 0);
@@ -2164,7 +2165,7 @@ open_line(
}
else
{
// In VREPLACE mode we are starting to replace the next line.
// In MODE_VREPLACE state we are starting to replace the next line.
curwin->w_cursor.lnum++;
if (curwin->w_cursor.lnum >= Insstart.lnum + vr_lines_changed)
{
@@ -2212,8 +2213,8 @@ open_line(
ai_col = curwin->w_cursor.col;
// In REPLACE mode, for each character in the new indent, there must
// be a NUL on the replace stack, for when it is deleted with BS
// In MODE_REPLACE state, for each character in the new indent, there
// must be a NUL on the replace stack, for when it is deleted with BS
if (REPLACE_NORMAL(State))
for (n = 0; n < (int)curwin->w_cursor.col; ++n)
replace_push(NUL);
@@ -2224,8 +2225,8 @@ open_line(
#endif
}
// In REPLACE mode, for each character in the extra leader, there must be
// a NUL on the replace stack, for when it is deleted with BS.
// In MODE_REPLACE state, for each character in the extra leader, there
// must be a NUL on the replace stack, for when it is deleted with BS.
if (REPLACE_NORMAL(State))
while (lead_len-- > 0)
replace_push(NUL);
@@ -2234,7 +2235,7 @@ open_line(
if (dir == FORWARD)
{
if (trunc_line || (State & INSERT))
if (trunc_line || (State & MODE_INSERT))
{
// truncate current line at cursor
saved_line[curwin->w_cursor.col] = NUL;
@@ -2270,13 +2271,13 @@ open_line(
curwin->w_cursor.coladd = 0;
#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
// In VREPLACE mode, we are handling the replace stack ourselves, so stop
// fixthisline() from doing it (via change_indent()) by telling it we're in
// normal INSERT mode.
// In MODE_VREPLACE state, we are handling the replace stack ourselves, so
// stop fixthisline() from doing it (via change_indent()) by telling it
// we're in normal MODE_INSERT state.
if (State & VREPLACE_FLAG)
{
vreplace_mode = State; // So we know to put things right later
State = INSERT;
State = MODE_INSERT;
}
else
vreplace_mode = 0;
@@ -2305,9 +2306,9 @@ open_line(
State = vreplace_mode;
#endif
// Finally, VREPLACE gets the stuff on the new line, then puts back the
// original line, and inserts the new stuff char by char, pushing old stuff
// onto the replace stack (via ins_char()).
// Finally, MODE_VREPLACE gets the stuff on the new line, then puts back
// the original line, and inserts the new stuff char by char, pushing old
// stuff onto the replace stack (via ins_char()).
if (State & VREPLACE_FLAG)
{
// Put new line in p_extra