escape, getkey, escin, escout - send and receive terminal escape



int escape (function)
int function;

int escape (MOVCUR, row, column)
int row;
int column;

int getkey()

int escin (function)
int function;

int escout (function)
int function;


Escape sends to standard output the escape sequence specified by
the function parameter. The functions performed by escape are
defined as constants in the include file . As a
special case, the MOVCUR function (move cursor) has two extra
parameters that specify the row and column of where to move the
cursor. Row and column numbers start at 1. Row 1 is the topmost
row on the terminal screen. Column 1 is the leftmost column.

Some terminals may not be able to perform all the defined
functions. For example, some terminals cannot perform INSLINE or
DELLINE. If no escape sequence is defined for a particular
function, escape returns a negative value. If the function can be
performed by escape, it returns a positive value.

The escout function tests whether a function is defined for the
terminal. If escout returns a non-zero value for a function, an
escape sequence is defined for that function. If it returns a
zero value, no escape sequence is defined for that function.

The escin function tests whether an input key is defined for the
terminal. It returns a non-zero value if the input key is
defined, and zero if it is not defined.

Getkey reads terminal key strokes from standard input and returns
their ASCII integer equivalent. Its function is analogous to the
getchar(3) function in the standard I/O library. In addition,
getkey translates escape sequences that are typed and returns the
corresponding integer equivalent. The integer constants that are
returned are defined in the include file ; for
example, UPARROW and DELLINE.

If you wish to use escape sequences defined in a terminal
definition file, you must set the environment string TERM to the
name of a terminal type defined in the terminal definition
directory. This is normally done by executing

set TERM=terminaltype

before starting any command that uses escape or getkey. Any
program using escape or getkey should call the ttyinit(C-3)
function to initialize the terminal, and call the ttyrestore
function to restore the terminal before exiting. If TERM is not
set, ttyinit uses an internal terminal definition for PC's that
calls ROM BIOS routines instead of using a terminal definition

Escape and getkey provide a method for using CRT terminals in a
terminal independent manner. A program using escape and getkey
need not be concerned with the exact escape sequences necessary
to perform terminal functions.


ttyinit(C-3), ttyrestore(C-3), termparm(C-3)
Chapter 2, Terminal Independent I/O
C/Base Reference Manual Chapter 11, "Creating Terminal