This is the mail archive of the
mailing list for the Cygwin project.
RE: BLODA extension: console interoperability
- From: Pavel Fedin <p dot fedin at samsung dot com>
- To: 'Andy Koppe' <andy dot koppe at gmail dot com>
- Cc: cygwin at cygwin dot com
- Date: Fri, 26 Jul 2013 16:07:55 +0400
- Subject: RE: BLODA extension: console interoperability
- References: <51F1A863 dot 8060403 at etr-usa dot com> <51F1AF90 dot 3080409 at cygwin dot com> <51F1F7B4 dot 4060202 at etr-usa dot com> <CAHWeT-bBvWyv0dzFkwbgyKJKuNyaVY85ZBkksCC-Qs_dZ6H+GA at mail dot gmail dot com>
> 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