patch 8.1.0826: too many #ifdefs

Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_VIRTUALEDIT.  Adds about 10Kbyte to the code.
This commit is contained in:
Bram Moolenaar
2019-01-26 17:28:26 +01:00
parent 3e460fd8b7
commit 29ddebef40
35 changed files with 65 additions and 493 deletions
+1 -9
View File
@@ -1729,9 +1729,7 @@ enter_buffer(buf_T *buf)
/* Cursor on first line by default. */
curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
curwin->w_topline_was_set = FALSE;
@@ -2333,9 +2331,7 @@ buflist_getfile(
{
curwin->w_cursor.col = col;
check_cursor_col();
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
}
return OK;
@@ -2363,9 +2359,7 @@ buflist_getfpos(void)
{
curwin->w_cursor.col = fpos->col;
check_cursor_col();
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
}
}
@@ -2958,7 +2952,7 @@ get_winopts(buf_T *buf)
buflist_findfpos(buf_T *buf)
{
wininfo_T *wip;
static pos_T no_position = INIT_POS_T(1, 0, 0);
static pos_T no_position = {1, 0, 0};
wip = find_wininfo(buf, FALSE);
if (wip != NULL)
@@ -3955,9 +3949,7 @@ build_stl_str_hl(
// Line may have changed since checking the cursor column, or the lnum
// was adjusted above.
wp->w_cursor.col = (colnr_T)len;
#ifdef FEAT_VIRTUALEDIT
wp->w_cursor.coladd = 0;
#endif
byteval = 0;
}
else
-4
View File
@@ -1365,17 +1365,14 @@ getvcol_nolist(pos_T *posp)
colnr_T vcol;
curwin->w_p_list = FALSE;
#ifdef FEAT_VIRTUALEDIT
if (posp->coladd)
getvvcol(curwin, posp, NULL, &vcol, NULL);
else
#endif
getvcol(curwin, posp, NULL, &vcol, NULL);
curwin->w_p_list = list_save;
return vcol;
}
#if defined(FEAT_VIRTUALEDIT) || defined(PROTO)
/*
* Get virtual column in virtual mode.
*/
@@ -1425,7 +1422,6 @@ getvvcol(
else
getvcol(wp, pos, start, cursor, end);
}
#endif
/*
* Get the leftmost and rightmost virtual column of pos1 and pos2.
+10 -45
View File
@@ -1072,14 +1072,12 @@ doESCkey:
break;
ins_ctrl_o();
#ifdef FEAT_VIRTUALEDIT
/* don't move the cursor left when 'virtualedit' has "onemore". */
if (ve_flags & VE_ONEMORE)
{
ins_at_eol = FALSE;
nomove = TRUE;
}
#endif
count = 0;
goto doESCkey;
@@ -7125,14 +7123,12 @@ stop_insert(
{
if (gchar_cursor() != NUL)
inc_cursor();
#ifdef FEAT_VIRTUALEDIT
/* If the cursor is still at the same character, also keep
* the "coladd". */
// If the cursor is still at the same character, also keep
// the "coladd".
if (gchar_cursor() == NUL
&& curwin->w_cursor.lnum == tpos.lnum
&& curwin->w_cursor.col == tpos.col)
curwin->w_cursor.coladd = tpos.coladd;
#endif
}
}
@@ -7182,9 +7178,7 @@ stop_insert(
if (VIsual.col > len)
{
VIsual.col = len;
#ifdef FEAT_VIRTUALEDIT
VIsual.coladd = 0;
#endif
}
}
}
@@ -7293,9 +7287,7 @@ beginline(int flags)
else
{
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
if (flags & (BL_WHITE | BL_SOL))
{
@@ -7323,7 +7315,6 @@ oneright(void)
char_u *ptr;
int l;
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
{
pos_T prevpos = curwin->w_cursor;
@@ -7338,7 +7329,6 @@ oneright(void)
return (prevpos.col != curwin->w_cursor.col
|| prevpos.coladd != curwin->w_cursor.coladd) ? OK : FAIL;
}
#endif
ptr = ml_get_cursor();
if (*ptr == NUL)
@@ -7351,11 +7341,7 @@ oneright(void)
/* move "l" bytes right, but don't end up on the NUL, unless 'virtualedit'
* contains "onemore". */
if (ptr[l] == NUL
#ifdef FEAT_VIRTUALEDIT
&& (ve_flags & VE_ONEMORE) == 0
#endif
)
if (ptr[l] == NUL && (ve_flags & VE_ONEMORE) == 0)
return FAIL;
curwin->w_cursor.col += l;
@@ -7366,18 +7352,17 @@ oneright(void)
int
oneleft(void)
{
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
{
# ifdef FEAT_LINEBREAK
#ifdef FEAT_LINEBREAK
int width;
# endif
#endif
int v = getviscol();
if (v == 0)
return FAIL;
# ifdef FEAT_LINEBREAK
#ifdef FEAT_LINEBREAK
/* We might get stuck on 'showbreak', skip over it. */
width = 1;
for (;;)
@@ -7391,9 +7376,9 @@ oneleft(void)
break;
++width;
}
# else
#else
coladvance(v - 1);
# endif
#endif
if (curwin->w_cursor.coladd == 1)
{
@@ -7409,7 +7394,6 @@ oneleft(void)
curwin->w_set_curswant = TRUE;
return OK;
}
#endif
if (curwin->w_cursor.col == 0)
return FAIL;
@@ -8665,10 +8649,7 @@ ins_esc(
*/
if (!nomove
&& (curwin->w_cursor.col != 0
#ifdef FEAT_VIRTUALEDIT
|| curwin->w_cursor.coladd > 0
#endif
)
|| curwin->w_cursor.coladd > 0)
&& (restart_edit == NUL
|| (gchar_cursor() == NUL && !VIsual_active))
#ifdef FEAT_RIGHTLEFT
@@ -8676,7 +8657,6 @@ ins_esc(
#endif
)
{
#ifdef FEAT_VIRTUALEDIT
if (curwin->w_cursor.coladd > 0 || ve_flags == VE_ALL)
{
oneleft();
@@ -8684,7 +8664,6 @@ ins_esc(
++curwin->w_cursor.coladd;
}
else
#endif
{
--curwin->w_cursor.col;
/* Correct cursor for multi-byte character. */
@@ -8874,11 +8853,9 @@ ins_ctrl_o(void)
restart_edit = 'R';
else
restart_edit = 'I';
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
ins_at_eol = FALSE; /* cursor always keeps its column */
else
#endif
ins_at_eol = (gchar_cursor() == NUL);
}
@@ -9040,7 +9017,6 @@ ins_bs(
inc_cursor();
#endif
#ifdef FEAT_VIRTUALEDIT
/* Virtualedit:
* BACKSPACE_CHAR eats a virtual space
* BACKSPACE_WORD eats all coladd
@@ -9060,7 +9036,6 @@ ins_bs(
}
curwin->w_cursor.coladd = 0;
}
#endif
/*
* Delete newline!
@@ -9744,9 +9719,7 @@ ins_home(int c)
if (c == K_C_HOME)
curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_curswant = 0;
start_arrow(&tpos);
}
@@ -9797,21 +9770,15 @@ ins_right(
foldOpenCursor();
#endif
undisplay_dollar();
if (gchar_cursor() != NUL
#ifdef FEAT_VIRTUALEDIT
|| virtual_active()
#endif
)
if (gchar_cursor() != NUL || virtual_active())
{
start_arrow_with_change(&curwin->w_cursor, end_change);
if (!end_change)
AppendCharToRedobuff(K_RIGHT);
curwin->w_set_curswant = TRUE;
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
oneright();
else
#endif
{
if (has_mbyte)
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
@@ -10268,12 +10235,10 @@ ins_eol(int c)
* in open_line().
*/
#ifdef FEAT_VIRTUALEDIT
/* Put cursor on NUL if on the last char and coladd is 1 (happens after
* CTRL-O). */
if (virtual_active() && curwin->w_cursor.coladd > 0)
coladvance(getviscol());
#endif
#ifdef FEAT_RIGHTLEFT
# ifdef FEAT_FKMAP
-6
View File
@@ -6207,12 +6207,10 @@ var2fpos(
return NULL; /* invalid column number */
--pos.col;
#ifdef FEAT_VIRTUALEDIT
/* Get the virtual offset. Defaults to zero. */
pos.coladd = list_find_nr(l, 2L, &error);
if (error)
pos.coladd = 0;
#endif
return &pos;
}
@@ -6236,9 +6234,7 @@ var2fpos(
return pp;
}
#ifdef FEAT_VIRTUALEDIT
pos.coladd = 0;
#endif
if (name[0] == 'w' && dollar_lnum)
{
@@ -6323,13 +6319,11 @@ list2fpos(
return FAIL;
posp->col = n;
#ifdef FEAT_VIRTUALEDIT
n = list_find_nr(l, i, NULL); /* off */
if (n < 0)
posp->coladd = 0;
else
posp->coladd = n;
#endif
if (curswantp != NULL)
*curswantp = list_find_nr(l, i + 1, NULL); /* curswant */
+2 -29
View File
@@ -2517,7 +2517,6 @@ f_col(typval_T *argvars, typval_T *rettv)
else
{
col = fp->col + 1;
#ifdef FEAT_VIRTUALEDIT
/* col(".") when the cursor is on the NUL at the end of the line
* because of "coladd" can be seen as an extra column. */
if (virtual_active() && fp == &curwin->w_cursor)
@@ -2533,7 +2532,6 @@ f_col(typval_T *argvars, typval_T *rettv)
col += l;
}
}
#endif
}
}
rettv->vval.v_number = col;
@@ -2838,9 +2836,7 @@ f_cscope_connection(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
f_cursor(typval_T *argvars, typval_T *rettv)
{
long line, col;
#ifdef FEAT_VIRTUALEDIT
long coladd = 0;
#endif
int set_curswant = TRUE;
rettv->vval.v_number = -1;
@@ -2856,9 +2852,7 @@ f_cursor(typval_T *argvars, typval_T *rettv)
}
line = pos.lnum;
col = pos.col;
#ifdef FEAT_VIRTUALEDIT
coladd = pos.coladd;
#endif
if (curswant >= 0)
{
curwin->w_curswant = curswant - 1;
@@ -2869,24 +2863,16 @@ f_cursor(typval_T *argvars, typval_T *rettv)
{
line = tv_get_lnum(argvars);
col = (long)tv_get_number_chk(&argvars[1], NULL);
#ifdef FEAT_VIRTUALEDIT
if (argvars[2].v_type != VAR_UNKNOWN)
coladd = (long)tv_get_number_chk(&argvars[2], NULL);
#endif
}
if (line < 0 || col < 0
#ifdef FEAT_VIRTUALEDIT
|| coladd < 0
#endif
)
if (line < 0 || col < 0 || coladd < 0)
return; /* type error; errmsg already given */
if (line > 0)
curwin->w_cursor.lnum = line;
if (col > 0)
curwin->w_cursor.col = col - 1;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = coladd;
#endif
/* Make sure the cursor is in a valid position. */
check_cursor();
@@ -4810,9 +4796,7 @@ f_getchangelist(typval_T *argvars, typval_T *rettv)
return;
dict_add_number(d, "lnum", (long)buf->b_changelist[i].lnum);
dict_add_number(d, "col", (long)buf->b_changelist[i].col);
# ifdef FEAT_VIRTUALEDIT
dict_add_number(d, "coladd", (long)buf->b_changelist[i].coladd);
# endif
}
#endif
}
@@ -5304,9 +5288,7 @@ f_getjumplist(typval_T *argvars, typval_T *rettv)
return;
dict_add_number(d, "lnum", (long)wp->w_jumplist[i].fmark.mark.lnum);
dict_add_number(d, "col", (long)wp->w_jumplist[i].fmark.mark.col);
# ifdef FEAT_VIRTUALEDIT
dict_add_number(d, "coladd", (long)wp->w_jumplist[i].fmark.mark.coladd);
# endif
dict_add_number(d, "bufnr", (long)wp->w_jumplist[i].fmark.fnum);
if (wp->w_jumplist[i].fname != NULL)
dict_add_string(d, "filename", wp->w_jumplist[i].fname);
@@ -5483,10 +5465,7 @@ getpos_both(
list_append_number(l, (fp != NULL)
? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
: (varnumber_T)0);
list_append_number(l,
#ifdef FEAT_VIRTUALEDIT
(fp != NULL) ? (varnumber_T)fp->coladd :
#endif
list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd :
(varnumber_T)0);
if (getcurpos)
{
@@ -6574,9 +6553,7 @@ f_has(typval_T *argvars, typval_T *rettv)
"viminfo",
#endif
"vertsplit",
#ifdef FEAT_VIRTUALEDIT
"virtualedit",
#endif
"visual",
"visualextra",
"vreplace",
@@ -14611,10 +14588,8 @@ f_winrestview(typval_T *argvars, typval_T *rettv UNUSED)
curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, (char_u *)"lnum");
if (dict_find(dict, (char_u *)"col", -1) != NULL)
curwin->w_cursor.col = (colnr_T)dict_get_number(dict, (char_u *)"col");
#ifdef FEAT_VIRTUALEDIT
if (dict_find(dict, (char_u *)"coladd", -1) != NULL)
curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, (char_u *)"coladd");
#endif
if (dict_find(dict, (char_u *)"curswant", -1) != NULL)
{
curwin->w_curswant = (colnr_T)dict_get_number(dict, (char_u *)"curswant");
@@ -14661,9 +14636,7 @@ f_winsaveview(typval_T *argvars UNUSED, typval_T *rettv)
dict_add_number(dict, "lnum", (long)curwin->w_cursor.lnum);
dict_add_number(dict, "col", (long)curwin->w_cursor.col);
#ifdef FEAT_VIRTUALEDIT
dict_add_number(dict, "coladd", (long)curwin->w_cursor.coladd);
#endif
update_curswant();
dict_add_number(dict, "curswant", (long)curwin->w_curswant);
-2
View File
@@ -4332,9 +4332,7 @@ do_ecmd(
/* 'sol' is off: Use last known column. */
curwin->w_cursor.col = solcol;
check_cursor_col();
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
}
else
-6
View File
@@ -4650,9 +4650,7 @@ get_address(
pos.col = MAXCOL;
else
pos.col = 0;
#ifdef FEAT_VIRTUALEDIT
pos.coladd = 0;
#endif
if (searchit(curwin, curbuf, &pos, NULL,
*cmd == '?' ? BACKWARD : FORWARD,
(char_u *)"", 1L, SEARCH_MSG,
@@ -9421,9 +9419,7 @@ ex_operators(exarg_T *eap)
oa.end.lnum = eap->line2;
oa.line_count = eap->line2 - eap->line1 + 1;
oa.motion_type = MLINE;
#ifdef FEAT_VIRTUALEDIT
virtual_op = FALSE;
#endif
if (eap->cmdidx != CMD_yank) /* position cursor for undo */
{
setpcmark();
@@ -9460,9 +9456,7 @@ ex_operators(exarg_T *eap)
op_shift(&oa, FALSE, eap->amount);
break;
}
#ifdef FEAT_VIRTUALEDIT
virtual_op = MAYBE;
#endif
ex_may_print(eap);
}
+1 -3
View File
@@ -199,10 +199,8 @@
/*
* +virtualedit 'virtualedit' option and its implementation
* Now always included.
*/
#ifdef FEAT_NORMAL
# define FEAT_VIRTUALEDIT
#endif
/*
* +cmdline_info 'showcmd' and 'ruler' options.
+2 -4
View File
@@ -771,7 +771,7 @@ EXTERN int can_si_back INIT(= FALSE);
EXTERN pos_T saved_cursor /* w_cursor before formatting text. */
#ifdef DO_INIT
= INIT_POS_T(0, 0, 0)
= {0, 0, 0}
#endif
;
@@ -1066,7 +1066,7 @@ EXTERN char_u *autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
EXTERN int did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
EXTERN pos_T last_cursormoved /* for CursorMoved event */
# ifdef DO_INIT
= INIT_POS_T(0, 0, 0)
= {0, 0, 0}
# endif
;
@@ -1335,11 +1335,9 @@ EXTERN char psepcN INIT(= '/'); /* abnormal path separator character */
EXTERN char pseps[2] INIT(= {'\\' COMMA 0});
#endif
#ifdef FEAT_VIRTUALEDIT
/* Set to TRUE when an operator is being executed with virtual editing, MAYBE
* when no operator is being executed, FALSE otherwise. */
EXTERN int virtual_op INIT(= MAYBE);
#endif
#ifdef FEAT_SYN_HL
/* Display tick, incremented for each call to update_screen() */
-2
View File
@@ -4599,14 +4599,12 @@ gui_update_horiz_scrollbar(int force)
longest_lnum = gui_find_longest_lnum();
max = scroll_line_len(longest_lnum);
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
{
/* May move the cursor even further to the right. */
if (curwin->w_virtcol >= (colnr_T)max)
max = curwin->w_virtcol;
}
#endif
#ifndef SCROLL_PAST_END
max += curwin->w_width - 1;
-2
View File
@@ -4033,9 +4033,7 @@ WindowSetattr(WindowObject *self, char *name, PyObject *valObject)
self->win->w_cursor.lnum = lnum;
self->win->w_cursor.col = col;
self->win->w_set_curswant = TRUE;
#ifdef FEAT_VIRTUALEDIT
self->win->w_cursor.coladd = 0;
#endif
/* When column is out of range silently correct it. */
check_cursor_col_win(self->win);
+4 -13
View File
@@ -21,27 +21,18 @@
/*
* Position comparisons
*/
#ifdef FEAT_VIRTUALEDIT
# define LT_POS(a, b) (((a).lnum != (b).lnum) \
#define LT_POS(a, b) (((a).lnum != (b).lnum) \
? (a).lnum < (b).lnum \
: (a).col != (b).col \
? (a).col < (b).col \
: (a).coladd < (b).coladd)
# define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
#define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
? (a)->lnum < (b)->lnum \
: (a)->col != (b)->col \
? (a)->col < (b)->col \
: (a)->coladd < (b)->coladd)
# define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd))
# define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;}
#else
# define LT_POS(a, b) (((a).lnum != (b).lnum) \
? ((a).lnum < (b).lnum) : ((a).col < (b).col))
# define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
? ((a)->lnum < (b)->lnum) : ((a)->col < (b)->col))
# define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
# define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0;}
#endif
#define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd))
#define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;}
#define LTOREQ_POS(a, b) (LT_POS(a, b) || EQUAL_POS(a, b))
+1 -11
View File
@@ -414,9 +414,7 @@ getmark_buf_fnum(
pos_copy.col = 0;
else
pos_copy.col = MAXCOL;
#ifdef FEAT_VIRTUALEDIT
pos_copy.coladd = 0;
#endif
}
}
else if (ASCII_ISLOWER(c)) /* normal named mark */
@@ -651,9 +649,7 @@ clrallmarks(buf_T *buf)
buf->b_op_end.lnum = 0;
buf->b_last_cursor.lnum = 1; /* '" mark cleared */
buf->b_last_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
buf->b_last_cursor.coladd = 0;
#endif
buf->b_last_insert.lnum = 0; /* '^ mark cleared */
buf->b_last_change.lnum = 0; /* '. mark cleared */
#ifdef FEAT_JUMPLIST
@@ -1052,7 +1048,7 @@ mark_adjust_internal(
linenr_T *lp;
win_T *win;
tabpage_T *tab;
static pos_T initpos = INIT_POS_T(1, 0, 0);
static pos_T initpos = {1, 0, 0};
if (line2 < line1 && amount_after == 0L) /* nothing to do */
return;
@@ -1451,9 +1447,7 @@ read_viminfo_filemark(vir_T *virp, int force)
fm->fmark.mark.lnum = getdigits(&str);
str = skipwhite(str);
fm->fmark.mark.col = getdigits(&str);
#ifdef FEAT_VIRTUALEDIT
fm->fmark.mark.coladd = 0;
#endif
fm->fmark.fnum = 0;
str = skipwhite(str);
vim_free(fm->fname);
@@ -1641,9 +1635,7 @@ handle_viminfo_mark(garray_T *values, int force)
{
fm->fmark.mark.lnum = lnum;
fm->fmark.mark.col = col;
#ifdef FEAT_VIRTUALEDIT
fm->fmark.mark.coladd = 0;
#endif
fm->fmark.fnum = 0;
vim_free(fm->fname);
if (vp[4].bv_allocated)
@@ -2146,9 +2138,7 @@ copy_viminfo_marks(
}
vim_free(str);
#ifdef FEAT_VIRTUALEDIT
pos.coladd = 0;
#endif
while (!(eof = viminfo_readline(virp)) && line[0] == TAB)
{
if (load_marks)
+1 -9
View File
@@ -3994,9 +3994,7 @@ utf_find_illegal(void)
convert_setup(&vimconv, p_enc, curbuf->b_p_fenc);
}
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
for (;;)
{
p = ml_get_cursor();
@@ -4118,18 +4116,13 @@ mb_adjustpos(buf_T *buf, pos_T *lp)
{
char_u *p;
if (lp->col > 0
#ifdef FEAT_VIRTUALEDIT
|| lp->coladd > 1
#endif
)
if (lp->col > 0 || lp->coladd > 1)
{
p = ml_get_buf(buf, lp->lnum, FALSE);
if (*p == NUL || (int)STRLEN(p) < lp->col)
lp->col = 0;
else
lp->col -= (*mb_head_off)(p, p + lp->col);
#ifdef FEAT_VIRTUALEDIT
/* Reset "coladd" when the cursor would be on the right half of a
* double-wide character. */
if (lp->coladd == 1
@@ -4137,7 +4130,6 @@ mb_adjustpos(buf_T *buf, pos_T *lp)
&& vim_isprintc((*mb_ptr2char)(p + lp->col))
&& ptr2cells(p + lp->col) > 1)
lp->coladd = 0;
#endif
}
}
-2
View File
@@ -5667,9 +5667,7 @@ goto_byte(long cnt)
{
curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = (colnr_T)boff;
# ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
# endif
curwin->w_set_curswant = TRUE;
}
check_cursor();
-2
View File
@@ -2318,9 +2318,7 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
curwin->w_cursor.col = 1;
tpos.lnum = eap->line2;
tpos.col = MAXCOL;
#ifdef FEAT_VIRTUALEDIT
tpos.coladd = 0;
#endif
}
/* Activate visual mode */
+1 -16
View File
@@ -622,9 +622,7 @@ get_number_indent(linenr_T lnum)
{
pos.lnum = lnum;
pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum));
#ifdef FEAT_VIRTUALEDIT
pos.coladd = 0;
#endif
}
vim_regfree(regmatch.regprog);
}
@@ -1708,9 +1706,7 @@ open_line(
changed_lines(curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1L);
curwin->w_cursor.col = newcol;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
/*
@@ -1781,9 +1777,7 @@ open_line(
/* Insert new stuff into line again */
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
ins_bytes(p_extra); /* will call changed_bytes() */
vim_free(p_extra);
next_line = NULL;
@@ -2354,11 +2348,9 @@ ins_char_bytes(char_u *buf, int charlen)
linenr_T lnum = curwin->w_cursor.lnum;
int i;
#ifdef FEAT_VIRTUALEDIT
/* Break tabs if needed. */
if (virtual_active() && curwin->w_cursor.coladd > 0)
coladvance_force(getviscol());
#endif
col = curwin->w_cursor.col;
oldp = ml_get(lnum);
@@ -2499,10 +2491,8 @@ ins_str(char_u *s)
colnr_T col;
linenr_T lnum = curwin->w_cursor.lnum;
#ifdef FEAT_VIRTUALEDIT
if (virtual_active() && curwin->w_cursor.coladd > 0)
coladvance_force(getviscol());
#endif
col = curwin->w_cursor.col;
oldp = ml_get(lnum);
@@ -2637,15 +2627,10 @@ del_bytes(
* unless "restart_edit" is set or 'virtualedit' contains "onemore".
*/
if (col > 0 && fixpos && restart_edit == 0
#ifdef FEAT_VIRTUALEDIT
&& (ve_flags & VE_ONEMORE) == 0
#endif
)
&& (ve_flags & VE_ONEMORE) == 0)
{
--curwin->w_cursor.col;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
if (has_mbyte)
curwin->w_cursor.col -=
(*mb_head_off)(oldp, oldp + curwin->w_cursor.col);
+2 -31
View File
@@ -16,7 +16,6 @@ static char_u *username = NULL; /* cached result of mch_get_user_name() */
static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
#if defined(FEAT_VIRTUALEDIT) || defined(PROTO)
static int coladvance2(pos_T *pos, int addspaces, int finetune, colnr_T wcol);
/*
@@ -67,7 +66,6 @@ coladvance_force(colnr_T wcol)
}
return rc;
}
#endif
/*
* Get the screen position of character col with a coladd in the cursor line.
@@ -80,9 +78,7 @@ getviscol2(colnr_T col, colnr_T coladd UNUSED)
pos.lnum = curwin->w_cursor.lnum;
pos.col = col;
#ifdef FEAT_VIRTUALEDIT
pos.coladd = coladd;
#endif
getvvcol(curwin, &pos, &x, NULL, NULL);
return (int)x;
}
@@ -119,7 +115,6 @@ coladvance(colnr_T wcol)
int
getvpos(pos_T *pos, colnr_T wcol)
{
#ifdef FEAT_VIRTUALEDIT
return coladvance2(pos, FALSE, virtual_active(), wcol);
}
@@ -130,7 +125,6 @@ coladvance2(
int finetune, /* change char offset for the exact column */
colnr_T wcol) /* column to move to */
{
#endif
int idx;
char_u *ptr;
char_u *line;
@@ -144,10 +138,7 @@ coladvance2(
one_more = (State & INSERT)
|| restart_edit != NUL
|| (VIsual_active && *p_sel != 'o')
#ifdef FEAT_VIRTUALEDIT
|| ((ve_flags & VE_ONEMORE) && wcol < MAXCOL)
#endif
;
|| ((ve_flags & VE_ONEMORE) && wcol < MAXCOL) ;
line = ml_get_buf(curbuf, pos->lnum, FALSE);
if (wcol >= MAXCOL)
@@ -155,18 +146,15 @@ coladvance2(
idx = (int)STRLEN(line) - 1 + one_more;
col = wcol;
#ifdef FEAT_VIRTUALEDIT
if ((addspaces || finetune) && !VIsual_active)
{
curwin->w_curswant = linetabsize(line) + one_more;
if (curwin->w_curswant > 0)
--curwin->w_curswant;
}
#endif
}
else
{
#ifdef FEAT_VIRTUALEDIT
int width = curwin->w_width - win_col_off(curwin);
if (finetune
@@ -188,7 +176,6 @@ coladvance2(
wcol = (csize / width + 1) * width - 1;
}
}
#endif
ptr = line;
while (col <= wcol && *ptr != NUL)
@@ -219,7 +206,6 @@ coladvance2(
col -= csize;
}
#ifdef FEAT_VIRTUALEDIT
if (virtual_active()
&& addspaces
&& ((col != wcol && col != wcol + 1) || csize > 1))
@@ -283,7 +269,6 @@ coladvance2(
col += correct;
}
}
#endif
}
if (idx < 0)
@@ -291,7 +276,6 @@ coladvance2(
else
pos->col = idx;
#ifdef FEAT_VIRTUALEDIT
pos->coladd = 0;
if (finetune)
@@ -318,7 +302,6 @@ coladvance2(
col += b;
}
}
#endif
/* prevent from moving onto a trail byte */
if (has_mbyte)
@@ -364,9 +347,7 @@ inc(pos_T *lp)
return ((p[l] != NUL) ? 0 : 2);
}
lp->col++;
#ifdef FEAT_VIRTUALEDIT
lp->coladd = 0;
#endif
return ((p[1] != NUL) ? 0 : 2);
}
}
@@ -374,9 +355,7 @@ inc(pos_T *lp)
{
lp->col = 0;
lp->lnum++;
#ifdef FEAT_VIRTUALEDIT
lp->coladd = 0;
#endif
return 1;
}
return -1;
@@ -412,9 +391,7 @@ dec(pos_T *lp)
{
char_u *p;
#ifdef FEAT_VIRTUALEDIT
lp->coladd = 0;
#endif
if (lp->col == MAXCOL)
{
/* past end of line */
@@ -574,10 +551,8 @@ check_cursor_col(void)
check_cursor_col_win(win_T *win)
{
colnr_T len;
#ifdef FEAT_VIRTUALEDIT
colnr_T oldcol = win->w_cursor.col;
colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
#endif
len = (colnr_T)STRLEN(ml_get_buf(win->w_buffer, win->w_cursor.lnum, FALSE));
if (len == 0)
@@ -590,9 +565,7 @@ check_cursor_col_win(win_T *win)
* - 'virtualedit' is set */
if ((State & INSERT) || restart_edit
|| (VIsual_active && *p_sel != 'o')
#ifdef FEAT_VIRTUALEDIT
|| (ve_flags & VE_ONEMORE)
#endif
|| virtual_active())
win->w_cursor.col = len;
else
@@ -606,7 +579,6 @@ check_cursor_col_win(win_T *win)
else if (win->w_cursor.col < 0)
win->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
/* If virtual editing is on, we can leave the cursor on the old position,
* only we must set it to virtual. But don't do it when at the end of the
* line. */
@@ -634,7 +606,6 @@ check_cursor_col_win(win_T *win)
/* avoid weird number when there is a miscalculation or overflow */
win->w_cursor.coladd = 0;
}
#endif
}
/*
@@ -2172,7 +2143,7 @@ ga_add_string(garray_T *gap, char_u *p)
#endif
/*
* Concatenate a string to a growarray which contains characters.
* Concatenate a string to a growarray which contains bytes.
* When "s" is NULL does not do anything.
* Note: Does NOT copy the NUL at the end!
*/
+1 -10
View File
@@ -508,17 +508,12 @@ check_cursor_moved(win_T *wp)
}
else if (wp->w_cursor.col != wp->w_valid_cursor.col
|| wp->w_leftcol != wp->w_valid_leftcol
#ifdef FEAT_VIRTUALEDIT
|| wp->w_cursor.coladd != wp->w_valid_cursor.coladd
#endif
)
|| wp->w_cursor.coladd != wp->w_valid_cursor.coladd)
{
wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
wp->w_valid_cursor.col = wp->w_cursor.col;
wp->w_valid_leftcol = wp->w_leftcol;
#ifdef FEAT_VIRTUALEDIT
wp->w_valid_cursor.coladd = wp->w_cursor.coladd;
#endif
}
}
@@ -2800,9 +2795,7 @@ do_check_cursorbind(void)
{
linenr_T line = curwin->w_cursor.lnum;
colnr_T col = curwin->w_cursor.col;
# ifdef FEAT_VIRTUALEDIT
colnr_T coladd = curwin->w_cursor.coladd;
# endif
colnr_T curswant = curwin->w_curswant;
int set_curswant = curwin->w_set_curswant;
win_T *old_curwin = curwin;
@@ -2829,9 +2822,7 @@ do_check_cursorbind(void)
# endif
curwin->w_cursor.lnum = line;
curwin->w_cursor.col = col;
# ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = coladd;
# endif
curwin->w_curswant = curswant;
curwin->w_set_curswant = set_curswant;
-4
View File
@@ -3344,9 +3344,7 @@ off2pos(buf_T *buf, long offset)
pos.lnum = 0;
pos.col = 0;
#ifdef FEAT_VIRTUALEDIT
pos.coladd = 0;
#endif
if (!(buf->b_ml.ml_flags & ML_EMPTY))
{
@@ -3378,9 +3376,7 @@ get_off_or_lnum(buf_T *buf, char_u **argp)
mypos.lnum = (linenr_T)off;
++*argp;
mypos.col = strtol((char *)*argp, (char **)argp, 10);
#ifdef FEAT_VIRTUALEDIT
mypos.coladd = 0;
#endif
return &mypos;
}
return off2pos(buf, off);
+10 -86
View File
@@ -1340,9 +1340,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
static colnr_T redo_VIsual_vcol; /* number of cols or end column */
static long redo_VIsual_count; /* count for Visual operator */
static int redo_VIsual_arg; /* extra argument */
#ifdef FEAT_VIRTUALEDIT
int include_line_break = FALSE;
#endif
#if defined(FEAT_CLIPBOARD)
/*
@@ -1527,20 +1525,13 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
/* If 'selection' is "exclusive", backup one character for
* charwise selections. */
else if (VIsual_mode == 'v')
{
# ifdef FEAT_VIRTUALEDIT
include_line_break =
# endif
unadjust_for_sel();
}
include_line_break = unadjust_for_sel();
oap->start = VIsual;
if (VIsual_mode == 'V')
{
oap->start.col = 0;
# ifdef FEAT_VIRTUALEDIT
oap->start.coladd = 0;
# endif
}
}
@@ -1590,10 +1581,8 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
check_pos(curwin->w_buffer, &oap->end);
oap->line_count = oap->end.lnum - oap->start.lnum + 1;
#ifdef FEAT_VIRTUALEDIT
/* Set "virtual_op" before resetting VIsual_active. */
virtual_op = virtual_active();
#endif
if (VIsual_active || redo_VIsual_busy)
{
@@ -1685,10 +1674,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
{
oap->motion_type = MCHAR;
if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL
#ifdef FEAT_VIRTUALEDIT
&& (include_line_break || !virtual_op)
#endif
)
&& (include_line_break || !virtual_op))
{
oap->inclusive = FALSE;
/* Try to include the newline, unless it's an operator
@@ -1699,9 +1685,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
{
++oap->end.lnum;
oap->end.col = 0;
#ifdef FEAT_VIRTUALEDIT
oap->end.coladd = 0;
#endif
++oap->line_count;
}
}
@@ -1759,10 +1743,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
|| (oap->op_type == OP_YANK
&& gchar_pos(&oap->end) == NUL))
&& EQUAL_POS(oap->start, oap->end)
#ifdef FEAT_VIRTUALEDIT
&& !(virtual_op && oap->start.coladd != oap->end.coladd)
#endif
);
&& !(virtual_op && oap->start.coladd != oap->end.coladd));
/*
* For delete, change and yank, it's an error to operate on an
* empty region, when 'E' included in 'cpoptions' (Vi compatible).
@@ -2097,9 +2078,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
default:
clearopbeep(oap);
}
#ifdef FEAT_VIRTUALEDIT
virtual_op = MAYBE;
#endif
if (!gui_yank)
{
/*
@@ -2198,9 +2177,7 @@ op_function(oparg_T *oap UNUSED)
{
#ifdef FEAT_EVAL
typval_T argv[2];
# ifdef FEAT_VIRTUALEDIT
int save_virtual_op = virtual_op;
# endif
if (*p_opfunc == NUL)
emsg(_("E774: 'operatorfunc' is empty"));
@@ -2222,17 +2199,13 @@ op_function(oparg_T *oap UNUSED)
argv[0].vval.v_string = (char_u *)"char";
argv[1].v_type = VAR_UNKNOWN;
# ifdef FEAT_VIRTUALEDIT
/* Reset virtual_op so that 'virtualedit' can be changed in the
* function. */
virtual_op = MAYBE;
# endif
(void)call_func_retnr(p_opfunc, 1, argv);
# ifdef FEAT_VIRTUALEDIT
virtual_op = save_virtual_op;
# endif
}
#else
emsg(_("E775: Eval feature not available"));
@@ -3290,10 +3263,8 @@ end_visual_mode(void)
#ifdef FEAT_EVAL
curbuf->b_visual_mode_eval = VIsual_mode;
#endif
#ifdef FEAT_VIRTUALEDIT
if (!virtual_active())
curwin->w_cursor.coladd = 0;
#endif
may_clear_cmdline();
adjust_cursor_eol();
@@ -5944,14 +5915,12 @@ nv_right(cmdarg_T *cap)
cap->oap->inclusive = FALSE;
past_line = (VIsual_active && *p_sel != 'o');
#ifdef FEAT_VIRTUALEDIT
/*
* In virtual edit mode, there's no such thing as "past_line", as lines
* are (theoretically) infinitely long.
*/
if (virtual_active())
past_line = 0;
#endif
for (n = cap->count1; n > 0; --n)
{
@@ -5983,9 +5952,7 @@ nv_right(cmdarg_T *cap)
{
++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
cap->oap->inclusive = FALSE;
}
@@ -6007,11 +5974,9 @@ nv_right(cmdarg_T *cap)
else if (past_line)
{
curwin->w_set_curswant = TRUE;
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
oneright();
else
#endif
{
if (has_mbyte)
curwin->w_cursor.col +=
@@ -6242,13 +6207,11 @@ nv_dollar(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
cap->oap->inclusive = TRUE;
#ifdef FEAT_VIRTUALEDIT
/* In virtual mode when off the edge of a line and an operator
* is pending (whew!) keep the cursor where it is.
* Otherwise, send it to the end of the line. */
if (!virtual_active() || gchar_cursor() != NUL
|| cap->oap->op_type == OP_NOP)
#endif
curwin->w_curswant = MAXCOL; /* so we stay at the end */
if (cursor_down((long)(cap->count1 - 1),
cap->oap->op_type == OP_NOP) == FAIL)
@@ -6341,9 +6304,7 @@ normal_search(
{
if (i == 2)
cap->oap->motion_type = MLINE;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
#ifdef FEAT_FOLDING
if (cap->oap->op_type == OP_NOP && (fdo_flags & FDO_SEARCH) && KeyTyped)
foldOpenCursor();
@@ -6378,7 +6339,6 @@ nv_csearch(cmdarg_T *cap)
else
{
curwin->w_set_curswant = TRUE;
#ifdef FEAT_VIRTUALEDIT
/* Include a Tab for "tx" and for "dfx". */
if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD
&& (t_cmd || cap->oap->op_type != OP_NOP))
@@ -6390,7 +6350,6 @@ nv_csearch(cmdarg_T *cap)
}
else
curwin->w_cursor.coladd = 0;
#endif
adjust_for_sel(cap);
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
@@ -6406,7 +6365,7 @@ nv_csearch(cmdarg_T *cap)
static void
nv_brackets(cmdarg_T *cap)
{
pos_T new_pos = INIT_POS_T(0, 0, 0);
pos_T new_pos = {0, 0, 0};
pos_T prev_pos;
pos_T *pos = NULL; /* init for GCC */
pos_T old_pos; /* cursor position before command */
@@ -6418,9 +6377,7 @@ nv_brackets(cmdarg_T *cap)
cap->oap->motion_type = MCHAR;
cap->oap->inclusive = FALSE;
old_pos = curwin->w_cursor;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0; // TODO: don't do this for an error.
#endif
#ifdef FEAT_SEARCHPATH
/*
@@ -6815,9 +6772,7 @@ nv_percent(cmdarg_T *cap)
setpcmark();
curwin->w_cursor = *pos;
curwin->w_set_curswant = TRUE;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
adjust_for_sel(cap);
}
}
@@ -6849,9 +6804,7 @@ nv_brace(cmdarg_T *cap)
{
/* Don't leave the cursor on the NUL past end of line. */
adjust_cursor(cap->oap);
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
foldOpenCursor();
@@ -6887,9 +6840,7 @@ nv_findpar(cmdarg_T *cap)
clearopbeep(cap->oap);
else
{
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP)
foldOpenCursor();
@@ -6991,7 +6942,6 @@ nv_replace(cmdarg_T *cap)
return;
}
#ifdef FEAT_VIRTUALEDIT
/* Break tabs, etc. */
if (virtual_active())
{
@@ -7006,7 +6956,6 @@ nv_replace(cmdarg_T *cap)
else if (gchar_cursor() == TAB)
coladvance_force(getviscol());
}
#endif
/* Abort if not enough characters to replace. */
ptr = ml_get_cursor();
@@ -7172,11 +7121,8 @@ v_swap_corners(int cmdchar)
++curwin->w_curswant;
coladvance(curwin->w_curswant);
if (curwin->w_cursor.col == old_cursor.col
#ifdef FEAT_VIRTUALEDIT
&& (!virtual_active()
|| curwin->w_cursor.coladd == old_cursor.coladd)
#endif
)
|| curwin->w_cursor.coladd == old_cursor.coladd))
{
curwin->w_cursor.lnum = VIsual.lnum;
if (old_cursor.lnum <= VIsual.lnum && *p_sel == 'e')
@@ -7218,10 +7164,8 @@ nv_Replace(cmdarg_T *cap)
emsg(_(e_modifiable));
else
{
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
coladvance(getviscol());
#endif
invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE);
}
}
@@ -7249,10 +7193,8 @@ nv_vreplace(cmdarg_T *cap)
cap->extra_char = get_literal();
stuffcharReadbuff(cap->extra_char);
stuffcharReadbuff(ESC);
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
coladvance(getviscol());
#endif
invoke_edit(cap, TRUE, 'v', FALSE);
}
}
@@ -7524,11 +7466,9 @@ nv_gomark(cmdarg_T *cap)
else
nv_cursormark(cap, cap->arg, pos);
#ifdef FEAT_VIRTUALEDIT
/* May need to clear the coladd that a mark includes. */
if (!virtual_active())
curwin->w_cursor.coladd = 0;
#endif
check_cursor_col();
#ifdef FEAT_FOLDING
if (cap->oap->op_type == OP_NOP
@@ -7761,16 +7701,14 @@ n_start_visual_mode(int c)
VIsual_mode = c;
VIsual_active = TRUE;
VIsual_reselect = TRUE;
#ifdef FEAT_VIRTUALEDIT
/* Corner case: the 0 position in a tab may change when going into
* virtualedit. Recalculate curwin->w_cursor to avoid bad hilighting.
*/
// Corner case: the 0 position in a tab may change when going into
// virtualedit. Recalculate curwin->w_cursor to avoid bad hilighting.
if (c == Ctrl_V && (ve_flags & VE_BLOCK) && gchar_cursor() == TAB)
{
validate_virtcol();
coladvance(curwin->w_virtcol);
}
#endif
VIsual = curwin->w_cursor;
#ifdef FEAT_FOLDING
@@ -8212,10 +8150,8 @@ nv_g_cmd(cmdarg_T *cap)
i = (int)STRLEN(ml_get_curline());
if (curwin->w_cursor.col > (colnr_T)i)
{
#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
curwin->w_cursor.coladd += curwin->w_cursor.col - i;
#endif
curwin->w_cursor.col = i;
}
}
@@ -8773,10 +8709,7 @@ adjust_cursor(oparg_T *oap)
*/
if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL
&& (!VIsual_active || *p_sel == 'o')
#ifdef FEAT_VIRTUALEDIT
&& !virtual_active() && (ve_flags & VE_ONEMORE) == 0
#endif
)
&& !virtual_active() && (ve_flags & VE_ONEMORE) == 0)
{
--curwin->w_cursor.col;
/* prevent cursor from moving on the trail byte */
@@ -8837,11 +8770,9 @@ unadjust_for_sel(void)
pp = &curwin->w_cursor;
else
pp = &VIsual;
#ifdef FEAT_VIRTUALEDIT
if (pp->coladd > 0)
--pp->coladd;
else
#endif
if (pp->col > 0)
{
--pp->col;
@@ -9077,7 +9008,6 @@ nv_edit(cmdarg_T *cap)
{
case 'A': /* "A"ppend after the line */
curwin->w_set_curswant = TRUE;
#ifdef FEAT_VIRTUALEDIT
if (ve_flags == VE_ALL)
{
int save_State = State;
@@ -9089,7 +9019,6 @@ nv_edit(cmdarg_T *cap)
State = save_State;
}
else
#endif
curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());
break;
@@ -9108,7 +9037,6 @@ nv_edit(cmdarg_T *cap)
/* FALLTHROUGH */
case 'a': /* "a"ppend is like "i"nsert on the next character. */
#ifdef FEAT_VIRTUALEDIT
/* increment coladd when in virtual space, increment the
* column otherwise, also to append after an unprintable char */
if (virtual_active()
@@ -9116,14 +9044,11 @@ nv_edit(cmdarg_T *cap)
|| *ml_get_cursor() == NUL
|| *ml_get_cursor() == TAB))
curwin->w_cursor.coladd++;
else
#endif
if (*ml_get_cursor() != NUL)
else if (*ml_get_cursor() != NUL)
inc_cursor();
break;
}
#ifdef FEAT_VIRTUALEDIT
if (curwin->w_cursor.coladd && cap->cmdchar != 'A')
{
int save_State = State;
@@ -9134,7 +9059,6 @@ nv_edit(cmdarg_T *cap)
coladvance(getviscol());
State = save_State;
}
#endif
invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
}
+10 -94
View File
@@ -1802,12 +1802,10 @@ op_delete(oparg_T *oap)
* It's an error to operate on an empty region, when 'E' included in
* 'cpoptions' (Vi compatible).
*/
#ifdef FEAT_VIRTUALEDIT
if (virtual_op)
/* Virtual editing: Nothing gets deleted, but we set the '[ and ']
* marks as if it happened. */
goto setmarks;
#endif
if (vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL)
beep_flush();
return OK;
@@ -1909,9 +1907,7 @@ op_delete(oparg_T *oap)
if (lnum == curwin->w_cursor.lnum)
{
curwin->w_cursor.col = bd.textcol + bd.startspaces;
# ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
# endif
}
/* n == number of chars deleted
@@ -1979,7 +1975,6 @@ op_delete(oparg_T *oap)
}
else
{
#ifdef FEAT_VIRTUALEDIT
if (virtual_op)
{
int endcol = 0;
@@ -2016,7 +2011,6 @@ op_delete(oparg_T *oap)
curwin->w_cursor = oap->start;
}
}
#endif
if (oap->line_count == 1) /* delete characters within one line */
{
@@ -2032,7 +2026,6 @@ op_delete(oparg_T *oap)
n = oap->end.col - oap->start.col + 1 - !oap->inclusive;
#ifdef FEAT_VIRTUALEDIT
if (virtual_op)
{
/* fix up things for virtualedit-delete:
@@ -2053,7 +2046,6 @@ op_delete(oparg_T *oap)
if (gchar_cursor() != NUL)
curwin->w_cursor.coladd = 0;
}
#endif
(void)del_bytes((long)n, !virtual_op,
oap->op_type == OP_DELETE && !oap->is_VIsual);
}
@@ -2084,9 +2076,7 @@ op_delete(oparg_T *oap)
msgmore(curbuf->b_ml.ml_line_count - old_lcount);
#ifdef FEAT_VIRTUALEDIT
setmarks:
#endif
if (oap->block_mode)
{
curbuf->b_op_end.lnum = oap->end.lnum;
@@ -2183,7 +2173,6 @@ op_replace(oparg_T *oap, int c)
* If we split a TAB, it may be replaced by several characters.
* Thus the number of characters may increase!
*/
#ifdef FEAT_VIRTUALEDIT
/* If the range starts in virtual space, count the initial
* coladd offset as part of "startspaces" */
if (virtual_op && bd.is_short && *bd.textstart == NUL)
@@ -2196,15 +2185,12 @@ op_replace(oparg_T *oap, int c)
n = bd.startspaces;
}
else
#endif
/* allow for pre spaces */
n = (bd.startspaces ? bd.start_char_vcols - 1 : 0);
/* allow for post spp */
n += (bd.endspaces
#ifdef FEAT_VIRTUALEDIT
&& !bd.is_oneChar
#endif
&& bd.end_char_vcols > 0) ? bd.end_char_vcols - 1 : 0;
/* Figure out how many characters to replace. */
numc = oap->end_vcol - oap->start_vcol + 1;
@@ -2311,7 +2297,6 @@ op_replace(oparg_T *oap, int c)
}
else
{
#ifdef FEAT_VIRTUALEDIT
if (n == TAB)
{
int end_vcol = 0;
@@ -2327,11 +2312,9 @@ op_replace(oparg_T *oap, int c)
if (curwin->w_cursor.lnum == oap->end.lnum)
getvpos(&oap->end, end_vcol);
}
#endif
PBYTE(curwin->w_cursor, c);
}
}
#ifdef FEAT_VIRTUALEDIT
else if (virtual_op && curwin->w_cursor.lnum == oap->end.lnum)
{
int virtcols = oap->end.coladd;
@@ -2355,7 +2338,6 @@ op_replace(oparg_T *oap, int c)
break;
}
}
#endif
/* Advance to next character, stop at the end of the file. */
if (inc_cursor() == -1)
@@ -2609,7 +2591,6 @@ op_insert(oparg_T *oap, long count1)
if (oap->block_mode)
{
#ifdef FEAT_VIRTUALEDIT
/* When 'virtualedit' is used, need to insert the extra spaces before
* doing block_prep(). When only "block" is used, virtual edit is
* already disabled, but still need it when calling
@@ -2627,7 +2608,6 @@ op_insert(oparg_T *oap, long count1)
--curwin->w_cursor.col;
ve_flags = old_ve_flags;
}
#endif
/* Get the info about the block before entering the text */
block_prep(oap, &bd, oap->start.lnum, TRUE);
/* Get indent information */
@@ -2641,11 +2621,7 @@ op_insert(oparg_T *oap, long count1)
if (oap->op_type == OP_APPEND)
{
if (oap->block_mode
#ifdef FEAT_VIRTUALEDIT
&& curwin->w_cursor.coladd == 0
#endif
)
if (oap->block_mode && curwin->w_cursor.coladd == 0)
{
/* Move the cursor to the character right of the block. */
curwin->w_set_curswant = TRUE;
@@ -2715,45 +2691,23 @@ op_insert(oparg_T *oap, long count1)
&& !bd.is_MAX && !did_indent)
{
if (oap->op_type == OP_INSERT
&& oap->start.col
#ifdef FEAT_VIRTUALEDIT
+ oap->start.coladd
#endif
&& oap->start.col + oap->start.coladd
!= curbuf->b_op_start_orig.col
#ifdef FEAT_VIRTUALEDIT
+ curbuf->b_op_start_orig.coladd
#endif
)
+ curbuf->b_op_start_orig.coladd)
{
int t = getviscol2(curbuf->b_op_start_orig.col,
#ifdef FEAT_VIRTUALEDIT
curbuf->b_op_start_orig.coladd
#else
0
#endif
);
curbuf->b_op_start_orig.coladd);
oap->start.col = curbuf->b_op_start_orig.col;
pre_textlen -= t - oap->start_vcol;
oap->start_vcol = t;
}
else if (oap->op_type == OP_APPEND
&& oap->end.col
#ifdef FEAT_VIRTUALEDIT
+ oap->end.coladd
#endif
&& oap->end.col + oap->end.coladd
>= curbuf->b_op_start_orig.col
#ifdef FEAT_VIRTUALEDIT
+ curbuf->b_op_start_orig.coladd
#endif
)
+ curbuf->b_op_start_orig.coladd)
{
int t = getviscol2(curbuf->b_op_start_orig.col,
#ifdef FEAT_VIRTUALEDIT
curbuf->b_op_start_orig.coladd
#else
0
#endif
);
curbuf->b_op_start_orig.coladd);
oap->start.col = curbuf->b_op_start_orig.col;
/* reset pre_textlen to the value of OP_INSERT */
pre_textlen += bd.textlen;
@@ -2865,12 +2819,10 @@ op_change(oparg_T *oap)
/* skip blank lines too */
if (oap->block_mode)
{
#ifdef FEAT_VIRTUALEDIT
/* Add spaces before getting the current line length. */
if (virtual_op && (curwin->w_cursor.coladd > 0
|| gchar_cursor() == NUL))
coladvance_force(getviscol());
#endif
firstline = ml_get(oap->start.lnum);
pre_textlen = (long)STRLEN(firstline);
pre_indent = (long)getwhitecols(firstline);
@@ -2916,7 +2868,6 @@ op_change(oparg_T *oap)
block_prep(oap, &bd, linenr, TRUE);
if (!bd.is_short || virtual_op)
{
#ifdef FEAT_VIRTUALEDIT
pos_T vpos;
/* If the block starts in virtual space, count the
@@ -2928,22 +2879,16 @@ op_change(oparg_T *oap)
}
else
vpos.coladd = 0;
#endif
oldp = ml_get(linenr);
newp = alloc_check((unsigned)(STRLEN(oldp)
#ifdef FEAT_VIRTUALEDIT
+ vpos.coladd
#endif
+ ins_len + 1));
+ vpos.coladd + ins_len + 1));
if (newp == NULL)
continue;
/* copy up to block start */
mch_memmove(newp, oldp, (size_t)bd.textcol);
offset = bd.textcol;
#ifdef FEAT_VIRTUALEDIT
vim_memset(newp + offset, ' ', (size_t)vpos.coladd);
offset += vpos.coladd;
#endif
mch_memmove(newp + offset, ins_text, (size_t)ins_len);
offset += ins_len;
oldp += bd.textcol;
@@ -3148,10 +3093,9 @@ op_yank(oparg_T *oap, int deleting, int mess)
case MCHAR:
{
colnr_T startcol = 0, endcol = MAXCOL;
#ifdef FEAT_VIRTUALEDIT
int is_oneChar = FALSE;
colnr_T cs, ce;
#endif
p = ml_get(lnum);
bd.startspaces = 0;
bd.endspaces = 0;
@@ -3159,7 +3103,6 @@ op_yank(oparg_T *oap, int deleting, int mess)
if (lnum == oap->start.lnum)
{
startcol = oap->start.col;
#ifdef FEAT_VIRTUALEDIT
if (virtual_op)
{
getvcol(curwin, &oap->start, &cs, NULL, &ce);
@@ -3172,13 +3115,11 @@ op_yank(oparg_T *oap, int deleting, int mess)
startcol++;
}
}
#endif
}
if (lnum == oap->end.lnum)
{
endcol = oap->end.col;
#ifdef FEAT_VIRTUALEDIT
if (virtual_op)
{
getvcol(curwin, &oap->end, &cs, NULL, &ce);
@@ -3205,15 +3146,10 @@ op_yank(oparg_T *oap, int deleting, int mess)
}
}
}
#endif
}
if (endcol == MAXCOL)
endcol = (colnr_T)STRLEN(p);
if (startcol > endcol
#ifdef FEAT_VIRTUALEDIT
|| is_oneChar
#endif
)
if (startcol > endcol || is_oneChar)
bd.textlen = 0;
else
{
@@ -3661,7 +3597,6 @@ do_put(
yanklen = (int)STRLEN(y_array[0]);
#ifdef FEAT_VIRTUALEDIT
if (ve_flags == VE_ALL && y_type == MCHAR)
{
if (gchar_cursor() == TAB)
@@ -3687,7 +3622,6 @@ do_put(
else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)
coladvance_force(getviscol() + (dir == FORWARD));
}
#endif
lnum = curwin->w_cursor.lnum;
col = curwin->w_cursor.col;
@@ -3702,27 +3636,22 @@ do_put(
if (dir == FORWARD && c != NUL)
{
#ifdef FEAT_VIRTUALEDIT
if (ve_flags == VE_ALL)
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
else
#endif
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
if (has_mbyte)
/* move to start of next multi-byte character */
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
else
#ifdef FEAT_VIRTUALEDIT
if (c != TAB || ve_flags != VE_ALL)
#endif
++curwin->w_cursor.col;
++col;
}
else
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
#ifdef FEAT_VIRTUALEDIT
col += curwin->w_cursor.coladd;
if (ve_flags == VE_ALL
&& (curwin->w_cursor.coladd > 0
@@ -3741,7 +3670,6 @@ do_put(
}
}
curwin->w_cursor.coladd = 0;
#endif
bd.textcol = 0;
for (i = 0; i < y_size; ++i)
{
@@ -3850,9 +3778,7 @@ do_put(
/* adjust '] mark */
curbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;
curbuf->b_op_end.col = bd.textcol + totlen - 1;
# ifdef FEAT_VIRTUALEDIT
curbuf->b_op_end.coladd = 0;
# endif
if (flags & PUT_CURSEND)
{
colnr_T len;
@@ -4144,15 +4070,12 @@ adjust_cursor_eol(void)
{
if (curwin->w_cursor.col > 0
&& gchar_cursor() == NUL
#ifdef FEAT_VIRTUALEDIT
&& (ve_flags & VE_ONEMORE) == 0
#endif
&& !(restart_edit || (State & INSERT)))
{
/* Put the cursor on the last character in the line. */
dec_cursor();
#ifdef FEAT_VIRTUALEDIT
if (ve_flags == VE_ALL)
{
colnr_T scol, ecol;
@@ -4161,7 +4084,6 @@ adjust_cursor_eol(void)
getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol);
curwin->w_cursor.coladd = ecol - scol + 1;
}
#endif
}
}
@@ -4704,9 +4626,7 @@ do_join(
(vim_strchr(p_cpo, CPO_JOINCOL) != NULL ? currsize : col);
check_cursor_col();
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
theend:
@@ -7394,13 +7314,9 @@ cursor_pos_info(dict_T *dict)
switch (VIsual_mode)
{
case Ctrl_V:
#ifdef FEAT_VIRTUALEDIT
virtual_op = virtual_active();
#endif
block_prep(&oparg, &bd, lnum, 0);
#ifdef FEAT_VIRTUALEDIT
virtual_op = MAYBE;
#endif
s = bd.textstart;
len = (long)bd.textlen;
break;
-9
View File
@@ -2939,13 +2939,8 @@ static struct vimoption options[] =
SCTX_INIT},
{"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
|P_VIM|P_CURSWANT,
#ifdef FEAT_VIRTUALEDIT
(char_u *)&p_ve, PV_NONE,
{(char_u *)"", (char_u *)""}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"visualbell", "vb", P_BOOL|P_VI_DEF,
(char_u *)&p_vb, PV_NONE,
@@ -5526,9 +5521,7 @@ didset_options(void)
#endif
(void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
(void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
#ifdef FEAT_VIRTUALEDIT
(void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
#endif
#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
(void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
#endif
@@ -7374,7 +7367,6 @@ did_set_string_option(
}
#endif
#ifdef FEAT_VIRTUALEDIT
/* 'virtualedit' */
else if (varp == &p_ve)
{
@@ -7388,7 +7380,6 @@ did_set_string_option(
coladvance(curwin->w_virtcol);
}
}
#endif
#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
else if (varp == &p_csqf)
+5 -7
View File
@@ -908,17 +908,15 @@ EXTERN char_u *p_vop; /* 'viewoptions' */
EXTERN unsigned vop_flags; /* uses SSOP_ flags */
#endif
EXTERN int p_vb; /* 'visualbell' */
#ifdef FEAT_VIRTUALEDIT
EXTERN char_u *p_ve; /* 'virtualedit' */
EXTERN unsigned ve_flags;
# ifdef IN_OPTION_C
#ifdef IN_OPTION_C
static char *(p_ve_values[]) = {"block", "insert", "all", "onemore", NULL};
# endif
# define VE_BLOCK 5 /* includes "all" */
# define VE_INSERT 6 /* includes "all" */
# define VE_ALL 4
# define VE_ONEMORE 8
#endif
#define VE_BLOCK 5 /* includes "all" */
#define VE_INSERT 6 /* includes "all" */
#define VE_ALL 4
#define VE_ONEMORE 8
EXTERN long p_verbose; /* 'verbose' */
#ifdef IN_OPTION_C
char_u *p_vfile = (char_u *)""; /* used before options are initialized */
+5 -17
View File
@@ -1622,14 +1622,14 @@ win_update(win_T *wp)
if (VIsual_mode == Ctrl_V)
{
colnr_T fromc, toc;
#if defined(FEAT_VIRTUALEDIT) && defined(FEAT_LINEBREAK)
#if defined(FEAT_LINEBREAK)
int save_ve_flags = ve_flags;
if (curwin->w_p_lbr)
ve_flags = VE_ALL;
#endif
getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
#if defined(FEAT_VIRTUALEDIT) && defined(FEAT_LINEBREAK)
#if defined(FEAT_LINEBREAK)
ve_flags = save_ve_flags;
#endif
++toc;
@@ -3342,11 +3342,7 @@ win_line(
}
if (VIsual_mode != 'V' && lnum == bot->lnum)
{
if (*p_sel == 'e' && bot->col == 0
#ifdef FEAT_VIRTUALEDIT
&& bot->coladd == 0
#endif
)
if (*p_sel == 'e' && bot->col == 0 && bot->coladd == 0)
{
fromcol = -10;
tocol = MAXCOL;
@@ -3545,9 +3541,7 @@ win_line(
#ifdef FEAT_SYN_HL
wp->w_p_cuc || draw_color_col ||
#endif
#ifdef FEAT_VIRTUALEDIT
virtual_active() ||
#endif
(VIsual_active && wp->w_buffer == curwin->w_buffer)))
{
vcol = v;
@@ -5033,14 +5027,12 @@ win_line(
)
#endif
{
#ifdef FEAT_VIRTUALEDIT
/* In virtualedit, visual selections may extend
* beyond end of line. */
if (area_highlighting && virtual_active()
&& tocol != MAXCOL && vcol < tocol)
n_extra = 0;
else
#endif
{
p_extra = at_end_str;
n_extra = 1;
@@ -5107,7 +5099,6 @@ win_line(
}
mb_utf8 = FALSE; /* don't draw as UTF-8 */
}
#ifdef FEAT_VIRTUALEDIT
else if (VIsual_active
&& (VIsual_mode == Ctrl_V
|| VIsual_mode == 'v')
@@ -5115,15 +5106,14 @@ win_line(
&& tocol != MAXCOL
&& vcol < tocol
&& (
# ifdef FEAT_RIGHTLEFT
#ifdef FEAT_RIGHTLEFT
wp->w_p_rl ? (col >= 0) :
# endif
#endif
(col < wp->w_width)))
{
c = ' ';
--ptr; /* put it back at the NUL */
}
#endif
#if defined(LINE_ATTR)
else if ((
# ifdef FEAT_DIFF
@@ -10866,9 +10856,7 @@ win_redr_ruler(win_T *wp, int always, int ignore_pum)
|| wp->w_cursor.lnum != wp->w_ru_cursor.lnum
|| wp->w_cursor.col != wp->w_ru_cursor.col
|| wp->w_virtcol != wp->w_ru_virtcol
#ifdef FEAT_VIRTUALEDIT
|| wp->w_cursor.coladd != wp->w_ru_cursor.coladd
#endif
|| wp->w_topline != wp->w_ru_topline
|| wp->w_buffer->b_ml.ml_line_count != wp->w_ru_line_count
#ifdef FEAT_DIFF
-12
View File
@@ -1029,11 +1029,9 @@ searchit(
end_pos->col = endpos.col;
}
}
#ifdef FEAT_VIRTUALEDIT
pos->coladd = 0;
if (end_pos != NULL)
end_pos->coladd = 0;
#endif
found = 1;
first_match = FALSE;
@@ -1919,9 +1917,7 @@ findmatchlimit(
#endif
pos = curwin->w_cursor;
#ifdef FEAT_VIRTUALEDIT
pos.coladd = 0;
#endif
linep = ml_get(pos.lnum);
cpo_match = (vim_strchr(p_cpo, CPO_MATCH) != NULL);
@@ -3027,9 +3023,7 @@ fwd_word(
int i;
int last_line;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
cls_bigword = bigword;
while (--count >= 0)
{
@@ -3094,9 +3088,7 @@ bck_word(long count, int bigword, int stop)
{
int sclass; /* starting class */
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
cls_bigword = bigword;
while (--count >= 0)
{
@@ -3163,9 +3155,7 @@ end_word(
{
int sclass; /* starting class */
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
cls_bigword = bigword;
while (--count >= 0)
{
@@ -3233,9 +3223,7 @@ bckend_word(
int sclass; /* starting class */
int i;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
cls_bigword = bigword;
while (--count >= 0)
{
-2
View File
@@ -1652,9 +1652,7 @@ spell_move_to(
found_one = TRUE;
found_pos.lnum = lnum;
found_pos.col = (int)(p - buf);
#ifdef FEAT_VIRTUALEDIT
found_pos.coladd = 0;
#endif
if (dir == FORWARD)
{
/* No need to search further. */
+6 -15
View File
@@ -21,30 +21,23 @@ typedef unsigned short short_u;
#endif
/*
* position in file or buffer
* Position in file or buffer.
*/
typedef struct
{
linenr_T lnum; /* line number */
colnr_T col; /* column number */
#ifdef FEAT_VIRTUALEDIT
colnr_T coladd;
#endif
linenr_T lnum; // line number
colnr_T col; // column number
colnr_T coladd; // extra virtual column
} pos_T;
#ifdef FEAT_VIRTUALEDIT
# define INIT_POS_T(l, c, ca) {l, c, ca}
#else
# define INIT_POS_T(l, c, ca) {l, c}
#endif
/*
* Same, but without coladd.
*/
typedef struct
{
linenr_T lnum; /* line number */
colnr_T col; /* column number */
linenr_T lnum; // line number
colnr_T col; // column number
} lpos_T;
/*
@@ -395,9 +388,7 @@ struct u_header
u_entry_T *uh_entry; /* pointer to first entry */
u_entry_T *uh_getbot_entry; /* pointer to where ue_bot must be set */
pos_T uh_cursor; /* cursor position before saving */
#ifdef FEAT_VIRTUALEDIT
long uh_cursor_vcol;
#endif
int uh_flags; /* see below */
pos_T uh_namedm[NMARKS]; /* marks before undo/after redo */
visualinfo_T uh_visual; /* Visual areas before undo/after redo */
+1 -1
View File
@@ -85,7 +85,7 @@ static char_u *tagmatchname = NULL; /* name of last used tag */
* Tag for preview window is remembered separately, to avoid messing up the
* normal tagstack.
*/
static taggy_T ptag_entry = {NULL, {INIT_POS_T(0, 0, 0), 0}, 0, 0};
static taggy_T ptag_entry = {NULL, {{0, 0, 0}, 0}, 0, 0};
#endif
/*
-2
View File
@@ -3184,9 +3184,7 @@ get_fpos_of_mouse(pos_T *mpos)
if (mpos->col > 0)
--mpos->col;
#ifdef FEAT_VIRTUALEDIT
mpos->coladd = 0;
#endif
return IN_BUFFER;
}
#endif
-22
View File
@@ -548,12 +548,10 @@ u_savecommon(
uhp->uh_entry = NULL;
uhp->uh_getbot_entry = NULL;
uhp->uh_cursor = curwin->w_cursor; /* save cursor pos. for undo */
#ifdef FEAT_VIRTUALEDIT
if (virtual_active() && curwin->w_cursor.coladd > 0)
uhp->uh_cursor_vcol = getviscol();
else
uhp->uh_cursor_vcol = -1;
#endif
/* save changed and buffer empty flag for undo */
uhp->uh_flags = (curbuf->b_changed ? UH_CHANGED : 0) +
@@ -1250,11 +1248,7 @@ serialize_uhp(bufinfo_T *bi, u_header_T *uhp)
put_header_ptr(bi, uhp->uh_alt_prev.ptr);
undo_write_bytes(bi, uhp->uh_seq, 4);
serialize_pos(bi, uhp->uh_cursor);
#ifdef FEAT_VIRTUALEDIT
undo_write_bytes(bi, (long_u)uhp->uh_cursor_vcol, 4);
#else
undo_write_bytes(bi, (long_u)0, 4);
#endif
undo_write_bytes(bi, (long_u)uhp->uh_flags, 2);
/* Assume NMARKS will stay the same. */
for (i = 0; i < NMARKS; ++i)
@@ -1309,11 +1303,7 @@ unserialize_uhp(bufinfo_T *bi, char_u *file_name)
return NULL;
}
unserialize_pos(bi, &uhp->uh_cursor);
#ifdef FEAT_VIRTUALEDIT
uhp->uh_cursor_vcol = undo_read_4c(bi);
#else
(void)undo_read_4c(bi);
#endif
uhp->uh_flags = undo_read_2c(bi);
for (i = 0; i < NMARKS; ++i)
unserialize_pos(bi, &uhp->uh_namedm[i]);
@@ -1458,11 +1448,7 @@ serialize_pos(bufinfo_T *bi, pos_T pos)
{
undo_write_bytes(bi, (long_u)pos.lnum, 4);
undo_write_bytes(bi, (long_u)pos.col, 4);
#ifdef FEAT_VIRTUALEDIT
undo_write_bytes(bi, (long_u)pos.coladd, 4);
#else
undo_write_bytes(bi, (long_u)0, 4);
#endif
}
/*
@@ -1477,13 +1463,9 @@ unserialize_pos(bufinfo_T *bi, pos_T *pos)
pos->col = undo_read_4c(bi);
if (pos->col < 0)
pos->col = 0;
#ifdef FEAT_VIRTUALEDIT
pos->coladd = undo_read_4c(bi);
if (pos->coladd < 0)
pos->coladd = 0;
#else
(void)undo_read_4c(bi);
#endif
}
/*
@@ -2855,12 +2837,10 @@ u_undoredo(int undo)
if (curhead->uh_cursor.lnum == curwin->w_cursor.lnum)
{
curwin->w_cursor.col = curhead->uh_cursor.col;
#ifdef FEAT_VIRTUALEDIT
if (virtual_active() && curhead->uh_cursor_vcol >= 0)
coladvance((colnr_T)curhead->uh_cursor_vcol);
else
curwin->w_cursor.coladd = 0;
#endif
}
else
beginline(BL_SOL | BL_FIX);
@@ -2872,9 +2852,7 @@ u_undoredo(int undo)
* check_cursor() will move the cursor to the last line. Move it to
* the first column here. */
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
}
/* Make sure the cursor is on an existing line and column. */
-2
View File
@@ -3178,9 +3178,7 @@ ex_call(exarg_T *eap)
}
curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
}
arg = startarg;
if (get_func_tv(name, (int)STRLEN(name), &rettv, &arg,
+2 -4
View File
@@ -695,11 +695,7 @@ static char *(features[]) =
"-vartabs",
#endif
"+vertsplit",
#ifdef FEAT_VIRTUALEDIT
"+virtualedit",
#else
"-virtualedit",
#endif
"+visual",
"+visualextra",
#ifdef FEAT_VIMINFO
@@ -787,6 +783,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
826,
/**/
825,
/**/
-6
View File
@@ -2136,12 +2136,6 @@ typedef enum {
#include "globals.h" /* global variables and messages */
#ifndef FEAT_VIRTUALEDIT
# define getvvcol(w, p, s, c, e) getvcol((w), (p), (s), (c), (e))
# define virtual_active() FALSE
# define virtual_op FALSE
#endif
/*
* If console dialog not supported, but GUI dialog is, use the GUI one.
*/
-4
View File
@@ -3439,9 +3439,7 @@ win_init_empty(win_T *wp)
wp->w_lines_valid = 0;
wp->w_cursor.lnum = 1;
wp->w_curswant = wp->w_cursor.col = 0;
#ifdef FEAT_VIRTUALEDIT
wp->w_cursor.coladd = 0;
#endif
wp->w_pcmark.lnum = 1; /* pcmark not cleared but set to line 1 */
wp->w_pcmark.col = 0;
wp->w_prev_pcmark.lnum = 0;
@@ -4418,10 +4416,8 @@ win_enter_ext(
curwin = wp;
curbuf = wp->w_buffer;
check_cursor();
#ifdef FEAT_VIRTUALEDIT
if (!virtual_active())
curwin->w_cursor.coladd = 0;
#endif
changed_line_abv_curs(); /* assume cursor position needs updating */
if (curwin->w_localdir != NULL)