CURSES_TTY(3)

CURSES_TTY(3) | Library Functions Manual | CURSES_TTY(3)

# NAME

curses_tty, baudrate, beep, flash, curs_set, def_prog_mode, reset_prog_mode, def_shell_mode, reset_shell_mode, echo, noecho, delay_output, erasechar, flushinp, gettmode, halfdelay, has_ic, has_il, idcok, idlok, intrflush, noqiflush, qiflush, killchar, meta, napms, nl, nonl, cbreak, nocbreak, raw, noraw, typeahead, savetty, resetty — curses terminal manipulation routines

# LIBRARY

Curses Library (libcurses, -lcurses)

# SYNOPSIS

#include <curses.h>
int
baudrate(void);
int
beep(void);
int
flash(void);
int
curs_set(int visibility);
int
def_prog_mode(void);
int
reset_prog_mode(void);
int
def_shell_mode(void);
int
reset_shell_mode(void);
int
echo(void);
int
noecho(void);
int
delay_output(int ms);
char
erasechar(void);
int
flushinp(void);
int
gettmode(void);
bool
has_ic(void);
bool
has_il(void);
int
idcok(WINDOW *win, bool flag);
int
idlok(WINDOW *win, bool flag);
int
intrflush(WINDOW *win, bool flag);
void
noqiflush(void);
void
qiflush(void);
char
killchar(void);
int
meta(WINDOW *win, bool flag);
int
napms(int ms);
int
nl(void);
int
nonl(void);
int
cbreak(void);
int
nocbreak(void);
int
halfdelay(int);
int
raw(void);
int
noraw(void);
int
typeahead(int filedes);
int
savetty(void);
int
resetty(void);

# DESCRIPTION

These functions manipulate curses terminal settings.
The baudrate() function extrats the output speed of the terminal and returns it in bits per second.
The beep() function rings the terminal bell, if this is possible. Failing that, the terminal screen will be flashed. If neither of these are possible, then no action will be taken. flash() will flash the terminal screen if possible. Failing that, the terminal bell will be rung. If neither of these are possible then no action will be taken.
The cursor visibility can be set by calling curs_set(). The following visibility settings are valid for curs_set():

Visibility
  Effect
0
  cursor is invisible.
1
  cursor is normal visibility
2
  cursor is high visibility

A successful call to curs_set() will return the previous visibility setting for the cursor.
The delay_output() function pauses the output to the terminal by sending the appropriate number of terminal pad characters such that the transmission time of the pad characters will take ms milliseconds.
Calling def_prog_mode() will cause the current terminal curses setting to be saved. A subsequent call to reset_prog_mode(), will restore the saved settings. This is useful when calls to external programs are made that may reset the terminal characteristics.
The def_shell_mode() function saves the current terminal line settings. These settings are the ones that will be restored when the curses application exits. Conversely, reset_shell_mode() will save the current terminal curses settings for later restoration and restores the previously saved terminal line settings.
The echo() function turns on curses echo mode, characters entered will be echoed to the terminal by curses. The noecho() function disables this feature.
The current erase character for the terminal can be determined by calling the erasechar() function.
The flushinp() function discards any pending input for the current screen.
The modes for the current terminal can be reset by calling gettmode(), this will perform the initialisation on the terminal that is normally done by curses at start up.
The has_ic() function returns either `TRUE` or `FALSE` depending on whether or not the terminal has a insert character capability or not. Similarly the has_il() function does the same test but for a insert line capability.
The use of the insert character capability in curses operations can be enabled or disabled by calling idcok() on the desired window. Similarly, the use of the insert line capability can be controlled using the idlok() function.
The intrflush() function controls whether or not a flush of the input buffer is performed when an interrupt key (kill, suspend or quit) is pressed. The win parameter is ignored. The noqiflush() function is equivalent to intrflush(stdscr, FALSE). The qiflush() function is equivalent to intrflush(stdscr, TRUE).
The character that performs the line kill function can be determined by calling the killchar() function.
The meta() function turns on and off the generation of 8 bit characters by the terminal, if flag is `FALSE` then only 7 bit characters will be returned, if flag is `TRUE` then 8 bit characters will be returned by the terminal.
The napms() causes the application to sleep for the number of milliseconds specified by ms.
Calling nl() will cause curses to map all carriage returns to newlines on input, this functionality is enabled by default. The nonl() function disables this behaviour.
The cbreak() function will put the terminal into cbreak mode, which means that characters will be returned one at a time instead of waiting for a newline character, line discipline processing will be performed. The nocbreak() function disables this mode.
Calling halfdelay() puts the terminal into the same mode as cbreak() with the exception that if no character is received within the specified number of tenths of a second then the input routine will return `ERR`. This mode can be cancelled by calling nocbreak(). The valid range for the timeout is from 1 to 255 tenths of a second.
The noraw() function sets the input mode for the current terminal into Cooked mode, that is input character translation and signal character processing is performed. The raw() function puts the terminal into Raw mode, no input character translation is done nor is signal character processing.
The typeahead() function controls the detection of typeahead during a refresh based on the value of filedes:

- If filedes is a valid file descriptor, typeahead is enabled during refresh; Curses periodically checks filedes for input and aborts the refresh if any character is available. The value of filedes need not be the file descriptor on which the refresh is occurring.
- If filedes is -1, Curses does not check for typeahead during refresh.

The terminal tty flags can be saved by calling savetty() and may be restored by calling resetty(), the use of these functions is discouraged as they may cause the terminal to be put into a state that is incompatible with curses operation.

# RETURN VALUES

Functions returning pointers will return `NULL` if an error is detected. The functions that return an int will return one of the following values:

`OK`
  The function completed successfully.
`ERR`
  An error occurred in the function.

# SEE ALSO

getch(3), termios(4)

# NOTES

The idcok() and idlok() currently have no effect on the curses code at all, currently curses will always use the terminal insert character and insert line capabilities if available.

# STANDARDS

The NetBSD Curses library complies with the X/Open Curses specification, part of the Single Unix Specification.

# HISTORY

The Curses package appeared in 4.0BSD.

February 17, 2017 | NetBSD 8.3