Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Terminal] VT Mouse Support #545

Open
cerebrate opened this issue May 8, 2019 · 21 comments

Comments

@cerebrate
Copy link

commented May 8, 2019

  • Your Windows build number: (Type ver at a Windows Command Prompt)

10.0.18890.1000

  • What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)

I routinely use mouse mode in tmux with WSL for window selection, pane resizing, and scrollback, enabled in tmux.conf thus:

  # -- mouse support ---------------------------------------------------------                                                                                                                                                                                        
  # Enable mouse control (clickable windows, panes, resizable panes)                                                                
  set -g mouse on

While this works perfectly in conhost, it does not work at all in Terminal; nothing happens, as if the mouse events were never reaching tmux.

  • What's wrong / what should be happening instead:

tmux mouse support (and presumably other mouse-supporting applications) should work as they do in conhost.

@zadjii-msft zadjii-msft changed the title tmux mouse support not functioning in Terminal [Terminal] VT Mouse Support May 8, 2019

@zadjii-msft

This comment has been minimized.

Copy link
Member

commented May 8, 2019

Yea, this is a known issue at the moment. We need to add support for mouse in two places: both in the terminal, to be able to synthesize mouse sequences, and in conpty to be able to read mouse sequences.

This issue is tracking the first bit, the Terminal functionality.

For the second bit, the conpty part, see #376.

@guibirow

This comment has been minimized.

Copy link

commented Jun 25, 2019

Sadly this does not work, having the mouse events with TMUX would defer the need to have multiple panes.
I hope this feature get implemented before the panes, is much needed and will solve most of issues

@jgkawell

This comment has been minimized.

Copy link

commented Jun 28, 2019

I would like to point out that the mouse support is also not supported in tmux within Docker (through Powershell). I know this is because the functionality simply isn't there in Terminal so of course it won't work in WSL or Docker, but thought I'd go ahead and mention it.

@guibirow

This comment has been minimized.

Copy link

commented Jun 28, 2019

the mouse does work with TMUX in WSL

@kumarharsh

This comment has been minimized.

Copy link

commented Jun 28, 2019

Mouse works with wsltty: https://github.com/mintty/wsltty

@jgkawell

This comment has been minimized.

Copy link

commented Jun 28, 2019

@guibirow Maybe it's an issue with Docker from within Terminal then.

@kumarharsh

This comment has been minimized.

Copy link

commented Jun 28, 2019

No. It's not an issue with Docker. It's an issue with conpty (this repo). Try wsltty if you want mouse support.

@jgkawell

This comment has been minimized.

Copy link

commented Jun 28, 2019

Are there plans to enable full mouse support in tmux for Docker in the future through Terminal?

@kumarharsh

This comment has been minimized.

Copy link

commented Jun 28, 2019

I don't know about Docker specifically, but i sight see why it should be any different than a normal terminal. This issue is about that so keep an eye.

@jgkawell

This comment has been minimized.

Copy link

commented Jun 28, 2019

So I just checked tmux through WSL 1 in Terminal and the mouse isn't supported there either. So my guess is that tmux itself just doesn't work in Terminal at this point and that it's not a Docker issue. Not sure what @guibirow was seeing on his end.

@guibirow

This comment has been minimized.

Copy link

commented Jun 28, 2019

You have to run a command to enable it, isn't enabled by default.
I don't have it right now, but it is simple like this set mouse on
I will have to confirm next week when I get my laptop

It only works on wsl terminal though, not in the new windows terminal

@jgkawell

This comment has been minimized.

Copy link

commented Jun 28, 2019

Oh I gotcha. Yeah it works fine in the plain WSL window. It only fails to work when embedded within the new Windows Terminal.

@egmontkob

This comment has been minimized.

Copy link

commented Jul 9, 2019

If you implement mouse support, please make sure to implement the SGR (1006) extension as well.

The legacy, byte-based protocol only allows row and column numbers up to 223, because 32 is added to this number and this is sent as a single byte. The column limit is not uncommon to be too small. (By the way, beginning at column 95 the generated data is not 7-bit clean and not valid UTF-8 which is a problem for encoding conversion layers such as luit.)

The SGR 1006 extension fixes these problems by encoding the numbers as decimal digits, and is supported by plenty of applications.

If this extension is not requested, please don't generate any event if the row or column exceeds 223. Otherwise an overflow could have nasty consequences. E.g. clicking on column 227 could generate the byte 32+227 = 259 = 3 = Ctrl+C which is typically the interrupt character sending a SIGINT to the running process.

@DHowett-MSFT

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

So! Conhost actually does support DECSET 1006! Since we have this intervening layer (the pseudoconsole, which needs to talk to conhost), we get to choose what sort of mouse mode the pseudoconsole requests and supports. I see no reason that that shouldn't just be 1006 😄 Thanks for the info!

@DHowett-MSFT

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

To clarify, because we have conhost in the middle, that would look like this:

                                      +-----------------+
                                      |                 |
                 DECSET 1002, 1005    | Windows conhost |
+-------------+                       |  (in PTY mode)  |
|             +----------------------->                 |
| Application |                       |                 |
|             <-----------------------+                 |
+-------------+                       |                 |
                 mouse information    |                 |
                 1002 in 1005 format  |                 |
                                      |                 |
                                      +---+---------^---+
                                          |         |
                                          |         | mouse information in
                         DECSET 1002,1006 |         | SGR Extended Format
                                          |         | (1002+1006)
                                          |         |
                                      +---v---------+---+
                                      |                 |
                                      | Windows         |
                                      |  Terminal       |
                                      |                 |
                                      |                 |
                                      |                 |
                                      |                 |
                                      +-----------------+
@egmontkob

This comment has been minimized.

Copy link

commented Jul 9, 2019

Did you mean 1005 between the application and conhost, or is that a typo in this picture? Mouse extensions 1005 and 1015 also exist but they are hardly used (if at all) due to their flaws, it's not something that applications are interested in.

1005 (xterm's two-byte UTF-8), 1015 (urxvt) and 1006 (xterm SGR), in this chronological order, are three mutually exclusive extensions to address the limitation of the column number. See e.g. Midnight Commander issues 2662 and 2956 for technical description about the flaws of the first two. Note that this story is now 6-8 years old. I'm not aware of any application that supports the problematic 1005 and/or 1015 but not the okay 1006. As such, I don't see any point in implementing support for the first two (although it should be very easy to implement them).

@zadjii-msft

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

That very well could be a typo, right now, conhost actually supports a bunch of different mouse modes, including, but not limited to 1005 and 1006.

@DHowett-MSFT

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

It’s not a typo. Sorry, this was intended to illustrate how the pseudoconsole system could support a bunch of mouse modes on the client end (an application requests 1005, 1015, legacy VT220, etc.) but present a unified mouse mode interface (1006) to the pty pipe holder.

@DHowett-MSFT

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

That diagram admittedly fits better in #376, which is the infrastructural part of this bug.

@egmontkob

This comment has been minimized.

Copy link

commented Jul 9, 2019

@DHowett-MSFT Awesome, thanks for the clarification!

@rcarmo

This comment has been minimized.

Copy link

commented Aug 3, 2019

I'm eagerly awaiting this to show up in a future release - I keep clicking on tmux panes in hopes the mouse will work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.