This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

tty raw mode


Hi,

Just for your information:

I have managed to sort of get where I wanted to be, i.e. run a console
application in raw mode using GetConsoleMode and SetConsoleMode.

I use isatty() to find out whether I'm connected to a tty and then call
GetConsoleMode() to check whether I'm running on a console.

If GetConsoleMode returns FALSE, and isatty() returns TRUE I assume
I'm running from a pseudo tty and then there is no problem, because,
thanks
to the great work of Sergey, Mike Bernson and others, I'm now able to
run my
application using telnet and all my ioctl() settings work.

If I'm running from a console, I use SetConsoleMode to get to a kind of
raw mode (see below).

This does not avoid LF being interpreted as CR/LF though (sigh), so I
switch to
the escape sequence for arrow key down when running from a console.

One thing that struck me is that when I use getc(stdin) to read from the
console
CR (13) is always returned as LF (10) whereas using ReadConsole()
returns 13 upon CR,
even with the SetConsoleMode settings.

Cheers,
Kees

P.S.

For those interested in the Get/SetConsoleMode calls:


        DWORD input_mode, output_mode;
        if (GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),
&input_mode)==TRUE)
        {
                SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),
                        input_mode & ~( ENABLE_LINE_INPUT |
                                        ENABLE_ECHO_INPUT |
                                        ENABLE_PROCESSED_INPUT |
                                        ENABLE_WINDOW_INPUT));
        }
        if (GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),
&output_mode)==TRUE)
        {
                SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),
                        output_mode & ~(ENABLE_WRAP_AT_EOL_OUTPUT));
        }
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]