Scrolling in the Alternate Screen Buffer should send up/down keystrokes? #4642

Closed
opened 2026-01-30 23:52:39 +00:00 by claunia · 9 comments
Owner

Originally created by @yossizahn on GitHub (Oct 25, 2019).

Description of the new feature/enhancement

Many terminals will set different scrolling behavior within the Alternate Screen Buffer such that scrolling will send up/down key strokes. This seems to make more sense than scrolling through the main buffer's history.
xterm has this as an option (set by the 'alternatescroll' Xresource), VTE based terminals have this set as default behavior.
Please consider adding this capability to Windows Terminal.

Depends on #381.

Originally created by @yossizahn on GitHub (Oct 25, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Many terminals will set different scrolling behavior within the Alternate Screen Buffer such that scrolling will send up/down key strokes. This seems to make more sense than scrolling through the main buffer's history. xterm has this as an option (set by the 'alternatescroll' Xresource), VTE based terminals have this set as default behavior. Please consider adding this capability to Windows Terminal. Depends on #381.
Author
Owner

@egmontkob commented on GitHub (Oct 25, 2019):

FYI: Konsole supports this too. In all three of these emulators, you can toggle this behavior runtime using DECSET 1007.

@egmontkob commented on GitHub (Oct 25, 2019): FYI: Konsole supports this too. In all three of these emulators, you can toggle this behavior runtime using DECSET 1007.
Author
Owner

@zadjii-msft commented on GitHub (Oct 25, 2019):

I'd just like to add that the vintage console already does support this mode :)

I'd imagine that our mouse support will done in pieces, with basic mouse support coming first, and this being a follow-up. Once #376 and #545 are done, this would be the next logical follow-up task.

@zadjii-msft commented on GitHub (Oct 25, 2019): I'd just like to add that the vintage console already does support this mode :) I'd imagine that our mouse support will done in pieces, with basic mouse support coming first, and this being a follow-up. Once #376 and #545 are done, this would be the next logical follow-up task.
Author
Owner

@j4james commented on GitHub (Mar 22, 2020):

I'd just like to add that the vintage console already does support this mode :)

Note that there are issues with the current conhost implementation though. I just did a quick test in VIM (version 8.0.1453), and mouse wheel scrolling had no effect. There are two reasons for this:

  1. VIM doesn't actually enable alternate scroll mode (private mode 1007), and for us it's disabled by default. I'm not sure whether we'd consider this a bug or not, since Xterm has the same default. However, a lot of other emulators do have it enabled by default, (or don't even have the option of turning it off), so that's maybe something worth considering.
  2. Even if you enable the alternate scroll mode manually, it still doesn't work in VIM, because VIM turns on Cursor Keys Mode (DECCKM), and our alternate scroll implementation doesn't take that into account, so we are sending the wrong escape sequences. This is definitely a bug which we need to fix.
@j4james commented on GitHub (Mar 22, 2020): > I'd just like to add that the vintage console already does support this mode :) Note that there are issues with the current conhost implementation though. I just did a quick test in VIM (version 8.0.1453), and mouse wheel scrolling had no effect. There are two reasons for this: 1. VIM doesn't actually enable alternate scroll mode (private mode 1007), and for us it's disabled by default. I'm not sure whether we'd consider this a bug or not, since Xterm has the same default. However, a lot of other emulators do have it enabled by default, (or don't even have the option of turning it off), so that's maybe something worth considering. 2. Even if you enable the alternate scroll mode manually, it still doesn't work in VIM, because VIM turns on Cursor Keys Mode (`DECCKM`), and our alternate scroll implementation doesn't take that into account, so we are sending the wrong escape sequences. This is definitely a bug which we need to fix.
Author
Owner

@j4james commented on GitHub (Mar 23, 2020):

FYI, I've submitted a PR for the DECCKM problem mentioned in point 2 above. As for point 1, I think we were probably correct in leaving the scroll mode disabled by default as Xterm has done. I just discovered there is an option you can enable in VIM which will make it handle all the mouse scrolling itself. And if we were to enable the alternate scroll mode by default, we'd just end up breaking that functionality.

@j4james commented on GitHub (Mar 23, 2020): FYI, I've submitted a PR for the `DECCKM` problem mentioned in point 2 above. As for point 1, I think we were probably correct in leaving the scroll mode disabled by default as Xterm has done. I just discovered there is an option you can enable in VIM which will make it handle all the mouse scrolling itself. And if we were to enable the alternate scroll mode by default, we'd just end up breaking that functionality.
Author
Owner

@yossizahn commented on GitHub (Mar 25, 2020):

FYI, I've submitted a PR for the DECCKM problem mentioned in point 2 above

Er... I'm no console guru, so I may have not totally understood the previous discussion...
@j4james, will your fix allow mouse scrolling within less?

As for point 1, I think we were probably correct in leaving the scroll mode disabled by default as Xterm has done. I just discovered there is an option you can enable in VIM which will make it handle all the mouse scrolling itself. And if we were to enable the alternate scroll mode by default, we'd just end up breaking that functionality.

Are you sure about that? I just checked with Gnome Terminal (VTE based, I believe) and mintty. And they both behave correctly whether set mouse= or set mouse=a. i.e. when set mouse= they seem to send up/down key strokes, and when set mouse=a they seem to leave scroll handling to vim.

@yossizahn commented on GitHub (Mar 25, 2020): > FYI, I've submitted a PR for the DECCKM problem mentioned in point 2 above Er... I'm no console guru, so I may have not totally understood the previous discussion... @j4james, will your fix allow mouse scrolling within `less`? > As for point 1, I think we were probably correct in leaving the scroll mode disabled by default as Xterm has done. I just discovered there is an option you can enable in VIM which will make it handle all the mouse scrolling itself. And if we were to enable the alternate scroll mode by default, we'd just end up breaking that functionality. Are you sure about that? I just checked with Gnome Terminal (VTE based, I believe) and mintty. And they both behave correctly whether `set mouse=` or `set mouse=a`. i.e. when `set mouse=` they seem to send up/down key strokes, and when `set mouse=a` they seem to leave scroll handling to vim.
Author
Owner

@j4james commented on GitHub (Mar 26, 2020):

Er... I'm no console guru, so I may have not totally understood the previous discussion...
@j4james, will your fix allow mouse scrolling within less?

Yes, but only if you enable the alternate scrolling mode first (i.e. something like printf "\e[?1007h"). And note that this still only applies to conhost - it's not supported by Windows Terminal yet (that's why this issue is still open).

Are you sure about that? I just checked with Gnome Terminal (VTE based, I believe) and mintty. And they both behave correctly whether set mouse= or set mouse=a. i.e. when set mouse= they seem to send up/down key strokes, and when set mouse=a they seem to leave scroll handling to vim.

I haven't tried Gnome Terminal, but Mintty definitely behaves weirdly for me with set mouse=a. It seems like it's generating up/down key strokes as well as passing the mouse events through, so some of the time the cursor moves and some of the time the screen scrolls.

That said, I don't feel strongly about what this defaults too, and maybe there is a way to have it enabled by default and still work well with applications that handle the scrolling themselves. But for now at least we're compatible with XTerm, and anyone that prefers it on by default can still trigger that manually.

@j4james commented on GitHub (Mar 26, 2020): > Er... I'm no console guru, so I may have not totally understood the previous discussion... > @j4james, will your fix allow mouse scrolling within `less`? Yes, but only if you enable the alternate scrolling mode first (i.e. something like `printf "\e[?1007h"`). And note that this still only applies to conhost - it's not supported by Windows Terminal yet (that's why this issue is still open). > Are you sure about that? I just checked with Gnome Terminal (VTE based, I believe) and mintty. And they both behave correctly whether `set mouse=` or `set mouse=a`. i.e. when `set mouse=` they seem to send up/down key strokes, and when `set mouse=a` they seem to leave scroll handling to vim. I haven't tried Gnome Terminal, but Mintty definitely behaves weirdly for me with `set mouse=a`. It seems like it's generating up/down key strokes as well as passing the mouse events through, so some of the time the cursor moves and some of the time the screen scrolls. That said, I don't feel strongly about what this defaults too, and maybe there is a way to have it enabled by default and still work well with applications that handle the scrolling themselves. But for now at least we're compatible with XTerm, and anyone that prefers it on by default can still trigger that manually.
Author
Owner

@zadjii-msft commented on GitHub (Feb 24, 2022):

Ruh roh, did we regress this for conhost? I'm going to do this for the Terminal branched off of #12561 and it's not even working in conhost anymore 😨

Sorry for the panic. The correct thing to do here is

printf "\e[?1007h" ; man ps

That enables alternate scroll mode, then runs man. That works fine in conhost. It's been a while since I worked in this area, that's my b.

@zadjii-msft commented on GitHub (Feb 24, 2022): Ruh roh, did we regress this for conhost? I'm going to do this for the Terminal branched off of #12561 and it's not even working in conhost anymore 😨 Sorry for the panic. The correct thing to do here is ``` printf "\e[?1007h" ; man ps ``` That enables alternate scroll mode, then runs `man`. That works fine in conhost. It's been a while since I worked in this area, that's my b.
Author
Owner

@zadjii-msft commented on GitHub (Apr 28, 2022):

This was merged in #12657, I didn't notice the two didn't get linked up.

@zadjii-msft commented on GitHub (Apr 28, 2022): This was merged in #12657, I didn't notice the two didn't get linked up.
Author
Owner

@ghost commented on GitHub (May 24, 2022):

:tada:This issue was addressed in #12569, which has now been successfully released as Windows Terminal Preview v1.14.143.🎉

Handy links:

@ghost commented on GitHub (May 24, 2022): :tada:This issue was addressed in #12569, which has now been successfully released as `Windows Terminal Preview v1.14.143`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.14.143) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4642