(cedar-imports "TerminalIO" "Scheme") (cedar-directory "Rope" "Ascii") (define-proc (TerminalIO.TOS) "PROC [] RETURNS [stream: IO.STREAM]; Creates an output stream which writes its output into the terminal 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." result _ TerminalIO.TOS[]; ) (define-proc (TerminalIO.TIS) "PROC [] RETURNS [stream: IO.STREAM]; Creates an Input stream which reads from the terminal viewer. This procedure is lightweight; the viewer is only created when Input is done. No signals or errors are raised, neither on call nor on sequential output." result _ TerminalIO.TIS[]; ) (define-proc (TerminalIO.PutRope rope) "Output a Scheme Rope to TerminalIO.PutRope" TerminalIO.PutRope[Scheme.TheROPE[rope]]; ) (define-proc (TerminalIO.PutRopes rope1 (rope2) (rope3)) "PROC [text: Rope.ROPE];" TerminalIO.PutRopes[Scheme.TheROPE[rope1], IF rope2=undefined THEN NIL ELSE Scheme.TheROPE[rope2], IF rope3=undefined THEN NIL ELSE Scheme.TheROPE[rope3]]; ) (define-proc (TerminalIO.RequestRope (prompt) (timeout)) "PROC [prompt: Rope.ROPE_NIL, timeOut: NAT_0] 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]." result _ TerminalIO.RequestRope[ IF prompt=undefined THEN NIL ELSE Scheme.TheROPE[prompt], IF timeout=undefined THEN 0 ELSE TheNAT[timeout]]; ) (define-proc (TerminalIO.RequestInt (prompt) (timeout)) "PROC [prompt: Rope.ROPE _ NIL, timeOut: NAT_0] RETURNS [INT]; Shortcut; calls RequestRope and converts rope to integer." result _ MakeFixnum[TerminalIO.RequestInt[ IF prompt=undefined THEN NIL ELSE Scheme.TheROPE[prompt], IF timeout=undefined THEN 0 ELSE TheNAT[timeout]]]; ) (define-proc (TerminalIO.Confirm text (help) (timeout) (dontlog)) "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." result _ MakeBoolean[TerminalIO.Confirm[ Scheme.TheROPE[text], IF help=undefined THEN NIL ELSE TheROPE[help], IF timeout=undefined THEN 0 ELSE TheNAT[timeout], IF dontlog=undefined THEN FALSE ELSE TheBOOL[dontlog] ]]; ) (define-proc (TerminalIO.RequestSelection header choice (headerdoc) (choicedoc) (default) (timeout) (position) (dontlog)) "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." result _ MakeFixnum[TerminalIO.RequestSelection[ TheROPE[header], TheROPELIST[choice], IF headerdoc=undefined THEN NIL ELSE TheROPE[headerdoc], IF choicedoc=undefined THEN NIL ELSE TheROPELIST[choicedoc], IF default=undefined THEN 0 ELSE TheNAT[default], IF timeout=undefined THEN 0 ELSE TheNAT[timeout], IF position=undefined THEN NIL ELSE TheREF[position], IF dontlog=undefined THEN FALSE ELSE TheBOOL[dontlog] ]]; ) ROPE: TYPE ~ Rope.ROPE; -- a node with top-level Cedar code. This is underlined if you have the right style. TheNAT: PROC [val: Any] RETURNS [result: NAT] = { RETURN[Scheme.TheCARD[val]]; }; TheREF: PROC [val: Any] RETURNS [result: REF] = TRUSTED { RETURN[LOOPHOLE[val]]; }; TheROPELIST: PROC [val: Any] RETURNS [ropes: LIST OF ROPE] = { WITH val SELECT FROM val: LIST OF ROPE => RETURN [val]; ENDCASE => Complain[val, "is not a LIST OF ROPE"]; }; ˆ TerminalIO.mx Copyright Σ 1989, 1992 by Xerox Corporation. All rights reserved. Created by Bob Krivacic, December 18, 1989 1:38:28 pm PST Documentation Interface from Scheme to the Cedar TerminalIO routines. Now Scheme code can interact with the ChipNDale terminal log. Cedar Primitives add strings to DIRECTORY and IMPORT clauses add strings to DIRECTORY clause only Scheme Code ΚΪ•NewlineDelimiter –(cedarcode) style™codešœ ™ Kšœ Οeœ7™BKšœ9™9Ischeme™Ihead2™ Idefault™wM™šœΟn œ˜%Nšœ+™+—šœžœ˜ Nšœ$™$—šœž œΟt žœ˜Nš œΟkœ œ  œ œλ˜ŽIcedaršœ œŸ˜Nšœ˜—šœž œŸ žœ˜Nš œ œ œ  œ œέ˜€Ošœ œŸ˜Nšœ˜—šœž œŸ Πbtœ˜&Nšœ,˜,Ošœ(Ÿ˜)Nšœ˜—šœ‘Οbœ˜8Nšœ œ  œ˜Ošœ+ œ œ œ œ œ œ œ œŸ˜›Nšœ˜—šœž œ˜8Nš œ œ œ œ  œ œ œ΄˜τšœ ˜ Oš œ œ œ œ˜:Oš œ œ œŸ˜2—Nšœ˜—šœž œ˜7Nš œ œ œ œ  œ œ œ=˜yšœ*˜*Oš œ œ œ œ˜:Oš œ œ œŸ˜3—Nšœ˜—šœžœ!˜ANšœ œ  œ  œ œ  œ œ œ œ œ˜ρšœ(˜(Ošœ˜Oš œ œ œ œ˜/Oš œ œ œŸ˜1Oš œ œ œ œ˜5OšŸ˜—Nšœ˜—šœžœP˜yNš)œ œ œ œ  œ œ œ œ œ  œ œ œ œ  œ œ œ œ  œ œ œ œF˜œšœ0˜0Ošœ˜Ošœ˜Oš œ œ œ œ˜9Oš œ œ œ œ˜=Oš œ œ œŸ˜1Oš œ œ œŸ˜1Oš  œ œ œ œŸ˜5Oš œ œ œ œ˜5OšŸ˜—Nšœ˜—L˜Oš œ œ œΟcU˜mO˜šžœ œ  œ  œ˜1Oš œ˜Ošœ˜O˜—š žœ œ  œ  œ œ˜9Oš œ œ˜Ošœ˜O˜—š ž œ œ  œ  œ œ œ˜?š œ œ ˜Oš œ œ œ œ œ˜"Oš œ+˜2—O˜O˜—L˜—M™ L˜J˜—…—fΘ