Comment 13 for bug 113227

Micah Cowan (micahcowan) wrote :

It appears that the patch I've submitted to vim-dev will be accepted for inclusion:

For reference, here is the patch I submitted. I expect to roll a debdiff against Gutsy's vim soon.

The following known issue remains: this patch will cause vim to detect screen as supporting the "old style" xterm-style mouse protocol, (ttymouse=xterm), and send screen the appropriate control sequence to initiate that protocol. This is fine even when screen isn't running under a terminal that supports that protocol, as screen notices this and only forwards the "activate mouse" sequence to the terminal if the terminal claims to be xterm or rxvt.

However, there appears to be now way for vim to automatically detect support for the "new style" protocol (ttymouse=xterm2). The way vim does this is to send the xterm "request version" control sequence and listen for the response. Screen does not support the "request version" sequence, and will not forward it on, so there is no way for vim to know whether it should attempt to activate it or not. What this means practically, is that vim will automatically enable mouse click-and-release tracking when it sees that the terminal is "screen"; but it will never automatically enable click-and-drag tracking (which is needed to "select" things with the mouse), as it would do when directly running under a modern xterm, since it will be unable to ascertain whether it is safe to do so.

This can be worked around in the .vimrc (as indeed, the original problem could have been: but having vim just do it automatically seemed nicer :) ), by adding something like:

if &term =~ "^screen"
    set ttymouse=xterm2

Of course, this will still fail if you happen to run screen under an old-style xterm that doesn't support the newer protocol.