Next: , Previous: , Up: Curses   [Contents][Index]

5.12.2 Terminal Mode Setting

These routines set options within curses that deal with input. The options involve using ioctl(2) and therefore interact with curses routines. It is not necessary to turn these options off before calling endwin. The routines in this section all return an unspecified value.

Function: cbreak
Function: nocbreak

These two routines put the terminal into and out of CBREAK mode, respectively. In CBREAK mode, characters typed by the user are immediately available to the program and erase/kill character processing is not performed. When in NOCBREAK mode, the tty driver will buffer characters typed until a LFD or RET is typed. Interrupt and flowcontrol characters are unaffected by this mode. Initially the terminal may or may not be in CBREAK mode, as it is inherited, therefore, a program should call cbreak or nocbreak explicitly. Most interactive programs using curses will set CBREAK mode.

Note cbreak overrides raw. For a discussion of how these routines interact with echo and noecho See read-char.

Function: raw
Function: noraw

The terminal is placed into or out of RAW mode. RAW mode is similar to CBREAK mode, in that characters typed are immediately passed through to the user program. The differences are that in RAW mode, the interrupt, quit, suspend, and flow control characters are passed through uninterpreted, instead of generating a signal. RAW mode also causes 8-bit input and output. The behavior of the BREAK key depends on other bits in the terminal driver that are not set by curses.

Function: echo
Function: noecho

These routines control whether characters typed by the user are echoed by read-char as they are typed. Echoing by the tty driver is always disabled, but initially read-char is in ECHO mode, so characters typed are echoed. 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 disable echoing by calling noecho. For a discussion of how these routines interact with echo and noecho See read-char.

Function: nl
Function: nonl

These routines control whether LFD is translated into RET and LFD on output, and whether RET is translated into LFD on input. Initially, the translations do occur. By disabling these translations using nonl, curses is able to make better use of the linefeed capability, resulting in faster cursor motion.

Function: resetty
Function: savetty

These routines save and restore the state of the terminal modes. savetty saves the current state of the terminal in a buffer and resetty restores the state to what it was at the last call to savetty.

Next: , Previous: , Up: Curses   [Contents][Index]