From 29ddebef4038d2d2b3bc9d8d3b0109f4046d6fbf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 26 Jan 2019 17:28:26 +0100 Subject: patch 8.1.0826: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate FEAT_VIRTUALEDIT. Adds about 10Kbyte to the code. --- src/edit.c | 55 ++++++++++--------------------------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) (limited to 'src/edit.c') diff --git a/src/edit.c b/src/edit.c index f797d7f04e..de5adcb197 100644 --- a/src/edit.c +++ b/src/edit.c @@ -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 -- cgit v1.2.3