Repository: wezterm/wezterm (language: rust)

Issue:
[Windows] using portable_pty causes terminal to be cleared while trying to stream to stdout
### What Operating System(s) are you seeing this problem on?

Windows

### Which Wayland compositor or X11 Window manager(s) are you using?

_No response_

### WezTerm version

"0.8.1"

### Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

No, and I'll explain why below

### Describe the bug

While trying to stream output from the pty, the current terminal's output will be cleared. I attached a video recording:

https://github.com/wez/wezterm/assets/4332460/327789b8-763d-4266-902d-3e1fb41f30a0



### To Reproduce

repro repo:
https://github.com/Cammisuli/portable-pty-windows

1. On Windows, run `cargo run`

### Configuration

na

### Expected Behavior

Being able to configure this behaviour with the underlying ConPTY instance. 

### Logs

_No response_

### Anything else?

Diving deep into Windows ConPTY (and stumbling across issues in other libraries, like this https://github.com/microsoft/node-pty/issues/423) there are mentions of using `PSEUDOCONSOLE_INHERIT_CURSOR` to configure conpty. And based on other users reactions, it appears to work for them. 

Microsoft docs https://learn.microsoft.com/en-us/windows/console/createpseudoconsole


Discussion / hints:
Ah, interesting. In wezterm I have a workaround that skips those initial updates from conpty.
I didn't know that the inherit cursor stuff could disable it.

The MS docs make it seem like there needs to be a supplemental background thread required to respond to some additional RPCs that make it more awkward to generically implement in the portable_pty crate.

I'm not often active on Windows recently, so I'm not likely to get to this any time soon.  I'd be open to a PR that takes a crack at supporting this mode of operation if you or someone else feels like volunteering some time!

Fix patch:
diff --git a/pty/src/win/psuedocon.rs b/pty/src/win/psuedocon.rs
index 48e10c04016..13c7c5dba9e 100644
--- a/pty/src/win/psuedocon.rs
+++ b/pty/src/win/psuedocon.rs
@@ -24,6 +24,7 @@ use winapi::um::winnt::HANDLE;
 
 pub type HPCON = HANDLE;
 
+pub const PSUEDOCONSOLE_INHERIT_CURSOR: DWORD = 0x1;
 pub const PSEUDOCONSOLE_RESIZE_QUIRK: DWORD = 0x2;
 pub const PSEUDOCONSOLE_WIN32_INPUT_MODE: DWORD = 0x4;
 #[allow(dead_code)]
@@ -83,7 +84,9 @@ impl PsuedoCon {
                 size,
                 input.as_raw_handle() as _,
                 output.as_raw_handle() as _,
-                PSEUDOCONSOLE_RESIZE_QUIRK | PSEUDOCONSOLE_WIN32_INPUT_MODE,
+                PSUEDOCONSOLE_INHERIT_CURSOR
+                    | PSEUDOCONSOLE_RESIZE_QUIRK
+                    | PSEUDOCONSOLE_WIN32_INPUT_MODE,
                 &mut con,
             )
         };


Test patch: