-- EditNotify.mesa -- written by Bill Paxton, March 1981 -- last edit by Bill Paxton, March 18, 1981 4:48 PM DIRECTORY TextNode USING [Ref, RefTextNode, StyleName, TypeName], TextLooks USING [Looks]; EditNotify: DEFINITIONS = BEGIN OPEN nodeI:TextNode, looksI:TextLooks; Ref: TYPE = nodeI.Ref; RefTextNode: TYPE = nodeI.RefTextNode; Looks: TYPE = looksI.Looks; Char: TYPE = CHARACTER; Card: TYPE = LONG CARDINAL; -- **** Notification Operations **** EditNotifyProc: TYPE = PROC [t1, t2: Ref, change: REF READONLY Change, time: When ← after]; -- t1 and t2 are text nodes changed by the edit -- t2 will be NIL if only one node is changed When: TYPE = {before, after}; -- indicates whether before or after the change has taken place AddNotifyProc: PROC [proc: EditNotifyProc, time: When ← after]; -- add new proc to list of notification procedures -- call such procs before/after any node edit -- use time=before for applications such as saving text for undo -- use time=after for applications such as reformat & redisplay RemoveNotifyProc: PROC [proc: EditNotifyProc, time: When ← after]; -- remove proc from list of notification procedures CallNotifyProcs: PROC [t1, t2: Ref, change: REF READONLY Change, time: When ← after]; -- call notification procedures -- some clients may want to use this for their own applications -- standard edit routines do this automatically Change: TYPE = RECORD [SELECT kind:OfChange FROM ChangingLooks => [ text: RefTextNode, removeLooks, addLooks: Looks, startLoc, changeLen: Card], -- changeLen characters in text starting at startLoc get changed looks -- first remove the removeLooks, then add the addLooks ReplacingText => [ dest: RefTextNode, destStart, destLen: Card, source: RefTextNode, sourceStart, sourceLen: Card], -- replace destLen characters in dest starting at destStart -- by sourceLen characters from source starting at sourceStart -- this covers copying and deleting also -- destLen=0 for copying -- sourceLen=0 for deleting MovingText => [ dest: RefTextNode, destLoc: Card, source: RefTextNode, sourceStart, sourceLen: Card], -- delete sourceLen characters from source starting at sourceStart -- insert them in dest at destLoc TransposingText => [ alpha: RefTextNode, alphaStart, alphaLen: Card, beta: RefTextNode, betaStart, betaLen: Card], -- exchange alphaLen characters of alpha starting at alphaStart -- with betaLen characters of beta starting at betaStart InsertingText => [ -- for InsertChar, InsertString, and InsertRope dest: RefTextNode, destLoc, insertLen: Card, inherit: BOOLEAN, looks: Looks], -- insert insertLen characters at destLoc in dest -- if inherit is true, characters gets looks in following manner: -- if dest length is 0, then gets looks from argument list, else -- if location > 0, then looks and list of previous char, -- else looks and list of first char in dest ChangingType => [ node: Ref, newStyle, newType: BOOLEAN, styleName: nodeI.StyleName, typeName: nodeI.TypeName], -- change style and/or type of node ReplacingNodes => [ destParent: Ref, destStart, destLen: Card, sourceParent: Ref, sourceStart, sourceLen: Card], -- replace destLen children in destParent starting at destStart -- by sourceLen children from sourceParent starting at sourceStart -- this covers copying and deleting nodes also MovingNodes => [ destParent: Ref, destLoc: Card, sourceParent: Ref, sourceStart, sourceLen: Card], -- delete sourceLen children from sourceParent starting at sourceStart -- insert them in destParent at destLoc -- e.g., destLoc=0 to move to start of dest -- and destLoc=NumChildren[dest] to move to end TransposingNodes => [ alphaParent: Ref, alphaStart, alphaLen: Card, betaParent: Ref, betaStart, betaLen: Card], -- exchange alphaLen children of alphaParent starting with alphaStart -- with betaLen children of betaParent starting with betaStart InsertingNode => [ destParent: Ref, destLoc: Card], -- insert a new node as destLoc'th child of destParent ENDCASE]; OfChange: TYPE = { ChangingLooks, ReplacingText, MovingText, TransposingText, InsertingText, ChangingType, ReplacingNodes, MovingNodes, TransposingNodes, InsertingNode}; END.