diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-09-19 20:42:03 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-09-19 20:42:03 -0400 |
commit | 0375128377ef89d833e19a5e58a69f628a0e5d6c (patch) | |
tree | ce906ba95f258c9c40062bf34276f6615a4137f4 | |
parent | dc6db20febf1ce1848e87f8950c48a78aaffd8f6 (diff) | |
parent | 3253e7ec09e8c26c31ad5d2172fd664864012f38 (diff) | |
download | rneovim-0375128377ef89d833e19a5e58a69f628a0e5d6c.tar.gz rneovim-0375128377ef89d833e19a5e58a69f628a0e5d6c.tar.bz2 rneovim-0375128377ef89d833e19a5e58a69f628a0e5d6c.zip |
Merge pull request #1150 from splinterofchaos/vim-patch-7.4.305
Vim patch 7.4.305 + Vim patch 7.4.359
-rw-r--r-- | src/nvim/globals.h | 4 | ||||
-rw-r--r-- | src/nvim/os_unix.c | 41 | ||||
-rw-r--r-- | src/nvim/term.c | 44 | ||||
-rw-r--r-- | src/nvim/version.c | 4 |
4 files changed, 68 insertions, 25 deletions
diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 674786ff08..851022cd62 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -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' */ #endif +#if defined(UNIX) +EXTERN int xterm_conflict_mouse INIT(= FALSE); +#endif + #ifdef BACKSLASH_IN_FILENAME EXTERN char psepc INIT(= '\\'); /* normal path separator character */ EXTERN char psepcN INIT(= '/'); /* abnormal path separator character */ diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index a54ed000af..52f57f8262 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -761,11 +761,11 @@ void mch_setmouse(int on) } -/* - * Set the mouse termcode, depending on the 'term' and 'ttymouse' options. - */ +/// Sets the mouse termcode, depending on the 'term' and 'ttymouse' options. void check_mouse_termcode(void) { + xterm_conflict_mouse = false; + if (use_xterm_mouse() && use_xterm_mouse() != 3 ) { @@ -791,29 +791,31 @@ void check_mouse_termcode(void) else del_mouse_termcode(KS_NETTERM_MOUSE); - /* conflicts with xterm mouse: "\033[" and "\033[M" */ - if (!use_xterm_mouse() - ) + // Conflicts with xterm mouse: "\033[" and "\033[M". + // 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) ? "\233" : "\033[")); - else + xterm_conflict_mouse = true; + } + else { del_mouse_termcode(KS_DEC_MOUSE); + } /* same as the dec mouse */ - if (use_xterm_mouse() == 3 - ) { - set_mouse_termcode(KS_URXVT_MOUSE, (char_u *)(term_is_8bit(T_NAME) - ? "\233" - : "\033[")); - + if (use_xterm_mouse() == 3 && !did_request_esc_sequence()) { + set_mouse_termcode(KS_URXVT_MOUSE, + (char_u *)(term_is_8bit(T_NAME) ? "\233" : "\033[")); if (*p_mouse != NUL) { - mch_setmouse(FALSE); + mch_setmouse(false); setmouse(); } - } else + resume_get_esc_sequence(); + } else { 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) ? "\233<" : "\033[<")); @@ -822,8 +824,9 @@ void check_mouse_termcode(void) mch_setmouse(FALSE); setmouse(); } - } else + } else { del_mouse_termcode(KS_SGR_MOUSE); + } } /* diff --git a/src/nvim/term.c b/src/nvim/term.c index d2c524e2e8..263b81fc3a 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -152,6 +152,9 @@ char *UP, *BC, PC; # define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) #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 struct builtin_term builtin_termcaps[] = @@ -2408,8 +2411,9 @@ void starttermcap(void) may_req_termresponse(); /* Immediately check for a response. If t_Co changes, we don't * want to redraw with wrong colors first. */ - if (crv_status != CRV_GET) + if (crv_status == CRV_SENT) { check_for_codes_from_term(); + } } } } @@ -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. * Only do this after switching to raw mode, otherwise the result will be @@ -2458,6 +2494,8 @@ void stoptermcap(void) * Insert mode. * On Unix only do it when both output and input are a tty (avoid writing * 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(). */ void may_req_termresponse(void) @@ -2470,6 +2508,7 @@ void may_req_termresponse(void) # ifdef UNIX && isatty(1) && isatty(read_cmd_fd) + && !xterm_conflict_mouse # endif && *T_CRV != NUL) { 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. * 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) { xt_index_out = 0; diff --git a/src/nvim/version.c b/src/nvim/version.c index 9013542d3d..df4c3bd5ce 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -236,7 +236,7 @@ static int included_patches[] = { 362, 361, //360, - //359, + 359, 358, 357, //356 NA @@ -290,7 +290,7 @@ static int included_patches[] = { 308, //307 NA 306, - //305, + 305, //304 NA 303, 302, |