I have an application in Mono that creates a putty window, connects to it's PTY and communicates with the world via it.
Thanks to Putty I have a full terminal, I can send special codes (like Ctrl+C, Ctrl+Z) to my app.
I would like to go back to my terminal, in which I start the application. I would like to grab as many key combinations as possible. That way I'd be able to use my app via ssh, with no windows popping up.
My idea is to retrieve my current terminal from /dev/, ignore (or handle) all the possible signals, poll on the pressed keys and forward to my app. This could be done in C with P/Invoke.
This is possible, but painful and time-consuming to code.
I wonder if it's already done? Do you know about any libraries? The best option would be to register for a callback or two, but any solution making it easier would be great.
TL;DR
I need a library that would give my interface like:
event Action<byte> CharReceived;
void WriteChar(byte val);
and allowed me to receive ANSI terminal codes as sequence of bytes.
The alternative would be a library to translate ConsoleKeyInfo
to byte[]
, according to ANSI terminal rules.