Next: , Previous: , Up: The basic curses library   [Contents][Index]

5.2.22 Input options

Procedure: cbreak!
Procedure: nocbreak!

Normally, the TTY driver buffers typed characters until a NL or RET is typed. The cbreak! routine disables line buffering and erase/kill character processing (interrupt and flow control characters are unaffected), making characters typed by the user immediately available to the program.

The nocbreak! routine returns the terminal to normal (cooked) mode.

These routines will return #t on success and #f on failure. Failure may indicate that the underlying screen data is invalid. The routine may also fail if cbreak! was called on an ordinary file (such as might be used with newterm) instead of a TTY.

Initially the terminal may or may not be in cbreak mode, as the mode is inherited; therefore, a program should call cbreak! or nocbreak! explicitly. Most interactive programs using curses set the cbreak! mode. Note that cbreak! overrides raw!.

Procedure: echo!
Procedure: noecho!

The echo! and noecho! routines control whether characters typed by the user are echoed by getch as they are typed. Echoing by the TTY driver is always disabled, but initially getch 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!. See Getting characters from the keyboard for a discussion of how these routines interact with echo! and noecho!.

The return values are unspecified.

Procedure: halfdelay! tenths

The halfdelay! routine 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 seconds, #f is returned if nothing has been typed. The value of tenths must be a number between 1 and 255. Use nocbreak! to leave half-delay mode.

The return value is unspecified.

Procedure: intrflush! bf

If the intrflush option is enabled, (bf is #t), when an interrupt key is pressed on the keyboard (interrupt, break, quit) all output in the TTY driver queue will be flushed, giving the effect of faster response to the interrupt, but causing curses to have the wrong idea of what is on the screen. Disabling (bf is #f), the option prevents the flush. The default for the option is inherited from the TTY driver settings.

The return value is unspecified.

Procedure: keypad! win bf

The keypad! option enables the keypad of the user’s terminal. If enabled (bf is #t), the user can press a function key (such as an arrow key) and getch returns a single value representing the function key, as in KEY_LEFT. If disabled (bf is #f), 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 causes the terminal keypad to be turned on when getch is called. The default value for keypad is #f.

The return value is unspecified. This procedure could throw a “bad state” error.

Procedure: meta! bf

If Guile-Ncurses was compiled with the standard version of the ncurses library, and not the wide version, it operates on 8-bit characters.

Initially, whether the terminal returns 7 or 8 significant bits on input depends on the control mode of the TTY driver. To force 8 bits to be returned, invoke (meta! #t). This is equivalent, under POSIX, to setting the CS8 flag on the terminal. To force 7 bits to be returned, invoke (meta! #f). This is equivalent, under POSIX, to setting the CS7 flag on the terminal. The window argument, win, is always ignored. If the terminfo capabilities smm (meta-on) and rmm (meta-off) are defined for the terminal. The code for smm is sent to the terminal when (meta! #t) is called and rmm is sent when (meta! #f) is called.

The return value is unspecified.

Procedure: nodelay! win bf

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

The return value is unspecified.

Procedure: notimeout! win bf

While interpreting an input escape sequence, getch sets a timer while waiting for the next character. If (notimeout! win #t) is called, then getch does not set a timer. The purpose of the timeout is to differentiate between sequences received from a function key and those typed by a user.

The return value is unspecified.

Procedure: raw!
Procedure: noraw!

The raw! and noraw! routines place the terminal 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 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.

The return value is unspecified.

Procedure: noqiflush!
Procedure: qiflush!

When the noqiflush! routine is used, normal flush of input and output queues associated with the INTR, QUIT and SUSP characters will not be done. When qiflush! is called, the queues will be flushed when these control characters are read. You may want to call noqiflush! in a signal handler if you want output to continue as though the interrupt had not occurred, after the handler exits.

The return value is unspecified.

Procedure: timeout! win delay

The timeout! routine sets blocking or non-blocking read for a given window. If delay is negative, blocking read is used (i.e., waits indefinitely for input). If delay is zero, then non-blocking read is used (i.e., read returns #f if no input is waiting). If delay is positive, then read blocks for delay milliseconds, and returns #f if there is still no input. Hence, these routines provide the same functionality as nodelay!, plus the additional capability of being able to block for only delay milliseconds (where delay is positive).

Procedure: getdelay win

The getdelay procedure returns the timeout delay as set by timeout!.

This procedure may not be present if the underlying version of ncurses does not support it.

Procedure: typeahead! fd

The curses library 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 or doupdate is called again. This allows faster response to commands typed in advance. Normally, the input file port passed to newterm, or stdin in the case that initscr was used, will be used to do this typeahead checking. The typeahead! routine specifies that the (integer) file descriptor fd is to be used to check for typeahead instead. If fd is -1, then no typeahead checking is done.

The routine returns #t if the mode could be set and #f on failure.

There are a set of procedures to test the input options of a given window.

Procedure: is-keypad? win
Procedure: is-meta? win
Procedure: is-nodelay? win
Procedure: is-immedok? win
Procedure: is-notimeout? win

These test the input options of the window win and return #t if they are set.

Next: , Previous: , Up: The basic curses library   [Contents][Index]