Date: Thu, 1 Jan 1998 22:45:55 +0800 (HKT) From: Orlando Andico To: Noam Rotem cc: Eli Zaretskii , djgpp AT delorie DOT com Subject: Re: Escape Sequences / Reading from Console In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Thu, 1 Jan 1998, Noam Rotem wrote: .. > >What's wrong with `getc'? It can read single characters as well, if > >you switch stdin to binary mode (use `setmode') and make it unbuffered > >(use `setvbuf'). Did you try it? > > I can't use 'setmode' under UNIX. This is what's wrong with it... > Is there any other way to do it (using ANSI C / stdio.h)? you might want to try the curses routines, they work under unix and there is a djgpp version. i've attached the first part of the man page for wgetch() (solaris 2.5.1): curs_getch(3X) Miscellaneous Library Functions curs_getch(3X) NAME curs_getch, getch, wgetch, mvgetch, mvwgetch, ungetch - get (or push back) characters from curses terminal keyboard SYNOPSIS cc [ flag ... ] file ... -lcurses [ library .. ] #include int getch(void); int wgetch(WINDOW *win); int mvgetch(int y, int x); int mvwgetch(WINDOW *win, int y, int x); int ungetch(int ch); MT-LEVEL Unsafe DESCRIPTION With the getch(), wgetch(), mvgetch(), and mvwgetch() rou- tines a character is read from the terminal associated with the window. In no-delay mode, if no input is waiting, the value ERR is returned. In delay mode, the program waits until the system passes text through to the program. Depending on the setting of cbreak(), this is after one character (cbreak mode), or after the first newline (noc- break mode). In half-delay mode, the program waits until a character is typed or the specified timeout has been reached. Unless noecho() has been set, the character will also be echoed into the designated window. ---------------------------------------------------------------------- L L Orlando Andico orly AT mozcom DOT com L L L L Mosaic Communications, Inc. http://www2.mozcom.com/~orly/ L L L L L +63 2 848-2893 (office) L L L L L +63 2 932-2385 (home) MosCom ----------------------------------------------------------------------