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

ConPTY: pass through requests for the alt buffer #381

Closed
davidhewitt opened this issue Mar 4, 2019 · 28 comments · Fixed by #12561
Closed

ConPTY: pass through requests for the alt buffer #381

davidhewitt opened this issue Mar 4, 2019 · 28 comments · Fixed by #12561
Assignees
Labels
Area-Interop Communication between processes Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Conpty For console issues specifically related to conpty Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Work-Item It's being tracked by an actual work item internally. (to be removed soon)

Comments

@davidhewitt
Copy link

When running cmd.exe inside a pseudoconsole, trying to enter the alternate screen buffer escape sequences via echo �[?1049h and echo �[?1049l does not result in them being sent to the ConPTY output pipe. It appears to me they are being processed inside cmd.exe and swallowed.

Does it make sense / is it possible for these sequences be output by ConPTY? This would allow terminal emulators to do things like support scrolling inside programs such as less which make use of the alternate screen buffer.

@miniksa
Copy link
Member

miniksa commented Mar 4, 2019

They're processed inside the console host window (which is hosting cmd.exe and powering your ConPTY session) to establish and remove an alternate screen buffer at that level. The effects of the operation will be visible on the output pipe (that is, it should "clear the screen" and then draw the contents of the alternate one onto the final terminal attached to the ConPTY end). But the final terminal isn't responsible for the maintenence of that state right now.

I believe that tools like less that use an alternate screen buffer currently work just fine with this arrangement. If you have evidence to the contrary, we'd be interested in pursuing that as an issue itself.

Internally we have the potential future work item to make it so there is a ConPTY "pass-through" mode. MSFT: 20190846.

@miniksa miniksa added backlog Product-Conpty For console issues specifically related to conpty Work-Item It's being tracked by an actual work item internally. (to be removed soon) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Mar 4, 2019
@davidhewitt
Copy link
Author

Indeed tools such as less do work acceptably at the moment. I can see the console host window is processing the alternate buffer, thanks. However, comparing the experience of using less on Windows to Centos linux (gnome):

  • Centos: scrolling with the mousewheel scrolls less's alternate buffer, keeping the document in less correctly ordered
  • Windows / WSL: scrolling with the mousewheel scrolls the console window history, potentially creating garbled lines of output as the history gets mixed with the contents of the document in the alternate buffer.

It would be really nice if the console window behaved like Centos in this case, as I find it much more intuitive and a convenient way to read documents. Furthermore, terminal emulators with their own scrollback function are unable to provide the Centos-like behavior if they are not aware that the alternate buffer has been opened.

The pass-through mode sounds like it'd make it possible for terminal emulators to handle this themselves, thanks!

(Happy to provide some gifs if I've done a poor job explaining the behavior?)

@zadjii-msft
Copy link
Member

Unfortunately conpty doesn't support mouse input quite yet, though that's something fairly high on our backlog.

Pass-throughing the alt buffer switching is something that we'll likely do earlier than adding mouse support, and definitely before enabling a true passthrough mode.

@davidhewitt
Copy link
Author

Sounds great, thanks!

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label May 17, 2019
@DHowett-MSFT DHowett-MSFT changed the title ConPTY: alternate screen escape codes ConPTY: pass through requests for the alt buffer May 18, 2019
@DHowett-MSFT DHowett-MSFT added the Area-Interop Communication between processes label May 18, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 18, 2019
@ihor-sviziev
Copy link

Hi @DHowett-MSFT,
I see that last comment there was added more than 1 year ago. Is there any plans for fixing it?
This is follow up on #5762

@DHowett-MSFT
Copy link
Contributor

@ihor-sviziev every bug that we keep open is something we are hoping to fix :) we have been prioritizing other things because we wanted to make sure the basic experience worked properly. This one is more complicated because it needs to work for classic Win32 applications at the same time as modern VT applications (like the ones running inside WSL!)

@ihor-sviziev
Copy link

@DHowett-MSFT maybe there is a way to support it only for WSL as first part and later on add support for for win32 applications?

@DHowett-MSFT
Copy link
Contributor

It’s something we could consider, but if the solution to making it work for WSL wouldn’t be something we could build on for Win32, I’d rather not ask my team to do the throwaway work. Once the pressure from 1.0 lets up, we’ll be able to evaluate things like this 😄

@chenzhiwei

This comment was marked as spam.

@zadjii-msft

This comment was marked as off-topic.

@ghost

This comment was marked as off-topic.

@lucy

This comment was marked as off-topic.

@DHowett
Copy link
Member

DHowett commented Nov 16, 2021

The rendering settings will neither fix nor break this. If you observed them helping, that was just a stroke of luck. 😄

@GaroneHuang

This comment has been minimized.

@zadjii-msft

This comment has been minimized.

@eugenov

This comment has been minimized.

@zadjii-msft zadjii-msft modified the milestones: Terminal v2.0, 22H2 Jan 4, 2022
@zadjii-msft zadjii-msft modified the milestones: 22H2, Terminal v1.14 Feb 9, 2022
@zadjii-msft zadjii-msft self-assigned this Feb 23, 2022
@ghost ghost added the In-PR This issue has a related PR label Feb 23, 2022
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Apr 12, 2022
DHowett pushed a commit that referenced this issue Apr 12, 2022
This PR allows the Terminal to actually use the alt buffer
appropriately. Currently, we just render the alt buffer state into the
main buffer and that is wild. It means things like `vim` will let the
user scroll up to see the previous history (which it shouldn't).

Very first thing this PR does: updates the
`{Trigger|Invalidate}Circling` methods to instead be
`{Trigger|Invalidate}Flush(bool circling)`. We need this so that when an
app requests the alt buffer in conpty, we can immediately flush the
frame before asking the Terminal side to switch to the other buffer. The
`Circling` methods was a great place to do this, but we don't actually
want to set the circled flag in VtRenderer when that happens just for a
flush. 

The Terminal's implementation is a little different than conhost's.
Conhost's implementation grew organically, so I had it straight up
create an entire new screen buffer for the alt buffer. The Terminal
doesn't need all that! All we need to do is have a separate `TextBuffer`
for the alt buffer contents. This makes other parts easier as well - we
don't really need to do anything with the `_mutableViewport` in the alt
buffer, because it's always in the same place. So, we can just leave it
alone and when we come back to the main buffer, there it is. Helper
methods have been updated to account for this. 

* [x] Closes #381
* [x] Closes #3492
* #3686, #3082, #3321, #3493 are all good follow-ups here.
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Apr 12, 2022
@ghost
Copy link

ghost commented May 24, 2022

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

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interop Communication between processes Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Conpty For console issues specifically related to conpty Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Work-Item It's being tracked by an actual work item internally. (to be removed soon)
Projects
None yet
Development

Successfully merging a pull request may close this issue.