patch 8.1.0226: too many #ifdefs

Problem:    Too many #ifdefs.
Solution:   Graduate the +vreplace feature, it's not much code and quite a few
            #ifdefs.
This commit is contained in:
Bram Moolenaar
2018-07-29 16:09:22 +02:00
parent 612cc3888b
commit 1f0bfe5617
15 changed files with 21 additions and 158 deletions

View File

@@ -177,8 +177,6 @@ gR Enter Virtual Replace mode: Each character you type
<Tab> may replace several characters at once. <Tab> may replace several characters at once.
Repeat the entered text [count]-1 times. See Repeat the entered text [count]-1 times. See
|Virtual-Replace-mode| for more details. |Virtual-Replace-mode| for more details.
{not available when compiled without the |+vreplace|
feature}
*c* *c*
["x]c{motion} Delete {motion} text [into register x] and start ["x]c{motion} Delete {motion} text [into register x] and start
@@ -303,8 +301,6 @@ gr{char} Replace the virtual characters under the cursor with
space. See |gR| and |Virtual-Replace-mode| for more space. See |gR| and |Virtual-Replace-mode| for more
details. As with |r| a count may be given. details. As with |r| a count may be given.
{char} can be entered like with |r|. {char} can be entered like with |r|.
{not available when compiled without the |+vreplace|
feature}
*digraph-arg* *digraph-arg*
The argument for Normal mode commands like |r| and |t| is a single character. The argument for Normal mode commands like |r| and |t| is a single character.

View File

@@ -461,7 +461,7 @@ N *+viminfo* |'viminfo'|
N *+virtualedit* |'virtualedit'| N *+virtualedit* |'virtualedit'|
S *+visual* Visual mode |Visual-mode| Always enabled since 7.4.200. S *+visual* Visual mode |Visual-mode| Always enabled since 7.4.200.
N *+visualextra* extra Visual mode commands |blockwise-operators| N *+visualextra* extra Visual mode commands |blockwise-operators|
N *+vreplace* |gR| and |gr| T *+vreplace* |gR| and |gr|
*+vtp* on MS-Windows console: support for 'termguicolors' *+vtp* on MS-Windows console: support for 'termguicolors'
N *+wildignore* |'wildignore'| N *+wildignore* |'wildignore'|
N *+wildmenu* |'wildmenu'| N *+wildmenu* |'wildmenu'|

View File

@@ -463,7 +463,6 @@ edit(
{ {
ResetRedobuff(); ResetRedobuff();
AppendNumberToRedobuff(count); AppendNumberToRedobuff(count);
#ifdef FEAT_VREPLACE
if (cmdchar == 'V' || cmdchar == 'v') if (cmdchar == 'V' || cmdchar == 'v')
{ {
/* "gR" or "gr" command */ /* "gR" or "gr" command */
@@ -471,7 +470,6 @@ edit(
AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R'); AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R');
} }
else else
#endif
{ {
if (cmdchar == K_PS) if (cmdchar == K_PS)
AppendCharToRedobuff('a'); AppendCharToRedobuff('a');
@@ -497,7 +495,6 @@ edit(
#endif #endif
State = REPLACE; State = REPLACE;
} }
#ifdef FEAT_VREPLACE
else if (cmdchar == 'V' || cmdchar == 'v') else if (cmdchar == 'V' || cmdchar == 'v')
{ {
State = VREPLACE; State = VREPLACE;
@@ -505,7 +502,6 @@ edit(
orig_line_count = curbuf->b_ml.ml_line_count; orig_line_count = curbuf->b_ml.ml_line_count;
vr_lines_changed = 1; vr_lines_changed = 1;
} }
#endif
else else
State = INSERT; State = INSERT;
@@ -2042,7 +2038,6 @@ change_indent(
int save_p_list; int save_p_list;
int start_col; int start_col;
colnr_T vc; colnr_T vc;
#ifdef FEAT_VREPLACE
colnr_T orig_col = 0; /* init for GCC */ colnr_T orig_col = 0; /* init for GCC */
char_u *new_line, *orig_line = NULL; /* init for GCC */ char_u *new_line, *orig_line = NULL; /* init for GCC */
@@ -2052,7 +2047,6 @@ change_indent(
orig_line = vim_strsave(ml_get_curline()); /* Deal with NULL below */ orig_line = vim_strsave(ml_get_curline()); /* Deal with NULL below */
orig_col = curwin->w_cursor.col; orig_col = curwin->w_cursor.col;
} }
#endif
/* for the following tricks we don't want list mode */ /* for the following tricks we don't want list mode */
save_p_list = curwin->w_p_list; save_p_list = curwin->w_p_list;
@@ -2091,17 +2085,13 @@ change_indent(
(void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0); (void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
else else
{ {
#ifdef FEAT_VREPLACE
int save_State = State; int save_State = State;
/* Avoid being called recursively. */ /* Avoid being called recursively. */
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
State = INSERT; State = INSERT;
#endif
shift_line(type == INDENT_DEC, round, 1, call_changed_bytes); shift_line(type == INDENT_DEC, round, 1, call_changed_bytes);
#ifdef FEAT_VREPLACE
State = save_State; State = save_State;
#endif
} }
insstart_less -= curwin->w_cursor.col; insstart_less -= curwin->w_cursor.col;
@@ -2233,7 +2223,6 @@ change_indent(
} }
} }
#ifdef FEAT_VREPLACE
/* /*
* For VREPLACE mode, we also have to fix the replace stack. In this case * For VREPLACE mode, we also have to fix the replace stack. In this case
* it is always possible because we backspace over the whole line and then * it is always possible because we backspace over the whole line and then
@@ -2266,7 +2255,6 @@ change_indent(
vim_free(new_line); vim_free(new_line);
} }
#endif
} }
/* /*
@@ -2288,8 +2276,6 @@ truncate_spaces(char_u *line)
line[i + 1] = NUL; line[i + 1] = NUL;
} }
#if defined(FEAT_VREPLACE) || defined(FEAT_INS_EXPAND) \
|| defined(FEAT_COMMENTS) || defined(PROTO)
/* /*
* Backspace the cursor until the given column. Handles REPLACE and VREPLACE * Backspace the cursor until the given column. Handles REPLACE and VREPLACE
* modes correctly. May also be used when not in insert mode at all. * modes correctly. May also be used when not in insert mode at all.
@@ -2308,7 +2294,6 @@ backspace_until_column(int col)
break; break;
} }
} }
#endif
/* /*
* Like del_char(), but make sure not to go before column "limit_col". * Like del_char(), but make sure not to go before column "limit_col".
@@ -6224,9 +6209,7 @@ insertchar(
&& (force_format && (force_format
|| (!VIM_ISWHITE(c) || (!VIM_ISWHITE(c)
&& !((State & REPLACE_FLAG) && !((State & REPLACE_FLAG)
#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG) && !(State & VREPLACE_FLAG)
#endif
&& *ml_get_cursor() != NUL) && *ml_get_cursor() != NUL)
&& (curwin->w_cursor.lnum != Insstart.lnum && (curwin->w_cursor.lnum != Insstart.lnum
|| ((!has_format_option(FO_INS_LONG) || ((!has_format_option(FO_INS_LONG)
@@ -6471,11 +6454,7 @@ internal_format(
* When 'ai' is off we don't want a space under the cursor to be * When 'ai' is off we don't want a space under the cursor to be
* deleted. Replace it with an 'x' temporarily. * deleted. Replace it with an 'x' temporarily.
*/ */
if (!curbuf->b_p_ai if (!curbuf->b_p_ai && !(State & VREPLACE_FLAG))
#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG)
#endif
)
{ {
cc = gchar_cursor(); cc = gchar_cursor();
if (VIM_ISWHITE(cc)) if (VIM_ISWHITE(cc))
@@ -6496,10 +6475,8 @@ internal_format(
int end_foundcol = 0; /* column for start of word */ int end_foundcol = 0; /* column for start of word */
colnr_T len; colnr_T len;
colnr_T virtcol; colnr_T virtcol;
#ifdef FEAT_VREPLACE
int orig_col = 0; int orig_col = 0;
char_u *saved_text = NULL; char_u *saved_text = NULL;
#endif
colnr_T col; colnr_T col;
colnr_T end_col; colnr_T end_col;
@@ -6669,11 +6646,9 @@ internal_format(
* stack functions. VREPLACE does not use this, and backspaces * stack functions. VREPLACE does not use this, and backspaces
* over the text instead. * over the text instead.
*/ */
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
orig_col = startcol; /* Will start backspacing from here */ orig_col = startcol; /* Will start backspacing from here */
else else
#endif
replace_offset = startcol - end_foundcol; replace_offset = startcol - end_foundcol;
/* /*
@@ -6688,7 +6663,6 @@ internal_format(
if (startcol < 0) if (startcol < 0)
startcol = 0; startcol = 0;
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
/* /*
@@ -6706,7 +6680,6 @@ internal_format(
backspace_until_column(foundcol); backspace_until_column(foundcol);
} }
else else
#endif
{ {
/* put cursor after pos. to break line */ /* put cursor after pos. to break line */
if (!fo_white_par) if (!fo_white_par)
@@ -6744,12 +6717,10 @@ internal_format(
get_number_indent(curwin->w_cursor.lnum - 1); get_number_indent(curwin->w_cursor.lnum - 1);
if (second_indent >= 0) if (second_indent >= 0)
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, second_indent, change_indent(INDENT_SET, second_indent,
FALSE, NUL, TRUE); FALSE, NUL, TRUE);
else else
#endif
#ifdef FEAT_COMMENTS #ifdef FEAT_COMMENTS
if (leader_len > 0 && second_indent - leader_len > 0) if (leader_len > 0 && second_indent - leader_len > 0)
{ {
@@ -6778,7 +6749,6 @@ internal_format(
first_line = FALSE; first_line = FALSE;
} }
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
/* /*
@@ -6789,7 +6759,6 @@ internal_format(
vim_free(saved_text); vim_free(saved_text);
} }
else else
#endif
{ {
/* /*
* Check if cursor is not past the NUL off the line, cindent * Check if cursor is not past the NUL off the line, cindent
@@ -7140,13 +7109,11 @@ stop_arrow(void)
} }
ai_col = 0; ai_col = 0;
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
orig_line_count = curbuf->b_ml.ml_line_count; orig_line_count = curbuf->b_ml.ml_line_count;
vr_lines_changed = 1; vr_lines_changed = 1;
} }
#endif
ResetRedobuff(); ResetRedobuff();
AppendToRedobuff((char_u *)"1i"); /* pretend we start an insertion */ AppendToRedobuff((char_u *)"1i"); /* pretend we start an insertion */
new_insert_skip = 2; new_insert_skip = 2;
@@ -7983,7 +7950,6 @@ replace_flush(void)
replace_do_bs(int limit_col) replace_do_bs(int limit_col)
{ {
int cc; int cc;
#ifdef FEAT_VREPLACE
int orig_len = 0; int orig_len = 0;
int ins_len; int ins_len;
int orig_vcols = 0; int orig_vcols = 0;
@@ -7991,12 +7957,10 @@ replace_do_bs(int limit_col)
char_u *p; char_u *p;
int i; int i;
int vcol; int vcol;
#endif
cc = replace_pop(); cc = replace_pop();
if (cc > 0) if (cc > 0)
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
/* Get the number of screen cells used by the character we are /* Get the number of screen cells used by the character we are
@@ -8004,29 +7968,23 @@ replace_do_bs(int limit_col)
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL); getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
orig_vcols = chartabsize(ml_get_cursor(), start_vcol); orig_vcols = chartabsize(ml_get_cursor(), start_vcol);
} }
#endif
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
{ {
(void)del_char_after_col(limit_col); (void)del_char_after_col(limit_col);
# ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
orig_len = (int)STRLEN(ml_get_cursor()); orig_len = (int)STRLEN(ml_get_cursor());
# endif
replace_push(cc); replace_push(cc);
} }
else else
#endif #endif
{ {
pchar_cursor(cc); pchar_cursor(cc);
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
orig_len = (int)STRLEN(ml_get_cursor()) - 1; orig_len = (int)STRLEN(ml_get_cursor()) - 1;
#endif
} }
replace_pop_ins(); replace_pop_ins();
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
/* Get the number of screen cells used by the inserted characters */ /* Get the number of screen cells used by the inserted characters */
@@ -8052,7 +8010,6 @@ replace_do_bs(int limit_col)
} }
curwin->w_cursor.col -= ins_len; curwin->w_cursor.col -= ins_len;
} }
#endif
/* mark the buffer as changed and prepare for displaying */ /* mark the buffer as changed and prepare for displaying */
changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col); changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
@@ -8966,11 +8923,9 @@ ins_insert(int replaceState)
# ifdef FEAT_EVAL # ifdef FEAT_EVAL
set_vim_var_string(VV_INSERTMODE, set_vim_var_string(VV_INSERTMODE,
(char_u *)((State & REPLACE_FLAG) ? "i" : (char_u *)((State & REPLACE_FLAG) ? "i"
# ifdef FEAT_VREPLACE : replaceState == VREPLACE ? "v"
replaceState == VREPLACE ? "v" : : "r"), 1);
# endif
"r"), 1);
# endif # endif
apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf);
if (State & REPLACE_FLAG) if (State & REPLACE_FLAG)
@@ -8990,11 +8945,9 @@ ins_insert(int replaceState)
static void static void
ins_ctrl_o(void) ins_ctrl_o(void)
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
restart_edit = 'V'; restart_edit = 'V';
else else
#endif
if (State & REPLACE_FLAG) if (State & REPLACE_FLAG)
restart_edit = 'R'; restart_edit = 'R';
else else
@@ -9067,14 +9020,12 @@ ins_del(void)
else else
{ {
curwin->w_cursor.col = temp; curwin->w_cursor.col = temp;
#ifdef FEAT_VREPLACE
/* Adjust orig_line_count in case more lines have been deleted than /* Adjust orig_line_count in case more lines have been deleted than
* have been added. That makes sure, that open_line() later * have been added. That makes sure, that open_line() later
* can access all buffer lines correctly */ * can access all buffer lines correctly */
if (State & VREPLACE_FLAG && if (State & VREPLACE_FLAG &&
orig_line_count > curbuf->b_ml.ml_line_count) orig_line_count > curbuf->b_ml.ml_line_count)
orig_line_count = curbuf->b_ml.ml_line_count; orig_line_count = curbuf->b_ml.ml_line_count;
#endif
} }
} }
else if (del_char(FALSE) == FAIL) /* delete char under cursor */ else if (del_char(FALSE) == FAIL) /* delete char under cursor */
@@ -9229,10 +9180,8 @@ ins_bs(
} }
else else
{ {
#ifdef FEAT_VREPLACE
if (!(State & VREPLACE_FLAG) if (!(State & VREPLACE_FLAG)
|| curwin->w_cursor.lnum > orig_line_count) || curwin->w_cursor.lnum > orig_line_count)
#endif
{ {
temp = gchar_cursor(); /* remember current char */ temp = gchar_cursor(); /* remember current char */
--curwin->w_cursor.lnum; --curwin->w_cursor.lnum;
@@ -9256,10 +9205,8 @@ ins_bs(
if (temp == NUL && gchar_cursor() != NUL) if (temp == NUL && gchar_cursor() != NUL)
inc_cursor(); inc_cursor();
} }
#ifdef FEAT_VREPLACE
else else
dec_cursor(); dec_cursor();
#endif
/* /*
* In REPLACE mode we have to put back the text that was replaced * In REPLACE mode we have to put back the text that was replaced
@@ -9386,11 +9333,9 @@ ins_bs(
&& curwin->w_cursor.col < Insstart_orig.col) && curwin->w_cursor.col < Insstart_orig.col)
Insstart_orig.col = curwin->w_cursor.col; Insstart_orig.col = curwin->w_cursor.col;
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
ins_char(' '); ins_char(' ');
else else
#endif
{ {
ins_str((char_u *)" "); ins_str((char_u *)" ");
if ((State & REPLACE_FLAG)) if ((State & REPLACE_FLAG))
@@ -10231,11 +10176,9 @@ ins_tab(void)
ins_char(' '); ins_char(' ');
while (--temp > 0) while (--temp > 0)
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
ins_char(' '); ins_char(' ');
else else
#endif
{ {
ins_str((char_u *)" "); ins_str((char_u *)" ");
if (State & REPLACE_FLAG) /* no char replaced */ if (State & REPLACE_FLAG) /* no char replaced */
@@ -10255,10 +10198,8 @@ ins_tab(void)
#endif #endif
{ {
char_u *ptr; char_u *ptr;
#ifdef FEAT_VREPLACE
char_u *saved_line = NULL; /* init for GCC */ char_u *saved_line = NULL; /* init for GCC */
pos_T pos; pos_T pos;
#endif
pos_T fpos; pos_T fpos;
pos_T *cursor; pos_T *cursor;
colnr_T want_vcol, vcol; colnr_T want_vcol, vcol;
@@ -10269,7 +10210,6 @@ ins_tab(void)
* Get the current line. For VREPLACE mode, don't make real changes * Get the current line. For VREPLACE mode, don't make real changes
* yet, just work on a copy of the line. * yet, just work on a copy of the line.
*/ */
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
pos = curwin->w_cursor; pos = curwin->w_cursor;
@@ -10280,7 +10220,6 @@ ins_tab(void)
ptr = saved_line + pos.col; ptr = saved_line + pos.col;
} }
else else
#endif
{ {
ptr = ml_get_cursor(); ptr = ml_get_cursor();
cursor = &curwin->w_cursor; cursor = &curwin->w_cursor;
@@ -10360,11 +10299,7 @@ ins_tab(void)
{ {
STRMOVE(ptr, ptr + i); STRMOVE(ptr, ptr + i);
/* correct replace stack. */ /* correct replace stack. */
if ((State & REPLACE_FLAG) if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))
#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG)
#endif
)
for (temp = i; --temp >= 0; ) for (temp = i; --temp >= 0; )
replace_join(repl_off); replace_join(repl_off);
} }
@@ -10378,7 +10313,6 @@ ins_tab(void)
#endif #endif
cursor->col -= i; cursor->col -= i;
#ifdef FEAT_VREPLACE
/* /*
* In VREPLACE mode, we haven't changed anything yet. Do it now by * In VREPLACE mode, we haven't changed anything yet. Do it now by
* backspacing over the changed spacing and then inserting the new * backspacing over the changed spacing and then inserting the new
@@ -10394,13 +10328,10 @@ ins_tab(void)
ins_bytes_len(saved_line + change_col, ins_bytes_len(saved_line + change_col,
cursor->col - change_col); cursor->col - change_col);
} }
#endif
} }
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
vim_free(saved_line); vim_free(saved_line);
#endif
curwin->w_p_list = save_list; curwin->w_p_list = save_list;
} }
@@ -10427,11 +10358,7 @@ ins_eol(int c)
* character under the cursor. Only push a NUL on the replace stack, * character under the cursor. Only push a NUL on the replace stack,
* nothing to put back when the NL is deleted. * nothing to put back when the NL is deleted.
*/ */
if ((State & REPLACE_FLAG) if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))
#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG)
#endif
)
replace_push(NUL); replace_push(NUL);
/* /*
@@ -10700,11 +10627,9 @@ ins_try_si(int c)
curwin->w_cursor = *pos; curwin->w_cursor = *pos;
i = get_indent(); i = get_indent();
curwin->w_cursor = old_pos; curwin->w_cursor = old_pos;
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, i, FALSE, NUL, TRUE); change_indent(INDENT_SET, i, FALSE, NUL, TRUE);
else else
#endif
(void)set_indent(i, SIN_CHANGED); (void)set_indent(i, SIN_CHANGED);
} }
else if (curwin->w_cursor.col > 0) else if (curwin->w_cursor.col > 0)

View File

@@ -6450,9 +6450,7 @@ f_has(typval_T *argvars, typval_T *rettv)
#ifdef FEAT_VISUALEXTRA #ifdef FEAT_VISUALEXTRA
"visualextra", "visualextra",
#endif #endif
#ifdef FEAT_VREPLACE
"vreplace", "vreplace",
#endif
#ifdef FEAT_VTP #ifdef FEAT_VTP
"vtp", "vtp",
#endif #endif
@@ -8400,14 +8398,12 @@ f_mode(typval_T *argvars, typval_T *rettv)
buf[0] = '!'; buf[0] = '!';
else if (State & INSERT) else if (State & INSERT)
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
buf[0] = 'R'; buf[0] = 'R';
buf[1] = 'v'; buf[1] = 'v';
} }
else else
#endif
{ {
if (State & REPLACE_FLAG) if (State & REPLACE_FLAG)
buf[0] = 'R'; buf[0] = 'R';

View File

@@ -206,13 +206,6 @@
# define FEAT_VIRTUALEDIT # define FEAT_VIRTUALEDIT
#endif #endif
/*
* +vreplace "gR" and "gr" commands.
*/
#ifdef FEAT_NORMAL
# define FEAT_VREPLACE
#endif
/* /*
* +cmdline_info 'showcmd' and 'ruler' options. * +cmdline_info 'showcmd' and 'ruler' options.
*/ */

View File

@@ -778,13 +778,11 @@ EXTERN pos_T Insstart; /* This is where the latest
* op_insert(), to detect correctly where inserting by the user started. */ * op_insert(), to detect correctly where inserting by the user started. */
EXTERN pos_T Insstart_orig; EXTERN pos_T Insstart_orig;
#ifdef FEAT_VREPLACE
/* /*
* Stuff for VREPLACE mode. * Stuff for VREPLACE mode.
*/ */
EXTERN int orig_line_count INIT(= 0); /* Line count when "gR" started */ EXTERN int orig_line_count INIT(= 0); /* Line count when "gR" started */
EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */ EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */
#endif
#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
/* argument to SETJMP() for handling X IO errors */ /* argument to SETJMP() for handling X IO errors */

View File

@@ -3181,10 +3181,8 @@ button_set:
case SELECTMODE: checkfor = MOUSE_VISUAL; break; case SELECTMODE: checkfor = MOUSE_VISUAL; break;
case REPLACE: case REPLACE:
case REPLACE+LANGMAP: case REPLACE+LANGMAP:
# ifdef FEAT_VREPLACE
case VREPLACE: case VREPLACE:
case VREPLACE+LANGMAP: case VREPLACE+LANGMAP:
# endif
case INSERT: case INSERT:
case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break; case INSERT+LANGMAP: checkfor = MOUSE_INSERT; break;
case ASKMORE: case ASKMORE:

View File

@@ -235,11 +235,7 @@
# define TIME_MSG(s) do { /**/ } while (0) # define TIME_MSG(s) do { /**/ } while (0)
#endif #endif
#ifdef FEAT_VREPLACE #define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
# define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
#else
# define REPLACE_NORMAL(s) ((s) & REPLACE_FLAG)
#endif
#ifdef FEAT_ARABIC #ifdef FEAT_ARABIC
# define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2)) # define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))

View File

@@ -784,10 +784,7 @@ open_line(
char_u *leader = NULL; /* copy of comment leader */ char_u *leader = NULL; /* copy of comment leader */
#endif #endif
char_u *allocated = NULL; /* allocated memory */ char_u *allocated = NULL; /* allocated memory */
#if defined(FEAT_SMARTINDENT) || defined(FEAT_VREPLACE) || defined(FEAT_LISP) \
|| defined(FEAT_CINDENT) || defined(FEAT_COMMENTS)
char_u *p; char_u *p;
#endif
int saved_char = NUL; /* init for GCC */ int saved_char = NUL; /* init for GCC */
#if defined(FEAT_SMARTINDENT) || defined(FEAT_COMMENTS) #if defined(FEAT_SMARTINDENT) || defined(FEAT_COMMENTS)
pos_T *pos; pos_T *pos;
@@ -804,7 +801,7 @@ open_line(
int no_si = FALSE; /* reset did_si afterwards */ int no_si = FALSE; /* reset did_si afterwards */
int first_char = NUL; /* init for GCC */ int first_char = NUL; /* init for GCC */
#endif #endif
#if defined(FEAT_VREPLACE) && (defined(FEAT_LISP) || defined(FEAT_CINDENT)) #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
int vreplace_mode; int vreplace_mode;
#endif #endif
int did_append; /* appended a new line */ int did_append; /* appended a new line */
@@ -817,7 +814,6 @@ open_line(
if (saved_line == NULL) /* out of memory! */ if (saved_line == NULL) /* out of memory! */
return FALSE; return FALSE;
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
/* /*
@@ -857,13 +853,8 @@ open_line(
} }
saved_line[curwin->w_cursor.col] = NUL; saved_line[curwin->w_cursor.col] = NUL;
} }
#endif
if ((State & INSERT) if ((State & INSERT) && !(State & VREPLACE_FLAG))
#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG)
#endif
)
{ {
p_extra = saved_line + curwin->w_cursor.col; p_extra = saved_line + curwin->w_cursor.col;
#ifdef FEAT_SMARTINDENT #ifdef FEAT_SMARTINDENT
@@ -1601,9 +1592,7 @@ open_line(
old_cursor = curwin->w_cursor; old_cursor = curwin->w_cursor;
if (dir == BACKWARD) if (dir == BACKWARD)
--curwin->w_cursor.lnum; --curwin->w_cursor.lnum;
#ifdef FEAT_VREPLACE
if (!(State & VREPLACE_FLAG) || old_cursor.lnum >= orig_line_count) if (!(State & VREPLACE_FLAG) || old_cursor.lnum >= orig_line_count)
#endif
{ {
if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE) if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE)
== FAIL) == FAIL)
@@ -1620,7 +1609,6 @@ open_line(
mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
did_append = TRUE; did_append = TRUE;
} }
#ifdef FEAT_VREPLACE
else else
{ {
/* /*
@@ -1640,7 +1628,6 @@ open_line(
curwin->w_cursor.lnum--; curwin->w_cursor.lnum--;
did_append = FALSE; did_append = FALSE;
} }
#endif
if (newindent if (newindent
#ifdef FEAT_SMARTINDENT #ifdef FEAT_SMARTINDENT
@@ -1744,7 +1731,7 @@ open_line(
curwin->w_cursor.coladd = 0; curwin->w_cursor.coladd = 0;
#endif #endif
#if defined(FEAT_VREPLACE) && (defined(FEAT_LISP) || defined(FEAT_CINDENT)) #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
/* /*
* In VREPLACE mode, we are handling the replace stack ourselves, so stop * 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 * fixthisline() from doing it (via change_indent()) by telling it we're in
@@ -1791,12 +1778,11 @@ open_line(
ai_col = (colnr_T)getwhitecols_curline(); ai_col = (colnr_T)getwhitecols_curline();
} }
#endif #endif
#if defined(FEAT_VREPLACE) && (defined(FEAT_LISP) || defined(FEAT_CINDENT)) #if defined(FEAT_LISP) || defined(FEAT_CINDENT)
if (vreplace_mode != 0) if (vreplace_mode != 0)
State = vreplace_mode; State = vreplace_mode;
#endif #endif
#ifdef FEAT_VREPLACE
/* /*
* Finally, VREPLACE gets the stuff on the new line, then puts back the * 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 * original line, and inserts the new stuff char by char, pushing old stuff
@@ -1821,7 +1807,6 @@ open_line(
vim_free(p_extra); vim_free(p_extra);
next_line = NULL; next_line = NULL;
} }
#endif
retval = OK; /* success! */ retval = OK; /* success! */
theend: theend:
@@ -2307,7 +2292,6 @@ plines_m_win(win_T *wp, linenr_T first, linenr_T last)
return (count); return (count);
} }
#if defined(FEAT_VREPLACE) || defined(FEAT_INS_EXPAND) || defined(PROTO)
/* /*
* 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.
@@ -2317,10 +2301,7 @@ ins_bytes(char_u *p)
{ {
ins_bytes_len(p, (int)STRLEN(p)); ins_bytes_len(p, (int)STRLEN(p));
} }
#endif
#if defined(FEAT_VREPLACE) || defined(FEAT_INS_EXPAND) \
|| defined(FEAT_COMMENTS) || defined(FEAT_MBYTE) || defined(PROTO)
/* /*
* 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.
@@ -2329,7 +2310,7 @@ ins_bytes(char_u *p)
ins_bytes_len(char_u *p, int len) ins_bytes_len(char_u *p, int len)
{ {
int i; int i;
# ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
int n; int n;
if (has_mbyte) if (has_mbyte)
@@ -2343,11 +2324,10 @@ ins_bytes_len(char_u *p, int len)
ins_char_bytes(p + i, n); ins_char_bytes(p + i, n);
} }
else else
# endif #endif
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
ins_char(p[i]); ins_char(p[i]);
} }
#endif
/* /*
* Insert or replace a single character at the cursor position. * Insert or replace a single character at the cursor position.
@@ -2406,7 +2386,6 @@ ins_char_bytes(char_u *buf, int charlen)
if (State & REPLACE_FLAG) if (State & REPLACE_FLAG)
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
{ {
colnr_T new_vcol = 0; /* init for GCC */ colnr_T new_vcol = 0; /* init for GCC */
@@ -2456,7 +2435,6 @@ ins_char_bytes(char_u *buf, int charlen)
curwin->w_p_list = old_list; curwin->w_p_list = old_list;
} }
else else
#endif
if (oldp[col] != NUL) if (oldp[col] != NUL)
{ {
/* normal replace */ /* normal replace */

View File

@@ -3766,10 +3766,8 @@ get_shape_idx(int mouse)
#endif #endif
if (!mouse && State == SHOWMATCH) if (!mouse && State == SHOWMATCH)
return SHAPE_IDX_SM; return SHAPE_IDX_SM;
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
return SHAPE_IDX_R; return SHAPE_IDX_R;
#endif
if (State & REPLACE_FLAG) if (State & REPLACE_FLAG)
return SHAPE_IDX_R; return SHAPE_IDX_R;
if (State & INSERT) if (State & INSERT)

View File

@@ -111,9 +111,7 @@ static void nv_findpar(cmdarg_T *cap);
static void nv_undo(cmdarg_T *cap); static void nv_undo(cmdarg_T *cap);
static void nv_kundo(cmdarg_T *cap); static void nv_kundo(cmdarg_T *cap);
static void nv_Replace(cmdarg_T *cap); static void nv_Replace(cmdarg_T *cap);
#ifdef FEAT_VREPLACE
static void nv_vreplace(cmdarg_T *cap); static void nv_vreplace(cmdarg_T *cap);
#endif
static void v_swap_corners(int cmdchar); static void v_swap_corners(int cmdchar);
static void nv_replace(cmdarg_T *cap); static void nv_replace(cmdarg_T *cap);
static void n_swapchar(cmdarg_T *cap); static void n_swapchar(cmdarg_T *cap);
@@ -7300,7 +7298,6 @@ nv_Replace(cmdarg_T *cap)
} }
} }
#ifdef FEAT_VREPLACE
/* /*
* "gr". * "gr".
*/ */
@@ -7323,15 +7320,14 @@ nv_vreplace(cmdarg_T *cap)
cap->extra_char = get_literal(); cap->extra_char = get_literal();
stuffcharReadbuff(cap->extra_char); stuffcharReadbuff(cap->extra_char);
stuffcharReadbuff(ESC); stuffcharReadbuff(ESC);
# ifdef FEAT_VIRTUALEDIT #ifdef FEAT_VIRTUALEDIT
if (virtual_active()) if (virtual_active())
coladvance(getviscol()); coladvance(getviscol());
# endif #endif
invoke_edit(cap, TRUE, 'v', FALSE); invoke_edit(cap, TRUE, 'v', FALSE);
} }
} }
} }
#endif
/* /*
* Swap case for "~" command, when it does not work like an operator. * Swap case for "~" command, when it does not work like an operator.
@@ -7944,7 +7940,6 @@ nv_g_cmd(cmdarg_T *cap)
clearopbeep(oap); clearopbeep(oap);
break; break;
#ifdef FEAT_VREPLACE
/* /*
* "gR": Enter virtual replace mode. * "gR": Enter virtual replace mode.
*/ */
@@ -7956,7 +7951,6 @@ nv_g_cmd(cmdarg_T *cap)
case 'r': case 'r':
nv_vreplace(cap); nv_vreplace(cap);
break; break;
#endif
case '&': case '&':
do_cmdline_cmd((char_u *)"%s//~/&"); do_cmdline_cmd((char_u *)"%s//~/&");

View File

@@ -376,11 +376,9 @@ shift_line(
} }
/* Set new indent */ /* Set new indent */
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes); change_indent(INDENT_SET, count, FALSE, NUL, call_changed_bytes);
else else
#endif
(void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0); (void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0);
} }

View File

@@ -10375,12 +10375,9 @@ showmode(void)
else else
#endif #endif
{ {
#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG) if (State & VREPLACE_FLAG)
MSG_PUTS_ATTR(_(" VREPLACE"), attr); MSG_PUTS_ATTR(_(" VREPLACE"), attr);
else else if (State & REPLACE_FLAG)
#endif
if (State & REPLACE_FLAG)
MSG_PUTS_ATTR(_(" REPLACE"), attr); MSG_PUTS_ATTR(_(" REPLACE"), attr);
else if (State & INSERT) else if (State & INSERT)
{ {

View File

@@ -714,11 +714,7 @@ static char *(features[]) =
#else #else
"-viminfo", "-viminfo",
#endif #endif
#ifdef FEAT_VREPLACE
"+vreplace", "+vreplace",
#else
"-vreplace",
#endif
#ifdef WIN3264 #ifdef WIN3264
# ifdef FEAT_VTP # ifdef FEAT_VTP
"+vtp", "+vtp",
@@ -798,6 +794,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
226,
/**/ /**/
225, 225,
/**/ /**/

View File

@@ -675,10 +675,8 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
#define REPLACE_FLAG 0x40 /* Replace mode flag */ #define REPLACE_FLAG 0x40 /* Replace mode flag */
#define REPLACE (REPLACE_FLAG + INSERT) #define REPLACE (REPLACE_FLAG + INSERT)
#ifdef FEAT_VREPLACE #define VREPLACE_FLAG 0x80 /* Virtual-replace mode flag */
# define VREPLACE_FLAG 0x80 /* Virtual-replace mode flag */ #define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
# define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
#endif
#define LREPLACE (REPLACE_FLAG + LANGMAP) #define LREPLACE (REPLACE_FLAG + LANGMAP)
#define NORMAL_BUSY (0x100 + NORMAL) /* Normal mode, busy with a command */ #define NORMAL_BUSY (0x100 + NORMAL) /* Normal mode, busy with a command */