TerminalIO.mesa
Copyright © 1983, 1985, 1986 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, August 3, 1983 9:54 am
Last edited by: Christian Jacobi, October 23, 1986 12:48:45 pm PDT
DIRECTORY
IO USING [STREAM, Value],
Rope USING [ROPE];
TerminalIO:
CEDAR
DEFINITIONS =
BEGIN
Sequential IO for "terminal and keyboard"
All processes share one log viewer.
Output may be delayed while input is pending.
Don't use procedures from inside a viewers-repaint or a TIP-notify procedure.
Output
Output must not overwhelm the user: the user must be able to recognize an
output line made by a different application. Output made in form of lines
simplifies the recognition of the output source. It is also a good idea to follow
the input convention for outputs.
CreateStream:
PROC []
RETURNS [stream:
IO.
STREAM];
Creates an output stream which writes its output into the log viewer.
This procedure is lightweight; the viewer is only created when output is done.
No signals or errors are raised, neither on call nor on sequential output.
PutRope: PROC [text: Rope.ROPE];
PutRopes: PROC [t1, t2, t3: Rope.ROPE←NIL];
PutF: PROC [format: Rope.ROPE ← NIL, v1, v2, v3, v4, v5: IO.Value ← [null[]]];
PutF1:
PROC [format: Rope.
ROPE ←
NIL, value:
IO.Value ← [null[]]];
Input
In order to allow different applications to share this package in an orderly fashion,
(one that will not confuse users) clients must follow the convention below:
Do not require input except as immediate response to an user action.
UserAbort: SIGNAL;
RequestRope:
PROC [prompt: Rope.
ROPE←
NIL, timeOut:
NAT𡤀]
RETURNS [Rope.
ROPE];
Requests user to type in a rope.
May raise UserAbort and TimeOut.
prompt: NIL is ok, but others are better.
timeOut: in seconds; 0 for no timeout [the user can always abort].
RequestInt:
PROC [prompt: Rope.
ROPE ←
NIL, timeOut:
NAT𡤀]
RETURNS [
INT];
Shortcut; calls RequestRope and converts rope to integer
Confirm:
PROC [text: Rope.
ROPE, help: Rope.
ROPE←
NIL, timeOut:
NAT ← 0, dontLog:
BOOL←
FALSE]
RETURNS [
BOOL];
Requests user for confirmation; defaults to FALSE
timeOut: in seconds; 0 for no timeout
dontLog: prevent loging in viewer and log file
RequestSelection:
PROC [
header: Rope.
ROPE ←
NIL, choice:
LIST
OF Rope.
ROPE,
headerDoc: Rope.
ROPE ←
NIL, choiceDoc:
LIST
OF Rope.
ROPE ←
NIL,
default:
NAT ← 0, timeOut:
NAT ← 0, position:
REF ←
NIL,
dontLog:
BOOL ←
FALSE
]
RETURNS [
INT];
Shows a pop-up menu and returns the number of the selected entry.
returns: 1 for first choice, 2 for second...
0 if selected outside menu or on header-line
-1 if timed out
header: Header text; can not be selected.
choice: List of possible selections.
headerDoc: Documentation shown if selection is on header or outside menu.
choiceDoc: Documentation for the corresponding choice.
default: Hint for initial selection by implicit mouse movement. 0 if no default.
timeOut: In seconds; 0 for no time out.
position: Hint to override mouse position. See documentation for possible types.
dontLog: prevent loging in viewer and log file
There might be a maximum number of choices, see documentation.
AddLock:
PRIVATE
PROC [lock, free:
PROC];
USE WITH CARE.
Procedures tell client module whether some input is in progress. This
is typically used to diplay a different cursor, so the user sees that input
is required. The lock procedure is a hint, do not rely on it.
The client procedures are called in a monitored way; they must be fast
and not cause any wedge. Do not make assumptions about the order of calls.
The registered procedures can not be removed, use only one per client.
END.