2.10 Ttyrestore



The ttyrestore function restores the terminal to its original state. The Ttyinit function sets the terminal so that it returns characters immediately and disables echoing. Ttyrestore should be called just before exiting your program to restore the terminal to its original state. Ttyinit saves the terminal state before it changes it, and ttyrestore uses what was saved to restore the original state.

Both ttyinit and ttyrestore can be called several times. If, for example, your program uses the system(3) function to execute another program, ttyrestore should be called first. Then call system to execute the program, and then call ttyinit to once again set the terminal so that characters are returned immediately.

With these routines, you can write programs that use terminals interactively, and yet not be concerned with the characteristics of the terminal. These routines are used by all the interactive programs in C/Base and provide a method for implementing these tools on a wide variety of terminals/monitors.