DIRECTORY CommandTool, IO, FS, NameSymbolTable, NodeProps, NodeStyle, PressPrinter, Rope, TEditDocument, TextNode, TSExtras, TSJaMPageBuilder, TSObject, TSOutput, TSOutputPress, TSTranslate, TSViewer, ViewerClasses, UserCredentials, UserProfile; TSExtrasImpl: MONITOR IMPORTS CommandTool, FS, NameSymbolTable, NodeProps, NodeStyle, 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 _ NodeStyle.Create[]; prop _ NodeProps.GetProp[node, $Prefix]; IF prop # NIL THEN NodeProps.PutProp[node, $Prefix, Rope.Cat[ NARROW[prop, Rope.ROPE], " \"", NameSymbolTable.RopeFromName[style.GetStyleName[]], "\" 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 ]; }; 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 { 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]; }; root _ TextNode.NewTextNode[]; root.last _ TRUE; UNTIL (node _ nodeProc[]) = NIL DO InsertAsLastChild[root, node, prevLast]; prevLast _ node; style _ NodeStyle.Create[]; prop _ NodeProps.GetProp[node, $Prefix]; IF prop # NIL THEN NodeProps.PutProp[node, $Prefix, Rope.Cat[ NARROW[prop, Rope.ROPE], " \"", NameSymbolTable.RopeFromName[style.GetStyleName[]], "\" style"]]; ENDLOOP; [galley, style] _ TSTranslate.TreeToVlist[root]; [] _ TSJaMPageBuilder.RunPageBuilder[ galley: galley, style: style, output: outputHandle, abortCheckProc: isAborted, documentName: nameOfDisplayViewer]; outputHandle.Close[]; }; END. 6TSExtrasImpl.mesa Michael Plass, December 14, 1983 5:21 pm Last Edited by: Beach, October 18, 1983 11:04 am 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. 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 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. Ê I˜JšÏc™Jšœ™)J™0J˜šÏk ˜ J˜ Jšœ˜Jšœ˜Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ J˜Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ˜Jšœ ˜ J˜—šœž˜Jšžœ¬žœ ˜ÅJšž˜J˜—šÏnœžœžœž œ˜*J˜Jšœžœ˜ Jšœ žœžœ˜Jšœ žœžœ˜Jšœžœ˜Jšœ žœžœž˜#Jšœžœžœžœ˜Jšœžœ4˜OJšœžœžœžœ$˜:Jšœžœžœ žœ'˜Jšœ?˜?Jšœ˜Jšœ#˜#Jšœž˜Jšœ˜—Jšœ˜Jšœ˜JšŸ œžœžœžœžœžœ žœžœžœžœ ˜XšŸ œžœ˜3Jšžœžœžœ+˜DJšžœ žœžœ žœ˜2J˜—Jšžœžœ?˜^Jšœ0˜0˜%Jšœ˜Jšœ ˜ J˜J˜Jšœ"˜"J˜—J˜šžœžœ˜Jšœ@žœ˜EJ˜—šžœ!˜%Jšœ˜Jšœ˜Jšœ˜J˜J˜$J˜—J˜J˜—šŸœžœžœž œ˜,Jšœ˜Jšœžœ˜ Jšœ žœžœ˜Jšœ žœžœ˜Jšœžœ˜Jšœ žœžœžœ˜(Jšžœžœžœ˜Jšœžœžœžœ$˜:Jšœžœžœ žœ'˜Jšœ?˜?Jšœ˜Jšœ#˜#Jšœž˜Jšœ˜—Jšœ˜J˜Jšœžœ˜Jšœžœ˜ Jšœ˜Jšœ˜JšŸ œžœžœžœžœžœ žœžœžœžœ ˜XšŸ œžœ˜3Jšžœžœžœ+˜DJšžœ žœžœ žœ˜2J˜—š Ÿ œžœžœžœžœžœ™LJš%™%Jš™J™šžœžœ™Jšžœ žœžœ"žœ™>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˜3J˜ ——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š Ÿ œžœžœžœžœžœ™LJš%™%Jš™J™šžœžœ™Jšžœ žœžœ"žœ™>Jšžœžœ™'J™—Jšžœ@žœ™MJ™ J™ J™—šŸ œž œ#žœžœ˜IJš%™%Jš™šžœžœ˜Jšžœžœžœ'žœ˜FJšžœ!žœ˜,Jšœ˜—JšžœOžœ˜[J˜—š Ÿœžœžœžœžœ™SJš#™#š žœ žœžœžœž™;Jšœ<™<—Jš œžœ žœžœžœžœžœ™RJ™—šŸœž œ)˜Eš žœ žœžœžœž˜>Jšœ?˜?—Jš žœ žœžœžœžœžœ˜YJ˜—J™HJ˜Jšœ ž˜šžœžœž˜"Jšœ(˜(J˜J™(J˜Jšœ(˜(šžœžœžœ˜˜*Jšžœ žœ˜J˜J˜3J˜ ——Jšž˜—J™!Jšœ0˜0˜%Jšœ˜Jšœ ˜ J˜Jšœ˜Jšœ#˜#—J˜Jšœ˜J˜—Jšžœ˜™(JšœB™B—™+Jšœ Ïrœ ™3J™—J™R—…—‚.