Date: Mon, 7 Aug 2000 22:41:02 -0400 (EDT) From: "David Witbrodt" To: DJGPP mailing list Subject: Termios settings (for no echo) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On Sun, 6 Aug 2000 eliz AT is DOT elta DOT co DOT il wrote: > > In the first demo I wrote for these students, I used kbhit(). They said, > > "What the h@#l is that?" So I wanted to try IOSTREAMs. Bad idea.... > > Not necessarily a bad idea, it's just that the way to get a no-echo > input is tricky. You *can* do it with iostreams, but you need to call > a termios function to switch the console into no-echo mode. > > See the node "Termios Functions" in the library reference manual, for > more about this. Using termios is better than conio, because termios > functions are supported on Unix and GNU/Linux systems. From reading some of the info docs, it seems like those termios functions only affect iostreams behavior because of the way DJGPP iostreams are implemented using stdio streams. Will modifying termios settings really cause the same effect on cin on, say, a GNU/Linux system? Are the iostreams libraries implemented the same way in UNIX? (I don't even pretend to know; I'm just wondering.) After looking at the docs you suggested, I think I understand what to try. Did you have something like this in mind?: // fragment: trying to keep cin from echoing to the screen struct termios oldsettings, newsettings; tcgetattr (fileno(stdin), &oldsettings); // save old termios settings newsettings = oldsettings; // copy current termios config newsettings.c_lflag = (ISIG | ICANON | IEXTEN); // no ECHO* flags set tcsetattr (fileno(stdin), TCSADRAIN, &newsettings); // load new // settings /* ... [program code here] ... */ tcsetattr (fileno(stdin), TCSANOW, &oldsettings); Thanks, Dave W. "... for if leisure and security were enjoyed by all alike, the great mass of human beings ... would learn to think for themselves; and when once they had done this, they would sooner or later realize that the privileged minority had no function, and they would sweep it away." - Emmanuel Goldstein