DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

curs_inopts(S-osr5)


curs_inopts: cbreak, nocbreak, echo, noecho, halfdelay, intrflush, keypad, meta, nodelay, notimeout, raw, noraw, noqiflush, qiflush, timeout, wtimeout, typeahead -- curses terminal input option control routines

Syntax

cc ... -lcurses

#include <curses.h>

int cbreak(void); int nocbreak(void); int echo(void); int noecho(void); int halfdelay(int tenths); int intrflush(WINDOW *win, bool bf); int keypad(WINDOW *win, bool bf); int meta(WINDOW *win, bool bf); int nodelay(WINDOW *win, bool bf); int notimeout(WINDOW *win, bool bf); int raw(void); int noraw(void); void noqiflush(void); void qiflush(void); void timeout(int delay); void wtimeout(WINDOW *win, int delay); int typeahead(int fd);

Description

cbreak and nocbreak

The routine cbreak(S-osr5) puts the terminal into cbreak mode and the routine nocbreak(S-osr5) takes the terminal out of cbreak mode.

In cbreak mode, characters typed by the user are immediately available to the program, and erase or kill characters are not processed.

When out of this mode, the tty driver buffers the typed characters until a newline or carriage return is typed.

Interrupt and flow control characters are not affected by the mode.

Initially the terminal can be in either mode, because the mode is inherited; therefore, a program should call cbreak( ) or nocbreak( ) explicitly. Most interactive programs using curses(S-osr5) set the cbreak mode.

cbreak( ) overrides raw(S-osr5). See curs_getch(S-osr5) for a discussion of how cbreak( ) and raw( ) interact with echo(S-osr5) and noecho(S-osr5).

echo and noecho

The routines echo( ) and noecho( ) control whether characters typed by the user are echoed by getch(S-osr5) as they are typed. Echoing by the tty driver is always disabled, but initially getch( ) is in echo mode and echoes each character. Authors of most interactive programs prefer to do their own echoing in a controlled area of the screen, or not to echo at all, so they call noecho( ). (See curs_getch(S-osr5) for a discussion of how echo( ) and noecho( ) interact with cbreak( ) and nocbreak( )).

halfdelay

The routine halfdelay(S-osr5) is used for half-delay mode, which is similar to cbreak mode in that characters typed by the user are immediately available to the program. However, after blocking for tenths tenths of a second, ERR is returned if nothing has been typed. tenths must be a number between 1 and 255. Use nocbreak( ) to leave half-delay mode.

intrflush

If the intrflush option is enabled (bf is TRUE), when an interrupt key (interrupt, break, or quit) is pressed on the keyboard all output in the tty driver queue is flushed, giving a faster response to the interrupt, but confusing curses( ) about what is on the screen. Disabling the option (bf is FALSE), prevents the flush. The default for this option is inherited from the tty driver settings. The window argument is ignored.

keypad

The keypad option enables the keypad of the user's terminal. If it is enabled (bf is TRUE), the user can press a function key (such as an arrow key) and wgetch(S-osr5) returns a single value representing the function key, as in KEY_LEFT.

If keypad is disabled (bf is FALSE), curses( ) does not treat function keys specially and the program has to interpret the escape sequences itself.

If the keypad in the terminal can be turned on (made to transmit) and off (made to work locally), turning on this option turns on the terminal keypad when wgetch( ) is called.

The default value for keypad is FALSE.

meta

Initially, whether the terminal returns 7 or 8 significant bits on input depends on the control mode of the tty driver (see termio(M)). To force 8 bits to be returned, invoke meta(win, TRUE). To force 7 bits to be returned, invoke meta(win, FALSE). The window argument, win, is always ignored. If the terminfo capabilities smm (meta_on) and rmm (meta_off) are defined for the terminal, smm is sent to the terminal when meta(win, TRUE) is called and rmm is sent when meta(win, FALSE) is called.

nodelay

The nodelay option causes getch( ) to be a non-blocking call. If no input is ready, getch( ) returns ERR. If nodelay is disabled (bf is FALSE), getch( ) waits until a key is pressed.

notimeout

While interpreting an input escape sequence, wgetch( ) sets a timer while waiting for the next character. If notimeout(win, TRUE) is called, then wgetch( ) does not set a timer. The timeout differentiates between sequences received from a function key and those typed by a user.

raw and noraw

The routines raw( ) and noraw(S-osr5) put the terminal into or out of raw mode. Raw mode is like cbreak mode, in that characters typed are immediately passed through to the user program. The differences are that in raw mode, characters for interrupt, quit, suspend, and flow control are all passed through uninterpreted, instead of generating a signal. The behavior of the <BREAK> key depends on other bits in the tty driver that are not set by curses( ).

noqiflush

When the noqiflush(S-osr5) routine is used, normal flush of input and output queues associated with the INTR, QUIT and SUSP characters is not done (see termio(M)).

When qiflush(S-osr5) is called, the queues are flushed when these control characters are read.

timeout and notimeout

The timeout(S-osr5) and wtimeout(S-osr5) routines set blocking or non-blocking read for a given window.

If delay is negative, blocking read is used (that is, read( ) waits indefinitely for input).

If delay is zero, then non-blocking read is used (that is, read( ) returns ERR if no input is waiting).

If delay is positive, then read( ) blocks for delay milliseconds, and returns ERR if there is still no input. Hence, these routines provide the same functionality as nodelay( ), as well as being able to block for only delay milliseconds.

typeahead

curses( ) does ``line-breakout optimization'' by looking for typeahead periodically while updating the screen. If input is found, and it is coming from a tty, the current update is postponed until refresh(S-osr5) or doupdate(S-osr5) is called again. This allows faster response to commands typed in advance.

Normally, to do typeahead checking the input FILE pointer passed to newterm(S-osr5), is used, or stdin if initscr(S-osr5) was used. However, typeahead(S-osr5) uses the file descriptor fd instead, to do this checking. If fd is -1, no typeahead checking is done.

Return values

All routines that return an integer return ERR on failure and an integer value other than ERR on successful completion, unless otherwise noted in the preceding routine descriptions.

Warning

The header file curses.h automatically includes the header files stdio.h and unctrl.h.

The following can be macros: echo( ), noecho( ), halfdelay( ), intrflush( ), meta(S-osr5), nodelay( ), notimeout(S-osr5), noqiflush( ), qiflush( ), timeout( ), and wtimeout( ).

Files


/usr/lib/libcurses.a
the library

See also

curses(S-osr5), curs_getch(S-osr5), curs_initscr(S-osr5), termio(M)

Standards conformance

cbreak(S-osr5), echo(S-osr5), halfdelay(S-osr5), intrflush(S-osr5), keypad(S-osr5), meta(S-osr5), nocbreak(S-osr5), nodelay(S-osr5), noecho(S-osr5), noraw(S-osr5), notimeout(S-osr5), raw(S-osr5), noqiflush(S-osr5), qiflush(S-osr5), timeout(S-osr5), wtimeout(S-osr5), and typeahead(S-osr5) are not part of any currently supported standard; they were developed by UNIX System Laboratories, Inc. and are maintained by The SCO Group.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005