Date: Wed, 25 Jun 1997 12:07:47 +1000 From: MARK SAYER <MSAYER@cuscal.com.au> To: "'freebsd-hackers@freebsd.org'" <freebsd-hackers@freebsd.org> Subject: RE: BSD io Message-ID: <199706250208.TAA23288@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
I have been looking for this for ages. I resorted to using ncurses, but
then I was stuck with using ncurses window management (yuk). So, I tried
the code below and it doesn't seem to work as promised. I just want the
program to trap 1 keypress and continue execution.
#include <termios.h>
#include <stdio.h>
struct termios old, new;
main()
{
char c;
tcgetattr (fileno(stdin), &old); new = old;
new.c_iflag &=~(ICANON|ECHO);
tcsetattr (fileno(stdin), TCSANOW, &new);
c = getc(stdin);
tcsetattr (fileno(stdin), TCSANOW, &old);
}
All it seems to do is stop trapping my CR key??
168: {9} ./a.out
a^M^M^M^Mò
168: {10}
the ò is a CBREAK.
I'm running FreeBSD 2.1.6.
Any ideas?
> ----------
> From: Tim Vanderhoek[SMTP:hoek@hwcn.org]
> Sent: Tuesday, June 24, 1997 11:36 PM
> To: Tim Vanderhoek
> Cc: Steve Howe; freebsd-hackers
> Subject: Re: BSD io
>
> On Tue, 24 Jun 1997, Tim Vanderhoek wrote:
>
> > #include <termios.h>
> > #include <stdio.h>
> > struct termios old, new;
> > main(){
> > tcgetattr (fileno(stdin), &old); new = old;
> > new &= ~(ICANON|ECHO);
>
> new.c_lflag &= ~(ICANON|ECHO);
>
> Actually, FWIW, I like the section the GNU C library reference
> manual has on this. Easier, more on-topic, and nicer than man 4
> termios. The manual is on the web in html (search Yahoo, "GNU
> Info"), if anyone cares...
>
>
> --
> Outnumbered? Maybe. Outspoken? Never!
> tIM...HOEk
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706250208.TAA23288>
