dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.96k stars 4.65k forks source link

Request: Guidance for easy mac & Linux/WSL terminal apps (full screen/raw tty mode) #91686

Closed kjpgit closed 1 year ago

kjpgit commented 1 year ago

I wrote a full-screen terminal app using C# and native AOT. It works great on WSL2/Linux. However, it does not compile on mac os because I am using the Tmds.LibC nuget package.

I looked at Mono.Posix but it does not appear to support tcgetattr / tcsetattr (and I did add an issue there asking about it.)

I looked at https://devblogs.microsoft.com/dotnet/console-readkey-improvements-in-net-7/ but am not sure if this is sufficient, for example tcsetattr also controls a lot of signal handling. This is how I'm calling it

Lastly, the new posix signal handling is nice, but I still need to call ioctl() to fetch the window size for SIGWINCH.

Basically, all the pieces are really close to make interesting terminal apps....that startup really fast, and are safe and maintainable in C#... but ideally they'd work both on mac and Linux without a lot manual P/Invoke work.

baronfel commented 1 year ago

I'm going to transfer this to dotnet/runtime as it's a request for more/lower-level console APIs.

kjpgit commented 1 year ago

I'm going to close this while I test the new posix signal handling api more, because that might solve my issues with sigstop/sigcont, assuming the Console class can do everything else. Knock on wood.