User guide
132 CHAPTER 5. CONSOLE INPUT AND OUTPUT
5.2 Cintpos console strea m s
Under Cintpos interaction with the console is somewhat more compli c at ed since Cintpos
can have several tasks all wishing to communicate with the keyboard and screen. This
interaction is controlled by a task called the Console Handler (typically task 3). Tasks
wishing to read from the keyboard or write to the screen must send request packets to
this task where they will be properly scheduled.
The call findinput("**") yields a new stream control b l ock connected to the
keyboard. Initially it has no buffer. When the client task tries to read from this
stream, a read request packet is sent to the console handler which will in due course
return with a b uffe r of one or more characters or an indication that the keyboard stream
is exhausted. Key board read requests can be sent simultaneously from several tasks
and, indeed, a single task can send multiple r e q ue st s. These are que ue d in the console
handler and processed on a first come first served basis.
The console handler obtains characters from the keyboard by sen di ng ttyin req u es t
packets to the keyboar d de v i ce ( typically device -2). This device returns keyboard
characters to the consol e handler as t he y are typed without echoing them to the scre en.
It does no translation except that the characters ctrl-j, ctrl-m and the ENTER key all
yield code 10 (the BCPL newl i ne character). Keyboard characters received by the
console handler are normally packed into an input buffer to form input lines. Simple
line editing is performed using the backspace key (code 8 or 127) whi ch causes the most
recent character in the l i ne buffer to be removed. When a newline is received or the
buffer is full or the escape sequence @e is typed, the line buffer is ready to send to the
currently sele c te d task. Initially this is task 1 (the main CLI task) but c an be changed
by t he user using the escape mechanism described be l ow. Whil e a user is typing an
input line, it will appear on the screen and other screen output reques ts will be held
until the input l i n e is complete. At any time if there is a completed input line for a
task that has sent a read request packet, it will be returned to the client with the line
buffer and number of characters in i ts two result fields. Lines t hat have not yet been
requested ar e queued as are read reque st s that are not yet satisfied. Note that a simple
way to temporally stop output to the scree n is to type a character such as SPACE, and
then delete it later using backspace.
Cintpos console input has the following escape mechanism. All escape sequence
start with an at sign (@) and the i r effects are shown in the foll owing table.