C# ConPTY Example #373

Closed
opened 2026-01-30 21:50:15 +00:00 by claunia · 8 comments
Owner

Originally created by @waf on GitHub (Sep 9, 2018).

I've created a (very) rough C# terminal using ConPTY. It's barely past "hello world" stage, but I thought it might be useful for others, as it includes the pinvoke constants and declarations required to get everything working.

https://github.com/waf/MiniTerm

It's pretty much a straight-forward translation of the C++ examples (including the work from @bitcrazed's PR). If there's interest, I could submit this in a PR to this repository. I'd need some help getting it up to an acceptable level of quality -- there are still rendering issues I'm trying to figure out.

The core of the interaction with the pseudoconsole is here:

ef13d4ea5e/MiniTerm/Program.cs (L37-L57)

Originally created by @waf on GitHub (Sep 9, 2018). I've created a (very) rough C# terminal using ConPTY. It's barely past "hello world" stage, but I thought it might be useful for others, as it includes the pinvoke constants and declarations required to get everything working. https://github.com/waf/MiniTerm It's pretty much a straight-forward translation of the C++ examples (including the work from @bitcrazed's PR). If there's interest, I could submit this in a PR to this repository. I'd need some help getting it up to an acceptable level of quality -- there are still rendering issues I'm trying to figure out. The core of the interaction with the pseudoconsole is here: https://github.com/waf/MiniTerm/blob/ef13d4ea5e5505aeb18efaad38d361a4ccf0c6f7/MiniTerm/Program.cs#L37-L57
claunia added the Product-Conpty label 2026-01-30 21:50:15 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Sep 10, 2018):

Absolutely, I'd be happy to take a look at the PR :)

I'd add your sample as another child of samples/ConPTY, next to where @bitcrazed's sample will end up.

@zadjii-msft commented on GitHub (Sep 10, 2018): Absolutely, I'd be happy to take a look at the PR :) I'd add your sample as another child of `samples/ConPTY`, next to where @bitcrazed's sample will end up.
Author
Owner

@bitcrazed commented on GitHub (Sep 10, 2018):

Nice! Thanks for sharing @waf.

Just wrapping-up final edits to our sample. Will be publishing soon.

@bitcrazed commented on GitHub (Sep 10, 2018): Nice! Thanks for sharing @waf. Just wrapping-up final edits to our sample. Will be publishing soon.
Author
Owner

@bitcrazed commented on GitHub (Sep 11, 2018):

Thanks again WAF - I've now published our "EchoCon" C++ ConPTY sample. Will add WAF's sample. Please feel free to submit a PR with your managed MinTerm sample, and we'll work with you to get it added :)

@bitcrazed commented on GitHub (Sep 11, 2018): Thanks again WAF - I've now published our ["EchoCon" C++ ConPTY sample](https://github.com/Microsoft/console/tree/master/samples/ConPTY/EchoCon). Will add WAF's sample. Please feel free to submit a PR with your managed MinTerm sample, and we'll work with you to get it added :)
Author
Owner

@waf commented on GitHub (Sep 13, 2018):

Great, thanks! I'll probably get a PR opened in the next week or so as I work through some of the known issues.

@waf commented on GitHub (Sep 13, 2018): Great, thanks! I'll probably get a PR opened in the next week or so as I work through some of the known issues.
Author
Owner

@bitcrazed commented on GitHub (Sep 13, 2018):

Great. Happy to help review/assist whenever you're ready.

@bitcrazed commented on GitHub (Sep 13, 2018): Great. Happy to help review/assist whenever you're ready.
Author
Owner

@waf commented on GitHub (Sep 20, 2018):

Opened https://github.com/Microsoft/console/pull/260, thanks!

@waf commented on GitHub (Sep 20, 2018): Opened https://github.com/Microsoft/console/pull/260, thanks!
Author
Owner

@emmatyping commented on GitHub (Nov 15, 2018):

Hi, I seem to be getting mojibake when I try this sample (I realize my prompt of ethanhs▶C:\❯ is not exactly common). I took a look but didn't see anything obvious that could cause this. Thoughts on what could cause this would be appreciated, as I am very interested in using ConPTY, but I am confused as to why this would break.

miniterm_2018-11-15_00-17-33
@emmatyping commented on GitHub (Nov 15, 2018): Hi, I seem to be getting mojibake when I try this sample (I realize my prompt of `ethanhs▶C:\❯` is not exactly common). I took a look but didn't see anything obvious that could cause this. Thoughts on what could cause this would be appreciated, as I am very interested in using ConPTY, but I am confused as to why this would break. <img width="175" alt="miniterm_2018-11-15_00-17-33" src="https://user-images.githubusercontent.com/9504279/48539904-677b1900-e86d-11e8-8899-364254904e6a.png">
Author
Owner

@miniksa commented on GitHub (Nov 15, 2018):

We don't support characters above U+FFFF yet. ▶ and ❯ both have codepoints over U+FFFF.

Also, I'd highly recommend that you choose to file a new issue next time instead of bumping an old closed one.

@miniksa commented on GitHub (Nov 15, 2018): We don't support characters above U+FFFF yet. ▶ and ❯ both have codepoints over U+FFFF. Also, I'd highly recommend that you choose to file a new issue next time instead of bumping an old closed one.
Sign in to join this conversation.
No Label Product-Conpty
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#373