TerminalIO.mesa
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
By Ch. Jacobi, August 3, 1983 9:54 am
Last edited by Ch. Jacobi, October 7, 1985 10:18:13 am PDT
DIRECTORY
IO USING [STREAM, Value],
Rope USING [ROPE];
TerminalIO: CEDAR DEFINITIONS =
BEGIN
Sequential IO for "terminal and keyboard"
All processes share one terminal viewer.
All procedures must not be called from inside a viewers-repaint or a TIP-notify procedure.
All output procedure might be delayed while input is pending.
ROPE: TYPE = Rope.ROPE;
--output
WriteRope: PROC [text: ROPE];
WriteRopes: PROC [t1, t2, t3: ROPE ← NIL];
WriteLn: PROC [];
WriteChar: PROC [ch: CHAR];
WriteInt: PROC [i: INT];
Write: PROC [v1, v2, v3: IO.Value ← [null[]]];
Write1: PROC [value: IO.Value ← [null[]]];
WriteF: PROC [format: ROPE ← NIL, v1, v2, v3, v4, v5: IO.Value ← [null[]]];
WriteF1: PROC [format: ROPE ← NIL, value: IO.Value ← [null[]]];
TOS:
PROC []
RETURNS [stream:
IO.
STREAM];
--creates an output stream which writes its output into the terminal
--input
UserAbort: SIGNAL;
RequestRope:
PROC [text:
ROPE ←
NIL]
RETURNS [
ROPE];
--may raise UserAbort
RequestChar:
PROC [text:
ROPE ←
NIL]
RETURNS [
CHAR];
--may raise UserAbort
RequestInt:
PROC [text:
ROPE ←
NIL]
RETURNS [
INT];
--may raise UserAbort
RequestSelection:
PROC [label:
ROPE ←
NIL, choice:
LIST
OF
ROPE, text:
ROPE ←
NIL, default:
NAT ← 0, timeOut:
NAT ← 0]
RETURNS [
INT];
--returns: 1 for first choice, 2 for second...
-- 0 if selected outside menu or on title-line
-- -1 if time out
--label: header text; can not be selected.
--choice: list of possible selections.
--text: written to the terminal.
--default: the cursor might be initially moved to this line.
--timeOut: in seconds; 0 for no time out.
Confirm:
PROC [choice:
ROPE, label:
ROPE ←
NIL, timeOut:
NAT ← 0, onTimeOut:
BOOL ←
FALSE]
RETURNS [
BOOL];
--choice: option to confirm
--label: header text; can not be selected
--timeOut: in seconds; 0 for no time out.
--onTimeOut: returned result if timed out.
--special
AddLock:
PRIVATE
PROC [lock, unLock:
PROC];
--USE WITH CARE.
--Procedures tell client module whether some input is in progress.
--The lock, unLock procedures are called within the monitorlock.
--Locks cannot be removed, use only one lock per module.
END.