widescreen selection problem vim 8.2.510

29 views
Skip to first unread message

Patrick Byrne

unread,
Apr 15, 2020, 6:39:32 AM4/15/20
to vim_dev
Hi,

I have a problem selecting text with the mouse in vim.

My monitor is 34" widescreen 2560x1080. Thats 284 columns in vim. I can only select up to column 223 using the mouse. I can still select and edit using keys in the columns right of here.

2560 / 283 is 9 pixels per character width, so 223 columns is 2007 pixels - so perhaps there is an internal 2000 pixel width limit in the mouse selection code? i can well believe that someone writing vim mouse selection code 20 years ago might have thought 2000 an decent upper limit for screen width!

This happens in vim 8.2.510 on archlinux which I think is a pretty recent build.

Cheers
Patrick

Christian Brabandt

unread,
Apr 15, 2020, 6:42:01 AM4/15/20
to vim_dev
Check your 'ttymouse' option please.


Best,
Christian
--
Was man Zuneigung nennt, ist in Wirklichkeit nichts anderes als
Sympathie der Gewohnheit.
-- Adam Smith

Patrick Byrne

unread,
Apr 15, 2020, 6:54:53 AM4/15/20
to vim_dev
It is xterm2. I tried changing it to xterm and same problem (plus I don't see selection update interactively - which I suppose it expected behaviour).

Christian Brabandt

unread,
Apr 15, 2020, 6:57:29 AM4/15/20
to vim_dev

On Mi, 15 Apr 2020, Patrick Byrne wrote:

> It is xterm2. I tried changing it to xterm and same problem (plus I don't see
> selection update interactively - which I suppose it expected behaviour).

I think you need sgr

Best,
Christian
--
Stilblüten aus Schreiben von Versicherungsnehmern:
Ich sah ein trauriges Gesicht langsam vorüberschweben, dann schlug
der Herr auf dem Dach meines Wagens auf.

Patrick Byrne

unread,
Apr 15, 2020, 7:13:46 AM4/15/20
to vim_dev
Yes 'sgr' did it - thanks! Sorry I assumed it was a bug. Perhaps 'sgr' ought to be the default these days.
Cheers
Patrick

Dominique Pellé

unread,
Apr 15, 2020, 7:39:19 AM4/15/20
to vim_dev
Patrick Byrne wrote:

> Yes 'sgr' did it - thanks! Sorry I assumed it was a bug.
> Perhaps 'sgr' ought to be the default these days.
> Cheers
> Patrick

Not sure how many terminals support sgr which supports more columns/rows.
Probably most of them support sgr these days.

In fact ":help ttymouse" says that default value depends on 'term'.
And if I do vim --clean then type :set ttymouse?
it shows: ttymouse=sgr

So it is already sgr by default at least with my xfce4-terminal.
I also see sgr in xterm.

Perhaps your .vimrc is explicitly setting ttymouse to xterm2?
Try running :verbose set ttymouse?
It may give a clue as to where ttymouse was set.

I just checked help files in neovim and interestingly, I see that neovim
has no 'ttymouse' variable. Quoting neovim help file:

=== BEGIN QUOTE nvim.txt ===
Your Vim configuration might not be entirely Nvim-compatible.
See vim-differences for the full list of changes.

The 'ttymouse' option, for example, was removed from Nvim (mouse support
should work without it).
=== END QUOTE ===

Regards
Dominique

Patrick Byrne

unread,
Apr 15, 2020, 8:04:07 AM4/15/20
to vim_dev
The vim docs say sgr should be set if xterm is v277 or later. The xterm binary on my system is 295 which is later, but I worry it is getting the version information from putty somehow. I can't see any xterm version information in the putty configuration dialog.
':verbose set ttymouse?' just yields 'xterm2' so no info thre.
Thanks for your attention, and the attention of others.
For myself I am content to set 'sgr' in my vimrc.

Dominique Pellé

unread,
Apr 15, 2020, 8:46:48 AM4/15/20
to vim_dev
Patrick Byrne <pjlb...@gmail.com> wrote:

> The vim docs say sgr should be set if xterm is v277 or later.
> The xterm binary on my system is 295 which is later, but
> I worry it is getting the version information from putty somehow.

It looks like vim's default value of 'ttymouse' is suboptimal
when using the PuTTY terminal.

Regards
Dominique

Christian Brabandt

unread,
Apr 15, 2020, 9:19:41 AM4/15/20
to vim_dev
So putty does support sgr like mouse reporting? I do not use the mouse,
but at least setting ttymouse=sgr worked in my putty version I use here
locally (0.71). Oh I see putty is already at 0.73 (after years of no new
release, need to update).

I guess this patch should enable it (totally untested):

diff --git a/src/term.c b/src/term.c
index ce935dcf4..fc0febba1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4783,7 +4783,11 @@ not_enough:
// PuTTY sends 0;136;0
// vandyke SecureCRT sends 1;136;0
else if (version == 136 && arg[2] == 0)
+ {
is_not_xterm = TRUE;
+ set_option_value((char_u *)"ttym", 0L,
+ (char_u *)"sgr", 0);
+ }

// Konsole sends 0;115;0
else if (version == 115 && arg[0] == 0 && arg[2] == 0)


Best,
Christian
--
Wer die Menge unbedeutender ungenial(ischer) Bücher sieht, hält die
Menschen für noch unbedeutender.
-- Jean Paul

Christian Brabandt

unread,
Apr 15, 2020, 1:35:31 PM4/15/20
to vim_dev

On Mi, 15 Apr 2020, Christian Brabandt wrote:

> diff --git a/src/term.c b/src/term.c
> index ce935dcf4..fc0febba1 100644
> --- a/src/term.c
> +++ b/src/term.c
> @@ -4783,7 +4783,11 @@ not_enough:
> // PuTTY sends 0;136;0
> // vandyke SecureCRT sends 1;136;0
> else if (version == 136 && arg[2] == 0)
> + {
> is_not_xterm = TRUE;
> + set_option_value((char_u *)"ttym", 0L,
> + (char_u *)"sgr", 0);
> + }
>
> // Konsole sends 0;115;0
> else if (version == 115 && arg[0] == 0 && arg[2] == 0)
>

Hm, this is not quite right. First of all, it also sets ttymouse for
SecureCRT, which is probably wrong. Additionally it only works for
TERM=xterm, however when I use putty, I either use $TERM=putty-256color
or inside tmux/screen where $TERM=screen (or tmux).

It seems this part of the code is only ever executed if T_CRV is not
null. However it looks a bit like magic to me, when this will be
initialized. So what would be a good way to initialize T_CRV in those
cases?

Best,
Christian
--
Delhikatesse:
Spezialität aus Indien, z.b. Delhi-Mehl, s.a. Reis-Leistungsverhältnis

Bram Moolenaar

unread,
Apr 15, 2020, 2:06:25 PM4/15/20
to vim...@googlegroups.com, Christian Brabandt
This most likely stops the mouse from working on older PuTTY versions.
Does PuTTY indicate what it supports somehow?
Not sure what Neovim does with this. If it doesn't need 'ttymouse' then
why wasn't a patch made for Vim?


--
ARTHUR: ... and I am your king ....
OLD WOMAN: Ooooh! I didn't know we had a king. I thought we were an
autonomous collective ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// 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 ///

Christian Brabandt

unread,
Apr 16, 2020, 2:22:50 AM4/16/20
to vim...@googlegroups.com

On Mi, 15 Apr 2020, Bram Moolenaar wrote:

> This most likely stops the mouse from working on older PuTTY versions.
> Does PuTTY indicate what it supports somehow?
> Not sure what Neovim does with this. If it doesn't need 'ttymouse' then
> why wasn't a patch made for Vim?

Not sure about neovim. Does it actually support ttymouse at all?

Anyhow, I went back until Putty 0.65, released 2015-07-25 and even that
old version did support sgr mouse reporting. I wanted to go further
back, but those older versions couldn't agree on a key exchange
algorithm so no connection to my test system was possible.

And there is one good argument for having users install at least PuTTY
0.71. It's the true color patch, that has been included as of that
release :)

So I think we should include this patch. Will post a better version
slightly later.

Best,
Christian
--
Eine Frau ist wie ein Gummibaum. Ist sie älter als 30, taugt sie
nichts mehr.
-- Achmed Sukarno
Reply all
Reply to author
Forward
0 new messages