-
Notifications
You must be signed in to change notification settings - Fork 167
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
Having trouble sending scroll events to vim or less #128
Comments
vim
or less
Could this possibly be related? #96 |
I don't think they're related? I think the important idea here is a VT/100 terminal's "alternate screen". A terminal's alternate screen has no scrollback, and IIRC, terminals typically convert mouse wheel scrolling into a number of up/down keypresses. IIRC, winpty never puts a terminal into alternate screen mode. It does enable a terminal's mouse input if the console's QuickEdit mode flag is disabled. I don't think WSL ever turns QuickEdit off, and in any case, you don't want the terminal's mouse mode enabled for less, because then you wouldn't be able to select text. winpty already detects when a console buffer is resized to the window size and enters a "direct" scraping mode. Maybe it could then activate the alternate screen. I wonder whether a terminal's alternate screen mode interacts with its mouse input setting at all. It could be interesting to look at a program like htop in WSL. On Linux, htop enables the terminal's mouse mode, so I can click a process' row to select it. The scroll wheel doesn't do anything. With winpty+WSL, I wouldn't expect a mouse click to change the selected row, and instead I'd be able to select text. If winpty were to then put the terminal into alternate screen mode, the scroll wheel would presumably move htop's selection. |
Hey thanks for responding! I'm trying to find out how the default "Bash on Ubuntu on Windows" does this however. For example if I enter Now, it also doesn't seem to be converting the scroll events into up/down keys, I can confirm this by looking at the cursor position, during mouse wheel scroll vs pressing arrow keys, the cursor is on the opposite sides (ie. top/bottom). iTerm2 does this here (https://github.com/gnachman/iTerm2/blob/469d65f3e1521504b96d707c0f272eb285589ca2/sources/VT100Output.m#L451) and I wonder if winpty or another terminal on windows can do the same. Would you know how this functionality can be achieved? |
Hmm, I was going through the source code and saw this (https://github.com/rprichard/winpty/blob/master/src/agent/ConsoleInput.cc#L526), clearly there's support for mouse events, but it doesn't seem to be working for some reason? |
That code converts a terminal scroll wheel escape into a console mouse event record. The terminal will only generate a scroll wheel escape if a terminal program (such as winpty or vim) has enabled its mouse input. winpty probably isn't enabling the terminal's mouse mode, because the underlying console's QuickEdit flag is probably still on. See here: Lines 510 to 527 in ce9239a
Once the terminal's mouse input mode is enabled (even with just flag 1000), mouse clicks (including scroll wheel "clicks") no longer affect text selection or scrollback. Because it prevents selection, it would be wrong to enable them for If these modes aren't enabled, then winpty can't detect use of the scroll wheel. Nonetheless, if winpty did notice scroll wheel clicks, it would write them to the console with As a "workaround" of the above BashOnWindows issue, winpty generates VT/100 input escapes when You could try winpty's I wasn't aware of vim's |
It would be interesting to see whether WSL mouse input works with ConEmu. This issue suggests that it doesn't: Maximus5/ConEmu#1114. |
Yep, can personally confirm that vim scrolling inside ConEmu does not work. |
Also calling |
so, I noticed I can type However, I can't find a way to figure out whether winpty sends a code to let the terminal know whether it enters this alternate screen mode when launching |
That seems still the issue. |
I'm having trouble getting
vim
orless
inside WSL to scroll. I'm using thewinpty.dll
with a wrapper application that sends codes such as\[M<buttonChar><xChar><yChar>
.buttonChar
is 32 + (64 or 65) depending on scroll direction andxChar
andyChar
are mouse coordinates, but the codes seem to be ignored bywinpty
server and nothing happens...* Please let me know if I didn't explain anything properly or skipped information.
The text was updated successfully, but these errors were encountered: