summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-11 14:37:20 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-11 14:37:20 +0100
commit870ba5f6dce974b6c1c47bf9d3b20db805d10b36 (patch)
tree270e22e4affea836091d30ce0166fa1ad649ff92 /src/ops.c
parent402385a7f2fed23acef7ad3ce75252706b1d7606 (diff)
downloadvim-git-870ba5f6dce974b6c1c47bf9d3b20db805d10b36.tar.gz
patch 8.1.0719: too many #ifdefsv8.1.0719
Problem: Too many #ifdefs. Solution: Always build with the +visualextra feature.
Diffstat (limited to 'src/ops.c')
-rw-r--r--src/ops.c62
1 files changed, 15 insertions, 47 deletions
diff --git a/src/ops.c b/src/ops.c
index 58f201f29..e3df9b3a6 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -82,20 +82,16 @@ struct block_def
colnr_T textcol; /* index of chars (partially) in block */
colnr_T start_vcol; /* start col of 1st char wholly inside block */
colnr_T end_vcol; /* start col of 1st char wholly after block */
-#ifdef FEAT_VISUALEXTRA
int is_short; /* TRUE if line is too short to fit in block */
int is_MAX; /* TRUE if curswant==MAXCOL when starting */
int is_oneChar; /* TRUE if block within one character */
int pre_whitesp; /* screen cols of ws before block */
int pre_whitesp_c; /* chars of ws before block */
colnr_T end_char_vcols; /* number of vcols of post-block char */
-#endif
colnr_T start_char_vcols; /* number of vcols of pre-block char */
};
-#ifdef FEAT_VISUALEXTRA
static void shift_block(oparg_T *oap, int amount);
-#endif
static int stuff_yank(int, char_u *);
static void put_reedit_in_typebuf(int silent);
static int put_in_typebuf(char_u *s, int esc, int colon,
@@ -255,10 +251,8 @@ op_shift(oparg_T *oap, int curs_top, int amount)
first_char = *ml_get_curline();
if (first_char == NUL) /* empty line */
curwin->w_cursor.col = 0;
-#ifdef FEAT_VISUALEXTRA
else if (oap->block_mode)
shift_block(oap, amount);
-#endif
else
/* Move the line right if it doesn't start with '#', 'smartindent'
* isn't set or 'cindent' isn't set or '#' isn't in 'cino'. */
@@ -322,8 +316,8 @@ op_shift(oparg_T *oap, int curs_top, int amount)
}
/*
- * shift the current line one shiftwidth left (if left != 0) or right
- * leaves cursor on first blank in the line
+ * Shift the current line one shiftwidth left (if left != 0) or right
+ * leaves cursor on first blank in the line.
*/
void
shift_line(
@@ -373,7 +367,6 @@ shift_line(
(void)set_indent(count, call_changed_bytes ? SIN_CHANGED : 0);
}
-#if defined(FEAT_VISUALEXTRA) || defined(PROTO)
/*
* Shift one line of the current block one shiftwidth right or left.
* Leaves cursor on first character in block.
@@ -577,9 +570,7 @@ shift_block(oparg_T *oap, int amount)
p_ri = old_p_ri;
#endif
}
-#endif
-#ifdef FEAT_VISUALEXTRA
/*
* Insert string "s" (b_insert ? before : after) block :AKelly
* Caller must prepare for undo.
@@ -703,7 +694,6 @@ block_insert(
State = oldstate;
}
-#endif
#if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(PROTO)
/*
@@ -2132,9 +2122,8 @@ mb_adjust_opend(oparg_T *oap)
}
#endif
-#if defined(FEAT_VISUALEXTRA) || defined(PROTO)
-# ifdef FEAT_MBYTE
+#ifdef FEAT_MBYTE
/*
* Replace the character under the cursor with "c".
* This takes care of multi-byte characters.
@@ -2150,8 +2139,8 @@ replace_character(int c)
/* Backup to the replaced character. */
dec_cursor();
}
+#endif
-# endif
/*
* Replace a whole area with one character.
*/
@@ -2378,11 +2367,11 @@ op_replace(oparg_T *oap, int c)
curwin->w_cursor.col -= (virtcols + 1);
for (; virtcols >= 0; virtcols--)
{
-#ifdef FEAT_MBYTE
+# ifdef FEAT_MBYTE
if ((*mb_char2len)(c) > 1)
replace_character(c);
else
- #endif
+# endif
PBYTE(curwin->w_cursor, c);
if (inc(&curwin->w_cursor) == -1)
break;
@@ -2406,7 +2395,6 @@ op_replace(oparg_T *oap, int c)
return OK;
}
-#endif
static int swapchars(int op_type, pos_T *pos, int length);
@@ -2627,7 +2615,6 @@ swapchar(int op_type, pos_T *pos)
return FALSE;
}
-#if defined(FEAT_VISUALEXTRA) || defined(PROTO)
/*
* op_insert - Insert and append operators for Visual mode.
*/
@@ -2844,7 +2831,6 @@ op_insert(oparg_T *oap, long count1)
}
}
}
-#endif
/*
* op_change - handle a change operation
@@ -2856,7 +2842,6 @@ op_change(oparg_T *oap)
{
colnr_T l;
int retval;
-#ifdef FEAT_VISUALEXTRA
long offset;
linenr_T linenr;
long ins_len;
@@ -2865,7 +2850,6 @@ op_change(oparg_T *oap)
char_u *firstline;
char_u *ins_text, *newp, *oldp;
struct block_def bd;
-#endif
l = oap->start.col;
if (oap->motion_type == MLINE)
@@ -2895,23 +2879,21 @@ op_change(oparg_T *oap)
&& !virtual_op)
inc_cursor();
-#ifdef FEAT_VISUALEXTRA
/* check for still on same line (<CR> in inserted text meaningless) */
/* skip blank lines too */
if (oap->block_mode)
{
-# ifdef FEAT_VIRTUALEDIT
+#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
+#endif
firstline = ml_get(oap->start.lnum);
pre_textlen = (long)STRLEN(firstline);
pre_indent = (long)getwhitecols(firstline);
bd.textcol = curwin->w_cursor.col;
}
-#endif
#if defined(FEAT_LISP) || defined(FEAT_CINDENT)
if (oap->motion_type == MLINE)
@@ -2920,7 +2902,6 @@ op_change(oparg_T *oap)
retval = edit(NUL, FALSE, (linenr_T)1);
-#ifdef FEAT_VISUALEXTRA
/*
* In Visual block mode, handle copying the new text to all lines of the
* block.
@@ -2953,7 +2934,7 @@ op_change(oparg_T *oap)
block_prep(oap, &bd, linenr, TRUE);
if (!bd.is_short || virtual_op)
{
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
pos_T vpos;
/* If the block starts in virtual space, count the
@@ -2965,22 +2946,22 @@ op_change(oparg_T *oap)
}
else
vpos.coladd = 0;
-# endif
+#endif
oldp = ml_get(linenr);
newp = alloc_check((unsigned)(STRLEN(oldp)
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
+ vpos.coladd
-# endif
+#endif
+ 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
+#ifdef FEAT_VIRTUALEDIT
vim_memset(newp + offset, ' ', (size_t)vpos.coladd);
offset += vpos.coladd;
-# endif
+#endif
mch_memmove(newp + offset, ins_text, (size_t)ins_len);
offset += ins_len;
oldp += bd.textcol;
@@ -2995,7 +2976,6 @@ op_change(oparg_T *oap)
vim_free(ins_text);
}
}
-#endif
return retval;
}
@@ -5415,13 +5395,11 @@ block_prep(
bdp->textlen = 0;
bdp->start_vcol = 0;
bdp->end_vcol = 0;
-#ifdef FEAT_VISUALEXTRA
bdp->is_short = FALSE;
bdp->is_oneChar = FALSE;
bdp->pre_whitesp = 0;
bdp->pre_whitesp_c = 0;
bdp->end_char_vcols = 0;
-#endif
bdp->start_char_vcols = 0;
line = ml_get(lnum);
@@ -5432,7 +5410,6 @@ block_prep(
/* Count a tab for what it's worth (if list mode not on) */
incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol);
bdp->start_vcol += incr;
-#ifdef FEAT_VISUALEXTRA
if (VIM_ISWHITE(*pstart))
{
bdp->pre_whitesp += incr;
@@ -5443,7 +5420,6 @@ block_prep(
bdp->pre_whitesp = 0;
bdp->pre_whitesp_c = 0;
}
-#endif
prev_pstart = pstart;
MB_PTR_ADV(pstart);
}
@@ -5451,9 +5427,7 @@ block_prep(
if (bdp->start_vcol < oap->start_vcol) /* line too short */
{
bdp->end_vcol = bdp->start_vcol;
-#ifdef FEAT_VISUALEXTRA
bdp->is_short = TRUE;
-#endif
if (!is_del || oap->op_type == OP_APPEND)
bdp->endspaces = oap->end_vcol - oap->start_vcol + 1;
}
@@ -5468,9 +5442,7 @@ block_prep(
bdp->end_vcol = bdp->start_vcol;
if (bdp->end_vcol > oap->end_vcol) /* it's all in one character */
{
-#ifdef FEAT_VISUALEXTRA
bdp->is_oneChar = TRUE;
-#endif
if (oap->op_type == OP_INSERT)
bdp->endspaces = bdp->start_char_vcols - bdp->startspaces;
else if (oap->op_type == OP_APPEND)
@@ -5507,9 +5479,7 @@ block_prep(
|| oap->op_type == OP_APPEND
|| oap->op_type == OP_REPLACE)) /* line too short */
{
-#ifdef FEAT_VISUALEXTRA
bdp->is_short = TRUE;
-#endif
/* Alternative: include spaces to fill up the block.
* Disadvantage: can lead to trailing spaces when the line is
* short where the text is put */
@@ -5531,9 +5501,7 @@ block_prep(
}
}
}
-#ifdef FEAT_VISUALEXTRA
bdp->end_char_vcols = incr;
-#endif
if (is_del && bdp->startspaces)
pstart = prev_pstart;
bdp->textlen = (int)(pend - pstart);
@@ -6624,7 +6592,7 @@ clip_free_selection(VimClipboard *cbd)
}
/*
- * Get the selected text and put it in the gui selection register '*' or '+'.
+ * Get the selected text and put it in register '*' or '+'.
*/
void
clip_get_selection(VimClipboard *cbd)