DIRECTORY Ascii USING [ DEL ], Commander USING [CommandProc, Handle, Register], CommanderBackdoor USING [AdamOrEve], CommanderOps USING [ NextArgument ], Convert USING [ IntFromRope ], EditedStream USING [GetEcho, SetEcho ], IO, Rope USING [ROPE] ; MoreImpl: CEDAR PROGRAM IMPORTS Commander, CommanderBackdoor, CommanderOps, Convert, EditedStream, IO ~ { OPEN IO; MoreCmd: Commander.CommandProc = { controlStream: IO.STREAM¬NIL; echoStream: IO.STREAM¬NIL; RestoreEchoStream: PROC = { IF echoStream#NIL THEN EditedStream.SetEcho[controlStream, echoStream]; echoStream ¬ NIL; }; numLinesR: Rope.ROPE ¬ CommanderOps.NextArgument[cmd]; numLines: INT ¬ 0; lineCount: INT ¬ 0; IF numLinesR#NIL THEN numLines ¬ Convert.IntFromRope[numLinesR]; { ENABLE { IO.EndOfStream => { RestoreEchoStream[]; CONTINUE; }; IO.Error => GOTO Failed; UNWIND => RestoreEchoStream[]; }; controlChar: CHAR; waiting: BOOL ¬ FALSE; pleaseWait: BOOL ¬ FALSE; parentCmd: Commander.Handle ¬ CommanderBackdoor.AdamOrEve[cmd]; controlStream ¬ parentCmd.in; IF controlStream = NIL THEN RETURN[$Failed, "*** No error stream ***"]; echoStream ¬ EditedStream.GetEcho[controlStream]; IF echoStream#NIL THEN EditedStream.SetEcho[controlStream, NIL]; WHILE TRUE DO controlChar ¬ Ascii.DEL; IF controlStream.CharsAvail[]=0 AND ~waiting THEN { c: CHAR ¬ cmd.in.GetChar[]; IF c = '\015 THEN c ¬ '\n; cmd.out.PutChar[c]; IF c = '\n THEN { lineCount ¬ lineCount+1; IF pleaseWait THEN waiting ¬ TRUE ELSE IF numLines#0 AND lineCount MOD numLines = 0 THEN { cmd.err.PutRope["***More?"]; waiting ¬ TRUE; }; }; } ELSE { controlChar ¬ Ascii.DEL; controlChar¬ controlStream.GetChar[! IO.Rubout => CONTINUE]; SELECT controlChar FROM Ascii.DEL, '. => { RestoreEchoStream[]; RETURN[$ManualTermination, "-- "]; }; ENDCASE => IF waiting THEN { waiting ¬ pleaseWait ¬ FALSE; lineCount ¬ 0; } ELSE pleaseWait ¬ ~pleaseWait; }; ENDLOOP; RestoreEchoStream[]; EXITS Failed => { RestoreEchoStream[]; RETURN[$Failed, "*** Uncaught IO Error ***"]}; }; }; Commander.Register["More", MoreCmd, "Repeats its input"]; }. N MoreImpl.mesa Copyright Σ 1988, 1992 by Xerox Corporation. All rights reserved. Swinehart, December 2, 1991 11:45 am PST Willie-s, May 11, 1992 9:23 pm PDT [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] controlStream _ NARROW[ Commander.GetProperty[key: $ErrorInputStream, aList: cmd.propertyList]]; Κ;–(cedarcode) style•NewlineDelimiter ™code™ Kšœ Οeœ7™BK™(K™"K˜—šΟk ˜ Kšœžœžœ˜Kšœ žœ!˜0Kšœžœ ˜$Kšœ žœ˜$Kšœžœ˜Kšœ žœ˜'Kšžœ˜Kšœžœžœ˜K˜K˜—K˜šΠlnœžœž˜Kšžœ+Οtœ Πktœ˜QKšžœžœ˜K˜K˜•StartOfExpansionL -- [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]šΟnœ˜"Kš œžœ žœžœžœžœžœ™HKšœžœžœžœ˜Kšœ žœžœžœ˜š’œžœ˜Kšžœ žœžœ1˜GKšœ žœ˜K˜—Kšœžœ"˜6Kšœ žœ˜Kšœ žœ˜Kšžœ žœžœ+˜@K˜šžœ˜Kšžœ'žœ˜5Kšžœ žœ˜Kšžœ˜K˜—Kšœ žœ˜K–%[key: REF ANY, aList: List.AList]šœ žœžœ˜K–%[key: REF ANY, aList: List.AList]šœ žœžœ˜K˜?šœžœ™KšœH™H—K˜Kšžœžœžœžœ%˜GK˜1Kšžœ žœžœ%žœ˜@šžœžœž˜ Kšœžœ˜šžœžœ žœ˜3Kšœžœ˜Kšžœ žœ ˜Kšœ˜šžœ žœ˜K˜Kšžœ žœ ž˜!šžœ žœ žœžœ˜8Kšœ'žœ˜,K˜—K˜—K˜—šžœž˜Kšœžœ˜Kšœ%žœ žœ˜<šžœ ž˜Kšœžœžœ$˜Ršžœžœ žœžœ˜KKšžœ˜——K˜—Kšžœ˜—K˜šž˜Kšœ!žœ(˜O—K˜K˜K˜—K˜9—K˜Kšœ˜K˜—…— ™