Next: Format, Previous: Blocking Mode, Up: Input/Output [Contents][Index]
A port that reads from or writes to a terminal has a terminal mode; this is either cooked or raw. This mode is independent of the blocking mode: each can be changed independently of the other. Furthermore, a terminal I/O port has independent terminal modes both for input and for output.
A terminal port in cooked mode provides some standard processing to make the terminal easy to communicate with. For example, under unix, cooked mode on input reads from the terminal a line at a time and provides editing within the line, while cooked mode on output might translate linefeeds to carriage-return/linefeed pairs. In general, the precise meaning of cooked mode is operating-system dependent, and furthermore might be customizable by means of operating-system utilities. The basic idea is that cooked mode does whatever is necessary to make the terminal handle all of the usual user-interface conventions for the operating system, while keeping the program’s interaction with the port as normal as possible.
A terminal port in raw mode disables all of that processing. In raw mode, characters are directly read from and written to the device without any translation or interpretation by the operating system. On input, characters are available as soon as they are typed, and are not echoed on the terminal by the operating system. In general, programs that put ports in raw mode have to know the details of interacting with the terminal. In particular, raw mode is used for writing programs such as text editors.
Terminal ports are initially in cooked mode; this can be changed at any time with the procedures defined in this section.
These procedures represent cooked mode by the symbol cooked
,
and raw mode by the symbol raw
. An argument called mode
must be one of these symbols. A port argument to any of these
procedures may be any port, even if that port does not support
terminal mode; in that case, the port is not modified in any way.
Returns the terminal mode of input-port or output-port.
Returns #f
if the given port is not a terminal port.
Changes the terminal mode of input-port or output-port to be mode and returns an unspecified value.
Thunk must be a procedure of no arguments.
Binds the terminal mode of input-port or output-port to be mode, and calls thunk. When thunk returns, the original terminal mode is restored and the values yielded by thunk are returned.
These procedures are deprecated; instead use the corresponding procedures above.
Next: Format, Previous: Blocking Mode, Up: Input/Output [Contents][Index]