DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Simple input and output

Input options

The UNIX system does a considerable amount of processing on input before an application ever sees a character. For example, it does the following:

Because an ETI program maintains total control over the screen, low-level ETI turns off echoing on the UNIX system and does echoing itself. At times, you may not want the UNIX system to process other characters in the standard way in an interactive screen management program. Some ETI routines, noecho and cbreak, for example, have been designed so that you can change the standard character processing. Using these routines in an application controls how input is interpreted. ``Input option settings for ETI programs'' shows some of the major routines for controlling input.

Every low-level ETI program accepting input should set some input options. This is because when the program starts running, the terminal on which it runs may be in cbreak, raw, nocbreak, or noraw mode. Although the low-level ETI program starts up in echo mode, none of the other modes are guaranteed.

The combination of noecho and cbreak is most common in interactive screen management programs. Suppose, for instance, that you do not want the characters sent to your application program to be echoed wherever the cursor currently happens to be; instead, you want them echoed at the bottom of the screen. The ETI routine noecho is designed for this purpose. However, when noecho turns off echoing, normal erase and kill processing is still on. Using the routine cbreak causes these characters to be uninterpreted.

Input option settings for ETI programs

Input options Characters interpreted Characters uninterpreted
Normal ``out of ETI state'' interrupt, quit
stripping RETURN to <NL>
echoing erase, kill
EOF
 
Normal ETI ``start up state'' echoing (simulated) All else undefined
cbreak() and echo() interrupt, quit
stripping
echoing
erase, kill
EOF
cbreak() and noecho() interrupt, quit
stripping
erase, kill
EOF
nocbreak() and noecho() break, quit
stripping
erase, kill
EOF
echoing
nocbreak() and echo() See caution below.
nl() RETURN to <NL>  
nonl()   RETURN to <NL>
raw()
(instead of
cbreak())
  break, quit
stripping


CAUTION: Do not use the combination nocbreak and echo. If you use it in a program and also use getch, the program will go in and out of cbreak mode to get each character. Depending on the state of the tty driver when each character is typed, the program may produce undesirable output.

In addition to the routines noted in ``Input option settings for ETI programs'', you can use the ETI routines noraw, halfdelay, and nodelay to control input. See the curses(3ocurses) manual pages for discussions of these routines.

The next few pages describe noecho, cbreak, and the related routines echo and nocbreak in more detail.


Next topic: echo and noecho
Previous topic: Bells, whistles, and flashing lights: beep and flash

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004