summaryrefslogtreecommitdiff
path: root/src/normal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c359
1 files changed, 52 insertions, 307 deletions
diff --git a/src/normal.c b/src/normal.c
index 19025f75b..15abab290 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -14,7 +14,6 @@
#include "vim.h"
-#ifdef FEAT_VISUAL
/*
* The Visual area is remembered for reselection.
*/
@@ -24,7 +23,6 @@ static colnr_T resel_VIsual_vcol; /* nr of cols or end col */
static int VIsual_mode_orig = NUL; /* saved Visual mode */
static int restart_VIsual_select = 0;
-#endif
#ifdef FEAT_EVAL
static void set_vcount_ca __ARGS((cmdarg_T *cap, int *set_prevcount));
@@ -37,7 +35,7 @@ static int
static int find_command __ARGS((int cmdchar));
static void op_colon __ARGS((oparg_T *oap));
static void op_function __ARGS((oparg_T *oap));
-#if defined(FEAT_MOUSE) && defined(FEAT_VISUAL)
+#if defined(FEAT_MOUSE)
static void find_start_of_word __ARGS((pos_T *));
static void find_end_of_word __ARGS((pos_T *));
static int get_mouse_class __ARGS((char_u *p));
@@ -48,9 +46,7 @@ static int checkclearop __ARGS((oparg_T *oap));
static int checkclearopq __ARGS((oparg_T *oap));
static void clearop __ARGS((oparg_T *oap));
static void clearopbeep __ARGS((oparg_T *oap));
-#ifdef FEAT_VISUAL
static void unshift_special __ARGS((cmdarg_T *cap));
-#endif
#ifdef FEAT_CMDL_INFO
static void del_from_showcmd __ARGS((int));
#endif
@@ -117,25 +113,19 @@ static void nv_Replace __ARGS((cmdarg_T *cap));
#ifdef FEAT_VREPLACE
static void nv_vreplace __ARGS((cmdarg_T *cap));
#endif
-#ifdef FEAT_VISUAL
static void v_swap_corners __ARGS((int cmdchar));
-#endif
static void nv_replace __ARGS((cmdarg_T *cap));
static void n_swapchar __ARGS((cmdarg_T *cap));
static void nv_cursormark __ARGS((cmdarg_T *cap, int flag, pos_T *pos));
-#ifdef FEAT_VISUAL
static void v_visop __ARGS((cmdarg_T *cap));
-#endif
static void nv_subst __ARGS((cmdarg_T *cap));
static void nv_abbrev __ARGS((cmdarg_T *cap));
static void nv_optrans __ARGS((cmdarg_T *cap));
static void nv_gomark __ARGS((cmdarg_T *cap));
static void nv_pcmark __ARGS((cmdarg_T *cap));
static void nv_regname __ARGS((cmdarg_T *cap));
-#ifdef FEAT_VISUAL
static void nv_visual __ARGS((cmdarg_T *cap));
static void n_start_visual_mode __ARGS((int c));
-#endif
static void nv_window __ARGS((cmdarg_T *cap));
static void nv_suspend __ARGS((cmdarg_T *cap));
static void nv_g_cmd __ARGS((cmdarg_T *cap));
@@ -155,11 +145,9 @@ static void nv_bck_word __ARGS((cmdarg_T *cap));
static void nv_wordcmd __ARGS((cmdarg_T *cap));
static void nv_beginline __ARGS((cmdarg_T *cap));
static void adjust_cursor __ARGS((oparg_T *oap));
-#ifdef FEAT_VISUAL
static void adjust_for_sel __ARGS((cmdarg_T *cap));
static int unadjust_for_sel __ARGS((void));
static void nv_select __ARGS((cmdarg_T *cap));
-#endif
static void nv_goto __ARGS((cmdarg_T *cap));
static void nv_normal __ARGS((cmdarg_T *cap));
static void nv_esc __ARGS((cmdarg_T *oap));
@@ -248,24 +236,14 @@ static const struct nv_cmd
{Ctrl_N, nv_down, NV_STS, FALSE},
{Ctrl_O, nv_ctrlo, 0, 0},
{Ctrl_P, nv_up, NV_STS, FALSE},
-#ifdef FEAT_VISUAL
{Ctrl_Q, nv_visual, 0, FALSE},
-#else
- {Ctrl_Q, nv_ignore, 0, 0},
-#endif
{Ctrl_R, nv_redo, 0, 0},
{Ctrl_S, nv_ignore, 0, 0},
{Ctrl_T, nv_tagpop, NV_NCW, 0},
{Ctrl_U, nv_halfpage, 0, 0},
-#ifdef FEAT_VISUAL
{Ctrl_V, nv_visual, 0, FALSE},
{'V', nv_visual, 0, FALSE},
{'v', nv_visual, 0, FALSE},
-#else
- {Ctrl_V, nv_error, 0, 0},
- {'V', nv_error, 0, 0},
- {'v', nv_error, 0, 0},
-#endif
{Ctrl_W, nv_window, 0, 0},
{Ctrl_X, nv_addsub, 0, 0},
{Ctrl_Y, nv_scroll_line, 0, FALSE},
@@ -427,9 +405,7 @@ static const struct nv_cmd
{K_HELP, nv_help, NV_NCW, 0},
{K_F1, nv_help, NV_NCW, 0},
{K_XF1, nv_help, NV_NCW, 0},
-#ifdef FEAT_VISUAL
{K_SELECT, nv_select, 0, 0},
-#endif
#ifdef FEAT_GUI
{K_VER_SCROLLBAR, nv_ver_scrollbar, 0, 0},
{K_HOR_SCROLLBAR, nv_hor_scrollbar, 0, 0},
@@ -579,11 +555,9 @@ normal_cmd(oap, toplevel)
#ifdef FEAT_CMDL_INFO
int need_flushbuf; /* need to call out_flush() */
#endif
-#ifdef FEAT_VISUAL
pos_T old_pos; /* cursor position before command */
int mapped_len;
static int old_mapped_len = 0;
-#endif
int idx;
#ifdef FEAT_EVAL
int set_prevcount = FALSE;
@@ -643,9 +617,7 @@ normal_cmd(oap, toplevel)
}
#endif
-#ifdef FEAT_VISUAL
mapped_len = typebuf_maplen();
-#endif
State = NORMAL_BUSY;
#ifdef USE_ON_FLY_SCROLL
@@ -666,7 +638,6 @@ normal_cmd(oap, toplevel)
c = safe_vgetc();
LANGMAP_ADJUST(c, TRUE);
-#ifdef FEAT_VISUAL
/*
* If a mapping was started in Visual or Select mode, remember the length
* of the mapping. This is used below to not return to Insert mode for as
@@ -677,12 +648,10 @@ normal_cmd(oap, toplevel)
else if (old_mapped_len
|| (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0))
old_mapped_len = typebuf_maplen();
-#endif
if (c == NUL)
c = K_ZERO;
-#ifdef FEAT_VISUAL
/*
* In Select mode, typed text replaces the selection.
*/
@@ -703,16 +672,13 @@ normal_cmd(oap, toplevel)
msg_nowait = TRUE; /* don't delay going to insert mode */
old_mapped_len = 0; /* do go to Insert mode */
}
-#endif
#ifdef FEAT_CMDL_INFO
need_flushbuf = add_to_showcmd(c);
#endif
getcount:
-#ifdef FEAT_VISUAL
if (!(VIsual_active && VIsual_select))
-#endif
{
/*
* Handle a count before a command and compute ca.count0.
@@ -856,7 +822,6 @@ getcount:
goto normal_end;
#endif
-#ifdef FEAT_VISUAL
/*
* In Visual/Select mode, a few keys are handled in a special way.
*/
@@ -892,7 +857,6 @@ getcount:
}
}
}
-#endif
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl && KeyTyped && !KeyStuffed
@@ -930,11 +894,7 @@ getcount:
&& !Recording
&& !Exec_reg)
|| ((ca.cmdchar == 'a' || ca.cmdchar == 'i')
- && (oap->op_type != OP_NOP
-#ifdef FEAT_VISUAL
- || VIsual_active
-#endif
- ))))
+ && (oap->op_type != OP_NOP || VIsual_active))))
{
int *cp;
int repl = FALSE; /* get character for replace mode */
@@ -1168,7 +1128,6 @@ getcount:
msg_col = 0;
}
-#ifdef FEAT_VISUAL
old_pos = curwin->w_cursor; /* remember where cursor was */
/* When 'keymodel' contains "startsel" some keys start Select/Visual
@@ -1188,7 +1147,6 @@ getcount:
mod_mask &= ~MOD_MASK_SHIFT;
}
}
-#endif
/*
* Execute the command!
@@ -1220,12 +1178,10 @@ getcount:
#endif
}
-#ifdef FEAT_VISUAL
/* Get the length of mapped chars again after typing a count, second
* character or "z333<cr>". */
if (old_mapped_len > 0)
old_mapped_len = typebuf_maplen();
-#endif
/*
* If an operation is pending, handle it...
@@ -1247,11 +1203,9 @@ getcount:
if ( ((p_smd
&& msg_silent == 0
&& (restart_edit != 0
-#ifdef FEAT_VISUAL
|| (VIsual_active
&& old_pos.lnum == curwin->w_cursor.lnum
&& old_pos.col == curwin->w_cursor.col)
-#endif
)
&& (clear_cmdline
|| redraw_cmdline)
@@ -1259,9 +1213,7 @@ getcount:
&& !msg_nowait
&& KeyTyped)
|| (restart_edit != 0
-#ifdef FEAT_VISUAL
&& !VIsual_active
-#endif
&& (msg_scroll
|| emsg_on_display)))
&& oap->regname == 0
@@ -1368,36 +1320,24 @@ normal_end:
* May switch from Visual to Select mode after CTRL-O command.
*/
if ( oap->op_type == OP_NOP
-#ifdef FEAT_VISUAL
&& ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0)
|| restart_VIsual_select == 1)
-#else
- && restart_edit != 0
-#endif
&& !(ca.retval & CA_COMMAND_BUSY)
&& stuff_empty()
&& oap->regname == 0)
{
-#ifdef FEAT_VISUAL
if (restart_VIsual_select == 1)
{
VIsual_select = TRUE;
showmode();
restart_VIsual_select = 0;
}
-#endif
- if (restart_edit != 0
-#ifdef FEAT_VISUAL
- && !VIsual_active && old_mapped_len == 0
-#endif
- )
+ if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0)
(void)edit(restart_edit, FALSE, 1L);
}
-#ifdef FEAT_VISUAL
if (restart_VIsual_select == 2)
restart_VIsual_select = 1;
-#endif
/* Save count before an operator for next time. */
opcount = ca.opcount;
@@ -1437,15 +1377,13 @@ do_pending_operator(cap, old_col, gui_yank)
int empty_region_error;
int restart_edit_save;
-#ifdef FEAT_VISUAL
/* The visual area is remembered for redo */
static int redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
static linenr_T redo_VIsual_line_count; /* number of lines */
static colnr_T redo_VIsual_vcol; /* number of cols or end column */
static long redo_VIsual_count; /* count for Visual operator */
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
int include_line_break = FALSE;
-# endif
#endif
#if defined(FEAT_CLIPBOARD)
@@ -1459,10 +1397,8 @@ do_pending_operator(cap, old_col, gui_yank)
if ((clip_star.available || clip_plus.available)
&& oap->op_type != OP_NOP
&& !gui_yank
-# ifdef FEAT_VISUAL
&& VIsual_active
&& !redo_VIsual_busy
-# endif
&& oap->regname == 0)
clip_auto_select();
#endif
@@ -1471,13 +1407,8 @@ do_pending_operator(cap, old_col, gui_yank)
/*
* If an operation is pending, handle it...
*/
- if ((finish_op
-#ifdef FEAT_VISUAL
- || VIsual_active
-#endif
- ) && oap->op_type != OP_NOP)
+ if ((finish_op || VIsual_active) && oap->op_type != OP_NOP)
{
-#ifdef FEAT_VISUAL
oap->is_VIsual = VIsual_active;
if (oap->motion_force == 'V')
oap->motion_type = MLINE;
@@ -1501,17 +1432,14 @@ do_pending_operator(cap, old_col, gui_yank)
VIsual_select = FALSE;
VIsual_reselect = FALSE;
}
-#endif
/* Only redo yank when 'y' flag is in 'cpoptions'. */
/* Never redo "zf" (define fold). */
if ((vim_strchr(p_cpo, CPO_YANK) != NULL || oap->op_type != OP_YANK)
-#ifdef FEAT_VISUAL
&& ((!VIsual_active || oap->motion_force)
/* Also redo Operator-pending Visual mode mappings */
|| (VIsual_active && cap->cmdchar == ':'
&& oap->op_type != OP_COLON))
-#endif
&& cap->cmdchar != 'D'
#ifdef FEAT_FOLDING
&& oap->op_type != OP_FOLD
@@ -1554,7 +1482,6 @@ do_pending_operator(cap, old_col, gui_yank)
}
}
-#ifdef FEAT_VISUAL
if (redo_VIsual_busy)
{
/* Redo of an operation on a Visual area. Use the same size from
@@ -1639,7 +1566,6 @@ do_pending_operator(cap, old_col, gui_yank)
if (VIsual_mode == 'V')
oap->start.col = 0;
}
-#endif /* FEAT_VISUAL */
/*
* Set oap->start to the first position of the operated text, oap->end
@@ -1690,7 +1616,6 @@ do_pending_operator(cap, old_col, gui_yank)
virtual_op = virtual_active();
#endif
-#ifdef FEAT_VISUAL
if (VIsual_active || redo_VIsual_busy)
{
if (VIsual_mode == Ctrl_V) /* block mode */
@@ -1826,9 +1751,9 @@ do_pending_operator(cap, old_col, gui_yank)
{
oap->motion_type = MCHAR;
if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
&& (include_line_break || !virtual_op)
-# endif
+#endif
)
{
oap->inclusive = FALSE;
@@ -1840,9 +1765,9 @@ do_pending_operator(cap, old_col, gui_yank)
{
++oap->end.lnum;
oap->end.col = 0;
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
oap->end.coladd = 0;
-# endif
+#endif
++oap->line_count;
}
else
@@ -1868,10 +1793,10 @@ do_pending_operator(cap, old_col, gui_yank)
if (!gui_yank)
{
VIsual_active = FALSE;
-# ifdef FEAT_MOUSE
+#ifdef FEAT_MOUSE
setmouse();
mouse_dragging = 0;
-# endif
+#endif
if (mode_displayed)
clear_cmdline = TRUE; /* unshow visual mode later */
#ifdef FEAT_CMDL_INFO
@@ -1886,7 +1811,6 @@ do_pending_operator(cap, old_col, gui_yank)
redraw_curbuf_later(INVERTED);
}
}
-#endif
#ifdef FEAT_MBYTE
/* Include the trailing byte of a multi-byte char. */
@@ -1921,16 +1845,14 @@ do_pending_operator(cap, old_col, gui_yank)
empty_region_error = (oap->empty
&& vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL);
-#ifdef FEAT_VISUAL
/* Force a redraw when operating on an empty Visual region, when
* 'modifiable is off or creating a fold. */
if (oap->is_VIsual && (oap->empty || !curbuf->b_p_ma
-# ifdef FEAT_FOLDING
+#ifdef FEAT_FOLDING
|| oap->op_type == OP_FOLD
-# endif
+#endif
))
redraw_curbuf_later(INVERTED);
-#endif
/*
* If the end of an operator is in column one while oap->motion_type
@@ -1943,10 +1865,8 @@ do_pending_operator(cap, old_col, gui_yank)
&& oap->inclusive == FALSE
&& !(cap->retval & CA_NO_ADJ_OP_END)
&& oap->end.col == 0
-#ifdef FEAT_VISUAL
&& (!oap->is_VIsual || *p_sel == 'o')
&& !oap->block_mode
-#endif
&& oap->line_count > 1)
{
oap->end_adjusted = TRUE; /* remember that we did this */
@@ -1971,11 +1891,7 @@ do_pending_operator(cap, old_col, gui_yank)
{
case OP_LSHIFT:
case OP_RSHIFT:
- op_shift(oap, TRUE,
-#ifdef FEAT_VISUAL
- oap->is_VIsual ? (int)cap->count1 :
-#endif
- 1);
+ op_shift(oap, TRUE, oap->is_VIsual ? (int)cap->count1 : 1);
auto_format(FALSE, TRUE);
break;
@@ -1988,15 +1904,14 @@ do_pending_operator(cap, old_col, gui_yank)
beep_flush();
else
{
- (void)do_join(oap->line_count, oap->op_type == OP_JOIN, TRUE, TRUE);
+ (void)do_join(oap->line_count, oap->op_type == OP_JOIN,
+ TRUE, TRUE);
auto_format(FALSE, TRUE);
}
break;
case OP_DELETE:
-#ifdef FEAT_VISUAL
VIsual_reselect = FALSE; /* don't reselect now */
-#endif
if (empty_region_error)
{
vim_beep();
@@ -2026,9 +1941,7 @@ do_pending_operator(cap, old_col, gui_yank)
break;
case OP_CHANGE:
-#ifdef FEAT_VISUAL
VIsual_reselect = FALSE; /* don't reselect now */
-#endif
if (empty_region_error)
{
vim_beep();
@@ -2126,9 +2039,7 @@ do_pending_operator(cap, old_col, gui_yank)
case OP_INSERT:
case OP_APPEND:
-#ifdef FEAT_VISUAL
VIsual_reselect = FALSE; /* don't reselect now */
-#endif
#ifdef FEAT_VISUALEXTRA
if (empty_region_error)
{
@@ -2158,9 +2069,7 @@ do_pending_operator(cap, old_col, gui_yank)
break;
case OP_REPLACE:
-#ifdef FEAT_VISUAL
VIsual_reselect = FALSE; /* don't reselect now */
-#endif
#ifdef FEAT_VISUALEXTRA
if (empty_region_error)
#endif
@@ -2220,9 +2129,7 @@ do_pending_operator(cap, old_col, gui_yank)
{
curwin->w_cursor = old_cursor;
}
-#ifdef FEAT_VISUAL
oap->block_mode = FALSE;
-#endif
clearop(oap);
}
}
@@ -2235,11 +2142,9 @@ op_colon(oap)
oparg_T *oap;
{
stuffcharReadbuff(':');
-#ifdef FEAT_VISUAL
if (oap->is_VIsual)
stuffReadbuff((char_u *)"'<,'>");
else
-#endif
{
/*
* Make the range look nice, so it can be repeated.
@@ -2404,14 +2309,12 @@ do_mouse(oap, c, dir, count, fixindent)
pos_T save_cursor;
#endif
win_T *old_curwin = curwin;
-#ifdef FEAT_VISUAL
static pos_T orig_cursor;
colnr_T leftcol, rightcol;
pos_T end_visual;
int diff;
int old_active = VIsual_active;
int old_mode = VIsual_mode;
-#endif
int regname;
#if defined(FEAT_FOLDING)
@@ -2432,15 +2335,12 @@ do_mouse(oap, c, dir, count, fixindent)
if (!gui.in_use)
#endif
{
-#ifdef FEAT_VISUAL
if (VIsual_active)
{
if (!mouse_has(MOUSE_VISUAL))
return FALSE;
}
- else
-#endif
- if (State == NORMAL && !mouse_has(MOUSE_NORMAL))
+ else if (State == NORMAL && !mouse_has(MOUSE_NORMAL))
return FALSE;
}
@@ -2509,14 +2409,6 @@ do_mouse(oap, c, dir, count, fixindent)
}
}
-#ifndef FEAT_VISUAL
- /*
- * ALT is only used for starting/extending Visual mode.
- */
- if ((mod_mask & MOD_MASK_ALT))
- return FALSE;
-#endif
-
/*
* CTRL right mouse button does CTRL-T
*/
@@ -2586,7 +2478,6 @@ do_mouse(oap, c, dir, count, fixindent)
return FALSE;
}
-#ifdef FEAT_VISUAL
/*
* If visual was active, yank the highlighted text and put it
* before the mouse pointer position.
@@ -2607,7 +2498,6 @@ do_mouse(oap, c, dir, count, fixindent)
do_always = TRUE; /* ignore 'mouse' setting next time */
return FALSE;
}
-#endif
/*
* The rest is below jump_to_mouse()
*/
@@ -2761,7 +2651,6 @@ do_mouse(oap, c, dir, count, fixindent)
{
/* First set the cursor position before showing the popup
* menu. */
-#ifdef FEAT_VISUAL
if (VIsual_active)
{
pos_T m_pos;
@@ -2800,16 +2689,11 @@ do_mouse(oap, c, dir, count, fixindent)
}
else
jump_flags = MOUSE_MAY_STOP_VIS;
-#endif
}
if (jump_flags)
{
jump_flags = jump_to_mouse(jump_flags, NULL, which_button);
- update_curbuf(
-#ifdef FEAT_VISUAL
- VIsual_active ? INVERTED :
-#endif
- VALID);
+ update_curbuf(VIsual_active ? INVERTED : VALID);
setcursor();
out_flush(); /* Update before showing popup menu */
}
@@ -2832,7 +2716,6 @@ do_mouse(oap, c, dir, count, fixindent)
}
}
-#ifdef FEAT_VISUAL
if ((State & (NORMAL | INSERT))
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))
{
@@ -2872,7 +2755,6 @@ do_mouse(oap, c, dir, count, fixindent)
jump_flags |= MOUSE_MAY_VIS;
}
}
-#endif
/*
* If an operator is pending, ignore all drags and releases until the
@@ -2941,7 +2823,6 @@ do_mouse(oap, c, dir, count, fixindent)
}
#endif
-#ifdef FEAT_VISUAL
/* Set global flag that we are extending the Visual area with mouse
* dragging; temporarily minimize 'scrolloff'. */
if (VIsual_active && is_drag && p_so)
@@ -3040,7 +2921,6 @@ do_mouse(oap, c, dir, count, fixindent)
*/
else if ((State & INSERT) && VIsual_active)
stuffcharReadbuff(Ctrl_O);
-#endif
/*
* Middle mouse click: Put text before cursor.
@@ -3118,11 +2998,7 @@ do_mouse(oap, c, dir, count, fixindent)
*/
else if ((mod_mask & MOD_MASK_SHIFT))
{
- if (State & INSERT
-#ifdef FEAT_VISUAL
- || (VIsual_active && VIsual_select)
-#endif
- )
+ if ((State & INSERT) || (VIsual_active && VIsual_select))
stuffcharReadbuff(Ctrl_O);
if (which_button == MOUSE_LEFT)
stuffcharReadbuff('*');
@@ -3153,7 +3029,6 @@ do_mouse(oap, c, dir, count, fixindent)
# endif
}
#endif
-#ifdef FEAT_VISUAL
else if ((mod_mask & MOD_MASK_MULTI_CLICK) && (State & (NORMAL | INSERT))
&& mouse_has(MOUSE_VISUAL))
{
@@ -3267,12 +3142,10 @@ do_mouse(oap, c, dir, count, fixindent)
|| (VIsual_active && p_smd && msg_silent == 0
&& (!old_active || VIsual_mode != old_mode)))
redraw_cmdline = TRUE;
-#endif
return moved;
}
-#ifdef FEAT_VISUAL
/*
* Move "pos" back to the start of the word it's in.
*/
@@ -3372,10 +3245,8 @@ get_mouse_class(p)
return 1;
return c;
}
-#endif /* FEAT_VISUAL */
#endif /* FEAT_MOUSE */
-#if defined(FEAT_VISUAL) || defined(PROTO)
/*
* Check if highlighting for visual mode is possible, give a warning message
* if not.
@@ -3468,7 +3339,6 @@ reset_VIsual()
VIsual_reselect = FALSE;
}
}
-#endif /* FEAT_VISUAL */
#if defined(FEAT_BEVAL)
static int find_is_eval_item __ARGS((char_u *ptr, int *colp, int *nbp, int dir));
@@ -3802,11 +3672,7 @@ checkclearop(oap)
checkclearopq(oap)
oparg_T *oap;
{
- if (oap->op_type == OP_NOP
-#ifdef FEAT_VISUAL
- && !VIsual_active
-#endif
- )
+ if (oap->op_type == OP_NOP && !VIsual_active)
return FALSE;
clearopbeep(oap);
return TRUE;
@@ -3830,7 +3696,6 @@ clearopbeep(oap)
beep_flush();
}
-#ifdef FEAT_VISUAL
/*
* Remove the shift modifier from a special key.
*/
@@ -3849,18 +3714,13 @@ unshift_special(cap)
}
cap->cmdchar = simplify_key(cap->cmdchar, &mod_mask);
}
-#endif
#if defined(FEAT_CMDL_INFO) || defined(PROTO)
/*
* Routines for displaying a partly typed command
*/
-#ifdef FEAT_VISUAL /* need room for size of Visual area */
-# define SHOWCMD_BUFLEN SHOWCMD_COLS + 1 + 30
-#else
-# define SHOWCMD_BUFLEN SHOWCMD_COLS + 1
-#endif
+#define SHOWCMD_BUFLEN SHOWCMD_COLS + 1 + 30
static char_u showcmd_buf[SHOWCMD_BUFLEN];
static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; /* For push_showcmd() */
static int showcmd_is_clear = TRUE;
@@ -3874,7 +3734,6 @@ clear_showcmd()
if (!p_sc)
return;
-#ifdef FEAT_VISUAL
if (VIsual_active && !char_avail())
{
int cursor_bot = lt(VIsual, curwin->w_cursor);
@@ -3960,7 +3819,6 @@ clear_showcmd()
showcmd_visual = TRUE;
}
else
-#endif
{
showcmd_buf[0] = NUL;
showcmd_visual = FALSE;
@@ -4203,10 +4061,8 @@ check_scrollbind(topline_diff, leftcol_diff)
int want_hor;
win_T *old_curwin = curwin;
buf_T *old_curbuf = curbuf;
-#ifdef FEAT_VISUAL
int old_VIsual_select = VIsual_select;
int old_VIsual_active = VIsual_active;
-#endif
colnr_T tgt_leftcol = curwin->w_leftcol;
long topline;
long y;
@@ -4223,9 +4079,7 @@ check_scrollbind(topline_diff, leftcol_diff)
/*
* loop through the scrollbound windows and scroll accordingly
*/
-#ifdef FEAT_VISUAL
VIsual_select = VIsual_active = 0;
-#endif
for (curwin = firstwin; curwin; curwin = curwin->w_next)
{
curbuf = curwin->w_buffer;
@@ -4280,10 +4134,8 @@ check_scrollbind(topline_diff, leftcol_diff)
/*
* reset current-window
*/
-#ifdef FEAT_VISUAL
VIsual_select = old_VIsual_select;
VIsual_active = old_VIsual_active;
-#endif
curwin = old_curwin;
curbuf = old_curbuf;
}
@@ -5239,11 +5091,9 @@ dozet:
if (checkclearop(cap->oap))
break;
-# ifdef FEAT_VISUAL
if (VIsual_active && get_visual_text(cap, &ptr, &len)
== FAIL)
return;
-# endif
if (ptr == NULL)
{
pos_T pos = curwin->w_cursor;
@@ -5411,12 +5261,9 @@ nv_exmode(cap)
/*
* Ignore 'Q' in Visual mode, just give a beep.
*/
-#ifdef FEAT_VISUAL
if (VIsual_active)
vim_beep();
- else
-#endif
- if (!checkclearop(cap->oap))
+ else if (!checkclearop(cap->oap))
do_exmode(FALSE);
}
@@ -5430,11 +5277,9 @@ nv_colon(cap)
int old_p_im;
int cmd_result;
-#ifdef FEAT_VISUAL
if (VIsual_active)
nv_operator(cap);
else
-#endif
{
if (cap->oap->op_type != OP_NOP)
{
@@ -5494,15 +5339,12 @@ nv_colon(cap)
nv_ctrlg(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
if (VIsual_active) /* toggle Selection/Visual mode */
{
VIsual_select = !VIsual_select;
showmode();
}
- else
-#endif
- if (!checkclearop(cap->oap))
+ else if (!checkclearop(cap->oap))
/* print full name if count given or :cd used */
fileinfo((int)cap->count0, FALSE, TRUE);
}
@@ -5514,14 +5356,12 @@ nv_ctrlg(cap)
nv_ctrlh(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
if (VIsual_active && VIsual_select)
{
cap->cmdchar = 'x'; /* BS key behaves like 'x' in Select mode */
v_visop(cap);
}
else
-#endif
nv_left(cap);
}
@@ -5558,7 +5398,6 @@ nv_clear(cap)
nv_ctrlo(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
if (VIsual_active && VIsual_select)
{
VIsual_select = FALSE;
@@ -5566,7 +5405,6 @@ nv_ctrlo(cap)
restart_VIsual_select = 2; /* restart Select mode later */
}
else
-#endif
{
cap->count1 = -cap->count1;
nv_pcmark(cap);
@@ -5675,10 +5513,8 @@ nv_ident(cap)
*/
if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K')
{
-#ifdef FEAT_VISUAL
if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL)
return;
-#endif
if (checkclearopq(cap->oap))
return;
}
@@ -5872,7 +5708,6 @@ nv_ident(cap)
vim_free(buf);
}
-#if defined(FEAT_VISUAL) || defined(PROTO)
/*
* Get visually selected text, within one line only.
* Returns FAIL if more than one line selected.
@@ -5917,7 +5752,6 @@ get_visual_text(cap, pp, lenp)
reset_VIsual_and_resel();
return OK;
}
-#endif
/*
* CTRL-T: backwards in tag stack
@@ -6040,11 +5874,7 @@ nv_right(cap)
cmdarg_T *cap;
{
long n;
-#ifdef FEAT_VISUAL
- int PAST_LINE;
-#else
-# define PAST_LINE 0
-#endif
+ int past_line;
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
{
@@ -6057,25 +5887,21 @@ nv_right(cap)
cap->oap->motion_type = MCHAR;
cap->oap->inclusive = FALSE;
-#ifdef FEAT_VISUAL
- PAST_LINE = (VIsual_active && *p_sel != 'o');
+ past_line = (VIsual_active && *p_sel != 'o');
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
/*
- * In virtual mode, there's no such thing as "PAST_LINE", as lines are
- * (theoretically) infinitely long.
+ * 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
+ past_line = 0;
#endif
for (n = cap->count1; n > 0; --n)
{
- if ((!PAST_LINE && oneright() == FAIL)
-#ifdef FEAT_VISUAL
- || (PAST_LINE && *ml_get_cursor() == NUL)
-#endif
+ if ((!past_line && oneright() == FAIL)
+ || (past_line && *ml_get_cursor() == NUL)
)
{
/*
@@ -6123,26 +5949,24 @@ nv_right(cap)
}
break;
}
-#ifdef FEAT_VISUAL
- else if (PAST_LINE)
+ else if (past_line)
{
curwin->w_set_curswant = TRUE;
-# ifdef FEAT_VIRTUALEDIT
+#ifdef FEAT_VIRTUALEDIT
if (virtual_active())
oneright();
else
-# endif
+#endif
{
-# ifdef FEAT_MBYTE
+#ifdef FEAT_MBYTE
if (has_mbyte)
curwin->w_cursor.col +=
(*mb_ptr2len)(ml_get_cursor());
else
-# endif
+#endif
++curwin->w_cursor.col;
}
}
-#endif
}
#ifdef FEAT_FOLDING
if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
@@ -6503,9 +6327,7 @@ nv_csearch(cap)
else
curwin->w_cursor.coladd = 0;
#endif
-#ifdef FEAT_VISUAL
adjust_for_sel(cap);
-#endif
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
foldOpenCursor();
@@ -6754,7 +6576,6 @@ nv_brackets(cap)
int dir = (cap->cmdchar == ']' && cap->nchar == 'p')
? FORWARD : BACKWARD;
int regname = cap->oap->regname;
-#ifdef FEAT_VISUAL
int was_visual = VIsual_active;
int line_count = curbuf->b_ml.ml_line_count;
pos_T start, end;
@@ -6766,14 +6587,12 @@ nv_brackets(cap)
end = equalpos(start,VIsual) ? curwin->w_cursor : VIsual;
curwin->w_cursor = (dir == BACKWARD ? start : end);
}
-#endif
# ifdef FEAT_CLIPBOARD
adjust_clip_reg(&regname);
# endif
prep_redo_cmd(cap);
do_put(regname, dir, cap->count1, PUT_FIXINDENT);
-#ifdef FEAT_VISUAL
if (was_visual)
{
VIsual = start;
@@ -6802,7 +6621,6 @@ nv_brackets(cap)
redraw_later(SOME_VALID);
}
}
-#endif
}
}
@@ -6936,9 +6754,7 @@ nv_percent(cap)
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
-#ifdef FEAT_VISUAL
adjust_for_sel(cap);
-#endif
}
}
#ifdef FEAT_FOLDING
@@ -7027,11 +6843,7 @@ nv_findpar(cap)
nv_undo(cap)
cmdarg_T *cap;
{
- if (cap->oap->op_type == OP_LOWER
-#ifdef FEAT_VISUAL
- || VIsual_active
-#endif
- )
+ if (cap->oap->op_type == OP_LOWER || VIsual_active)
{
/* translate "<Visual>u" to "<Visual>gu" and "guu" to "gugu" */
cap->cmdchar = 'g';
@@ -7089,7 +6901,6 @@ nv_replace(cap)
return;
}
-#ifdef FEAT_VISUAL
/* Visual mode "r" */
if (VIsual_active)
{
@@ -7105,7 +6916,6 @@ nv_replace(cap)
nv_operator(cap);
return;
}
-#endif
#ifdef FEAT_VIRTUALEDIT
/* Break tabs, etc. */
@@ -7273,7 +7083,6 @@ nv_replace(cap)
}
}
-#ifdef FEAT_VISUAL
/*
* 'o': Exchange start and end of Visual area.
* 'O': same, but in block mode exchange left and right corners.
@@ -7326,7 +7135,6 @@ v_swap_corners(cmdchar)
curwin->w_set_curswant = TRUE;
}
}
-#endif /* FEAT_VISUAL */
/*
* "R" (cap->arg is FALSE) and "gR" (cap->arg is TRUE).
@@ -7335,7 +7143,6 @@ v_swap_corners(cmdchar)
nv_Replace(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
if (VIsual_active) /* "R" is replace lines */
{
cap->cmdchar = 'c';
@@ -7344,9 +7151,7 @@ nv_Replace(cap)
VIsual_mode = 'V';
nv_operator(cap);
}
- else
-#endif
- if (!checkclearopq(cap->oap))
+ else if (!checkclearopq(cap->oap))
{
if (!curbuf->b_p_ma)
EMSG(_(e_modifiable));
@@ -7369,16 +7174,13 @@ nv_Replace(cap)
nv_vreplace(cap)
cmdarg_T *cap;
{
-# ifdef FEAT_VISUAL
if (VIsual_active)
{
cap->cmdchar = 'r';
cap->nchar = cap->extra_char;
nv_replace(cap); /* Do same as "r" in Visual mode for now */
}
- else
-# endif
- if (!checkclearopq(cap->oap))
+ else if (!checkclearopq(cap->oap))
{
if (!curbuf->b_p_ma)
EMSG(_(e_modifiable));
@@ -7525,7 +7327,6 @@ nv_cursormark(cap, flag, pos)
curwin->w_set_curswant = TRUE;
}
-#ifdef FEAT_VISUAL
/*
* Handle commands that are operators in Visual mode.
*/
@@ -7550,7 +7351,6 @@ v_visop(cap)
cap->cmdchar = *(vim_strchr(trans, cap->cmdchar) + 1);
nv_operator(cap);
}
-#endif
/*
* "s" and "S" commands.
@@ -7559,7 +7359,6 @@ v_visop(cap)
nv_subst(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
if (VIsual_active) /* "vs" and "vS" are the same as "vc" */
{
if (cap->cmdchar == 'S')
@@ -7571,7 +7370,6 @@ nv_subst(cap)
nv_operator(cap);
}
else
-#endif
nv_optrans(cap);
}
@@ -7585,12 +7383,10 @@ nv_abbrev(cap)
if (cap->cmdchar == K_DEL || cap->cmdchar == K_KDEL)
cap->cmdchar = 'x'; /* DEL key behaves like 'x' */
-#ifdef FEAT_VISUAL
/* in Visual mode these commands are operators */
if (VIsual_active)
v_visop(cap);
else
-#endif
nv_optrans(cap);
}
@@ -7758,7 +7554,6 @@ nv_regname(cap)
clearopbeep(cap->oap);
}
-#ifdef FEAT_VISUAL
/*
* Handle "v", "V" and "CTRL-V" commands.
* Also for "gh", "gH" and "g^H" commands: Always start Select mode, cap->arg
@@ -7950,7 +7745,6 @@ n_start_visual_mode(c)
}
}
-#endif /* FEAT_VISUAL */
/*
* CTRL-W: Window commands
@@ -7975,10 +7769,8 @@ nv_suspend(cap)
cmdarg_T *cap;
{
clearop(cap->oap);
-#ifdef FEAT_VISUAL
if (VIsual_active)
end_visual_mode(); /* stop Visual mode */
-#endif
do_cmdline_cmd((char_u *)"st");
}
@@ -7990,9 +7782,7 @@ nv_g_cmd(cap)
cmdarg_T *cap;
{
oparg_T *oap = cap->oap;
-#ifdef FEAT_VISUAL
pos_T tpos;
-#endif
int i;
int flag = FALSE;
@@ -8025,7 +7815,6 @@ nv_g_cmd(cap)
do_cmdline_cmd((char_u *)"%s//~/&");
break;
-#ifdef FEAT_VISUAL
/*
* "gv": Reselect the previous Visual area. If Visual already active,
* exchange previous and current Visual area.
@@ -8126,7 +7915,6 @@ nv_g_cmd(cap)
cap->arg = TRUE;
nv_visual(cap);
break;
-#endif /* FEAT_VISUAL */
/* "gn", "gN" visually select next/previous search match
* "gn" selects next match
@@ -8134,9 +7922,7 @@ nv_g_cmd(cap)
*/
case 'N':
case 'n':
-#ifdef FEAT_VISUAL
if (!current_search(cap->count1, cap->nchar == 'n'))
-#endif
clearopbeep(oap);
break;
@@ -8258,9 +8044,7 @@ nv_g_cmd(cap)
&& vim_iswhite(ptr[curwin->w_cursor.col]))
--curwin->w_cursor.col;
curwin->w_set_curswant = TRUE;
-#ifdef FEAT_VISUAL
adjust_for_sel(cap);
-#endif
}
break;
@@ -8657,11 +8441,7 @@ nv_Undo(cap)
cmdarg_T *cap;
{
/* In Visual mode and typing "gUU" triggers an operator */
- if (cap->oap->op_type == OP_UPPER
-#ifdef FEAT_VISUAL
- || VIsual_active
-#endif
- )
+ if (cap->oap->op_type == OP_UPPER || VIsual_active)
{
/* translate "gUU" to "gUgU" */
cap->cmdchar = 'g';
@@ -8683,11 +8463,7 @@ nv_Undo(cap)
nv_tilde(cap)
cmdarg_T *cap;
{
- if (!p_to
-#ifdef FEAT_VISUAL
- && !VIsual_active
-#endif
- && cap->oap->op_type != OP_TILDE)
+ if (!p_to && !VIsual_active && cap->oap->op_type != OP_TILDE)
n_swapchar(cap);
else
nv_operator(cap);
@@ -8906,9 +8682,7 @@ nv_wordcmd(cap)
clearopbeep(cap->oap);
else
{
-#ifdef FEAT_VISUAL
adjust_for_sel(cap);
-#endif
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
foldOpenCursor();
@@ -8931,9 +8705,7 @@ adjust_cursor(oap)
* - 'virtualedit' is not "all" and not "onemore".
*/
if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL
-#ifdef FEAT_VISUAL
&& (!VIsual_active || *p_sel == 'o')
-#endif
#ifdef FEAT_VIRTUALEDIT
&& !virtual_active() && (ve_flags & VE_ONEMORE) == 0
#endif
@@ -8968,7 +8740,6 @@ nv_beginline(cap)
one-character line). */
}
-#ifdef FEAT_VISUAL
/*
* In exclusive Visual mode, may include the last character.
*/
@@ -8979,11 +8750,11 @@ adjust_for_sel(cap)
if (VIsual_active && cap->oap->inclusive && *p_sel == 'e'
&& gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor))
{
-# ifdef FEAT_MBYTE
+#ifdef FEAT_MBYTE
if (has_mbyte)
inc_cursor();
else
-# endif
+#endif
++curwin->w_cursor.col;
cap->oap->inclusive = FALSE;
}
@@ -9044,7 +8815,6 @@ nv_select(cap)
}
}
-#endif
/*
* "G", "gg", CTRL-END, CTRL-HOME.
@@ -9095,13 +8865,11 @@ nv_normal(cap)
if (cmdwin_type != 0)
cmdwin_result = Ctrl_C;
#endif
-#ifdef FEAT_VISUAL
if (VIsual_active)
{
end_visual_mode(); /* stop Visual */
redraw_curbuf_later(INVERTED);
}
-#endif
/* CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. */
if (cap->nchar == Ctrl_G && p_im)
restart_edit = 'a';
@@ -9132,9 +8900,7 @@ nv_esc(cap)
#ifdef FEAT_CMDWIN
&& cmdwin_type == 0
#endif
-#ifdef FEAT_VISUAL
&& !VIsual_active
-#endif
&& no_reason)
MSG(_("Type :quit<Enter> to exit Vim"));
@@ -9152,7 +8918,6 @@ nv_esc(cap)
#endif
}
-#ifdef FEAT_VISUAL
if (VIsual_active)
{
end_visual_mode(); /* stop Visual */
@@ -9160,10 +8925,8 @@ nv_esc(cap)
curwin->w_set_curswant = TRUE;
redraw_curbuf_later(INVERTED);
}
- else
-#endif
- if (no_reason)
- vim_beep();
+ else if (no_reason)
+ vim_beep();
clearop(cap->oap);
/* A CTRL-C is often used at the start of a menu. When 'insertmode' is
@@ -9187,20 +8950,13 @@ nv_edit(cap)
if (cap->cmdchar == K_INS || cap->cmdchar == K_KINS)
cap->cmdchar = 'i';
-#ifdef FEAT_VISUAL
/* in Visual mode "A" and "I" are an operator */
if (VIsual_active && (cap->cmdchar == 'A' || cap->cmdchar == 'I'))
v_visop(cap);
/* in Visual mode and after an operator "a" and "i" are for text objects */
- else
-#endif
- if ((cap->cmdchar == 'a' || cap->cmdchar == 'i')
- && (cap->oap->op_type != OP_NOP
-#ifdef FEAT_VISUAL
- || VIsual_active
-#endif
- ))
+ else if ((cap->cmdchar == 'a' || cap->cmdchar == 'i')
+ && (cap->oap->op_type != OP_NOP || VIsual_active))
{
#ifdef FEAT_TEXTOBJ
nv_object(cap);
@@ -9467,12 +9223,9 @@ nv_halfpage(cap)
nv_join(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
if (VIsual_active) /* join the visual lines */
nv_operator(cap);
- else
-#endif
- if (!checkclearop(cap->oap))
+ else if (!checkclearop(cap->oap))
{
if (cap->count0 <= 1)
cap->count0 = 2; /* default for join is two lines! */
@@ -9495,12 +9248,10 @@ nv_join(cap)
nv_put(cap)
cmdarg_T *cap;
{
-#ifdef FEAT_VISUAL
int regname = 0;
void *reg1 = NULL, *reg2 = NULL;
int empty = FALSE;
int was_visual = FALSE;
-#endif
int dir;
int flags = 0;
@@ -9526,7 +9277,6 @@ nv_put(cap)
if (cap->cmdchar == 'g')
flags |= PUT_CURSEND;
-#ifdef FEAT_VISUAL
if (VIsual_active)
{
/* Putting in Visual mode: The put text replaces the selected
@@ -9536,14 +9286,14 @@ nv_put(cap)
*/
was_visual = TRUE;
regname = cap->oap->regname;
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
adjust_clip_reg(&regname);
-# endif
+#endif
if (regname == 0 || regname == '"'
|| VIM_ISDIGIT(regname) || regname == '-'
-# ifdef FEAT_CLIPBOARD
+#ifdef FEAT_CLIPBOARD
|| (clip_unnamed && (regname == '*' || regname == '+'))
-# endif
+#endif
)
{
@@ -9591,10 +9341,8 @@ nv_put(cap)
/* May have been reset in do_put(). */
VIsual_active = TRUE;
}
-#endif
do_put(cap->oap->regname, dir, cap->count1, flags);
-#ifdef FEAT_VISUAL
/* If a register was saved, put it back now. */
if (reg2 != NULL)
put_register(regname, reg2);
@@ -9621,7 +9369,6 @@ nv_put(cap)
coladvance((colnr_T)MAXCOL);
}
}
-#endif
auto_format(FALSE, TRUE);
}
}
@@ -9642,11 +9389,9 @@ nv_open(cap)
}
else
#endif
-#ifdef FEAT_VISUAL
if (VIsual_active) /* switch start and end of visual */
v_swap_corners(cap->cmdchar);
else
-#endif
n_opencmd(cap);
}