BLODA extension: console interoperability
Fri Jul 26 14:59:00 GMT 2013
> I don't think that's fair, since such apps were designed for the
> Windows console, without being aware of Cygwin's pipe-based ptys. And
> unfortunately that list would be very long anyway: basically anything
> interactive that hasn't been explicitly adapted to Cygwin ptys
Let me also drop my 5 cents into this...
We should be very careful about this. At least there is one case where difference between Cygwin console and real Windows console plays a key role: ncurses. Normal Windows console is very basic and does not understand 90% of control sequences. As a result, ncurses has been extended with 'terminal drivers', which redirect certain control functions to OS (Windows in our case) API calls. Which, of course, work only with real Windows console.
So, it's crucial to be able to detect whether we are running on Windows console or not. Here i have patched version of ncurses which uses GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &mode) operation in order to detect this. This function returns error on non-console handles. This makes ncurses working from within MSYS console. Previously an attempt to run ncurses app simply trashed my console window with ESC sequences. Original ncurses relies on $TERM variable being empty, which works well with 'naked' cmd.exe, but fails miserably with MSYS environment because MSYS sets $TERM to 'cygwin', while still operating inside Windows console which does not really understand most of ESC sequences.
With this fix applications can correctly determine whether they are running in Cygwin's shell and even over ssh connection, and correctly render in all these cases.
P.S. There is still a problem with input in these applications if run from non-native console, but i think it's another story. I didn't look at it because of lack of time and motivation. The goal was to cross-compile an ncurses app for Windows here at work, and the goal was reached.
P.P.S. The patch is lying around and waiting to be submitted. I know, not here, but likely to ncurses ML directly. However looks like FSF guys are not very keen on people committing to them, and they perhaps worry about legal-mumbo-jumbo much more than about programming and real openess. My two patches sent to different lists (make and gnulib) were simply ignored.
Samsung Electronics Research center Russia
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin