In edited mode, io-char performs line-editing operations on each received character. Only when a line is "completely entered"—typically when a carriage return (CR) is received—will the line of data be made available to application processes. This mode of operation is often referred to as canonical or sometimes "cooked" mode.
Most nonfullscreen applications run in edited mode, because this allows the application to deal with the data a line at a time, rather than have to examine each character received, scanning for an end-of-line character.
In edited mode, each character is received into the raw input buffer by the interrupt handler. Unlike raw mode where the driver is scheduled to run only when some input conditions are met, the interrupt handler will schedule the driver on every received character.
There are two reasons for this. First, edited input mode is rarely used for high-performance communication protocols. Second, the work of editing is significant and not suitable for an interrupt handler.
When the driver runs, code in io-char will examine the character and apply it to the canonical buffer in which it's building a line. When a line is complete and an application requests input, the line will be transferred from the canonical buffer to the application—the transfer is direct from the canonical buffer to the application buffer without any intervening copies.
The editing code correctly handles multiple pending input lines in the canonical buffer and allows partial lines to be read. This can happen, for example, if an application asked only for 1 character when a 10-character line was available. In this case, the next read will continue where the last one left off.
The io-char module provides a rich set of editing capabilities, including full support for moving over the line with cursor keys and for changing, inserting, or deleting characters. Here are some of the more common capabilities:
Line-editing characters vary from terminal to terminal. The console always starts out with a full set of editing keys defined.
If a terminal is connected via a serial channel, you need to define the editing characters that apply to that particular terminal. To do this, you can use the stty utility. For example, if you have an ANSI terminal connected to a serial port (called /dev/ser1), you would use the following command to extract the appropriate editing keys from the terminfo database and apply them to /dev/ser1:
stty term=ansi </dev/ser1