changeset 18354:9f51d0cef8da v8.1.2171

patch 8.1.2171: mouse support not always available Commit: https://github.com/vim/vim/commit/a1cb1d1dce14dd005797590721f1bcd0e7c3b35f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 17 23:00:07 2019 +0200 patch 8.1.2171: mouse support not always available Problem: Mouse support not always available. Solution: Enable mouse support also in tiny version. Do not define FEAT_MOUSE_XTERM on MS-Windows (didn't really work).
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Oct 2019 23:15:04 +0200
parents c3a0f5d3c9d4
children 2deddc48eb5c
files src/edit.c src/evalfunc.c src/ex_getln.c src/feature.h src/getchar.c src/globals.h src/message.c src/misc1.c src/mouse.c src/move.c src/normal.c src/ops.c src/option.c src/option.h src/optiondefs.h src/optionstr.c src/os_unix.c src/os_win32.c src/os_win32.h src/register.c src/term.c src/testing.c src/version.c src/vim.h src/window.c
diffstat 25 files changed, 160 insertions(+), 354 deletions(-) [+]
line wrap: on
line diff
--- a/src/edit.c
+++ b/src/edit.c
@@ -235,7 +235,6 @@ edit(
     conceal_check_cursor_line();
 #endif
 
-#ifdef FEAT_MOUSE
     /*
      * When doing a paste with the middle mouse button, Insstart is set to
      * where the paste started.
@@ -243,7 +242,6 @@ edit(
     if (where_paste_started.lnum != 0)
 	Insstart = where_paste_started;
     else
-#endif
     {
 	Insstart = curwin->w_cursor;
 	if (startln)
@@ -336,7 +334,6 @@ edit(
      */
     if (restart_edit != 0 && stuff_empty())
     {
-#ifdef FEAT_MOUSE
 	/*
 	 * After a paste we consider text typed to be part of the insert for
 	 * the pasted text. You can backspace over the pasted text too.
@@ -344,7 +341,6 @@ edit(
 	if (where_paste_started.lnum)
 	    arrow_used = FALSE;
 	else
-#endif
 	    arrow_used = TRUE;
 	restart_edit = 0;
 
@@ -381,9 +377,7 @@ edit(
     /* Need to save the line for undo before inserting the first char. */
     ins_need_undo = TRUE;
 
-#ifdef FEAT_MOUSE
     where_paste_started.lnum = 0;
-#endif
 #ifdef FEAT_CINDENT
     can_cindent = TRUE;
 #endif
@@ -980,7 +974,6 @@ doESCkey:
 	    inserted_space = FALSE;
 	    break;
 
-#ifdef FEAT_MOUSE
 	case K_LEFTMOUSE:   /* mouse keys */
 	case K_LEFTMOUSE_NM:
 	case K_LEFTDRAG:
@@ -1017,7 +1010,7 @@ doESCkey:
 	case K_MOUSERIGHT: /* Scroll wheel right */
 	    ins_mousescroll(MSCR_RIGHT);
 	    break;
-#endif
+
 	case K_PS:
 	    bracketed_paste(PASTE_INSERT, FALSE, NULL);
 	    if (cmdchar == K_PS)
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -815,9 +815,7 @@ static funcentry_T global_functions[] =
 #ifdef FEAT_GUI
     {"test_scrollbar",	3, 3, FEARG_2,	  f_test_scrollbar},
 #endif
-#ifdef FEAT_MOUSE
     {"test_setmouse",	2, 2, 0,	  f_test_setmouse},
-#endif
     {"test_settime",	1, 1, FEARG_1,	  f_test_settime},
 #ifdef FEAT_TIMERS
     {"timer_info",	0, 1, FEARG_1,	  f_timer_info},
@@ -3433,9 +3431,7 @@ f_has(typval_T *argvars, typval_T *rettv
 	"mksession",
 #endif
 	"modify_fname",
-#ifdef FEAT_MOUSE
 	"mouse",
-#endif
 #ifdef FEAT_MOUSESHAPE
 	"mouseshape",
 #endif
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -795,11 +795,9 @@ getcmdline_int(
     int		save_msg_scroll = msg_scroll;
     int		save_State = State;	/* remember State when called */
     int		some_key_typed = FALSE;	/* one of the keys was typed */
-#ifdef FEAT_MOUSE
     /* mouse drag and release events are ignored, unless they are
      * preceded with a mouse down event */
     int		ignore_drag_release = TRUE;
-#endif
 #ifdef FEAT_EVAL
     int		break_ctrl_c = FALSE;
 #endif
@@ -1856,7 +1854,6 @@ getcmdline_int(
 	    break;
 #endif
 
-#ifdef FEAT_MOUSE
 	case K_MIDDLEDRAG:
 	case K_MIDDLERELEASE:
 		goto cmdline_not_changed;	/* Ignore mouse */
@@ -1961,8 +1958,6 @@ getcmdline_int(
 	case K_MOUSEMOVE:
 		goto cmdline_not_changed;
 
-#endif	/* FEAT_MOUSE */
-
 #ifdef FEAT_GUI
 	case K_LEFTMOUSE_NM:	/* mousefocus click, ignored */
 	case K_LEFTRELEASE_NM:
@@ -2195,9 +2190,7 @@ getcmdline_int(
 
 	case Ctrl_V:
 	case Ctrl_Q:
-#ifdef FEAT_MOUSE
 		ignore_drag_release = TRUE;
-#endif
 		putcmdline('^', TRUE);
 		c = get_literal();	    /* get next (two) character(s) */
 		do_abbr = FALSE;	    /* don't do abbreviation now */
@@ -2213,13 +2206,11 @@ getcmdline_int(
 
 #ifdef FEAT_DIGRAPHS
 	case Ctrl_K:
-#ifdef FEAT_MOUSE
 		ignore_drag_release = TRUE;
-#endif
 		putcmdline('?', TRUE);
-#ifdef USE_ON_FLY_SCROLL
+# ifdef USE_ON_FLY_SCROLL
 		dont_scroll = TRUE;	    /* disallow scrolling here */
-#endif
+# endif
 		c = get_digraph(TRUE);
 		extra_char = NUL;
 		if (c != NUL)
@@ -2227,7 +2218,7 @@ getcmdline_int(
 
 		redrawcmd();
 		goto cmdline_not_changed;
-#endif /* FEAT_DIGRAPHS */
+#endif // FEAT_DIGRAPHS
 
 #ifdef FEAT_RIGHTLEFT
 	case Ctrl__:	    /* CTRL-_: switch language mode */
--- a/src/feature.h
+++ b/src/feature.h
@@ -964,12 +964,12 @@
  *			console mouse handling.
  * +mouse_urxvt		Unix only: Include code for for urxvt mosue handling.
  * +mouse		Any mouse support (any of the above enabled).
+ *			Always included, since either FEAT_MOUSE_XTERM or
+ *			DOS_MOUSE is defined.
  */
 /* OS/2 and Amiga console have no mouse support */
-#if !defined(AMIGA)
-# ifdef FEAT_NORMAL
-#  define FEAT_MOUSE_XTERM
-# endif
+#if defined(UNIX) || defined(VMS)
+# define FEAT_MOUSE_XTERM
 # ifdef FEAT_BIG
 #  define FEAT_MOUSE_NET
 # endif
@@ -979,12 +979,12 @@
 # ifdef FEAT_BIG
 #  define FEAT_MOUSE_URXVT
 # endif
-# if defined(FEAT_NORMAL) && defined(MSWIN)
-#  define DOS_MOUSE
-# endif
-# if defined(FEAT_NORMAL) && defined(__QNX__)
-#  define FEAT_MOUSE_PTERM
-# endif
+#endif
+#if defined(MSWIN)
+# define DOS_MOUSE
+#endif
+#if defined(__QNX__)
+# define FEAT_MOUSE_PTERM
 #endif
 
 /*
@@ -1002,28 +1002,11 @@
 # define FEAT_SYSMOUSE
 #endif
 
-/* urxvt is a small variation of mouse_xterm, and shares its code */
+// urxvt is a small variation of mouse_xterm, and shares its code
 #if defined(FEAT_MOUSE_URXVT) && !defined(FEAT_MOUSE_XTERM)
 # define FEAT_MOUSE_XTERM
 #endif
 
-/* Define FEAT_MOUSE when any of the above is defined or FEAT_GUI. */
-#if !defined(FEAT_MOUSE_TTY) \
-	&& (defined(FEAT_MOUSE_XTERM) \
-	    || defined(FEAT_MOUSE_NET) \
-	    || defined(FEAT_MOUSE_DEC) \
-	    || defined(DOS_MOUSE) \
-	    || defined(FEAT_MOUSE_GPM) \
-	    || defined(FEAT_MOUSE_JSB) \
-	    || defined(FEAT_MOUSE_PTERM) \
-	    || defined(FEAT_SYSMOUSE) \
-	    || defined(FEAT_MOUSE_URXVT))
-# define FEAT_MOUSE_TTY		/* include non-GUI mouse support */
-#endif
-#if !defined(FEAT_MOUSE) && (defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI))
-# define FEAT_MOUSE		/* include generic mouse support */
-#endif
-
 /*
  * +clipboard		Clipboard support.  Always used for the GUI.
  * +xterm_clipboard	Unix only: Include code for handling the clipboard
@@ -1093,7 +1076,7 @@
  *			to check if mouse dragging can be used and if term
  *			codes can be obtained.
  */
-#if (defined(FEAT_NORMAL) || defined(FEAT_MOUSE)) && defined(HAVE_TGETENT)
+#if defined(HAVE_TGETENT)
 # define FEAT_TERMRESPONSE
 #endif
 
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1325,10 +1325,8 @@ save_typebuf(void)
 
 static int old_char = -1;	/* character put back by vungetc() */
 static int old_mod_mask;	/* mod_mask for ungotten character */
-#ifdef FEAT_MOUSE
 static int old_mouse_row;	/* mouse_row related to old_char */
 static int old_mouse_col;	/* mouse_col related to old_char */
-#endif
 
 /*
  * Save all three kinds of typeahead, so that the user must type at a prompt.
@@ -1559,10 +1557,8 @@ vgetc(void)
 	c = old_char;
 	old_char = -1;
 	mod_mask = old_mod_mask;
-#ifdef FEAT_MOUSE
 	mouse_row = old_mouse_row;
 	mouse_col = old_mouse_col;
-#endif
     }
     else
     {
@@ -2007,7 +2003,6 @@ f_getchar(typval_T *argvars, typval_T *r
 	rettv->v_type = VAR_STRING;
 	rettv->vval.v_string = vim_strsave(temp);
 
-#ifdef FEAT_MOUSE
 	if (is_mouse_key(n))
 	{
 	    int		row = mouse_row;
@@ -2025,11 +2020,11 @@ f_getchar(typval_T *argvars, typval_T *r
 		if (win == NULL)
 		    return;
 		(void)mouse_comp_pos(win, &row, &col, &lnum, NULL);
-# ifdef FEAT_TEXT_PROP
+#ifdef FEAT_TEXT_PROP
 		if (WIN_IS_POPUP(win))
 		    winnr = 0;
 		else
-# endif
+#endif
 		    for (wp = firstwin; wp != win && wp != NULL;
 							       wp = wp->w_next)
 			++winnr;
@@ -2039,7 +2034,6 @@ f_getchar(typval_T *argvars, typval_T *r
 		set_vim_var_nr(VV_MOUSE_COL, col + 1);
 	    }
 	}
-#endif
     }
 }
 
@@ -2636,10 +2630,8 @@ vungetc(int c)
 {
     old_char = c;
     old_mod_mask = mod_mask;
-#ifdef FEAT_MOUSE
     old_mouse_row = mouse_row;
     old_mouse_col = mouse_col;
-#endif
 }
 
 /*
--- a/src/globals.h
+++ b/src/globals.h
@@ -470,7 +470,6 @@ EXTERN bufref_T	au_new_curbuf INIT(= {NU
 EXTERN buf_T	*au_pending_free_buf INIT(= NULL);
 EXTERN win_T	*au_pending_free_win INIT(= NULL);
 
-#ifdef FEAT_MOUSE
 /*
  * Mouse coordinates, set by check_termcode()
  */
@@ -480,15 +479,15 @@ EXTERN int	mouse_past_bottom INIT(= FALS
 EXTERN int	mouse_past_eol INIT(= FALSE);	// mouse right of line
 EXTERN int	mouse_dragging INIT(= 0);	// extending Visual area with
 						// mouse dragging
-# if defined(FEAT_MOUSE_DEC)
+#if defined(FEAT_MOUSE_DEC)
 /*
  * When the DEC mouse has been pressed but not yet released we enable
  * automatic queries for the mouse position.
  */
 EXTERN int	WantQueryMouse INIT(= FALSE);
-# endif
+#endif
 
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
 // When the window layout is about to be changed, need_mouse_correct is set,
 // so that gui_mouse_correct() is called afterwards, to correct the mouse
 // pointer when focus-follow-mouse is being used.
@@ -496,10 +495,10 @@ EXTERN int	need_mouse_correct INIT(= FAL
 
 // When double clicking, topline must be the same
 EXTERN linenr_T gui_prev_topline INIT(= 0);
-#  ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
 EXTERN int	gui_prev_topfill INIT(= 0);
-#  endif
 # endif
+#endif
 
 # ifdef FEAT_MOUSESHAPE
 EXTERN int	drag_status_line INIT(= FALSE);	// dragging the status line
@@ -508,7 +507,6 @@ EXTERN int	postponed_mouseshape INIT(= F
 EXTERN int	drag_sep_line INIT(= FALSE);	// dragging vert separator
 # endif
 
-#endif
 
 #ifdef FEAT_DIFF
 // Value set from 'diffopt'.
@@ -785,13 +783,11 @@ EXTERN int	resel_VIsual_mode INIT(= NUL)
 EXTERN linenr_T	resel_VIsual_line_count;	// number of lines
 EXTERN colnr_T	resel_VIsual_vcol;		// nr of cols or end col
 
-#ifdef FEAT_MOUSE
 /*
  * When pasting text with the middle mouse button in visual mode with
  * restart_edit set, remember where it started so we can set Insstart.
  */
 EXTERN pos_T	where_paste_started;
-#endif
 
 /*
  * This flag is used to make auto-indent work right on lines where only a
--- a/src/message.c
+++ b/src/message.c
@@ -1200,7 +1200,6 @@ wait_return(int redraw)
 #ifdef FEAT_GUI
 				|| c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR
 #endif
-#ifdef FEAT_MOUSE
 				|| c == K_LEFTDRAG   || c == K_LEFTRELEASE
 				|| c == K_MIDDLEDRAG || c == K_MIDDLERELEASE
 				|| c == K_RIGHTDRAG  || c == K_RIGHTRELEASE
@@ -1214,19 +1213,15 @@ wait_return(int redraw)
 					|| c == K_RIGHTMOUSE
 					|| c == K_X1MOUSE
 					|| c == K_X2MOUSE))
-#endif
 				);
 	ui_breakcheck();
-#ifdef FEAT_MOUSE
 	/*
 	 * Avoid that the mouse-up event causes visual mode to start.
 	 */
 	if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE
 					  || c == K_X1MOUSE || c == K_X2MOUSE)
 	    (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0);
-	else
-#endif
-	    if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C)
+	else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C)
 	{
 	    /* Put the character back in the typeahead buffer.  Don't use the
 	     * stuff buffer, because lmaps wouldn't work. */
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -847,9 +847,7 @@ get_keystroke(void)
 	    n = TO_SPECIAL(buf[1], buf[2]);
 	    if (buf[1] == KS_MODIFIER
 		    || n == K_IGNORE
-#ifdef FEAT_MOUSE
 		    || (is_mouse_key(n) && n != K_LEFTMOUSE)
-#endif
 #ifdef FEAT_GUI
 		    || n == K_VER_SCROLLBAR
 		    || n == K_HOR_SCROLLBAR
@@ -929,14 +927,12 @@ get_number(
 	    }
 	    n /= 10;
 	}
-#ifdef FEAT_MOUSE
 	else if (mouse_used != NULL && c == K_LEFTMOUSE)
 	{
 	    *mouse_used = TRUE;
 	    n = mouse_row + 1;
 	    break;
 	}
-#endif
 	else if (n == 0 && c == ':' && colon)
 	{
 	    stuffcharReadbuff(':');
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -13,8 +13,6 @@
 
 #include "vim.h"
 
-#if defined(FEAT_MOUSE) || defined(PROTO)
-
 /*
  * Get class of a character for selection: same class means same word.
  * 0: blank
@@ -1258,20 +1256,17 @@ get_pseudo_mouse_code(
     return (int)KE_IGNORE;	    // not recognized, ignore it
 }
 
-# ifdef FEAT_MOUSE_TTY
-#  define HMT_NORMAL	1
-#  define HMT_NETTERM	2
-#  define HMT_DEC	4
-#  define HMT_JSBTERM	8
-#  define HMT_PTERM	16
-#  define HMT_URXVT	32
-#  define HMT_GPM	64
-#  define HMT_SGR	128
-#  define HMT_SGR_REL	256
+# define HMT_NORMAL	1
+# define HMT_NETTERM	2
+# define HMT_DEC	4
+# define HMT_JSBTERM	8
+# define HMT_PTERM	16
+# define HMT_URXVT	32
+# define HMT_GPM	64
+# define HMT_SGR	128
+# define HMT_SGR_REL	256
 static int has_mouse_termcode = 0;
-# endif
 
-# if (!defined(UNIX) || defined(FEAT_MOUSE_TTY)) || defined(PROTO)
     void
 set_mouse_termcode(
     int		n,	// KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE
@@ -1282,7 +1277,6 @@ set_mouse_termcode(
     name[0] = n;
     name[1] = KE_FILLER;
     add_termcode(name, s, FALSE);
-#  ifdef FEAT_MOUSE_TTY
 #   ifdef FEAT_MOUSE_JSB
     if (n == KS_JSBTERM_MOUSE)
 	has_mouse_termcode |= HMT_JSBTERM;
@@ -1319,12 +1313,9 @@ set_mouse_termcode(
 	has_mouse_termcode |= HMT_SGR_REL;
     else
 	has_mouse_termcode |= HMT_NORMAL;
-#  endif
 }
-# endif
 
-# if ((defined(UNIX) || defined(VMS)) \
-	&& defined(FEAT_MOUSE_TTY)) || defined(PROTO)
+# if defined(UNIX) || defined(VMS) || defined(PROTO)
     void
 del_mouse_termcode(
     int		n)	// KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE
@@ -1334,7 +1325,6 @@ del_mouse_termcode(
     name[0] = n;
     name[1] = KE_FILLER;
     del_termcode(name);
-#  ifdef FEAT_MOUSE_TTY
 #   ifdef FEAT_MOUSE_JSB
     if (n == KS_JSBTERM_MOUSE)
 	has_mouse_termcode &= ~HMT_JSBTERM;
@@ -1371,7 +1361,6 @@ del_mouse_termcode(
 	has_mouse_termcode &= ~HMT_SGR_REL;
     else
 	has_mouse_termcode &= ~HMT_NORMAL;
-#  endif
 }
 # endif
 
@@ -1381,15 +1370,13 @@ del_mouse_termcode(
     void
 setmouse(void)
 {
-# ifdef FEAT_MOUSE_TTY
     int	    checkfor;
-# endif
 
 # ifdef FEAT_MOUSESHAPE
     update_mouseshape(-1);
 # endif
 
-# ifdef FEAT_MOUSE_TTY // Should be outside proc, but may break MOUSESHAPE
+    // Should be outside proc, but may break MOUSESHAPE
 #  ifdef FEAT_GUI
     // In the GUI the mouse is always enabled.
     if (gui.in_use)
@@ -1423,7 +1410,6 @@ setmouse(void)
 	mch_setmouse(TRUE);
     else
 	mch_setmouse(FALSE);
-# endif
 }
 
 /*
@@ -2289,7 +2275,7 @@ check_termcode_mouse(
 #   endif
 	   )
 	{
-#   if defined(UNIX) && defined(FEAT_MOUSE_TTY)
+#   if defined(UNIX)
 	    if (use_xterm_mouse() > 1 && mouse_code >= 0x80)
 		// mouse-move event, using MOUSE_DRAG works
 		mouse_code = MOUSE_DRAG;
@@ -2314,7 +2300,7 @@ check_termcode_mouse(
 	}
 #   endif
 
-#   if defined(UNIX) && defined(FEAT_MOUSE_TTY)
+#   if defined(UNIX)
 	else if (use_xterm_mouse() > 1)
 	{
 	    if (mouse_code & MOUSE_DRAG_XTERM)
@@ -2810,10 +2796,8 @@ check_termcode_mouse(
 
     return 0;
 }
-#endif // FEAT_MOUSE
 
 // Functions also used for popup windows.
-#if defined(FEAT_MOUSE) || defined(FEAT_TEXT_PROP) || defined(PROTO)
 
 /*
  * Compute the buffer line position from the screen position "rowp" / "colp" in
@@ -3017,15 +3001,3 @@ vcol2col(win_T *wp, linenr_T lnum, int v
     return (int)(ptr - line);
 }
 #endif
-
-#else // FEAT_MOUSE
-
-/*
- * Dummy implementation of setmouse() to avoid lots of #ifdefs.
- */
-    void
-setmouse(void)
-{
-}
-
-#endif // FEAT_MOUSE
--- a/src/move.c
+++ b/src/move.c
@@ -190,9 +190,7 @@ update_topline(void)
     int		check_topline = FALSE;
     int		check_botline = FALSE;
     long        *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
-#ifdef FEAT_MOUSE
     int		save_so = *so_ptr;
-#endif
 
     /* If there is no valid screen and when the window height is zero just use
      * the cursor line. */
@@ -209,11 +207,9 @@ update_topline(void)
     if (curwin->w_valid & VALID_TOPLINE)
 	return;
 
-#ifdef FEAT_MOUSE
     /* When dragging with the mouse, don't scroll that quickly */
     if (mouse_dragging > 0)
 	*so_ptr = mouse_dragging - 1;
-#endif
 
     old_topline = curwin->w_topline;
 #ifdef FEAT_DIFF
@@ -418,9 +414,7 @@ update_topline(void)
 	    validate_cursor();
     }
 
-#ifdef FEAT_MOUSE
     *so_ptr = save_so;
-#endif
 }
 
 /*
@@ -1751,10 +1745,8 @@ scroll_cursor_top(int min_scroll, int al
     linenr_T	new_topline;
     int		off = get_scrolloff_value();
 
-#ifdef FEAT_MOUSE
     if (mouse_dragging > 0)
 	off = mouse_dragging - 1;
-#endif
 
     /*
      * Decrease topline until:
@@ -2004,11 +1996,7 @@ scroll_cursor_bot(int min_scroll, int se
 	/* Stop when scrolled nothing or at least "min_scroll", found "extra"
 	 * context for 'scrolloff' and counted all lines below the window. */
 	if ((((scrolled <= 0 || scrolled >= min_scroll)
-			&& extra >= (
-#ifdef FEAT_MOUSE
-			    mouse_dragging > 0 ? mouse_dragging - 1 :
-#endif
-			    so))
+		    && extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so))
 		    || boff.lnum + 1 > curbuf->b_ml.ml_line_count)
 		&& loff.lnum <= curwin->w_botline
 #ifdef FEAT_DIFF
@@ -2050,11 +2038,8 @@ scroll_cursor_bot(int min_scroll, int se
 	    used += boff.height;
 	    if (used > curwin->w_height)
 		break;
-	    if (extra < (
-#ifdef FEAT_MOUSE
-			mouse_dragging > 0 ? mouse_dragging - 1 :
-#endif
-			so) || scrolled < min_scroll)
+	    if (extra < ( mouse_dragging > 0 ? mouse_dragging - 1 : so)
+		    || scrolled < min_scroll)
 	    {
 		extra += boff.height;
 		if (boff.lnum >= curwin->w_botline
@@ -2230,13 +2215,11 @@ cursor_correct(void)
      */
     above_wanted = so;
     below_wanted = so;
-#ifdef FEAT_MOUSE
     if (mouse_dragging > 0)
     {
 	above_wanted = mouse_dragging - 1;
 	below_wanted = mouse_dragging - 1;
     }
-#endif
     if (curwin->w_topline == 1)
     {
 	above_wanted = 0;
@@ -2246,10 +2229,7 @@ cursor_correct(void)
     }
     validate_botline();
     if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1
-#ifdef FEAT_MOUSE
-	    && mouse_dragging == 0
-#endif
-	    )
+	    && mouse_dragging == 0)
     {
 	below_wanted = 0;
 	max_off = (curwin->w_height - 1) / 2;
--- a/src/normal.c
+++ b/src/normal.c
@@ -303,7 +303,6 @@ static const struct nv_cmd
 
     /* pound sign */
     {POUND,	nv_ident,	0,			0},
-#ifdef FEAT_MOUSE
     {K_MOUSEUP, nv_mousescroll,	0,			MSCR_UP},
     {K_MOUSEDOWN, nv_mousescroll, 0,			MSCR_DOWN},
     {K_MOUSELEFT, nv_mousescroll, 0,			MSCR_LEFT},
@@ -326,7 +325,6 @@ static const struct nv_cmd
     {K_X2MOUSE, nv_mouse,	0,			0},
     {K_X2DRAG, nv_mouse,	0,			0},
     {K_X2RELEASE, nv_mouse,	0,			0},
-#endif
     {K_IGNORE,	nv_ignore,	NV_KEEPREG,		0},
     {K_NOP,	nv_nop,		0,			0},
     {K_INS,	nv_edit,	0,			0},
@@ -1319,10 +1317,8 @@ end_visual_mode(void)
 #endif
 
     VIsual_active = FALSE;
-#ifdef FEAT_MOUSE
     setmouse();
     mouse_dragging = 0;
-#endif
 
     /* Save the current VIsual area for '< and '> marks, and "gv" */
     curbuf->b_visual.vi_mode = VIsual_mode;
@@ -1849,14 +1845,13 @@ add_to_showcmd(int c)
     int		old_len;
     int		extra_len;
     int		overflow;
-#if defined(FEAT_MOUSE)
     int		i;
     static int	ignore[] =
     {
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
 	K_VER_SCROLLBAR, K_HOR_SCROLLBAR,
 	K_LEFTMOUSE_NM, K_LEFTRELEASE_NM,
-# endif
+#endif
 	K_IGNORE, K_PS,
 	K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE, K_MOUSEMOVE,
 	K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE,
@@ -1866,7 +1861,6 @@ add_to_showcmd(int c)
 	K_CURSORHOLD,
 	0
     };
-#endif
 
     if (!p_sc || msg_silent != 0)
 	return FALSE;
@@ -1877,13 +1871,11 @@ add_to_showcmd(int c)
 	showcmd_visual = FALSE;
     }
 
-#if defined(FEAT_MOUSE)
     /* Ignore keys that are scrollbar updates and mouse clicks */
     if (IS_SPECIAL(c))
 	for (i = 0; ignore[i] != 0; ++i)
 	    if (ignore[i] == c)
 		return FALSE;
-#endif
 
     p = transchar(c);
     if (*p == ' ')
@@ -4625,7 +4617,6 @@ nv_brackets(cmdarg_T *cap)
 	nv_cursormark(cap, cap->nchar == '\'', pos);
     }
 
-#ifdef FEAT_MOUSE
     /*
      * [ or ] followed by a middle mouse click: put selected text with
      * indent adjustment.  Any other button just does as usual.
@@ -4636,7 +4627,6 @@ nv_brackets(cmdarg_T *cap)
 		       (cap->cmdchar == ']') ? FORWARD : BACKWARD,
 		       cap->count1, PUT_FIXINDENT);
     }
-#endif /* FEAT_MOUSE */
 
 #ifdef FEAT_FOLDING
     /*
@@ -6220,7 +6210,6 @@ nv_g_cmd(cmdarg_T *cap)
 	nv_gd(oap, cap->nchar, (int)cap->count0);
 	break;
 
-#ifdef FEAT_MOUSE
     /*
      * g<*Mouse> : <C-*mouse>
      */
@@ -6243,7 +6232,6 @@ nv_g_cmd(cmdarg_T *cap)
 	mod_mask = MOD_MASK_CTRL;
 	(void)do_mouse(oap, cap->nchar, BACKWARD, cap->count1, 0);
 	break;
-#endif
 
     case K_IGNORE:
 	break;
--- a/src/ops.c
+++ b/src/ops.c
@@ -4369,10 +4369,8 @@ do_pending_operator(cmdarg_T *cap, int o
 	    if (!gui_yank)
 	    {
 		VIsual_active = FALSE;
-#ifdef FEAT_MOUSE
 		setmouse();
 		mouse_dragging = 0;
-#endif
 		may_clear_cmdline();
 		if ((oap->op_type == OP_YANK
 			    || oap->op_type == OP_COLON
--- a/src/option.c
+++ b/src/option.c
@@ -4976,9 +4976,7 @@ clear_termoptions(void)
      * outputting a few things that the terminal doesn't understand, but the
      * screen will be cleared later, so this is OK.
      */
-#ifdef FEAT_MOUSE_TTY
-    mch_setmouse(FALSE);	    /* switch mouse off */
-#endif
+    mch_setmouse(FALSE);	    // switch mouse off
 #ifdef FEAT_TITLE
     mch_restore_title(SAVE_RESTORE_BOTH);    /* restore window titles */
 #endif
--- a/src/option.h
+++ b/src/option.h
@@ -979,7 +979,7 @@ EXTERN unsigned tbis_flags;
 # define TBIS_GIANT		0x20
 #endif
 EXTERN long	p_ttyscroll;	// 'ttyscroll'
-#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
+#if defined(UNIX) || defined(VMS)
 EXTERN char_u	*p_ttym;	// 'ttymouse'
 EXTERN unsigned ttym_flags;
 # define TTYM_XTERM		0x01
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -2655,7 +2655,7 @@ static struct vimoption options[] =
 			    (char_u *)&p_tf, PV_NONE,
 			    {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
     {"ttymouse",    "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
-#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
+#if defined(UNIX) || defined(VMS)
 			    (char_u *)&p_ttym, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -47,7 +47,7 @@ static char *(p_toolbar_values[]) = {"te
 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
 static char *(p_tbis_values[]) = {"tiny", "small", "medium", "large", "huge", "giant", NULL};
 #endif
-#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
+#if defined(UNIX) || defined(VMS)
 static char *(p_ttym_values[]) = {"xterm", "xterm2", "dec", "netterm", "jsbterm", "pterm", "urxvt", "sgr", NULL};
 #endif
 static char *(p_ve_values[]) = {"block", "insert", "all", "onemore", NULL};
@@ -110,7 +110,7 @@ didset_string_options(void)
     (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
     (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
     (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
-#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
+#if defined(UNIX) || defined(VMS)
     (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
 #endif
 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
@@ -1588,7 +1588,7 @@ did_set_string_option(
     }
 #endif
 
-#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
+#if defined(UNIX) || defined(VMS)
     // 'ttymouse'
     else if (varp == &p_ttym)
     {
@@ -2254,12 +2254,7 @@ did_set_string_option(
 #endif
 	else if (varp == &p_mouse) // 'mouse'
 	{
-#ifdef FEAT_MOUSE
 	    p = (char_u *)MOUSE_ALL;
-#else
-	    if (*p_mouse != NUL)
-		errmsg = N_("E538: No mouse support");
-#endif
 	}
 #if defined(FEAT_GUI)
 	else if (varp == &p_go) // 'guioptions'
@@ -2389,20 +2384,16 @@ did_set_string_option(
 #endif
     }
 
-#ifdef FEAT_MOUSE
     if (varp == &p_mouse)
     {
-# ifdef FEAT_MOUSE_TTY
 	if (*p_mouse == NUL)
 	    mch_setmouse(FALSE);    // switch mouse off
 	else
-# endif
 	    setmouse();		    // in case 'mouse' changed
     }
-#endif
 
     if (curwin->w_curswant != MAXCOL
-		     && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0)
+		   && (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0)
 	curwin->w_set_curswant = TRUE;
 
 #ifdef FEAT_GUI
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2282,7 +2282,6 @@ use_xterm_like_mouse(char_u *name)
 }
 #endif
 
-#if defined(FEAT_MOUSE_TTY) || defined(PROTO)
 /*
  * Return non-zero when using an xterm mouse, according to 'ttymouse'.
  * Return 1 for "xterm".
@@ -2303,7 +2302,6 @@ use_xterm_mouse(void)
 	return 1;
     return 0;
 }
-#endif
 
     int
 vim_is_iris(char_u *name)
@@ -3592,7 +3590,6 @@ get_tty_info(int fd, ttyinfo_T *info)
 
 #endif /* VMS  */
 
-#if defined(FEAT_MOUSE_TTY) || defined(PROTO)
 static int	mouse_ison = FALSE;
 
 /*
@@ -3601,29 +3598,29 @@ static int	mouse_ison = FALSE;
     void
 mch_setmouse(int on)
 {
-# ifdef FEAT_BEVAL_TERM
+#ifdef FEAT_BEVAL_TERM
     static int	bevalterm_ison = FALSE;
-# endif
+#endif
     int		xterm_mouse_vers;
 
-# if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
+#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
     if (!on)
 	// Make sure not tracing mouse movements.  Important when a button-down
 	// was received but no release yet.
 	stop_xterm_trace();
-# endif
+#endif
 
     if (on == mouse_ison
-# ifdef FEAT_BEVAL_TERM
+#ifdef FEAT_BEVAL_TERM
 	    && p_bevalterm == bevalterm_ison
-# endif
+#endif
 	    )
 	/* return quickly if nothing to do */
 	return;
 
     xterm_mouse_vers = use_xterm_mouse();
 
-# ifdef FEAT_MOUSE_URXVT
+#ifdef FEAT_MOUSE_URXVT
     if (ttym_flags == TTYM_URXVT)
     {
 	out_str_nf((char_u *)
@@ -3632,7 +3629,7 @@ mch_setmouse(int on)
 		   : IF_EB("\033[?1015l", ESC_STR "[?1015l")));
 	mouse_ison = on;
     }
-# endif
+#endif
 
     if (ttym_flags == TTYM_SGR)
     {
@@ -3644,7 +3641,7 @@ mch_setmouse(int on)
 	mouse_ison = on;
     }
 
-# ifdef FEAT_BEVAL_TERM
+#ifdef FEAT_BEVAL_TERM
     if (bevalterm_ison != (p_bevalterm && on))
     {
 	bevalterm_ison = (p_bevalterm && on);
@@ -3653,7 +3650,7 @@ mch_setmouse(int on)
 	    out_str_nf((char_u *)
 			(IF_EB("\033[?1003l", ESC_STR "[?1003l")));
     }
-# endif
+#endif
 
     if (xterm_mouse_vers > 0)
     {
@@ -3661,10 +3658,10 @@ mch_setmouse(int on)
 	    out_str_nf((char_u *)
 		       (xterm_mouse_vers > 1
 			? (
-# ifdef FEAT_BEVAL_TERM
+#ifdef FEAT_BEVAL_TERM
 			    bevalterm_ison
 			       ? IF_EB("\033[?1003h", ESC_STR "[?1003h") :
-# endif
+#endif
 			      IF_EB("\033[?1002h", ESC_STR "[?1002h"))
 			: IF_EB("\033[?1000h", ESC_STR "[?1000h")));
 	else	/* disable mouse events, could probably always send the same */
@@ -3675,7 +3672,7 @@ mch_setmouse(int on)
 	mouse_ison = on;
     }
 
-# ifdef FEAT_MOUSE_DEC
+#ifdef FEAT_MOUSE_DEC
     else if (ttym_flags == TTYM_DEC)
     {
 	if (on)	/* enable mouse events */
@@ -3684,9 +3681,9 @@ mch_setmouse(int on)
 	    out_str_nf((char_u *)"\033['z");
 	mouse_ison = on;
     }
-# endif
-
-# ifdef FEAT_MOUSE_GPM
+#endif
+
+#ifdef FEAT_MOUSE_GPM
     else
     {
 	if (on)
@@ -3700,9 +3697,9 @@ mch_setmouse(int on)
 	    mouse_ison = FALSE;
 	}
     }
-# endif
-
-# ifdef FEAT_SYSMOUSE
+#endif
+
+#ifdef FEAT_SYSMOUSE
     else
     {
 	if (on)
@@ -3716,9 +3713,9 @@ mch_setmouse(int on)
 	    mouse_ison = FALSE;
 	}
     }
-# endif
-
-# ifdef FEAT_MOUSE_JSB
+#endif
+
+#ifdef FEAT_MOUSE_JSB
     else
     {
 	if (on)
@@ -3738,14 +3735,14 @@ mch_setmouse(int on)
 	     *	  4 = Windows Cross Hair
 	     *	  5 = Windows UP Arrow
 	     */
-#  ifdef JSBTERM_MOUSE_NONADVANCED
+# ifdef JSBTERM_MOUSE_NONADVANCED
 	    /* Disables full feedback of pointer movements */
 	    out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK1Q\033\\",
 					 ESC_STR "[0~ZwLMRK1Q" ESC_STR "\\"));
-#  else
+# else
 	    out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK+1Q\033\\",
 					ESC_STR "[0~ZwLMRK+1Q" ESC_STR "\\"));
-#  endif
+# endif
 	    mouse_ison = TRUE;
 	}
 	else
@@ -3755,8 +3752,8 @@ mch_setmouse(int on)
 	    mouse_ison = FALSE;
 	}
     }
-# endif
-# ifdef FEAT_MOUSE_PTERM
+#endif
+#ifdef FEAT_MOUSE_PTERM
     else
     {
 	/* 1 = button press, 6 = release, 7 = drag, 1h...9l = right button */
@@ -3766,7 +3763,7 @@ mch_setmouse(int on)
 	    out_str_nf("\033[>1l\033[>6l\033[>7l\033[>1l\033[>9h");
 	mouse_ison = on;
     }
-# endif
+#endif
 }
 
 #if defined(FEAT_BEVAL_TERM) || defined(PROTO)
@@ -3929,7 +3926,6 @@ check_mouse_termcode(void)
 	del_mouse_termcode(KS_SGR_MOUSE_RELEASE);
     }
 }
-#endif
 
 /*
  * set screen mode, always fails.
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1127,17 +1127,15 @@ decode_key_event(
 #endif /* FEAT_GUI_MSWIN */
 
 
-#ifdef FEAT_MOUSE
-
 /*
  * For the GUI the mouse handling is in gui_w32.c.
  */
-# if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
+#if defined(FEAT_GUI_MSWIN) && !defined(VIMDLL)
     void
 mch_setmouse(int on UNUSED)
 {
 }
-# else
+#else
 static int g_fMouseAvail = FALSE;   /* mouse present */
 static int g_fMouseActive = FALSE;  /* mouse enabled */
 static int g_nMouseClick = -1;	    /* mouse status */
@@ -1152,10 +1150,10 @@ mch_setmouse(int on)
 {
     DWORD cmodein;
 
-#  ifdef VIMDLL
+# ifdef VIMDLL
     if (gui.in_use)
 	return;
-#  endif
+# endif
     if (!g_fMouseAvail)
 	return;
 
@@ -1171,7 +1169,7 @@ mch_setmouse(int on)
 }
 
 
-#if defined(FEAT_BEVAL_TERM) || defined(PROTO)
+# if defined(FEAT_BEVAL_TERM) || defined(PROTO)
 /*
  * Called when 'balloonevalterm' changed.
  */
@@ -1180,7 +1178,7 @@ mch_bevalterm_changed(void)
 {
     mch_setmouse(g_fMouseActive);
 }
-#endif
+# endif
 
 /*
  * Decode a MOUSE_EVENT.  If it's a valid event, return MOUSE_LEFT,
@@ -1218,9 +1216,9 @@ decode_mouse_event(
     static int s_xOldMouse = -1;
     static int s_yOldMouse = -1;
     static linenr_T s_old_topline = 0;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
     static int s_old_topfill = 0;
-#endif
+# endif
     static int s_cClicks = 1;
     static BOOL s_fReleased = TRUE;
     static DWORD s_dwLastClickTime = 0;
@@ -1275,12 +1273,12 @@ decode_mouse_event(
 	/* If the last thing returned was MOUSE_RELEASE, ignore this */
 	if (s_fReleased)
 	{
-#ifdef FEAT_BEVAL_TERM
+# ifdef FEAT_BEVAL_TERM
 	    /* do return mouse move events when we want them */
 	    if (p_bevalterm)
 		nButton = MOUSE_DRAG;
 	    else
-#endif
+# endif
 		return FALSE;
 	}
 
@@ -1386,9 +1384,9 @@ decode_mouse_event(
 		    || s_yOldMouse != g_yMouse
 		    || s_nOldButton != nButton
 		    || s_old_topline != curwin->w_topline
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
 		    || s_old_topfill != curwin->w_topfill
-#endif
+# endif
 		    || (int)(dwCurrentTime - s_dwLastClickTime) > p_mouset)
 	    {
 		s_cClicks = 1;
@@ -1439,16 +1437,15 @@ decode_mouse_event(
     s_xOldMouse = g_xMouse;
     s_yOldMouse = g_yMouse;
     s_old_topline = curwin->w_topline;
-#ifdef FEAT_DIFF
+# ifdef FEAT_DIFF
     s_old_topfill = curwin->w_topfill;
-#endif
+# endif
     s_nOldMouseClick = g_nMouseClick;
 
     return TRUE;
 }
 
-# endif /* FEAT_GUI_MSWIN */
-#endif /* FEAT_MOUSE */
+#endif // FEAT_GUI_MSWIN
 
 
 #ifdef MCH_CURSOR_SHAPE
@@ -1547,10 +1544,7 @@ WaitForChar(long msec, int ignore_input)
 #endif
 	}
 
-	if (0
-#ifdef FEAT_MOUSE
-		|| g_nMouseClick != -1
-#endif
+	if (g_nMouseClick != -1
 #ifdef FEAT_CLIENTSERVER
 		|| (!ignore_input && input_available())
 #endif
@@ -1683,11 +1677,9 @@ WaitForChar(long msec, int ignore_input)
 		    shell_resized();
 		}
 	    }
-#ifdef FEAT_MOUSE
 	    else if (ir.EventType == MOUSE_EVENT
 		    && decode_mouse_event(&ir.Event.MouseEvent))
 		return TRUE;
-#endif
 	}
 	else if (msec == 0)
 	    break;
@@ -1760,10 +1752,8 @@ tgetch(int *pmodifiers, WCHAR *pch2)
 	(void)WaitForChar(-1L, FALSE);
 	if (input_available())
 	    return 0;
-# ifdef FEAT_MOUSE
 	if (g_nMouseClick != -1)
 	    return 0;
-# endif
 #endif
 	if (read_console_input(g_hConIn, &ir, 1, &cRecords) == 0)
 	{
@@ -1783,13 +1773,11 @@ tgetch(int *pmodifiers, WCHAR *pch2)
 	    handle_focus_event(ir);
 	else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT)
 	    shell_resized();
-#ifdef FEAT_MOUSE
 	else if (ir.EventType == MOUSE_EVENT)
 	{
 	    if (decode_mouse_event(&ir.Event.MouseEvent))
 		return 0;
 	}
-#endif
     }
 }
 #endif /* !FEAT_GUI_MSWIN */
@@ -1879,14 +1867,13 @@ mch_inchar(
 	    typeaheadlen = 0;
 	    break;
 	}
-#ifdef FEAT_MOUSE
 	if (g_nMouseClick != -1)
 	{
-# ifdef MCH_WRITE_DUMP
+#ifdef MCH_WRITE_DUMP
 	    if (fdDump)
 		fprintf(fdDump, "{%02x @ %d, %d}",
 			g_nMouseClick, g_xMouse, g_yMouse);
-# endif
+#endif
 	    typeahead[typeaheadlen++] = ESC + 128;
 	    typeahead[typeaheadlen++] = 'M';
 	    typeahead[typeaheadlen++] = g_nMouseClick;
@@ -1895,7 +1882,6 @@ mch_inchar(
 	    g_nMouseClick = -1;
 	}
 	else
-#endif
 	{
 	    WCHAR	ch2 = NUL;
 	    int		modifiers = 0;
@@ -1918,9 +1904,7 @@ mch_inchar(
 		got_int = TRUE;
 	    }
 
-#ifdef FEAT_MOUSE
 	    if (g_nMouseClick == -1)
-#endif
 	    {
 		int	n = 1;
 
@@ -2675,9 +2659,7 @@ mch_init_c(void)
 
     g_fWindInitCalled = TRUE;
 
-#ifdef FEAT_MOUSE
     g_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT);
-#endif
 
 #ifdef FEAT_CLIPBOARD
     win_clip_init();
@@ -3609,10 +3591,8 @@ mch_settmode(int tmode)
     {
 	cmodein &= ~(ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT |
 		     ENABLE_ECHO_INPUT);
-#ifdef FEAT_MOUSE
 	if (g_fMouseActive)
 	    cmodein |= ENABLE_MOUSE_INPUT;
-#endif
 	cmodeout &= ~(
 #ifdef FEAT_TERMGUICOLORS
 	    /* Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using
@@ -5501,12 +5481,10 @@ termcap_mode_start(void)
 #endif
 
     GetConsoleMode(g_hConIn, &cmodein);
-#ifdef FEAT_MOUSE
     if (g_fMouseActive)
 	cmodein |= ENABLE_MOUSE_INPUT;
     else
 	cmodein &= ~ENABLE_MOUSE_INPUT;
-#endif
     cmodein |= ENABLE_WINDOW_INPUT;
     SetConsoleMode(g_hConIn, cmodein);
 
--- a/src/os_win32.h
+++ b/src/os_win32.h
@@ -62,7 +62,7 @@
 #endif
 
 #define USE_FNAME_CASE		/* adjust case of file names */
-#if !defined(FEAT_CLIPBOARD) && defined(FEAT_MOUSE)
+#if !defined(FEAT_CLIPBOARD)
 # define FEAT_CLIPBOARD		/* include clipboard support */
 #endif
 #if defined(__DATE__) && defined(__TIME__)
--- a/src/register.c
+++ b/src/register.c
@@ -352,7 +352,6 @@ free_register(void *reg)
 }
 #endif
 
-#if defined(FEAT_MOUSE) || defined(PROTO)
 /*
  * return TRUE if the current yank register has type MLINE
  */
@@ -366,7 +365,6 @@ yank_register_mline(int regname)
     get_yank_register(regname, FALSE);
     return (y_current->y_type == MLINE);
 }
-#endif
 
 /*
  * Start or stop recording into a yank register.
--- a/src/term.c
+++ b/src/term.c
@@ -1962,9 +1962,7 @@ set_termname(char_u *term)
     is_mac_terminal = FALSE;
 #endif
 
-#ifdef FEAT_MOUSE
-# if defined(UNIX) || defined(VMS)
-#  ifdef FEAT_MOUSE_TTY
+#if defined(UNIX) || defined(VMS)
     /*
      * For Unix, set the 'ttymouse' option to the type of mouse to be used.
      * The termcode for the mouse is added as a side effect in option.c.
@@ -1972,7 +1970,7 @@ set_termname(char_u *term)
     {
 	char_u	*p = (char_u *)"";
 
-#  ifdef FEAT_MOUSE_XTERM
+# ifdef FEAT_MOUSE_XTERM
 	if (use_xterm_like_mouse(term))
 	{
 	    if (use_xterm_mouse())
@@ -1980,7 +1978,7 @@ set_termname(char_u *term)
 	    else
 		p = (char_u *)"xterm";
 	}
-#  endif
+# endif
 	if (p != NULL)
 	{
 	    set_option_value((char_u *)"ttym", 0L, p, 0);
@@ -1989,17 +1987,15 @@ set_termname(char_u *term)
 	    reset_option_was_set((char_u *)"ttym");
 	}
 	if (p == NULL
-#   ifdef FEAT_GUI
+#  ifdef FEAT_GUI
 		|| gui.in_use
-#   endif
+#  endif
 		)
 	    check_mouse_termcode();	/* set mouse termcode anyway */
     }
-#  endif
-# else
+#else
     set_mouse_termcode(KS_MOUSE, (char_u *)"\233M");
-# endif
-#endif	/* FEAT_MOUSE */
+#endif
 
 #ifdef USE_TERM_CONSOLE
     /* DEFAULT_TERM indicates that it is the machine console. */
@@ -2565,8 +2561,6 @@ out_char_nf(unsigned c)
 	out_flush();
 }
 
-#if defined(FEAT_TITLE) || defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI) \
-    || defined(FEAT_TERMRESPONSE) || defined(PROTO)
 /*
  * A never-padding out_str.
  * use this whenever you don't want to run the string through tputs.
@@ -2590,7 +2584,6 @@ out_str_nf(char_u *s)
     if (p_wd)
 	out_flush();
 }
-#endif
 
 /*
  * A conditional-flushing out_str, mainly for visualbell.
@@ -3151,9 +3144,6 @@ get_long_from_buf(char_u *buf, long_u *v
 }
 #endif
 
-#if defined(FEAT_GUI) \
-    || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \
-		|| defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)))
 /*
  * Read the next num_bytes bytes from buf, and store them in bytes.  Assume
  * that buf has been through inchar().	Returns the actual number of bytes used
@@ -3191,7 +3181,6 @@ get_bytes_from_buf(char_u *buf, char_u *
     }
     return len;
 }
-#endif
 
 /*
  * Check if the new shell size is valid, correct it if it's too small or way
@@ -3436,10 +3425,8 @@ settmode(int tmode)
 		check_for_codes_from_term();
 	    }
 #endif
-#ifdef FEAT_MOUSE_TTY
 	    if (tmode != TMODE_RAW)
 		mch_setmouse(FALSE);	// switch mouse off
-#endif
 	    if (termcap_active)
 	    {
 		if (tmode != TMODE_RAW)
@@ -5084,8 +5071,7 @@ not_enough:
 
 	/* We only get here when we have a complete termcode match */
 
-#ifdef FEAT_MOUSE
-# ifdef FEAT_GUI
+#ifdef FEAT_GUI
 	/*
 	 * Only in the GUI: Fetch the pointer coordinates of the scroll event
 	 * so that we know which window to scroll later.
@@ -5109,29 +5095,29 @@ not_enough:
 	    slen += num_bytes;
 	}
 	else
-# endif
+#endif
 	/*
 	 * If it is a mouse click, get the coordinates.
 	 */
 	if (key_name[0] == KS_MOUSE
-# ifdef FEAT_MOUSE_GPM
+#ifdef FEAT_MOUSE_GPM
 		|| key_name[0] == KS_GPM_MOUSE
-# endif
-# ifdef FEAT_MOUSE_JSB
+#endif
+#ifdef FEAT_MOUSE_JSB
 		|| key_name[0] == KS_JSBTERM_MOUSE
-# endif
-# ifdef FEAT_MOUSE_NET
+#endif
+#ifdef FEAT_MOUSE_NET
 		|| key_name[0] == KS_NETTERM_MOUSE
-# endif
-# ifdef FEAT_MOUSE_DEC
+#endif
+#ifdef FEAT_MOUSE_DEC
 		|| key_name[0] == KS_DEC_MOUSE
-# endif
-# ifdef FEAT_MOUSE_PTERM
+#endif
+#ifdef FEAT_MOUSE_PTERM
 		|| key_name[0] == KS_PTERM_MOUSE
-# endif
-# ifdef FEAT_MOUSE_URXVT
+#endif
+#ifdef FEAT_MOUSE_URXVT
 		|| key_name[0] == KS_URXVT_MOUSE
-# endif
+#endif
 		|| key_name[0] == KS_SGR_MOUSE
 		|| key_name[0] == KS_SGR_MOUSE_RELEASE)
 	{
@@ -5139,7 +5125,6 @@ not_enough:
 							     &modifiers) == -1)
 		return -1;
 	}
-#endif /* FEAT_MOUSE */
 
 #ifdef FEAT_GUI
 	/*
--- a/src/testing.c
+++ b/src/testing.c
@@ -926,14 +926,12 @@ f_test_scrollbar(typval_T *argvars, typv
 }
 #endif
 
-#ifdef FEAT_MOUSE
     void
 f_test_setmouse(typval_T *argvars, typval_T *rettv UNUSED)
 {
     mouse_row = (time_t)tv_get_number(&argvars[0]) - 1;
     mouse_col = (time_t)tv_get_number(&argvars[1]) - 1;
 }
-#endif
 
     void
 f_test_settime(typval_T *argvars, typval_T *rettv UNUSED)
--- a/src/version.c
+++ b/src/version.c
@@ -359,15 +359,11 @@ static char *(features[]) =
 	"-mksession",
 #endif
 	"+modify_fname",
-#ifdef FEAT_MOUSE
 	"+mouse",
-#  ifdef FEAT_MOUSESHAPE
+#ifdef FEAT_MOUSESHAPE
 	"+mouseshape",
-#  else
+#else
 	"-mouseshape",
-#  endif
-# else
-	"-mouse",
 #endif
 
 #if defined(UNIX) || defined(VMS)
@@ -402,11 +398,7 @@ static char *(features[]) =
 #endif
 
 #if defined(UNIX) || defined(VMS)
-# ifdef FEAT_MOUSE_XTERM
 	"+mouse_sgr",
-# else
-	"-mouse_sgr",
-# endif
 # ifdef FEAT_SYSMOUSE
 	"+mouse_sysmouse",
 # else
@@ -417,11 +409,7 @@ static char *(features[]) =
 # else
 	"-mouse_urxvt",
 # endif
-# ifdef FEAT_MOUSE_XTERM
 	"+mouse_xterm",
-# else
-	"-mouse_xterm",
-# endif
 #endif
 
 #ifdef FEAT_MBYTE_IME
@@ -754,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2171,
+/**/
     2170,
 /**/
     2169,
--- a/src/vim.h
+++ b/src/vim.h
@@ -151,9 +151,6 @@
 # if defined(FEAT_SMALL) && !defined(FEAT_CLIPBOARD)
 #  define FEAT_CLIPBOARD
 # endif
-# if defined(FEAT_SMALL) && !defined(FEAT_MOUSE)
-#  define FEAT_MOUSE
-# endif
 #endif
 
 // +x11 is only enabled when it's both available and wanted.
@@ -1817,80 +1814,78 @@ typedef int sock_T;
 #define PROF_YES	1	// profiling busy
 #define PROF_PAUSED	2	// profiling paused
 
-#ifdef FEAT_MOUSE
 
 // Codes for mouse button events in lower three bits:
-# define MOUSE_LEFT	0x00
-# define MOUSE_MIDDLE	0x01
-# define MOUSE_RIGHT	0x02
-# define MOUSE_RELEASE	0x03
+#define MOUSE_LEFT	0x00
+#define MOUSE_MIDDLE	0x01
+#define MOUSE_RIGHT	0x02
+#define MOUSE_RELEASE	0x03
 
 // bit masks for modifiers:
-# define MOUSE_SHIFT	0x04
-# define MOUSE_ALT	0x08
-# define MOUSE_CTRL	0x10
+#define MOUSE_SHIFT	0x04
+#define MOUSE_ALT	0x08
+#define MOUSE_CTRL	0x10
 
 // mouse buttons that are handled like a key press (GUI only)
 // Note that the scroll wheel keys are inverted: MOUSE_5 scrolls lines up but
 // the result of this is that the window moves down, similarly MOUSE_6 scrolls
 // columns left but the window moves right.
-# define MOUSE_4	0x100	// scroll wheel down
-# define MOUSE_5	0x200	// scroll wheel up
+#define MOUSE_4	0x100	// scroll wheel down
+#define MOUSE_5	0x200	// scroll wheel up
 
-# define MOUSE_X1	0x300 // Mouse-button X1 (6th)
-# define MOUSE_X2	0x400 // Mouse-button X2
+#define MOUSE_X1	0x300 // Mouse-button X1 (6th)
+#define MOUSE_X2	0x400 // Mouse-button X2
 
-# define MOUSE_6	0x500	// scroll wheel left
-# define MOUSE_7	0x600	// scroll wheel right
+#define MOUSE_6	0x500	// scroll wheel left
+#define MOUSE_7	0x600	// scroll wheel right
 
 // 0x20 is reserved by xterm
-# define MOUSE_DRAG_XTERM   0x40
+#define MOUSE_DRAG_XTERM   0x40
 
-# define MOUSE_DRAG	(0x40 | MOUSE_RELEASE)
+#define MOUSE_DRAG	(0x40 | MOUSE_RELEASE)
 
 // Lowest button code for using the mouse wheel (xterm only)
-# define MOUSEWHEEL_LOW		0x60
+#define MOUSEWHEEL_LOW		0x60
 
-# define MOUSE_CLICK_MASK	0x03
+#define MOUSE_CLICK_MASK	0x03
 
-# define NUM_MOUSE_CLICKS(code) \
+#define NUM_MOUSE_CLICKS(code) \
     (((unsigned)((code) & 0xC0) >> 6) + 1)
 
-# define SET_NUM_MOUSE_CLICKS(code, num) \
+#define SET_NUM_MOUSE_CLICKS(code, num) \
     (code) = ((code) & 0x3f) | ((((num) - 1) & 3) << 6)
 
 // Added to mouse column for GUI when 'mousefocus' wants to give focus to a
 // window by simulating a click on its status line.  We could use up to 128 *
 // 128 = 16384 columns, now it's reduced to 10000.
-# define MOUSE_COLOFF 10000
+#define MOUSE_COLOFF 10000
 
 /*
  * jump_to_mouse() returns one of first four these values, possibly with
  * some of the other three added.
  */
-# define IN_UNKNOWN		0
-# define IN_BUFFER		1
-# define IN_STATUS_LINE		2	// on status or command line
-# define IN_SEP_LINE		4	// on vertical separator line
-# define IN_OTHER_WIN		8	// in other window but can't go there
-# define CURSOR_MOVED		0x100
-# define MOUSE_FOLD_CLOSE	0x200	// clicked on '-' in fold column
-# define MOUSE_FOLD_OPEN	0x400	// clicked on '+' in fold column
-# define MOUSE_WINBAR		0x800	// in window toolbar
+#define IN_UNKNOWN		0
+#define IN_BUFFER		1
+#define IN_STATUS_LINE		2	// on status or command line
+#define IN_SEP_LINE		4	// on vertical separator line
+#define IN_OTHER_WIN		8	// in other window but can't go there
+#define CURSOR_MOVED		0x100
+#define MOUSE_FOLD_CLOSE	0x200	// clicked on '-' in fold column
+#define MOUSE_FOLD_OPEN		0x400	// clicked on '+' in fold column
+#define MOUSE_WINBAR		0x800	// in window toolbar
 
 // flags for jump_to_mouse()
-# define MOUSE_FOCUS		0x01	// need to stay in this window
-# define MOUSE_MAY_VIS		0x02	// may start Visual mode
-# define MOUSE_DID_MOVE		0x04	// only act when mouse has moved
-# define MOUSE_SETPOS		0x08	// only set current mouse position
-# define MOUSE_MAY_STOP_VIS	0x10	// may stop Visual mode
-# define MOUSE_RELEASED		0x20	// button was released
+#define MOUSE_FOCUS		0x01	// need to stay in this window
+#define MOUSE_MAY_VIS		0x02	// may start Visual mode
+#define MOUSE_DID_MOVE		0x04	// only act when mouse has moved
+#define MOUSE_SETPOS		0x08	// only set current mouse position
+#define MOUSE_MAY_STOP_VIS	0x10	// may stop Visual mode
+#define MOUSE_RELEASED		0x20	// button was released
 
-# if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
-#  define CHECK_DOUBLE_CLICK 1	// Checking for double clicks ourselves.
-# endif
+#if defined(UNIX) && defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+# define CHECK_DOUBLE_CLICK 1	// Checking for double clicks ourselves.
+#endif
 
-#endif // FEAT_MOUSE
 
 // defines for eval_vars()
 #define VALID_PATH		1
--- a/src/window.c
+++ b/src/window.c
@@ -5725,8 +5725,6 @@ win_setminwidth(void)
     }
 }
 
-#if defined(FEAT_MOUSE) || defined(PROTO)
-
 /*
  * Status line of dragwin is dragged "offset" lines down (negative is up).
  */
@@ -5958,7 +5956,6 @@ win_drag_vsep_line(win_T *dragwin, int o
     (void)win_comp_pos();
     redraw_all_later(NOT_VALID);
 }
-#endif /* FEAT_MOUSE */
 
 #define FRACTION_MULT	16384L