Next Previous Contents

108. SLang_init_tty

Synopsis

Initialize the terminal keyboard interface

Usage

int SLang_init_tty (int intr_ch, int no_flow_ctrl, int opost)

Description

SLang_init_tty initializes the terminal for single character input. If the first parameter intr_ch is in the range 0-255, it will be used as the interrupt character, e.g., under Unix this character will generate a SIGINT signal. Otherwise, if it is -1, the interrupt character will be left unchanged.

If the second parameter no_flow_ctrl is non-zero, flow control (XON/XOFF) processing will be enabled.

If the last parmeter opost is non-zero, output processing by the terminal will be enabled. If one intends to use this function in conjunction with the S-lang screen management routines (SLsmg), this paramete shold be set to zero.

SLang_init_tty returns zero upon success, or -1 upon error.

Notes

Terminal I/O is a complex subject. The S-lang interface presents a simplification that the author has found useful in practice. For example, the only special character processing that SLang_init_tty enables is that of the SIGINT character, and the generation of other signals via the keyboard is disabled. However, generation of the job control signal SIGTSTP is possible via the SLtty_set_suspend_state function.

Under Unix, the integer variable SLang_TT_Read_FD is used to specify the input descriptor for the terminal. If SLang_TT_Read_FD represents a terminal device as determined via the isatty system call, then it will be used as the terminal file descriptor. Otherwise, the terminal device /dev/tty will used as the input device. The default value of SLang_TT_Read_FD is -1 which causes /dev/tty to be used. So, if you prefer to use stdin for input, then set SLang_TT_Read_FD to fileno(stdin) before calling SLang_init_tty.

If the variable SLang_TT_Baud_Rate is zero when this function is called, the function will attempt to determine the baud rate by querying the terminal driver and set SLang_TT_Baud_Rate to that value.

See Also

SLang_reset_tty, SLang_getkey, SLtty_set_suspend_state


Next Previous Contents