DIRECTORY Atom USING [GetPName], CommandTool USING [DoCommand], FS USING [GetName, OpenFileFromStream, StreamOpen], IO USING [STREAM], NodeProps USING [GetProp, PutProp], NodeStyle USING [Ref], NodeStyleOps USING [Create, defaultStyleName], PressPrinter USING [Abort, CurrentStateMessage, Handle, ProgressProc, SendPressFile], Rope USING [Cat, Concat, Equal, Length, ROPE], TEditDocument USING [TEditDocumentData], TextNode USING [LastChild, NarrowToTextNode, NewTextNode, Ref], TSExtras USING [NodeProc], TSJaMPageBuilder USING [RunPageBuilder], TSObject USING [ItemList], TSOutput USING [Close, Handle], TSOutputPress USING [CreateWithCursor], TSTranslate USING [ProgressProc, TreeToVlist], TSViewer USING [], UserCredentials USING [Get], UserProfile USING [Token], ViewerClasses USING [Viewer]; TSExtrasImpl: CEDAR MONITOR IMPORTS CommandTool, FS, Atom, NodeProps, NodeStyleOps, PressPrinter, Rope, TextNode, TSJaMPageBuilder, TSOutput, TSOutputPress, TSTranslate, UserCredentials, UserProfile EXPORTS TSExtras = BEGIN PrintTiogaViewer: PUBLIC ENTRY PROCEDURE [ viewer: ViewerClasses.Viewer, nameForSeparatorPage: Rope.ROPE, aborted: REF BOOLEAN, server: Rope.ROPE _ NIL, copies: INT _ 1, messageProc: PROC [Rope.ROPE] _ NIL ] = {ENABLE UNWIND => NULL; node: TextNode.Ref _ NARROW[viewer.data, TEditDocument.TEditDocumentData].text; stream: IO.STREAM _ FS.StreamOpen["temp.press$", $create]; fullName: Rope.ROPE _ FS.GetName[FS.OpenFileFromStream[stream]].fullFName; outputHandle: TSOutput.Handle _ TSOutputPress.CreateWithCursor[ stream: stream, documentName: nameForSeparatorPage, cursorObject: NIL ]; galley: TSObject.ItemList; style: NodeStyle.Ref; isAborted: PROC RETURNS [BOOLEAN] = {RETURN[IF aborted = NIL THEN FALSE ELSE aborted^]}; progressProc: PressPrinter.ProgressProc = TRUSTED { IF messageProc # NIL THEN messageProc[handle.CurrentStateMessage[]]; IF aborted # NIL AND aborted^ THEN handle.Abort[]; }; IF Rope.Length[server] = 0 THEN server _ UserProfile.Token["Hardcopy.PressPrinter", "Clover"]; [galley, style] _ TSTranslate.TreeToVlist[node]; [] _ TSJaMPageBuilder.RunPageBuilder[ galley: galley, style: style, output: outputHandle, abortCheckProc: isAborted, documentName: nameForSeparatorPage ]; outputHandle.Close[]; IF server.Equal["*"] THEN { [] _ CommandTool.DoCommand[Rope.Concat["ShowPress ", fullName], NIL]; } ELSE [] _ PressPrinter.SendPressFile[ fileName: fullName, server: server, progressProc: progressProc, copies: copies, userName: UserCredentials.Get[].name ]; }; PrintSuppliedNodes: PUBLIC ENTRY PROCEDURE [ nodeProc: TSExtras.NodeProc, nameForSeparatorPage: Rope.ROPE, aborted: REF BOOLEAN, server: Rope.ROPE _ NIL, copies: INT _ 1, messageProc: PROC [Rope.ROPE] _ NIL] = { ENABLE UNWIND => NULL; stream: IO.STREAM _ FS.StreamOpen["temp.press$", $create]; fullName: Rope.ROPE _ FS.GetName[FS.OpenFileFromStream[stream]].fullFName; outputHandle: TSOutput.Handle _ TSOutputPress.CreateWithCursor[ stream: stream, documentName: nameForSeparatorPage, cursorObject: NIL ]; root: TextNode.Ref; node: TextNode.Ref; prevLast: TextNode.Ref _ NIL; prop: REF; galley: TSObject.ItemList; style: NodeStyle.Ref; isAborted: PROC RETURNS [BOOLEAN] = {RETURN[IF aborted = NIL THEN FALSE ELSE aborted^]}; progressProc: PressPrinter.ProgressProc = TRUSTED { IF messageProc # NIL THEN messageProc[handle.CurrentStateMessage[]]; IF aborted # NIL AND aborted^ THEN handle.Abort[]; }; InsertNode: PROCEDURE [root, node: TextNode.Ref, child: BOOL _ FALSE] = { IF child THEN { IF root.child # NIL THEN { node.next _ root.child; node.last _ FALSE } ELSE { node.next _ root; node.last _ TRUE }; root.child _ node } ELSE { node.next _ root.next; node.last _ root.last; root.next _ node; root.last _ FALSE }; }; InsertAsLastChild: PROCEDURE [root, node, prevLast: TextNode.Ref] = { IF prevLast=NIL OR ~prevLast.last OR prevLast.next # root THEN prevLast _ TextNode.NarrowToTextNode[TextNode.LastChild[root]]; IF prevLast=NIL THEN InsertNode[root, node, TRUE] ELSE InsertNode[prevLast, node, FALSE]; }; IF Rope.Length[server]=0 THEN server _ UserProfile.Token["Hardcopy.PressPrinter", "Clover"]; root _ TextNode.NewTextNode[]; root.last _ TRUE; UNTIL (node _ nodeProc[]) = NIL DO InsertAsLastChild[root, node, prevLast]; prevLast _ node; style _ NodeStyleOps.Create[]; prop _ NodeProps.GetProp[node, $Prefix]; IF prop # NIL THEN NodeProps.PutProp[node, $Prefix, Rope.Cat[ NARROW[prop, Rope.ROPE], " \"", Atom.GetPName[NodeStyleOps.defaultStyleName], "\" style"]]; ENDLOOP; [galley, style] _ TSTranslate.TreeToVlist[root]; [] _ TSJaMPageBuilder.RunPageBuilder[ galley: galley, style: style, output: outputHandle, abortCheckProc: isAborted, documentName: nameForSeparatorPage]; outputHandle.Close[]; IF server.Equal["*"] THEN { [] _ CommandTool.DoCommand[Rope.Concat["ShowPress ", fullName], NIL]; } ELSE [] _ PressPrinter.SendPressFile[ fileName: fullName, server: server, progressProc: progressProc, copies: copies, userName: UserCredentials.Get[].name ]; }; END. ΔTSExtrasImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Michael Plass, April 25, 1985 12:40:38 pm PST Rick Beach, April 28, 1985 12:46:31 pm PDT InsertNode: PUBLIC PROC [x: Ref, child: BOOL _ FALSE] RETURNS [new: Ref] = { -- if ~child then new is sibling of x -- else new is first child of x new _ TextNode.NewTextNode[]; IF child THEN { IF x.child # NIL THEN { new.next _ x.child; new.last _ FALSE } ELSE { new.next _ x; new.last _ TRUE }; x.child _ new } ELSE { new.next _ x.next; new.last _ x.last; x.next _ new; x.last _ FALSE }}; new -> node x -> root -- if ~child then new is sibling of x -- else new is first child of x InsertAsLastChild: PUBLIC PROC [x: Ref, prevLast: Ref _ NIL] RETURNS [new: Ref] = { -- prevLast is optional accelerator IF prevLast=NIL OR ~prevLast.last OR prevLast.next # x THEN prevLast _ TextNode.NarrowToTextNode[TextNode.LastChild[x]]; new _ IF prevLast=NIL THEN InsertNode[x, TRUE] ELSE InsertNode[prevLast, FALSE] }; build a tree with the supplied nodes, each with the right style property put "styleName" Style in Prefix property with the tree in hand, typeset it stream _ NIL; -- gets closed elsewhere. DisplayTiogaViewer: PUBLIC ENTRY PROCEDURE [ viewer: ViewerClasses.Viewer, nameOfDisplayViewer: Rope.ROPE, aborted: REF BOOLEAN ] = {ENABLE UNWIND => NULL; node: TextNode.Ref _ NARROW[viewer.data, TEditDocument.TEditDocumentData].text; outputHandle: TSOutput.Handle _ TSOutput.CreateViewer[nameOfDisplayViewer]; galley: TSObject.ItemList; style: NodeStyle.Ref; isAborted: PROC RETURNS [BOOLEAN] = {RETURN[IF aborted = NIL THEN FALSE ELSE aborted^]}; [galley, style] _ TSTranslate.TreeToVlist[node]; [] _ TSJaMPageBuilder.RunPageBuilder[ galley: galley, style: style, output: outputHandle, abortCheckProc: isAborted, documentName: nameOfDisplayViewer ]; outputHandle.Close[]; }; DisplaySuppliedNodes: PUBLIC ENTRY PROCEDURE [ nodeProc: TSExtras.NodeProc, nameOfDisplayViewer: Rope.ROPE, aborted: REF BOOLEAN] = { ENABLE UNWIND => NULL; outputHandle: TSOutput.Handle _ TSOutput.CreateViewer[nameOfDisplayViewer]; root: TextNode.Ref; node: TextNode.Ref; prevLast: TextNode.Ref _ NIL; prop: REF; galley: TSObject.ItemList; style: NodeStyle.Ref; isAborted: PROC RETURNS [BOOLEAN] = {RETURN[IF aborted = NIL THEN FALSE ELSE aborted^]}; InsertNode: PROCEDURE [root, node: TextNode.Ref, child: BOOL _ FALSE] = { -- if ~child then new is sibling of x -- else new is first child of x IF child THEN { IF root.child # NIL THEN { node.next _ root.child; node.last _ FALSE } ELSE { node.next _ root; node.last _ TRUE }; root.child _ node } ELSE { node.next _ root.next; node.last _ root.last; root.next _ node; root.last _ FALSE }; }; InsertAsLastChild: PROCEDURE [root, node, prevLast: TextNode.Ref] = { IF prevLast=NIL OR ~prevLast.last OR prevLast.next # root THEN prevLast _ TextNode.NarrowToTextNode[TextNode.LastChild[root]]; IF prevLast=NIL THEN InsertNode[root, node, TRUE] ELSE InsertNode[prevLast, node, FALSE]; }; -- build a tree with the supplied nodes, each with the right style property root _ TextNode.NewTextNode[]; root.last _ TRUE; UNTIL (node _ nodeProc[]) = NIL DO InsertAsLastChild[root, node, prevLast]; prevLast _ node; -- put "styleName" Style in Prefix property style _ NodeStyleOps.Create[]; prop _ NodeProps.GetProp[node, $Prefix]; IF prop # NIL THEN NodeProps.PutProp[node, $Prefix, Rope.Cat[ NARROW[prop, Rope.ROPE], " \"", Atom.GetPName[NodeStyleOps.defaultStyleName], "\" style"]]; ENDLOOP; -- with the tree in hand, typeset it [galley, style] _ TSTranslate.TreeToVlist[root]; [] _ TSJaMPageBuilder.RunPageBuilder[ galley: galley, style: style, output: outputHandle, abortCheckProc: isAborted, documentName: nameOfDisplayViewer]; outputHandle.Close[]; }; Edited on May 16, 1983 3:47 pm, by Beach Add PrintSuppliedNodes interface for printing Walnut message sets. Edited on October 6, 1983 5:18 pm, by Beach implement FormatTiogaViewer and FormatSuppliedNodes Michael Plass, December 14, 1983 3:11 pm. Added check for empty server, * server. Κ ˜šΟc™Icodešœ Οmœ1™JšŸœŸœ™'J™—JšŸœ@Ÿœ™MJ™ J™ J™—š‘ œŸ œ#ŸœŸœ˜IJš%™%Jš™šŸœŸœ˜JšŸœŸœŸœ'Ÿœ˜FJšŸœ!Ÿœ˜,Jšœ˜—JšŸœOŸœ˜[J˜—š ‘œŸœŸœŸœŸœ™SJš#™#š Ÿœ ŸœŸœŸœŸ™;Jšœ<™<—Jš œŸœ ŸœŸœŸœŸœŸœ™RJ™—š‘œŸ œ)˜Eš Ÿœ ŸœŸœŸœŸ˜>Jšœ?˜?—Jš Ÿœ ŸœŸœŸœŸœŸœ˜YJ˜—JšŸœŸœ?˜\J™HJ˜Jšœ Ÿ˜šŸœŸœŸ˜"Jšœ(˜(J˜J™(J˜Jšœ(˜(šŸœŸœŸœ˜˜*JšŸœ Ÿœ˜J˜Jšœ-˜-J˜ ——JšŸ˜—J™!J™'Jšœ0˜0˜%Jšœ˜Jšœ ˜ J˜Jšœ˜Jšœ$˜$—J˜šŸœŸœ˜Jšœ@Ÿœ˜EJ˜—šŸœ!˜%Jšœ˜Jšœ˜Jšœ˜J˜J˜$J˜—Jšœ˜J˜—š‘œŸœŸœŸ œ™,J™JšœŸœ™Jšœ ŸœŸ™JšœŸœŸœŸœ™JšœŸœ4™OJšœK™KJšœ™Jšœ™Jš‘ œŸœŸœŸœŸœŸœ ŸœŸœŸœŸœ ™XJšœ0™0™%Jšœ™Jšœ ™ J™J™Jšœ!™!J™—J™J™J™—š‘œŸœŸœŸ œ™.Jšœ™JšœŸ™Jšœ ŸœŸœ™JšŸœŸœŸœ™JšœK™KJšœ™J™JšœŸœ™JšœŸœ™ Jšœ™Jšœ™Jš‘ œŸœŸœŸœŸœŸœ ŸœŸœŸœŸœ ™Xš‘ œŸ œ#ŸœŸœ™IJš%™%Jš™šŸœŸœ™JšŸœŸœŸœ'Ÿœ™FJšŸœ!Ÿœ™,Jšœ™—JšŸœOŸœ™[J™—š‘œŸ œ)™Eš Ÿœ ŸœŸœŸœŸ™>Jšœ?™?—Jš Ÿœ ŸœŸœŸœŸœŸœ™YJ™—J™KJ™Jšœ Ÿ™šŸœŸœŸ™"Jšœ(™(J™J™+J™Jšœ(™(šŸœŸœŸœ™™*JšŸœ Ÿœ™J™Jšœ-™-J™ ——JšŸ™—J™$Jšœ0™0™%Jšœ™Jšœ ™ J™Jšœ™Jšœ#™#—J™Jšœ™J™—J˜JšŸœ˜™(JšœB™B—™+Jšœ Οrœ’™3J™—J™R—…—v-;