DIRECTORY TiogaLooks, TiogaNode, TiogaTreeOps, TextEdit, EditNotify, UndoEvent; EditSpan: CEDAR DEFINITIONS IMPORTS TiogaLooks = BEGIN Ref: TYPE = TiogaNode.Ref; RefBranchNode: TYPE = TiogaNode.RefBranchNode; TreeLoc: TYPE = TiogaTreeOps.TreeLoc; TreeSpan: TYPE = TiogaTreeOps.TreeSpan; Event: TYPE = UndoEvent.Ref; CannotDoEdit: ERROR; afterMoved1, afterMoved2: TreeLoc; Looks: TYPE = TiogaLooks.Looks; noLooks: Looks = TiogaLooks.noLooks; allLooks: Looks = TiogaLooks.allLooks; ChangeLooks: PROC [root: RefBranchNode, span: TreeSpan, remove, add: Looks, event: Event _ NIL]; AddLooks: PROC [root: RefBranchNode, span: TreeSpan, add: Looks, event: Event _ NIL] = INLINE { ChangeLooks[root, span, noLooks, add, event] }; RemoveLooks: PROC [root: RefBranchNode, span: TreeSpan, remove: Looks, event: Event _ NIL] = INLINE { ChangeLooks[root, span, remove, noLooks, event] }; SetLooks: PROC [root: RefBranchNode, span: TreeSpan, new: Looks, event: Event _ NIL] = INLINE { ChangeLooks[root, span, allLooks, new, event] }; ClearLooks: PROC [root: RefBranchNode, span: TreeSpan, event: Event _ NIL] = INLINE { ChangeLooks[root, span, allLooks, noLooks, event] }; Replace: PROC [ destRoot, sourceRoot: RefBranchNode, dest, source: TreeSpan, saveForPaste: BOOLEAN _ TRUE, event: Event _ NIL] RETURNS [result: TreeSpan]; Delete: PROC [root: RefBranchNode, del: TreeSpan, event: Event _ NIL, saveForPaste: BOOLEAN _ TRUE]; RecordGroupForPaste: PROC [start, end: Ref, event: Event]; -- for use by EditGroupImpl.Delete etc. SaveForPaste: PROC [span: TreeSpan, event: Event _ NIL]; SavedForPaste: PROC RETURNS [span: TreeSpan]; Place: TYPE = EditNotify.Place; -- { before, after, sibling, child }; Copy: PROC [destRoot, sourceRoot: RefBranchNode, dest: TreeLoc, source: TreeSpan, where: Place _ after, nesting: INTEGER _ 0, event: Event _ NIL] RETURNS [result: TreeSpan]; Move: PROC [destRoot, sourceRoot: RefBranchNode, dest: TreeLoc, source: TreeSpan, where: Place _ after, nesting: INTEGER _ 0, event: Event _ NIL] RETURNS [result: TreeSpan]; MoveOnto: PROC [destRoot, sourceRoot: RefBranchNode, dest, source: TreeSpan, saveForPaste: BOOLEAN _ TRUE, event: Event _ NIL] RETURNS [result: TreeSpan]; Transpose: PROC [ alphaRoot, betaRoot: RefBranchNode, alpha, beta: TreeSpan, event: Event _ NIL] RETURNS [newAlpha, newBeta: TreeSpan]; Insert: PROC [root: RefBranchNode, old: Ref, where: Place _ after, event: Event _ NIL] RETURNS [new: Ref]; Inherit: PROC [old, new: Ref, allprops: BOOL _ FALSE]; InsertTextNode: PROC [ root: RefBranchNode, old: Ref, class: TiogaNode.ItemClassID _ TiogaNode.defaultTextClassID, where: Place _ after, inherit: BOOL _ FALSE, event: Event _ NIL] RETURNS [new: TiogaNode.RefTextNode]; InsertBranchNode: PROC [ root: RefBranchNode, old: Ref, where: Place _ after, inherit: BOOL _ FALSE, event: Event _ NIL] RETURNS [new: TiogaNode.RefBranchNode]; InsertBoxNode: PROC [ root: RefBranchNode, old: Ref, class: TiogaNode.ItemClassID, where: Place _ after, inherit: BOOL _ FALSE, event: Event _ NIL] RETURNS [new: TiogaNode.RefBoxNode]; InsertListNode: PROC [ root: RefBranchNode, old: Ref, class: TiogaNode.ItemClassID, where: Place _ after, inherit: BOOL _ FALSE, event: Event _ NIL] RETURNS [new: TiogaNode.RefListNode]; InsertBasicNode: PROC [ root: RefBranchNode, old: Ref, class: TiogaNode.BasicClassID, where: Place _ after, inherit: BOOL _ FALSE, event: Event _ NIL] RETURNS [new: TiogaNode.RefBasicNode]; BreakTextNode: PROC [root: RefBranchNode, loc: TreeLoc, event: Event _ NIL] RETURNS [new: Ref]; BreakParent: PROC [root: RefBranchNode, node: Ref, before: BOOL _ TRUE, event: Event _ NIL] RETURNS [Ref]; BreakStatement: PROC [root: RefBranchNode, node: Ref, before: BOOL _ TRUE, event: Event _ NIL] RETURNS [RefBranchNode]; JoinStatements: PROC [root, statement: RefBranchNode, event: Event _ NIL] RETURNS [loc: TreeLoc]; Nest: PROC [root: RefBranchNode, span: TreeSpan, event: Event _ NIL] RETURNS [new: TreeSpan] = INLINE { new _ ChangeNesting[root,span,1,event] }; UnNest: PROC [root: RefBranchNode, span: TreeSpan, event: Event _ NIL] RETURNS [new: TreeSpan] = INLINE { new _ ChangeNesting[root,span,-1,event] }; ChangeNesting: PROC [root: RefBranchNode, span: TreeSpan, change: INTEGER, event: Event _ NIL] RETURNS [new: TreeSpan]; END. DEditSpan.mesa; written by Bill Paxton, June 1981 edited by McGregor, August 12, 1983 10:04 am edited by Bill Paxton, June 14, 1983 4:11 pm **** Miscellaneous **** hints for repaint set by Move, MoveOnto, and Transpose gives pointers to locs after the moved spans **** Operations to add or delete looks **** first remove then add in the given span ***** Editing operations on spans replace dest span by copy of source span if words flag is true, does ReplaceWords instead of ReplaceText result is the new copy of source result is last thing deleted or explicitly saved for Paste these are modifiers for the destination of a Move or Copy or Insert only apply when destination is an entire node (i.e., dest.where = NodeItself) place = before means insert as sibling before dest place = after means insert as sibling after dest; inherit children of dest place = sibling means insert as sibling after dest; don't inherit children of dest place = child means insert as first child of dest result is the new copy of source dest cannot be within source or get error BadMove result is moved span nesting is relative to dest e.g., where=after and nesting=1 makes source be child of dest like Replace, but moves source instead of copying it result is moved span alpha and beta must not overlap or get error BadTranspose newAlpha is new location of alpha span; ditto for newBeta ***** Insert new nodes empty copy of old node is inserted in tree in position determined by "where" empty text item node is inserted in tree empty branch node is inserted in tree empty box item node is inserted in tree empty list item node is inserted in tree empty basic node is inserted in tree ***** Break & Join Inserts copy of loc.node as next sibling and returns this as "new". Moves text starting with loc.where to new. Error if loc.node is not a text node. Inserts copy of parent as next sibling of parent. If before is true, moves children starting with node to be contents of new. Otherwise, moves children starting with next sibling of node. Returns the parent of node after the break. loc points somewhere in the contents of a statement. This works its way up breaking nodes until contents from node on have been moved to a new statement. If before is true, node moves to the new statement; otherwise, it stays in the old one. Returns the statement which contains node after the break. moves contents of statement to end of previous one and then deletes statement ***** Nesting moves span to a deeper nesting level in tree moves all nodes of span, even if don't have entire node selected moves span to a shallower nesting level in tree Ê ˜JšÏc0™0Jš,™,Jš,™,J˜šÏk ˜ J˜ J˜ Jšœ ˜ J˜ J˜ J˜ —J˜Jšœ žœ˜Jšžœ ž˜J˜Jšœžœ˜Jšœžœ˜.Jšœ žœ˜%Jšœ žœ˜'Jšœžœ˜J˜Jš™˜šœžœ˜J˜—˜"Jš6™6Jš,™,—J˜—Jš+™+˜Jšœžœ˜J˜$J˜&J˜šÏn œžœJžœ˜`Jš'™'J˜—šŸœžœBžœ˜TJšœžœ2˜:J˜—šŸ œžœEžœ˜ZJšœžœ5˜=J˜—šŸœžœBžœ˜TJšœžœ3˜;J˜—šŸ œžœ6žœ˜JJšœžœ7˜?—J™—Jš!™!˜šŸœžœ˜Jšœ<˜˜LJšœžœžœžœ˜1Jšžœ˜Jš4™4Jš™J˜—šŸ œžœ˜JšœJžœ˜NJšžœ˜&Jš9™9Jš9™9—J˜—š™J˜šŸœžœFžœ˜VJšžœ ˜JšL™LJ˜—šŸœžœžœžœ˜6J˜—šŸœžœ˜Jšœ[˜[Jšœžœžœžœ˜@Jšžœ˜%Jš(™(J˜—šŸœžœ˜Jšœ>žœžœžœ˜_Jšžœ ˜'Jš%™%J˜—šŸ œžœ˜Jšœ<˜