Terminal in Runt

Terminal is a big part of my workflow, so I naturally want it in Runt, on Windows. At the moment it is able to run Runt's build.bat script as well as cmd.exe. There is still some work to do on it to get close to xterm level, but that work is mostly in dealing with more escape sequences.

Windows doesn't follow the Unix architecture of standard streams for console applications. Simple applications that use printf do output to stdout, but if you want to work with colors, or move cursor you have to use specialized console APIs that doesn't go through stdout. Handling input is another story altogether. You're out of luck with applications that require input, like cmd.exe itself.

WinPTY solves this by silently running process in a hidden console window piping back updates to the console's screen buffer as TTY stream to stdout. Also translates key strokes from the stdin to events required by the console API. This is quite handy, because you can use the same TTY parsing code for both Windows and Unix.

There's also a new console API being rolled out to Windows 10 these days that brings in Unix-style streams, which obsoletes WinPTY. I'll be switching to that once I get my hands on it.