patch 8.1.1034: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Merge FEAT_MOUSE_SGR into FEAT_MOUSE_XTERM / FEAT_MOUSE_TTY.
diff --git a/src/term.c b/src/term.c
index 8ee9264..c058171 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2126,13 +2126,11 @@
has_mouse_termcode |= HMT_URXVT;
else
# endif
-# ifdef FEAT_MOUSE_SGR
if (n == KS_SGR_MOUSE)
has_mouse_termcode |= HMT_SGR;
else if (n == KS_SGR_MOUSE_RELEASE)
has_mouse_termcode |= HMT_SGR_REL;
else
-# endif
has_mouse_termcode |= HMT_NORMAL;
# endif
}
@@ -2175,13 +2173,11 @@
has_mouse_termcode &= ~HMT_URXVT;
else
# endif
-# ifdef FEAT_MOUSE_SGR
if (n == KS_SGR_MOUSE)
has_mouse_termcode &= ~HMT_SGR;
else if (n == KS_SGR_MOUSE_RELEASE)
has_mouse_termcode &= ~HMT_SGR_REL;
else
-# endif
has_mouse_termcode &= ~HMT_NORMAL;
# endif
}
@@ -4690,7 +4686,6 @@
if (tp[1 + (tp[0] != CSI)] == '>' && semicols == 2)
{
int need_flush = FALSE;
-# ifdef FEAT_MOUSE_SGR
int is_iterm2 = FALSE;
int is_mintty = FALSE;
@@ -4698,7 +4693,6 @@
// (77 is ASCII 'M' for mintty.)
if (STRNCMP(tp + extra - 3, "77;", 3) == 0)
is_mintty = TRUE;
-# endif
/* if xterm version >= 141 try to get termcap codes */
if (version >= 141)
@@ -4718,12 +4712,10 @@
* 256, libvterm supports even more. */
if (mch_getenv((char_u *)"COLORS") == NULL)
may_adjust_color_count(256);
-# ifdef FEAT_MOUSE_SGR
/* Libvterm can handle SGR mouse reporting. */
if (!option_was_set((char_u *)"ttym"))
set_option_value((char_u *)"ttym", 0L,
(char_u *)"sgr", 0);
-# endif
}
if (version == 95)
@@ -4734,14 +4726,11 @@
is_not_xterm = TRUE;
is_mac_terminal = TRUE;
}
-# ifdef FEAT_MOUSE_SGR
// iTerm2 sends 0;95;0
if (STRNCMP(tp + extra - 2, "0;95;0c", 7) == 0)
is_iterm2 = TRUE;
- else
-# endif
// old iTerm2 sends 0;95;
- if (STRNCMP(tp + extra - 2, "0;95;c", 6) == 0)
+ else if (STRNCMP(tp + extra - 2, "0;95;c", 6) == 0)
is_not_xterm = TRUE;
}
@@ -4749,17 +4738,14 @@
* by the user already. */
if (!option_was_set((char_u *)"ttym"))
{
-# ifdef FEAT_MOUSE_SGR
/* Xterm version 277 supports SGR. Also support
* Terminal.app, iTerm2 and mintty. */
if (version >= 277 || is_iterm2 || is_mac_terminal
|| is_mintty)
set_option_value((char_u *)"ttym", 0L,
(char_u *)"sgr", 0);
- else
-# endif
/* if xterm version >= 95 use mouse dragging */
- if (version >= 95)
+ else if (version >= 95)
set_option_value((char_u *)"ttym", 0L,
(char_u *)"xterm2", 0);
}
@@ -5127,11 +5113,8 @@
# ifdef FEAT_MOUSE_URXVT
|| key_name[0] == KS_URXVT_MOUSE
# endif
-# ifdef FEAT_MOUSE_SGR
|| key_name[0] == KS_SGR_MOUSE
- || key_name[0] == KS_SGR_MOUSE_RELEASE
-# endif
- )
+ || key_name[0] == KS_SGR_MOUSE_RELEASE)
{
is_click = is_drag = FALSE;
@@ -5163,7 +5146,7 @@
*/
for (;;)
{
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use)
{
/* GUI uses more bits for columns > 223 */
@@ -5177,7 +5160,7 @@
+ bytes[4] - ' ' - 1;
}
else
-#endif
+# endif
{
num_bytes = get_bytes_from_buf(tp + slen, bytes, 3);
if (num_bytes == -1) /* not enough coordinates */
@@ -5191,21 +5174,21 @@
/* If the following bytes is also a mouse code and it has
* the same code, dump this one and get the next. This
* makes dragging a whole lot faster. */
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
if (gui.in_use)
j = 3;
else
-#endif
+# endif
j = termcodes[idx].len;
if (STRNCMP(tp, tp + slen, (size_t)j) == 0
&& tp[slen + j] == mouse_code
&& tp[slen + j + 1] != NUL
&& tp[slen + j + 2] != NUL
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
&& (!gui.in_use
|| (tp[slen + j + 3] != NUL
&& tp[slen + j + 4] != NUL))
-#endif
+# endif
)
slen += j;
else
@@ -5213,7 +5196,6 @@
}
}
-# if defined(FEAT_MOUSE_URXVT) || defined(FEAT_MOUSE_SGR)
if (key_name[0] == KS_URXVT_MOUSE
|| key_name[0] == KS_SGR_MOUSE
|| key_name[0] == KS_SGR_MOUSE_RELEASE)
@@ -5267,17 +5249,13 @@
* modifier keys (alt/shift/ctrl/meta) state. */
modifiers = 0;
}
-# endif
if (key_name[0] == (int)KS_MOUSE
-#ifdef FEAT_MOUSE_URXVT
+# ifdef FEAT_MOUSE_URXVT
|| key_name[0] == (int)KS_URXVT_MOUSE
-#endif
-#ifdef FEAT_MOUSE_SGR
+# endif
|| key_name[0] == KS_SGR_MOUSE
- || key_name[0] == KS_SGR_MOUSE_RELEASE
-#endif
- )
+ || key_name[0] == KS_SGR_MOUSE_RELEASE)
{
# if !defined(MSWIN)
/*