Subject: tty raw mode
From: [email-masked] (Kees van Veen)

29 Oct 1997 11:51:14 -0800
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

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
"[email-masked]" with one line of text: "help".