Вопрос

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.

Это было полезно?

Решение

I found the following project link very helpful. You can download the project, then look at the first comment on the codeproject site to see how to extend it to SerialPort support (which is what I needed).

http://www.codeproject.com/Articles/20781/Terminal-Control-Library-C-VT100-ANSI-XTERM-SSH-Te

The project is really a thin wrapper around the Poderosa project, but unless you speak Japanese, this thin wrapper is useful. The Poderosa project supports SerialPorts already, but it wasn't brought to the surface by "Columbus-MCSD".

Другие советы

Actually, observing the lack of good support for this kind of scenario (and having changed our requirements a little bit), we developed our own terminal emulator, Termsharp:

https://github.com/antmicro/termsharp

It is window-based (running on XWT), but can be used as a library, decoding VT100 sequences.

Although I respond to my own question with a product of the company I work for, it was created a long time after the original post, so I hope it's acceptable.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top