ttyinit, ttyrestore, erasechar, killchar - initialize and restore terminal for I/O


#include <cbase/escape.h>



int erasechar()

int intrchar()

int killchar()


The ttyinit function initializes escape(C-3) and getkey for terminal input and output. The TERM environment variable must contain the name of a terminal in the terminal definition. The string TERM is used to access the terminal definition file, if the terminal definition file is used. This can be done by the following command:

set TERM=terminaltype

Ttyinit reads the terminal definition named by TERM. If there is no environment variable TERM, ttyinit returns -1. If the terminal named by the TERM name is not defined, ttyinit returns 0 (zero). Ttyinit returns 1 on success. Any program using getkey, escape or termparm must first call ttyinit to determine that there is a valid terminal type defined. If there is a valid terminal definition file, it is loaded into program memory and used for all calls to escape, getkey, and termparm.

Normally input is read from the keyboard one line at a time. The ttyinit function sets the terminal driver so that characters can be read when they are typed rather than waiting until the RETURN key is pressed. The ttyinit function also disables character echoing, so it is the responsibility of the program calling ttyinit to echo typed characters.

The ttyrestore function restores the terminal state as it was before ttyinit was called. The first time the ttyinit function is called, it saves the current terminal state before it changes it, and ttyrestore uses this to reset the terminal.

The erasechar function returns the character that is typed when a character should be erased. The killchar function returns the character that is typed when a line should be erased. The ttyinit function disables character erasing and line killing that is normally performed. These functions are used to determine what characters are typed to erase a character or erase a line, so that they can be simulated by the program using ttyinit.

The intrchar functions returns the character that is typed to interrupt the process. Ttyinit does not disable interrupt characters.

The functions ttyinit and ttyrestore are not utilized in the MS-DOS version.


escape(C-3), termparm(C-3)

Chapter 2,

Terminal Independent I/O

C/Base Reference Manual Chapter 11,

Creating Terminal Definitions