delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/17/18:55:03

From: cvn AT interchain DOT nl (Kees van Veen)
Subject: tty raw mode
17 Oct 1997 18:55:03 -0700 :
Message-ID: <34477B57.3C07A027.cygnus.gnu-win32@interchain.nl>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Hi,

A while ago I posted a question about getting the console in raw mode.
In the meantime I found a partially working solution using
GetConsoleMode and
SetConsoleMode.

Here's a piece of code:

#include <stdio.h>
#include <fcntl.h>
#include <windows.h>

main()
{
        DWORD dwMode;
        HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
        
        if (GetConsoleMode(hStdIn, &dwMode) == TRUE)
                SetConsoleMode(hStdIn, 
                    dwMode & ~(ENABLE_LINE_INPUT |		/* No buffering */
                               ENABLE_PROCESSED_INPUT |
                               ENABLE_ECHO_INPUT |		/* No echo
*/            			               ENABLE_WINDOW_INPUT));
        for (;;)
        {
                int c = getchar();
                printf("%d <%c>\n", c, c);
        }
}

Now all works fine except for two things:

1) getchar() does not distinguish between <CR> and <LF>
2) <LF) produces <CR><LF>

I've also tried a version using ReadConsole(), I've tried _setmode(0,
O_BINARY), but
without any success.

Does any of you have any idea ?

Thanks in advance for your time.

Kees
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019