I've created a small utility for running native console programs in
mintty and other terminals based on Cygwin ptys. This is for
interactive programs that otherwise don't work properly in ttys.
The source can be found at http://mintty.googlecode.com/svn/utils/conin.c
and a zipped executable is available at http://mintty.googlecode.com/files/conin-0.0.1.zip
(It's compiled with 'cc -std=c99 conin.c -lreadline -o conin -mwindows
It can be used by simply prefixing the program to be run, e.g.:
$ conin C:/Python26/python
Conin works by creating a hidden console and connecting the child
program's stdin to that. It then translates keypresses coming in via
its own stdin and writes them to the console's input buffer using the
Readline is used to handle keyboard input, which means that all the
usual readline line editing facilities, including anything configured
in .inputrc, are available. It also recognises when the program wants
raw console input (scala is an example of that), and in that case
skips readline and passes input straight on.
The child program's stdout and stderr, meanwhile, are not connected to
the hidden console, and instead go more or less directly to the
terminal. That's because the Windows console API does not provide a
way to intercept console output before it's rendered to the console
screen buffer. This means that anything that depends on console-
specific output functions will still not work.
Nevertheless this approach seems to work at least for python, cmd.exe,
and scala. Please give it a go on any other problem cases you might
have come across, but keep in mind that this is little more than proof-
of-concept at the moment, with some big limitations:
- Non-ASCII characters are not supported.
- Raw mode only supports keys that translate to ASCII characters and
unmodified arrow keys.
- Ctrl+C kills the child process dead. (I've tried quite hard to
translate it to a "console ctrl event", but unfortunately without
- No documentation.
Let me know whether this seems useful and worth spending more time on.
Bug reports and enhancement suggestions welcome.