DIRECTORY FileIO, NameSymbolTable, NodeProps, NodeStyle, PressPrinter, Rope, TEditDocument, TextNode, TSExtras, TSJaMPageBuilder, TSObject, TSOutput, TSOutputPress, TSTranslate, TSViewer, ViewerClasses, UserCredentials, UserProfile; TSExtrasImpl: MONITOR IMPORTS FileIO, 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; outputHandle: TSOutput.Handle _ TSOutputPress.CreateWithCursor[ stream: FileIO.Open["temp.press$", overwrite], 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 server = NIL THEN server _ UserProfile.Token["Hardcopy.PressPrinter", ""]; [galley, style] _ TSTranslate.TreeToVlist[node]; [] _ TSJaMPageBuilder.RunPageBuilder[ galley: galley, style: style, output: outputHandle, abortCheckProc: isAborted, documentName: nameForSeparatorPage ]; outputHandle.Close[]; [] _ PressPrinter.SendPressFile[ fileName: "temp.press$", server: server, progressProc: progressProc, copies: copies, userName: UserCredentials.GetUserCredentials[].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; outputHandle: TSOutput.Handle _ TSOutputPress.CreateWithCursor[ stream: FileIO.Open["temp.press$", overwrite], 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 server = NIL THEN server _ UserProfile.Token["Hardcopy.PressPrinter", ""]; 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[]; [] _ PressPrinter.SendPressFile[ fileName: "temp.press$", server: server, progressProc: progressProc, copies: copies, userName: UserCredentials.GetUserCredentials[].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. ´TSExtrasImpl.mesa Michael Plass, May 2, 1983 9:47 am 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 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 Ê ±˜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˜—šÏnœžœžœž œ˜*J˜Jšœžœ˜ Jšœ žœžœ˜Jšœ žœžœ˜Jšœžœ˜Jšœ žœžœž˜#Jšœžœžœžœ˜Jšœžœ4˜Ošœ?˜?Jšœ.˜.Jšœ#˜#Jšœž˜Jšœ˜—Jšœ˜Jšœ˜JšŸ œžœžœžœžœžœ žœžœžœžœ ˜XšŸ œžœ˜3Jšžœžœžœ+˜DJšžœ žœžœ žœ˜2J˜—Jšžœ žœžœ9˜MJšœ0˜0˜%Jšœ˜Jšœ ˜ J˜J˜Jšœ"˜"J˜—J˜˜ Jšœ˜Jšœ˜Jšœ˜J˜J˜3J˜—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šžœ žœžœ9˜MJ™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˜J˜3J˜—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™——…—Ô+9