{
ResetRedobuff();
AppendNumberToRedobuff(count);
-#ifdef FEAT_VREPLACE
if (cmdchar == 'V' || cmdchar == 'v')
{
/* "gR" or "gr" command */
AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R');
}
else
-#endif
{
if (cmdchar == K_PS)
AppendCharToRedobuff('a');
#endif
State = REPLACE;
}
-#ifdef FEAT_VREPLACE
else if (cmdchar == 'V' || cmdchar == 'v')
{
State = VREPLACE;
orig_line_count = curbuf->b_ml.ml_line_count;
vr_lines_changed = 1;
}
-#endif
else
State = INSERT;
int save_p_list;
int start_col;
colnr_T vc;
-#ifdef FEAT_VREPLACE
colnr_T orig_col = 0; /* init for GCC */
char_u *new_line, *orig_line = NULL; /* init for GCC */
orig_line = vim_strsave(ml_get_curline()); /* Deal with NULL below */
orig_col = curwin->w_cursor.col;
}
-#endif
/* for the following tricks we don't want list mode */
save_p_list = curwin->w_p_list;
(void)set_indent(amount, call_changed_bytes ? SIN_CHANGED : 0);
else
{
-#ifdef FEAT_VREPLACE
int save_State = State;
/* Avoid being called recursively. */
if (State & VREPLACE_FLAG)
State = INSERT;
-#endif
shift_line(type == INDENT_DEC, round, 1, call_changed_bytes);
-#ifdef FEAT_VREPLACE
State = save_State;
-#endif
}
insstart_less -= curwin->w_cursor.col;
}
}
-#ifdef FEAT_VREPLACE
/*
* 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
vim_free(new_line);
}
-#endif
}
/*
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
* modes correctly. May also be used when not in insert mode at all.
break;
}
}
-#endif
/*
* Like del_char(), but make sure not to go before column "limit_col".
&& (force_format
|| (!VIM_ISWHITE(c)
&& !((State & REPLACE_FLAG)
-#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG)
-#endif
&& *ml_get_cursor() != NUL)
&& (curwin->w_cursor.lnum != Insstart.lnum
|| ((!has_format_option(FO_INS_LONG)
* When 'ai' is off we don't want a space under the cursor to be
* deleted. Replace it with an 'x' temporarily.
*/
- if (!curbuf->b_p_ai
-#ifdef FEAT_VREPLACE
- && !(State & VREPLACE_FLAG)
-#endif
- )
+ if (!curbuf->b_p_ai && !(State & VREPLACE_FLAG))
{
cc = gchar_cursor();
if (VIM_ISWHITE(cc))
int end_foundcol = 0; /* column for start of word */
colnr_T len;
colnr_T virtcol;
-#ifdef FEAT_VREPLACE
int orig_col = 0;
char_u *saved_text = NULL;
-#endif
colnr_T col;
colnr_T end_col;
* stack functions. VREPLACE does not use this, and backspaces
* over the text instead.
*/
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
orig_col = startcol; /* Will start backspacing from here */
else
-#endif
replace_offset = startcol - end_foundcol;
/*
if (startcol < 0)
startcol = 0;
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
/*
backspace_until_column(foundcol);
}
else
-#endif
{
/* put cursor after pos. to break line */
if (!fo_white_par)
get_number_indent(curwin->w_cursor.lnum - 1);
if (second_indent >= 0)
{
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, second_indent,
FALSE, NUL, TRUE);
else
-#endif
#ifdef FEAT_COMMENTS
if (leader_len > 0 && second_indent - leader_len > 0)
{
first_line = FALSE;
}
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
/*
vim_free(saved_text);
}
else
-#endif
{
/*
* Check if cursor is not past the NUL off the line, cindent
}
ai_col = 0;
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
orig_line_count = curbuf->b_ml.ml_line_count;
vr_lines_changed = 1;
}
-#endif
ResetRedobuff();
AppendToRedobuff((char_u *)"1i"); /* pretend we start an insertion */
new_insert_skip = 2;
replace_do_bs(int limit_col)
{
int cc;
-#ifdef FEAT_VREPLACE
int orig_len = 0;
int ins_len;
int orig_vcols = 0;
char_u *p;
int i;
int vcol;
-#endif
cc = replace_pop();
if (cc > 0)
{
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
/* Get the number of screen cells used by the character we are
getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL);
orig_vcols = chartabsize(ml_get_cursor(), start_vcol);
}
-#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
{
(void)del_char_after_col(limit_col);
-# ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
orig_len = (int)STRLEN(ml_get_cursor());
-# endif
replace_push(cc);
}
else
#endif
{
pchar_cursor(cc);
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
orig_len = (int)STRLEN(ml_get_cursor()) - 1;
-#endif
}
replace_pop_ins();
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
/* Get the number of screen cells used by the inserted characters */
}
curwin->w_cursor.col -= ins_len;
}
-#endif
/* mark the buffer as changed and prepare for displaying */
changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
# ifdef FEAT_EVAL
set_vim_var_string(VV_INSERTMODE,
- (char_u *)((State & REPLACE_FLAG) ? "i" :
-# ifdef FEAT_VREPLACE
- replaceState == VREPLACE ? "v" :
-# endif
- "r"), 1);
+ (char_u *)((State & REPLACE_FLAG) ? "i"
+ : replaceState == VREPLACE ? "v"
+ : "r"), 1);
# endif
apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf);
if (State & REPLACE_FLAG)
static void
ins_ctrl_o(void)
{
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
restart_edit = 'V';
else
-#endif
if (State & REPLACE_FLAG)
restart_edit = 'R';
else
else
{
curwin->w_cursor.col = temp;
-#ifdef FEAT_VREPLACE
/* Adjust orig_line_count in case more lines have been deleted than
* have been added. That makes sure, that open_line() later
* can access all buffer lines correctly */
if (State & VREPLACE_FLAG &&
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
{
-#ifdef FEAT_VREPLACE
if (!(State & VREPLACE_FLAG)
|| curwin->w_cursor.lnum > orig_line_count)
-#endif
{
temp = gchar_cursor(); /* remember current char */
--curwin->w_cursor.lnum;
if (temp == NUL && gchar_cursor() != NUL)
inc_cursor();
}
-#ifdef FEAT_VREPLACE
else
dec_cursor();
-#endif
/*
* In REPLACE mode we have to put back the text that was replaced
&& curwin->w_cursor.col < Insstart_orig.col)
Insstart_orig.col = curwin->w_cursor.col;
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
ins_char(' ');
else
-#endif
{
ins_str((char_u *)" ");
if ((State & REPLACE_FLAG))
ins_char(' ');
while (--temp > 0)
{
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
ins_char(' ');
else
-#endif
{
ins_str((char_u *)" ");
if (State & REPLACE_FLAG) /* no char replaced */
#endif
{
char_u *ptr;
-#ifdef FEAT_VREPLACE
char_u *saved_line = NULL; /* init for GCC */
pos_T pos;
-#endif
pos_T fpos;
pos_T *cursor;
colnr_T want_vcol, vcol;
* Get the current line. For VREPLACE mode, don't make real changes
* yet, just work on a copy of the line.
*/
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
pos = curwin->w_cursor;
ptr = saved_line + pos.col;
}
else
-#endif
{
ptr = ml_get_cursor();
cursor = &curwin->w_cursor;
{
STRMOVE(ptr, ptr + i);
/* correct replace stack. */
- if ((State & REPLACE_FLAG)
-#ifdef FEAT_VREPLACE
- && !(State & VREPLACE_FLAG)
-#endif
- )
+ if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))
for (temp = i; --temp >= 0; )
replace_join(repl_off);
}
#endif
cursor->col -= i;
-#ifdef FEAT_VREPLACE
/*
* In VREPLACE mode, we haven't changed anything yet. Do it now by
* backspacing over the changed spacing and then inserting the new
ins_bytes_len(saved_line + change_col,
cursor->col - change_col);
}
-#endif
}
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
vim_free(saved_line);
-#endif
curwin->w_p_list = save_list;
}
* character under the cursor. Only push a NUL on the replace stack,
* nothing to put back when the NL is deleted.
*/
- if ((State & REPLACE_FLAG)
-#ifdef FEAT_VREPLACE
- && !(State & VREPLACE_FLAG)
-#endif
- )
+ if ((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG))
replace_push(NUL);
/*
curwin->w_cursor = *pos;
i = get_indent();
curwin->w_cursor = old_pos;
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, i, FALSE, NUL, TRUE);
else
-#endif
(void)set_indent(i, SIN_CHANGED);
}
else if (curwin->w_cursor.col > 0)
char_u *leader = NULL; /* copy of comment leader */
#endif
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;
-#endif
int saved_char = NUL; /* init for GCC */
#if defined(FEAT_SMARTINDENT) || defined(FEAT_COMMENTS)
pos_T *pos;
int no_si = FALSE; /* reset did_si afterwards */
int first_char = NUL; /* init for GCC */
#endif
-#if defined(FEAT_VREPLACE) && (defined(FEAT_LISP) || defined(FEAT_CINDENT))
+#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
int vreplace_mode;
#endif
int did_append; /* appended a new line */
if (saved_line == NULL) /* out of memory! */
return FALSE;
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
/*
}
saved_line[curwin->w_cursor.col] = NUL;
}
-#endif
- if ((State & INSERT)
-#ifdef FEAT_VREPLACE
- && !(State & VREPLACE_FLAG)
-#endif
- )
+ if ((State & INSERT) && !(State & VREPLACE_FLAG))
{
p_extra = saved_line + curwin->w_cursor.col;
#ifdef FEAT_SMARTINDENT
old_cursor = curwin->w_cursor;
if (dir == BACKWARD)
--curwin->w_cursor.lnum;
-#ifdef FEAT_VREPLACE
if (!(State & VREPLACE_FLAG) || old_cursor.lnum >= orig_line_count)
-#endif
{
if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE)
== FAIL)
mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
did_append = TRUE;
}
-#ifdef FEAT_VREPLACE
else
{
/*
curwin->w_cursor.lnum--;
did_append = FALSE;
}
-#endif
if (newindent
#ifdef FEAT_SMARTINDENT
curwin->w_cursor.coladd = 0;
#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
* fixthisline() from doing it (via change_indent()) by telling it we're in
ai_col = (colnr_T)getwhitecols_curline();
}
#endif
-#if defined(FEAT_VREPLACE) && (defined(FEAT_LISP) || defined(FEAT_CINDENT))
+#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
if (vreplace_mode != 0)
State = vreplace_mode;
#endif
-#ifdef FEAT_VREPLACE
/*
* 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
vim_free(p_extra);
next_line = NULL;
}
-#endif
retval = OK; /* success! */
theend:
return (count);
}
-#if defined(FEAT_VREPLACE) || defined(FEAT_INS_EXPAND) || defined(PROTO)
/*
* Insert string "p" at the cursor position. Stops at a NUL byte.
* Handles Replace mode and multi-byte characters.
{
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.
* Handles Replace mode and multi-byte characters.
ins_bytes_len(char_u *p, int len)
{
int i;
-# ifdef FEAT_MBYTE
+#ifdef FEAT_MBYTE
int n;
if (has_mbyte)
ins_char_bytes(p + i, n);
}
else
-# endif
+#endif
for (i = 0; i < len; ++i)
ins_char(p[i]);
}
-#endif
/*
* Insert or replace a single character at the cursor position.
if (State & REPLACE_FLAG)
{
-#ifdef FEAT_VREPLACE
if (State & VREPLACE_FLAG)
{
colnr_T new_vcol = 0; /* init for GCC */
curwin->w_p_list = old_list;
}
else
-#endif
if (oldp[col] != NUL)
{
/* normal replace */