Patch 7.4.305

79 views
Skip to first unread message

Bram Moolenaar

unread,
May 22, 2014, 12:14:46 PM5/22/14
to vim...@googlegroups.com

Patch 7.4.305
Problem: Making 'ttymouse' empty after the xterm version was requested
causes problems. (Elijah Griffin)
Solution: Do not check for DEC mouse sequences when the xterm version was
requested. Also don't request the xterm version when DEC mouse
was enabled.
Files: src/term.c, src/os_unix.c, src/proto/term.pro, src/globals.h


*** ../vim-7.4.304/src/term.c 2014-03-25 13:46:22.841832960 +0100
--- src/term.c 2014-05-22 17:12:59.198299628 +0200
***************
*** 153,158 ****
--- 153,163 ----
static char_u *vim_tgetstr __ARGS((char *s, char_u **pp));
#endif /* HAVE_TGETENT */

+ #if defined(FEAT_TERMRESPONSE)
+ static int xt_index_in = 0;
+ static int xt_index_out = 0;
+ #endif
+
static int detected_8bit = FALSE; /* detected 8-bit terminal */

static struct builtin_term builtin_termcaps[] =
***************
*** 3259,3265 ****
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)
check_for_codes_from_term();
}
#endif
--- 3264,3270 ----
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_SENT)
check_for_codes_from_term();
}
#endif
***************
*** 3306,3311 ****
--- 3311,3340 ----
}
}

+ #if defined(UNIX) || defined(PROTO)
+ /*
+ * Return 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.
+ */
+ int
+ did_request_esc_sequence()
+ {
+ 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
+ # if defined(FEAT_TERMRESPONSE)
+ || xt_index_out > xt_index_in
+ # endif
+ ;
+ }
+ #endif
+
+
#if defined(FEAT_TERMRESPONSE) || defined(PROTO)
/*
* Request version string (for xterm) when needed.
***************
*** 3319,3324 ****
--- 3348,3355 ----
* 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
***************
*** 3332,3337 ****
--- 3363,3369 ----
# ifdef UNIX
&& isatty(1)
&& isatty(read_cmd_fd)
+ && !xterm_conflict_mouse
# endif
&& *T_CRV != NUL)
{
***************
*** 5714,5722 ****
* 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()
{
--- 5746,5751 ----
*** ../vim-7.4.304/src/os_unix.c 2014-05-13 20:19:53.573808877 +0200
--- src/os_unix.c 2014-05-22 17:11:10.274301842 +0200
***************
*** 3667,3672 ****
--- 3667,3674 ----
void
check_mouse_termcode()
{
+ xterm_conflict_mouse = FALSE;
+
# ifdef FEAT_MOUSE_XTERM
if (use_xterm_mouse()
# ifdef FEAT_MOUSE_URXVT
***************
*** 3711,3717 ****
# endif

# ifdef FEAT_MOUSE_JSB
! /* conflicts with xterm mouse: "\033[" and "\033[M" ??? */
if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
--- 3713,3719 ----
# endif

# ifdef FEAT_MOUSE_JSB
! /* There is no conflict, but it was disabled for xterm before. */
if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
***************
*** 3738,3769 ****
# endif

# ifdef FEAT_MOUSE_DEC
! /* conflicts with xterm mouse: "\033[" and "\033[M" */
! if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
# endif
)
set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
else
del_mouse_termcode(KS_DEC_MOUSE);
# endif
# ifdef FEAT_MOUSE_PTERM
/* same as the dec mouse */
! if (!use_xterm_mouse()
# ifdef FEAT_GUI
&& !gui.in_use
# endif
)
set_mouse_termcode(KS_PTERM_MOUSE,
(char_u *) IF_EB("\033[", ESC_STR "["));
else
del_mouse_termcode(KS_PTERM_MOUSE);
# endif
# ifdef FEAT_MOUSE_URXVT
/* same as the dec mouse */
! if (use_xterm_mouse() == 3
# ifdef FEAT_GUI
&& !gui.in_use
# endif
--- 3740,3779 ----
# endif

# ifdef FEAT_MOUSE_DEC
! /* 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() && !did_request_esc_sequence()
# ifdef FEAT_GUI
&& !gui.in_use
# endif
)
+ {
set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
+ xterm_conflict_mouse = TRUE;
+ }
else
del_mouse_termcode(KS_DEC_MOUSE);
# endif
# ifdef FEAT_MOUSE_PTERM
/* same as the dec mouse */
! if (!use_xterm_mouse() && !did_request_esc_sequence()
# ifdef FEAT_GUI
&& !gui.in_use
# endif
)
+ {
set_mouse_termcode(KS_PTERM_MOUSE,
(char_u *) IF_EB("\033[", ESC_STR "["));
+ xterm_conflict_mouse = TRUE;
+ }
else
del_mouse_termcode(KS_PTERM_MOUSE);
# endif
# ifdef FEAT_MOUSE_URXVT
/* same as the dec mouse */
! if (use_xterm_mouse() == 3 && !did_request_esc_sequence()
# ifdef FEAT_GUI
&& !gui.in_use
# endif
***************
*** 3778,3783 ****
--- 3788,3794 ----
mch_setmouse(FALSE);
setmouse();
}
+ xterm_conflict_mouse = TRUE;
}
else
del_mouse_termcode(KS_URXVT_MOUSE);
*** ../vim-7.4.304/src/proto/term.pro 2013-09-29 16:27:42.000000000 +0200
--- src/proto/term.pro 2014-05-22 16:58:25.806317380 +0200
***************
*** 34,39 ****
--- 34,40 ----
void settmode __ARGS((int tmode));
void starttermcap __ARGS((void));
void stoptermcap __ARGS((void));
+ int did_request_esc_sequence __ARGS((void));
void may_req_termresponse __ARGS((void));
void may_req_ambiguous_char_width __ARGS((void));
int swapping_screen __ARGS((void));
*** ../vim-7.4.304/src/globals.h 2014-04-06 20:45:40.123357453 +0200
--- src/globals.h 2014-05-22 17:07:39.130306133 +0200
***************
*** 1333,1338 ****
--- 1333,1341 ----
#if defined(UNIX) || defined(VMS)
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 */
*** ../vim-7.4.304/src/version.c 2014-05-22 16:29:03.378353200 +0200
--- src/version.c 2014-05-22 16:58:16.150317576 +0200
***************
*** 736,737 ****
--- 736,739 ----
{ /* Add new patch number below this line */
+ /**/
+ 305,
/**/

--
hundred-and-one symptoms of being an internet addict:
195. Your cat has its own home page.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tomas Janousek

unread,
Jul 1, 2014, 5:46:45 PM7/1/14
to vim...@googlegroups.com, Bram Moolenaar
Hi,

On Thu, May 22, 2014 at 06:14:46PM +0200, Bram Moolenaar wrote:
> Patch 7.4.305
> Problem: Making 'ttymouse' empty after the xterm version was requested
> causes problems. (Elijah Griffin)
> Solution: Do not check for DEC mouse sequences when the xterm version was
> requested. Also don't request the xterm version when DEC mouse
> was enabled.
> Files: src/term.c, src/os_unix.c, src/proto/term.pro, src/globals.h

This patch makes vim stop requesting termresponse altogether if ttymouse is
explicitly set in .vimrc (in my case to urxvt), which causes some problems
(https://github.com/kien/ctrlp.vim/issues/579). Is that intended?

Would it perhaps be possible to request xterm version first and only then
check/enable mouse?

--
Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/

Bram Moolenaar

unread,
Jul 2, 2014, 7:37:29 AM7/2/14
to Tomas Janousek, vim...@googlegroups.com

Tomas Janousek wrote:

> On Thu, May 22, 2014 at 06:14:46PM +0200, Bram Moolenaar wrote:
> > Patch 7.4.305
> > Problem: Making 'ttymouse' empty after the xterm version was requested
> > causes problems. (Elijah Griffin)
> > Solution: Do not check for DEC mouse sequences when the xterm version was
> > requested. Also don't request the xterm version when DEC mouse
> > was enabled.
> > Files: src/term.c, src/os_unix.c, src/proto/term.pro, src/globals.h
>
> This patch makes vim stop requesting termresponse altogether if ttymouse is
> explicitly set in .vimrc (in my case to urxvt), which causes some problems
> (https://github.com/kien/ctrlp.vim/issues/579). Is that intended?

So, if your .vimrc only contains a line to set ttymouse to "urxvt" you
see no request for termresponse? Or is more required to reproduce this.
Perhaps it also depends on what the default value is that Vim uses?

> Would it perhaps be possible to request xterm version first and only then
> check/enable mouse?

Something like that already happens. Unfortunately handling all the
exceptions makes it complicated. And that the terminal mixes what the
user types with these responses is tricky, not understanding a response
means it's used as a command or text.

--
"It's so simple to be wise. Just think of something stupid to say
and then don't say it." -- Sam Levenson

Tomáš Janoušek

unread,
Jul 2, 2014, 7:56:10 AM7/2/14
to Bram Moolenaar, vim...@googlegroups.com
Hi,

On Wed, Jul 02, 2014 at 01:37:25PM +0200, Bram Moolenaar wrote:
> So, if your .vimrc only contains a line to set ttymouse to "urxvt" you
> see no request for termresponse? Or is more required to reproduce this.
> Perhaps it also depends on what the default value is that Vim uses?

Well, almost. If my .vimrc contains no lines at all, there's no request for
termresponse either. With only "set nocompatible", I see a request, with both
"set nocompatible" and "set ttymouse=urxvt", I see no request.

(Or, to be more precise, I hear no request, as I put printf("\a"); just before
LOG_TR("Sending CRV"); for easier debugging. :-))

I compiled it using

./configure --enable-multibyte --prefix=/usr --with-features=huge

As mentioned in the ctrlp issue, "autocmd TermResponse * set ttymouse=urxvt"
fixes the issue again.
Reply all
Reply to author
Forward
0 new messages