DIRECTORY EditSpan USING [CompareNodeOrder, NodeOrder], NodeProps USING [CopyInfoProc, GetProp, MapProps, NullCopy, NullRead, NullWrite, PutProp, Register, RemProp], PutGet USING [FromFile, ToFile], Rope USING [ROPE], TEditDocument USING [SpinAndLock, TEditDocumentData, Unlock], TEditInput USING [CommandProc, FreeTree, Register, UnRegister], TextNode USING [FirstChild, FirstSibling, LastChild, LastLocWithin, LastSibling, LastWithin, Location, Next, Node, NodeBody, Parent, Previous, Root, StepBackward, StepForward], TiogaOps USING [CommandProc, CopyInfoProc, Location, MapPropsAction, NodeBody, Order, ReadSpecsProc, SetSelection, Viewer, WhichSelection, WriteSpecsProc]; TiogaExtraOpsImpl: CEDAR PROGRAM IMPORTS EditSpan, NodeProps, PutGet, TEditDocument, TEditInput, TextNode, TiogaOps EXPORTS TiogaOps = BEGIN OPEN TiogaOps; ROPE: TYPE ~ Rope.ROPE; Node: TYPE = TextNode.Node; -- points to a Tioga node NodeBody: PUBLIC TYPE = TextNode.NodeBody; GetRope: PUBLIC PROC [node: Node] RETURNS [ROPE] = { RETURN [IF node=NIL THEN NIL ELSE node.rope] }; Parent: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.Parent[node]] }; Root: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.Root[node]] }; Next: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.Next[node]] }; Previous: PUBLIC PROC [node: Node, parent: Node _ NIL] RETURNS [nx: Node] = { RETURN [TextNode.Previous[node]] }; StepForward: PUBLIC PROC [node: Node] RETURNS [nx: Node] = { RETURN [TextNode.StepForward[node]] }; StepBackward: PUBLIC PROC [node: Node, parent: Node _ NIL] RETURNS [back: Node] = { RETURN [TextNode.StepBackward[node, parent]] }; FirstSibling: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.FirstSibling[node]] }; LastSibling: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.LastSibling[node]] }; LastWithin: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.LastWithin[node]] }; LastLocWithin: PUBLIC PROC [node: Node] RETURNS [Location] = { loc: TextNode.Location ~ TextNode.LastLocWithin[node]; RETURN [[loc.node, loc.where]]; }; FirstChild: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.FirstChild[node]] }; LastChild: PUBLIC PROC [node: Node] RETURNS [Node] = { RETURN [TextNode.LastChild[node]] }; IsDirty: PUBLIC PROC [node: Node] RETURNS [BOOL] = { RETURN [node.dirty] }; IsNew: PUBLIC PROC [node: Node] RETURNS [BOOL] = { RETURN [node.new] }; ClearDirty: PUBLIC PROC [node: Node] = { node.dirty _ FALSE }; ClearNew: PUBLIC PROC [node: Node] = { node.new _ FALSE }; ViewerDoc: PUBLIC PROC [viewer: Viewer] RETURNS [root: Node] = { tdd: TEditDocument.TEditDocumentData = NARROW[viewer.data]; IF tdd = NIL THEN RETURN [NIL]; [] _ TEditDocument.SpinAndLock[tdd, "ViewerDoc"]; -- make sure nothing else going on root _ tdd.text; TEditDocument.Unlock[tdd] }; PutProp: PUBLIC PROC [n: Node, name: ATOM, value: REF] = { NodeProps.PutProp[n, name, value] }; GetProp: PUBLIC PROC [n: Node, name: ATOM] RETURNS [REF] = { RETURN [NodeProps.GetProp[n, name]] }; RemProp: PUBLIC PROC [n: Node, name: ATOM] = { NodeProps.RemProp[n, name] }; MapProps: PUBLIC PROC [ n: Node, action: MapPropsAction, formatFlag, commentFlag: BOOL _ TRUE] RETURNS [BOOL] = { RETURN [NodeProps.MapProps[n, action, formatFlag, commentFlag]] }; RegisterPropProc: PUBLIC PROC [name: ATOM, reader: ReadSpecsProc, writer: WriteSpecsProc, copier: CopyInfoProc] = { NodeProps.Register[name, reader, writer, copier]; }; NullRead: PUBLIC ReadSpecsProc = { [] _ NodeProps.NullRead[name, specs] }; NullWrite: PUBLIC WriteSpecsProc = { [] _ NodeProps.NullWrite[name, value] }; NullCopy: PUBLIC CopyInfoProc = { [] _ NodeProps.NullCopy[name, value] }; NodeOrder: PROC [order: EditSpan.NodeOrder] RETURNS [Order] = { RETURN [SELECT order FROM before => before, same => same, after => after, disjoint => disjoint, ENDCASE => ERROR] }; CompareLocOrder: PUBLIC PROC [loc1, loc2: Location] RETURNS [order: Order] = { order _ NodeOrder[EditSpan.CompareNodeOrder[loc1.node, loc2.node]]; IF order=same THEN order _ SELECT loc1.where FROM < loc2.where => before, = loc2.where => same, ENDCASE => after }; CompareNodeOrder: PUBLIC PROC [node1, node2: Node] RETURNS [order: Order] = { RETURN [NodeOrder[EditSpan.CompareNodeOrder[node1, node2]]] }; GetFile: PUBLIC PROC [name: ROPE] RETURNS [root: Node] = { RETURN [PutGet.FromFile[name]] }; PutFile: PUBLIC PROC [name: ROPE, root: Node] = { [] _ PutGet.ToFile[name, root] }; FreeTree: PUBLIC PROC [root: Node] = { TEditInput.FreeTree[root] }; SelectPoint: PUBLIC PROC [ viewer: Viewer, caret: Location, which: WhichSelection _ primary] = { TiogaOps.SetSelection[viewer: viewer, start: caret, end: caret, level: point, which: which] }; RegisterCommand: PUBLIC PROC [name: ATOM, proc: CommandProc, before: BOOL _ TRUE] = { TEditInput.Register[name, proc, before] }; UnRegisterCommand: PUBLIC PROC [name: ATOM, proc: CommandProc] = { TEditInput.UnRegister[name, proc] }; END. ΞTiogaExtraOpsImpl.mesa Copyright c 1985, 1986 by Xerox Corporation. All rights reserved. written by Bill Paxton. June 1982 Last Edited by: Paxton, January 10, 1983 4:23 pm Last Edited by: Plass, March 29, 1985 5:48:25 pm PST Doug Wyatt, September 2, 1986 5:46:59 pm PDT Miscellaneous operations on nodes Node Property Lists read, write, copy props Comparing order of nodes or locations in document File I/O Make point selection Command registration Κw˜codešœ™Kšœ Οmœ7™BKšœ!™!Kšœ0™0K™4K™,—K˜šΟk ˜ Kšœ žœ˜-Kšœ žœ^˜mKšœžœ˜ Kšœžœžœ˜Kšœžœ*˜=Kšœ žœ/˜?Kšœ žœ’˜°Kšœ žœ˜›—K˜KšΠblœžœž˜ KšžœK˜RKšžœ ˜Kšœžœžœ ˜K˜Kšžœžœžœ˜KšœžœΟc˜5Kšœ žœžœ˜*K˜Kšœ!™!˜š Οnœžœžœžœžœ˜5Kš žœžœžœžœžœžœ˜/K˜—Kš ‘œžœžœžœ žœ˜UK˜Kš ‘œžœžœžœ žœ˜QK˜Kš ‘œžœžœžœ žœ˜QK˜š ‘œžœžœžœžœ˜MKšžœ˜#K˜—š‘ œžœžœžœ˜Kšœ6˜6Kšžœ˜Kšœ˜K˜—Kš ‘ œžœžœžœ žœ˜]K˜Kš ‘ œžœžœžœ žœ˜[K˜š ‘œžœžœžœžœžœ˜KK˜—š ‘œžœžœžœžœžœ˜GK˜—š‘ œžœžœžœ˜>K˜—š‘œžœžœžœ˜:K˜—š‘ œžœžœžœ˜@Kšœ'žœ˜;Kš žœžœžœžœžœ˜Kšœ2 "˜TK˜K˜—K˜—šœ™K™š ‘œžœžœžœ žœ˜:K˜$K™—š ‘œžœžœžœžœžœ˜K˜——šœ™K™š ‘œžœžœžœžœ˜:Kšžœ˜!—K˜Kš‘œžœžœžœ3˜SK˜š‘œžœžœ.˜CK˜K˜——šœ™K™š‘ œžœžœ˜KšœE˜EKšœ^˜^K˜——šœ™K™š ‘œžœžœžœžœžœ˜UK˜*—K˜š‘œžœžœžœ˜BK˜$——K˜Kšžœ˜K˜K˜K˜—…—‚Η