Terminal: ConPTY Passthrough mode

Created on 8 Jun 2019  Â·  42Comments  Â·  Source: microsoft/terminal

Modern apps won’t read the hidden character grid and do everything in VT. So why not an API/console mode to tell Console Host to completely throw away that?

Area-Output Issue-Feature Product-Conhost

Most helpful comment

run a second, hidden console in parallel

The people who hate how ConPTY is implemented today will _absolutely_ hate how it's implemented if we do that. :grin:

All 42 comments

@zadjii-msft was looking into this. The main issue, if I recall correctly, is that we need to trash the entire buffer when something enters or exits “passthrough” mode. It’s also only truly applicable _when there is a connected pseudoconsole session_.

And the reason one console might enter and exit passthrough mode multiple times is that you may run coolNewThing.exe from CMD, and perhaps it might launch a further process that needs legacy support.

Additional concerns: if you have a tree of four processes, each of which wants passthrough to be different, should the ones that are doing ReadConsoleOutput be able to read the buffers from the other legacy/non-passthrough ones?

It’s complicated when you get into compatibility discussions. :smile:

Yea, I tried getting this working for like a day last year, but it's something I've wanted to work on for a while.

As Dustin mentioned, there'd be real weirdness moving between passthrough mode and non-passthrough mode. However, I think it might still be something good to investigate.

From #1985:

I've discussed this a couple times on different threads before, but I think I never made a real issue for it.

The idea of conpty passthrough mode is that a commandline client application
that _knows_ it's only going to use VT sequences (and __not__ the API) to modify
the console could set a special mode, ENABLE_PASSTHROUGH_MODE. If conpty is
active, the console would then _stop_ rendering itself over conpty, and anything
that was written to the console would go straight to the terminal.

  • This would work especially well for something like wsl, where it's only ever going to be talking VT.
  • It would _not_ work for cmd.exe, because of cmd.exe's heavy reliance on the API.
  • Windows Powershell again needs the API pretty heavily, but maybe Powershell
    Core, which is cross-platform, could make use of it.

This has some rough edges that need to be sorted out.

  • [ ] What happens when the app exits, and passthrough mode is turned off? The
    terminal and conpty's buffers would not be equivalent anymore!

    • I've been toying with the idea of having conpty both pass the sequences

      through, and also process them itself, so that the terminal and conpty stay

      in sync.

  • [ ] What happens when someone tries to call Console API's in passthrough mode?

    • I'm thinking we just cause them to fail. All save for Get/SetConsoleMode and reading input / writing output.

    • We'll also probably need to be able to read resize events.

This needs a real spec written, but it probably needs prototyping done before that.

We need a SIGWINCH asynchronous signal for resizing somehow.

This is an essential feature for opening MS text-mode software (esp. WSL) to 3rd-party environments.
The current approach seems to tighly connect the Windows terminal implementation with ConPTY, however that limits applications unnecessarily and makes them highly dependent on Windows terminal progress (which may still take years, honestly).

It would not work for cmd.exe, because of cmd.exe's heavy reliance on the API.

It should be a combined mode: Whenever a console-API-based application is run, e.g. as started from a pure terminal-based application, the console API calls should be transformed into terminal escape sequences. Note as there are not so many features in the console API, this is a much easier approach than the reverse mapping, trying to squeeze terminal features through the conhost bottleneck.

Just realized #2035 is this ask framed differently.

however that limits applications unnecessarily and makes them highly dependent on Windows terminal progress

Not just progress. _Behavior_. This guy is writing a Tek4010 emulator. He is going to need a PTY if say his code were ever ported to native win32. And conhost sure as heck doesn't know what to do with the bytestream coming down that PTY. Never will. And need not care.

We need a SIGWINCH asynchronous signal for resizing somehow.

That too. Doesn't have to be a signal, mind, if there is some religious/philosophical reasons against. But if not it needs to be a separate (third rail) HANDLE on which I can WaitForMultipleObjects(), because no one said there is a ReadFile() byte coming, ever.

@mintty
There are many absurd console API usages, like reading the screen. That's really a legacy that ... IBM PC has a video card while PDPs aren't.
One idea is that ConPTY can have a "sync" stuff to read back the screen from a console application if some console API applications want to something strange. Otherwise the console host could simply convert console API calls into VT sequence, and forward that to the terminal app.

There are many absurd console API usages, like reading the screen.

Great. Invent a new CSI sequence for that. Send the PCHAR_INFO lpBuffer back as I dunno a base64 gzip. The feature is not supported by Mintty. Yet. No biggie. Not even unusual. Any 6502/Z80 assembler programmer working 1981 was free to add their own crazy vendor-specific sequence to their company's terminal if they were bored enough on a weekend too.

There are many absurd console API usages, like reading the screen.

Great. Invent a new CSI sequence for that.

I assume this concern is more about the other direction of such adaptation, i.e. how would you serve a Windows console program that wants to use that "absurd" feature? You could run a second, hidden console in parallel, to maintain backwards compatibility.

run a second, hidden console in parallel

The people who hate how ConPTY is implemented today will _absolutely_ hate how it's implemented if we do that. :grin:

They wouldn't even notice in pure pass-through applications. It might be necessary to solve an otherwise unresolvable dilemma.

run a second, hidden console in parallel

This solution makes no sense because there is no window in sshd.exe nor someoldprogram.exe. Both those programs are text only applications that wouldn't know a Consolas Font from a hole in the ground.

To the point of #2035, neither sshd.exe nor someoldprogram.exe are terminal emulators. Gnome Terminal is a terminal emulator. And gnome-terminal is the only thing that can give the correct answer as to the contents its screen buffer; ie what ReadConsoleOutput() should return. Similarly, the only thing that knows the contents of (VS Code) xterm.js's screen buffer is xterm.js. ConPTY doesn't have a clue what xterm.js internal screen buffer contains. At best it can only guess by scraping the data passing by.

I assume this concern is more about the other direction of such adaptation,

Yes. And as a practical matter I wouldn't expect the ESC[?GIVEMEBUFFERASIBM feature being added to vteterminal anytime soon. Unless someone can point out the killer app that calls ReadConsoleOutput().

[a hidden window] might be necessary to solve an otherwise unresolvable dilemma.

I think we are closer than that. If conhost wants to read-only scrape the data going by for the sole purpose of keeping a wild-ass-guess as what the _actual_ terminal emulator's buffer looks like, sure, I can live with that. ReadConsoleOutput() is a red herring. If conhost (call it a urxvtd analogy) wants to maintain a shadow buffer, it can knock itself out.

...So long as it is quiet about it. There is no reason for a pass-through "mode", which is how this issue was framed. There is never a reason for ConPTY to inject a VT sequence into a WriteFile() on a PTY handle -- ever. Daniel over on the VS Code team can't possibly care; because _he has his own terminal emulator_. PTYs don't care about VT100 sequences. Never heard of them.

[Then we need SIGWINCH (or equivalent thereof). Which isn't related to VT100 sequences or screen buffers either.]

@therealkenc,

Like it or not, conhost is the _API server_ that, regardless of whether it presents a window, makes all existing Win32 console applications work. It must continue to make those applications work, because organizations really ~hate~ love when Microsoft rolls through with a new standard and tells everybody to drop what they're doing and throw out thousands of lines of code.

I think you're looking to turn this request, and this project, into something it's not. You may be attempting to turn CreatePseudoConsole into something it's not, too. Things work the way they work because we need to maintain compatibility with the thirty years of applications written since the VGA text mode buffer became the "official" design inspiration for how consoles should work in DOS and Windows.

ConPTY exists to--narrowly-stated--allow an application that understands a number of sequences as specified by an xterm-256color terminfo to host a _windows console application_; to wit: an application that would otherwise run in conhost should be able to run in a "terminal emulator" of sufficient compatibility. It's not intended to support a TEK4010 application (those are not windows console subsystem applications), and it's not likely to want to support a TEK4010 terminal emulator that is expecting to receive a bytestream from a TEK4010 application. That guy will probably end up doing what everybody ELSE who doesn't want to write a windows console subsystem application does: use pipes, because they don't have the same compatibility requirements (neé guarantees) as the windows pseudoconsole infrastructure.

Through that lens, a "passthrough" mode is required. A console application _by default_, and this cannot be changed for compatibility reasons, starts up in a mode where it just has full access to all of the stupid Win32 console APIs that no terminal emulator developer wants to countenance. Nobody _should_ be able to read back the contents of a terminal buffer, local or remote, that they wrote to. Nobody _should_ be able to write into the offscreen section of the buffer, because there's no guarantee anywhere else that it actually exists. But, they do. Developers use this. Applications expect this, because they were written as windows console subsystem applications. A passthrough mode--mode!--is the only way we can offer an application a way to say "I promise I won't use the old ways" while still being a windows console subsystem application. That's the first step we can make towards ConPTY being the dumb pipe you want it to be.

If you'd like to debate whether the Windows Console was the right choice, or was well-designed, I'm happy to have you do it--but not here.


Two asides.

  1. If you're looking for a better SIGWINCH, follow #281.
  2. On machines where isatty(3) is a libc-provided fixture, you also have openpty(3). When somebody spawns a child application with a stdin/stdout hooked up to file descriptors they get back from openpty(3), isatty(3) suddenly returns 1. That application will, more often than not, decide that what that means is that it can send back VT100 escape sequences. That's what it means to most applications to be "on a tty." Sure, it's a terrible abstraction and a poor design and applications should be smarter than this, but they're not. The Windows Pseudoconsole fits right in, here, with the understanding that "I've allocated a PTY, which means I want VT".

I'm not intending to criticize the design or implementation -- at all. That was not the intent. I am trying (more slowly than intended) to find a solution to open-for-a-year issue WSL#3279. Of which Biswa96 has a very good start.

woah this thread got pretty out of hand over the weekend.

The stars aligned Friday, and I actually got a chance to play around with implementing a passthrough mode for conpty. I'm pretty happy with how it works so far, so I think it needs a spec and some polish, and maybe we can ship it one day. Here's the approach I've been taking:

  • I introduced a new ENABLE_PASSTHROUGH_MODE to the SetConsoleMode flags.
  • When a commandline application enables passthrough mode, and the console is currently attached to a terminal (it's in conpty mode), any text they write to the console is written _straight_ to the terminal as well, with no munging by conhost.
  • In passthrough mode, conpty stops "rendering" any changes to its buffer.
  • If a commandline application knows it's not going to be doing anything with the console API, it can safely set passthrough mode to be able to talk directly to the terminal.
  • [NOT DONE YET] If a commandline app in passthrough mode tries to call any API's, we'll either:

    • Convert the effects of that API call to VT, and pass that through to the terminal. We'll do this for API's where this is reasonable - SetConsoleTextAttribute is a good example.

    • For some APIs where the terminal doesn't _really_ matter, we'll just keep doing what we're currently doing (case in point GetConsoleProcessList).

    • For APIs that don't make sense for conhost to be able to respond in passthrough mode, or we can't create a VT sequence to perform the requested operation, we'll return E_UNSUPPORTED_API (or a real error) indicating that API isn't supported in passthrough mode. Case in point: ReadConsoleOutput*, ScrollConsoleScreenBuffer, SetConsoleDisplayMode, etc.

    • Since the client app was updated to _add_ support for passthrough mode, it should be able to be updated to handle this error case as well.

  • conhost _also_ processes the strings that a commandline app emitted. This is to _try_ and keep conpty's state in sync. This is important for the following.
  • When a client app exits passthrough mode, there's a chance that the terminal is in a torn state from the conpty. Case in point, if cmd.exe launched wsl.exe, and wsl enabled passthrough, did some stuff, then wsl exited, and cmd restored the console back to non-passthrough mode (as it needs to use the API). When passthrough mode is exited, conpty will redraw its screen, to re-sync the terminal to what conpty believes the buffer looks like.

    • For things like just launching wsl.exe or ssh.exe directly, or for mintty, this won't be as important, as the client will always be in passthrough mode, and the conpty will never "exit" passthrough.

This provides a way where we can be sure that apps that _weren't_ updated for running in a pty will still have access to the entire console API, but apps that want to live in the new world can say "I promise I know what I'm doing", and run even smoother in conpty. I believe there's going to be an _incredibly small_ intersection of apps that want to use VT and also call things like ReadConsoleOutput. Most apps are wither going to be console-like, using the API heavily, and might not be as likely to be updated for such a mode. However, for *nix-like apps that _aren't_ going to be using the API so much and are primarily speak VT, this is an excellent option. This flag creates a clear distinction between the two when running in a pty.

This sounds like an excellent plan, and thanks for caring about mintty.
From the description of the [not done yet] item, I guess even the following use case might work: A terminal runs wsl.exe through a pipe, and in the WSL session the user invokes cmd.exe...

Indeed sounds good. My points:

  • It seems like we can change the meaning of passthrough mode from "I won't use any of Console API" to "I won't use any of bizzare Console API functions that aren't convertible to VT or otherwise easliy handleable like GetConsoleProcessList". The list of such functions will go to docs.microsoft.com.

  • Actually the passthrough mode could be assumed by default and ConPTY can be lazily enabled. So if user runs a command line program and the program starts writting text/vt (or use sane API functions), conhost would then just pass them through and record changes, like @zadjii-msft described. But if it sudenly uses insane API function (e.g. it's shell and it launched a program that does so), then conhost would fallback to current behaviour with ConPTY, also like described above:

When passthrough mode is exited, conpty will redraw its screen, to re-sync the terminal to what conpty believes the buffer looks like.

This would make appropriate applications work with passthrough mode without any modifications.

  • In case of wsl or alike called directly, where they will always be in passthrough mode, then conhost wouldn't need to record the state. So if the terminal launches wsl and it says "I will ever use passthrough mode", then the terminal can say to system that he doesn't need ConPTY, becouse the app it launched will never use it. If on the other hand the terminal launches cmd which launches wsl it won't do that, becouse now wsl isn't the process that he [the terminal] launched, but some child process of it.
    Conhost would then just read from one pipe and pass that to other, which could be further optimised, but it would probably need to sit there to handle signal pipe.

I'd like to ask about progress in this issue.
Recent "WSL 2" mode (currently under evaluation in the Windows Insider program) appears to be incompatible with previous workarounds to run WSL properly from terminal environments. This makes the need for conpty passthrough mode more urgent and it would be highly appreciable to have it available before the release of WSL 2 mode into the main Windows branch.

@mintty WSL 2 doesn’t change anything about how WSL instances are hosted in consoles, so it’s very unlikely that passthrough mode would help. What specific issue are you seeing?

Without conpty, bash.exe or wsl.exe do not work well if connected directly to a pty or pipe. Previous wrappers like winpty or wslbridge work around that by running their backend in a hidden virtual console from which they grab output, poke input, mediate signal handling etc. This does not seem to work with WSL 2.
Conpty has the capability to replace this wrapping function, but it enforces its own terminal model which is not desirable in this scenario.

Previous wrappers ... work around that by running their backend in a hidden virtual console from which they ...

That 100% should still work today. Those are powered by the ReadConsoleOutput API, which we cannot break.

WSL2 doesn't change anything about how WSL instances are hosted in consoles. Any change in behavior there is absolutely a bug that we should fix before 20H1, but this feature request isn't the appropriate place to discuss that.

Since nobody here can reproduce this particular failure, can you please file a detailed bug report on what you're seeing? What wrapper, what version of Windows, _what is happening_ and _what should be happening_?

The wrapper does not actually use ReadConsoleOutput, so maybe it's proper to still discuss that here;
it's https://github.com/rprichard/wslbridge/, called from a cygwin terminal.
Its connection to WSL seems to be based on CreatePipe.

For the record, I prototyped passthrough mode about a month ago. I had quite a fair amount of success with it, and I felt pretty happy with the prototype. You can check out the prototype on this branch (fair warning - it's quite a bit out-of-date).

What are the next steps here?

  • A full spec needs to be written to formalize what passthough mode means. I mostly want to address what happens when applications call APIs other than just read/write on the console - which APIs will we be translating straight to VT, or will we just fail all of them? This is likely going to be the longest part of the process.
  • We'll need to review and approve the spec. Because this is affecting conhost and the Console API surface, we'll probably need slightly more formality to this than our typical spec reviews.
  • We'll then need to polish the implementation to match the spec and add tests. Again, because this is part of an inbox API, we'll probably need to sync this to the Windows dev cycle to get it checked it. This _we on the console team_ will have very little control over.

To be 100% transparent, it's not being looked at for the 20H1 release.


Because passthrough mode is _not_ going to be a timely solution to the WSL2 issue that @mintty mentions, we should fork a thread for that discussion, to debug and understand what's wrong.

conhost also processes the strings that a commandline app emitted. This is to try and keep conpty's state in sync. This is important for the following.

I think we should ask the CONPTY consumer to implement this -- so CONHOST could completely get rid of the character matrix in the passthrough mode.
If the consumer doesn’t implement this then CONHOST should reject entering passthrough mode.

There is no standard provision for a VT application to read back the buffer. Asking a terminal emulator to handle it is asking a lot of Terminal developers.
Consider that you wouldn’t be able to _ssh to windows_ unless you were using a terminal emulator that supported readback.

(@be5invis: you are basically asking us to create a _new API_ that will _force all terminal developers_ to support legacy windows console behaviors. That’s just not likely to happen, and nobody would be willing to support it.)

@DHowett-MSFT
Well the “new API” is one-shot: only when CONHOST switch back to traditional mode, this API would be called once to read what the current application renders.
A terminal developer can choose not to implement this — and CONHOST would disable passthrough mode in this case.

@be5invis @DHowett-MSFT
I understand it this way so that conhost starts in passthrough mode by default and doesn't record changes that passes through it. If app starts to use the insane, inconvertible-to-vt API functions, then conhost asks the terminal to get its current state (like buffer) and exits passthrough mode.
If a terminal doesn't support the get current state function, then conhost has to record the changes that passes through it, so when it eventually exits passthrough mode it is in the same state as terminal.

@be5invis : Ah, now I understand the proposal. What, for comparison, about my previous proposal to run a hidden/dummy console in parallel, so you're always prepared for this case and don't need to disable passthrough?

Hey ConPTY devs,

First, many thanks for this API, this is a huge step forward. I actually came here because I am developing my own terminal emulator, and mainly while being on my windows machine - until I realized that it was eating my VT sequences.

So I am very happy to read that there is indeed a strong motivation to implement a pass through mode.

What is actually needed for me to get my hands dirty early with this mode? As all this eating makes it basically impossible to debug my own code via ConPTY. I am not really a Win32-dev, so please go easy on me. ;)

Thanks you.

Thanks to everyone working on this! I've been hoping to see this for some time, so very excited to see progress!

Actually the passthrough mode could be assumed by default and ConPTY can be lazily enabled.

I just wanted to weigh in that passthrough-by-default seems highly desirable to me.

If I'm reading right, passthrough will result in faster and better rendering (e.g. resolves #405) more or less universally. The only downside is that it would break compatibility with some console APIs (which cross-platform VT-based apps will not need).

So it seems to me that a good balance would be:

  • By default apps run in passthrough. If an app uses an incompatible console API then switch to conpty mode.
  • Apps could ensure better performance / rendering by calling SetConsoleMode to explicitly enable passthrough mode. In this state, calling unsupported APIs will result in an unsupported error.
  • Apps could also call SetConsoleMode to explicitly disable passthrough mode. They might want to do this on startup so they can safely use incompatible APIs without causing a mode switch & redraw during program operation.

Also some interesting questions which just struck me:

  • what happens if a child process which inherits the parent's console attempts to enable passthrough mode, but the parent depends on incompatible APIs?
  • if a child process disables/enables passthrough mode and then exits, should the previous mode be restored once the child process exits?

A further thought: will the hosting terminal emulators be able to query if the pseudoconsole is in passthrough mode? This might be needed, for example when the window resizes:

  • If it is in passthrough, then the terminal emulator should perform text reflow when the window resizes
  • If it is not in passthrough, then ConPTY will perfom text reflow (so the terminal emulator should not)

I think if the terminal emulators request a ConPTY and state whether or not
to to get pass through mode, then the terminal emulator already knows what
to do in such circumstances.

On Mon, 9 Dec 2019, 06:51 David Hewitt notifications@github.com wrote:

A further thought: will the hosting terminal emulators be able to query if
the pseudoconsole is in passthrough mode? This might be needed, for example
when the window resizes:

  • If it is in passthrough, then the terminal emulator should perform
    text reflow when the window resizes
  • If it is not in passthrough, then ConPTY will perfom text reflow (so
    the terminal emulator should not)

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/terminal/issues/1173?email_source=notifications&email_token=AAAN3O2FBNHB5LIVP5O22FDQXXMHZA5CNFSM4HWHDMHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGH5QDA#issuecomment-563075084,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAN3OYWW4ENVN5F3DALG4TQXXMHZANCNFSM4HWHDMHA
.

I think if the terminal emulators request a ConPTY and state whether or not
to to get pass through mode, then the terminal emulator already knows what
to do in such circumstances.

Sure; however it sounded to me like for the solution proposed here the commandline app would request passthrough mode, rather than the terminal emulator. So the terminal emulator would have no knowledge of whether passthrough mode is enabled.

IMHO it doesn't make sense for the app (running inside a terminal emulator)
to request passthrough mode but the terminal emulator, the one to interpret
the VT sequences, must see the VT sequences as equivalent as possible to
what the app produced. ?The problem with ConPTY is, that it is going to
reimplement every single VT sequence out there, and it lags behind. Hence,
terminal emulator writers where reporting bugs (or missing features), and
the best way to work around that is to "just pass all VT sequences through
\"as-is\"", eliminating a whole range of issues within ConPTY, and thus,
giving the terminal emulator the chance to actually see what the apps
produce, and render that.

The app inside any terminal emulator, while it should know when it is going
to be resized, should not care about what terminal emulator of
man-in-the-middle (conpty) it is running in. Do you agree?

Am Mo., 9. Dez. 2019 um 08:51 Uhr schrieb David Hewitt <
[email protected]>:

I think if the terminal emulators request a ConPTY and state whether or not
to to get pass through mode, then the terminal emulator already knows what
to do in such circumstances.

Sure; however it sounded to me like for the solution proposed here the
commandline app would request passthrough mode, rather than the terminal
emulator. So the terminal emulator would have no knowledge of whether
passthrough mode is enabled.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/terminal/issues/1173?email_source=notifications&email_token=AAAN3OYOEQS5Q5RM5ORTTG3QXX2G7A5CNFSM4HWHDMHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGIF25I#issuecomment-563109237,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAN3O4XF6KLNQELYXBXMJLQXX2G7ANCNFSM4HWHDMHA
.

@christianparpart sometimes, there _are_ no VT sequences coming out of an application. The Windows Console APIs are not implemented using VT sequences.
The application must request passthrough mode to tell the console that it will not use one of the APIs that cannot be translated into VT sequences.

The terminal cannot set passthrough mode because it cannot force legacy applications to become compatible with VT sequences.

This is why ConPTY exists.

For a terminal, whether conhost is in ConPTY or passthrough mode should be irrelevant, because the terminal application will just receive VT sequences through the PTY pipe.

For a terminal, whether conhost is in ConPTY or passthrough mode should be irrelevant, because the terminal application will just receive VT sequences through the PTY pipe.

That's my point; it's not irrelevant in certain edge cases. For example when the window resizes: at the moment ConPTY reflows its buffer and sends the terminal emulator instructions to redraw everything. In passthrough mode this won't happen, so the terminal emulator will have to do reflow itself.

Idea: Perhaps an OSC escape sequence could be sent by conhost to inform the terminal emulator that conhost is entering / exiting passthrough mode?

The terminal cannot set passthrough mode because it cannot force legacy applications to become compatible with VT sequences.

No, the use case is a terminal running a specific backend, particularly WSL, so it knows the client will use VT mode and passthrough is needed to give it full functionality.

... when the window resizes: at the moment ConPTY reflows its buffer and sends the terminal emulator instructions to redraw everything. In passthrough mode this won't happen, so the terminal emulator will have to do reflow itself.

The terminal would "normally" notify the pty about changed terminal size. The pty would then send a SIGWINCH signal to the client application. ConPTY should handle this signal forwarding somehow. Then the client application can redraw itself.

No, the use case is a terminal running a specific backend, particularly WSL, so it knows the client will use VT mode and passthrough is needed to give it full functionality.

I disagree. Knowledge that passthrough is needed for full functionality would be better written once in the client app (e.g. wsl.exe) than in every terminal emulator which wants to host WSL.

The terminal would "normally" notify the pty about changed terminal size. The pty would then send a SIGWINCH signal to the client application. ConPTY should handle this signal forwarding somehow. Then the client application can redraw itself.

Agreed (I think it might already send this signal?). But I'm not talking about SIGWINCH here. I'm talking about the terminal emulator's own text layout & redraw, such as wrapping overflowing lines. At the moment ConPTY does line wrapping on its internal buffer and sends VT output to the emulator on how to draw the wrapped text. In passthrough mode the emulator will get unwrapped text and need to wrap it itself.

Was this page helpful?
0 / 5 - 0 ratings