Merge pull request #1150 from splinterofchaos/vim-patch-7.4.305

Vim patch 7.4.305 + Vim patch 7.4.359
This commit is contained in:
Justin M. Keyes 2014-09-19 20:42:03 -04:00
commit 0375128377
4 changed files with 68 additions and 25 deletions

View File

@ -1059,6 +1059,10 @@ EXTERN int typebuf_was_filled INIT(= FALSE); /* received text from client
EXTERN int term_is_xterm INIT(= FALSE); /* xterm-like 'term' */ EXTERN int term_is_xterm INIT(= FALSE); /* xterm-like 'term' */
#endif #endif
#if defined(UNIX)
EXTERN int xterm_conflict_mouse INIT(= FALSE);
#endif
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
EXTERN char psepc INIT(= '\\'); /* normal path separator character */ EXTERN char psepc INIT(= '\\'); /* normal path separator character */
EXTERN char psepcN INIT(= '/'); /* abnormal path separator character */ EXTERN char psepcN INIT(= '/'); /* abnormal path separator character */

View File

@ -761,11 +761,11 @@ void mch_setmouse(int on)
} }
/* /// Sets the mouse termcode, depending on the 'term' and 'ttymouse' options.
* Set the mouse termcode, depending on the 'term' and 'ttymouse' options.
*/
void check_mouse_termcode(void) void check_mouse_termcode(void)
{ {
xterm_conflict_mouse = false;
if (use_xterm_mouse() if (use_xterm_mouse()
&& use_xterm_mouse() != 3 && use_xterm_mouse() != 3
) { ) {
@ -791,29 +791,31 @@ void check_mouse_termcode(void)
else else
del_mouse_termcode(KS_NETTERM_MOUSE); del_mouse_termcode(KS_NETTERM_MOUSE);
/* conflicts with xterm mouse: "\033[" and "\033[M" */ // Conflicts with xterm mouse: "\033[" and "\033[M".
if (!use_xterm_mouse() // Also conflicts with the xterm termresponse, skip this if it was requested
) // already.
if (!use_xterm_mouse()) {
set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME) set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
? "\233" : "\033[")); ? "\233" : "\033["));
else xterm_conflict_mouse = true;
}
else {
del_mouse_termcode(KS_DEC_MOUSE); del_mouse_termcode(KS_DEC_MOUSE);
}
/* same as the dec mouse */ /* same as the dec mouse */
if (use_xterm_mouse() == 3 if (use_xterm_mouse() == 3 && !did_request_esc_sequence()) {
) { set_mouse_termcode(KS_URXVT_MOUSE,
set_mouse_termcode(KS_URXVT_MOUSE, (char_u *)(term_is_8bit(T_NAME) (char_u *)(term_is_8bit(T_NAME) ? "\233" : "\033["));
? "\233"
: "\033["));
if (*p_mouse != NUL) { if (*p_mouse != NUL) {
mch_setmouse(FALSE); mch_setmouse(false);
setmouse(); setmouse();
} }
} else resume_get_esc_sequence();
} else {
del_mouse_termcode(KS_URXVT_MOUSE); del_mouse_termcode(KS_URXVT_MOUSE);
/* There is no conflict with xterm mouse */ }
if (use_xterm_mouse() == 4 // There is no conflict with xterm mouse.
) { if (use_xterm_mouse() == 4) {
set_mouse_termcode(KS_SGR_MOUSE, (char_u *)(term_is_8bit(T_NAME) set_mouse_termcode(KS_SGR_MOUSE, (char_u *)(term_is_8bit(T_NAME)
? "\233<" ? "\233<"
: "\033[<")); : "\033[<"));
@ -822,8 +824,9 @@ void check_mouse_termcode(void)
mch_setmouse(FALSE); mch_setmouse(FALSE);
setmouse(); setmouse();
} }
} else } else {
del_mouse_termcode(KS_SGR_MOUSE); del_mouse_termcode(KS_SGR_MOUSE);
}
} }
/* /*

View File

@ -152,6 +152,9 @@ char *UP, *BC, PC;
# define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) # define TGETENT(b, t) tgetent((char *)(b), (char *)(t))
#endif /* HAVE_TGETENT */ #endif /* HAVE_TGETENT */
static int xt_index_in = 0;
static int xt_index_out = 0;
static bool detected_8bit = false; // detected 8-bit terminal static bool detected_8bit = false; // detected 8-bit terminal
static struct builtin_term builtin_termcaps[] = static struct builtin_term builtin_termcaps[] =
@ -2408,10 +2411,11 @@ void starttermcap(void)
may_req_termresponse(); may_req_termresponse();
/* Immediately check for a response. If t_Co changes, we don't /* Immediately check for a response. If t_Co changes, we don't
* want to redraw with wrong colors first. */ * want to redraw with wrong colors first. */
if (crv_status != CRV_GET) if (crv_status == CRV_SENT) {
check_for_codes_from_term(); check_for_codes_from_term();
} }
} }
}
} }
void stoptermcap(void) void stoptermcap(void)
@ -2446,6 +2450,38 @@ void stoptermcap(void)
} }
} }
#if defined(UNIX)
/// Returns true when the xterm version was requested or anything else that
/// would send an ESC sequence back to Vim.
///
/// If not sent yet, prevent it from being sent soon.
/// Used to check whether it is OK to enable checking for DEC mouse codes,
/// which conflict with may xterm ESC sequences.
bool did_request_esc_sequence(void)
{
if (crv_status == CRV_GET) {
crv_status = 0;
}
if (u7_status == U7_GET) {
u7_status = 0;
}
return crv_status == CRV_SENT || u7_status == U7_SENT
|| xt_index_out > xt_index_in;
}
/// If requesting the version was disabled in did_request_esc_sequence(),
/// enable it again.
void resume_get_esc_sequence(void)
{
if (crv_status == 0) {
crv_status = CRV_GET;
}
if (u7_status == 0) {
u7_status = U7_GET;
}
}
#endif
/* /*
* Request version string (for xterm) when needed. * Request version string (for xterm) when needed.
* Only do this after switching to raw mode, otherwise the result will be * Only do this after switching to raw mode, otherwise the result will be
@ -2458,6 +2494,8 @@ void stoptermcap(void)
* Insert mode. * Insert mode.
* On Unix only do it when both output and input are a tty (avoid writing * On Unix only do it when both output and input are a tty (avoid writing
* request to terminal while reading from a file). * request to terminal while reading from a file).
* Do not do this when a mouse is being detected that starts with the same ESC
* sequence as the termresponse.
* The result is caught in check_termcode(). * The result is caught in check_termcode().
*/ */
void may_req_termresponse(void) void may_req_termresponse(void)
@ -2470,6 +2508,7 @@ void may_req_termresponse(void)
# ifdef UNIX # ifdef UNIX
&& isatty(1) && isatty(1)
&& isatty(read_cmd_fd) && isatty(read_cmd_fd)
&& !xterm_conflict_mouse
# endif # endif
&& *T_CRV != NUL) { && *T_CRV != NUL) {
LOG_TR("Sending CRV"); LOG_TR("Sending CRV");
@ -4130,9 +4169,6 @@ int show_one_termcode(char_u *name, char_u *code, int printit)
* termcap codes from the terminal itself. * termcap codes from the terminal itself.
* We get them one by one to avoid a very long response string. * We get them one by one to avoid a very long response string.
*/ */
static int xt_index_in = 0;
static int xt_index_out = 0;
static void req_codes_from_term(void) static void req_codes_from_term(void)
{ {
xt_index_out = 0; xt_index_out = 0;

View File

@ -236,7 +236,7 @@ static int included_patches[] = {
362, 362,
361, 361,
//360, //360,
//359, 359,
358, 358,
357, 357,
//356 NA //356 NA
@ -290,7 +290,7 @@ static int included_patches[] = {
308, 308,
//307 NA //307 NA
306, 306,
//305, 305,
//304 NA //304 NA
303, 303,
302, 302,