DIRECTORY Char USING [XCHAR], Rope USING [ROPE], Rosary USING [ROSARY, Item], Tioga USING [allLooks, CapChange, CharSet, Event, Looks, Node, noLooks, PropList]; TextEdit: CEDAR DEFINITIONS ~ BEGIN Node: TYPE ~ Tioga.Node; ROPE: TYPE ~ Rope.ROPE; ROSARY: TYPE ~ Rosary.ROSARY; XCHAR: TYPE ~ Char.XCHAR; CharSet: TYPE ~ Tioga.CharSet; Looks: TYPE ~ Tioga.Looks; noLooks: Looks ~ Tioga.noLooks; allLooks: Looks ~ Tioga.allLooks; PropList: TYPE ~ Tioga.PropList; MaxLen: INT ~ LAST[INT]; MaxNat: NAT ~ LAST[NAT]; Event: TYPE ~ Tioga.Event; Ref: TYPE ~ Node; -- for compatibility RefTextNode: TYPE ~ Node; -- for compatibility Offset: TYPE ~ INT; -- for compatibility FetchChar: PROC [text: Node, index: INT] RETURNS [XCHAR]; FetchLooks: PROC [text: Node, index: INT] RETURNS [Looks]; Size: PROC [text: Node] RETURNS [INT]; Item: TYPE ~ Rosary.Item; ItemFromLooks: PROC [Looks] RETURNS [Item]; LooksFromItem: PROC [Item] RETURNS [Looks]; ItemFromCharSet: PROC [CharSet] RETURNS [Item]; CharSetFromItem: PROC [Item] RETURNS [CharSet]; ItemFromPropList: PROC [PropList] RETURNS [Item]; PropListFromItem: PROC [Item] RETURNS [PropList]; FromRope: PROC [rope: ROPE] RETURNS [Node]; DocFromNode: PROC [child: Node] RETURNS [root: Node]; ChangeLooks: PROC [root: Node, text: Node, remove, add: Looks ¬ noLooks, start: INT ¬ 0, len: INT ¬ MaxLen, event: Event ¬ NIL]; GetCharProp: PROC [node: Node, index: INT, name: ATOM] RETURNS [value: REF]; PutCharProp: PROC [node: Node, index: INT, name: ATOM, value: REF, nChars: INT ¬ 1, event: Event ¬ NIL, root: Node ¬ NIL]; GetCharPropList: PROC [node: Node, index: INT] RETURNS [PropList]; PutCharPropList: PROC [node: Node, index: INT, propList: PropList, nChars: INT ¬ 1, event: Event ¬ NIL, root: Node ¬ NIL]; MapPropsAction: TYPE ~ PROC [name: ATOM, value: REF] RETURNS [quit: BOOL ¬ FALSE]; MapCharProps: PROC [node: Node, index: INT, action: MapPropsAction] RETURNS [quit: BOOL]; ModifyPropsAction: TYPE ~ PROC [value: REF, index: INT, nChars: INT] RETURNS [quit: BOOL ¬ FALSE, newValue: REF]; ModifyCharProps: PROC [node: Node, name: ATOM, index: INT ¬ 0, nChars: INT ¬ INT.LAST, action: ModifyPropsAction, event: Event ¬ NIL, root: Node ¬ NIL] RETURNS [quit: BOOL]; GetPropFromList: PROC [propList: PropList, key: ATOM] RETURNS [value: REF]; PutPropOnList: PROC [propList: PropList, key: ATOM, value: REF] RETURNS [new: PropList]; GetProp: PROC [node: Node, name: ATOM] RETURNS [value: REF]; PutProp: PROC [node: Node, name: ATOM, value: REF, event: Event ¬ NIL]; GetFormat: PROC [node: Node] RETURNS [ATOM]; PutFormat: PROC [node: Node, format: ATOM, event: Event ¬ NIL]; GetComment: PROC [node: Node] RETURNS [BOOL]; PutComment: PROC [node: Node, comment: BOOL, event: Event ¬ NIL]; ChangeStyle: PROC [node: Node, name: ROPE, event: Event ¬ NIL]; TwoSpanProc: TYPE ~ PROC [destRoot, sourceRoot: Node, dest: Node, destStart: INT ¬ 0, destLen: INT ¬ MaxLen, source: Node, sourceStart: INT ¬ 0, sourceLen: INT ¬ MaxLen, event: Event ¬ NIL] RETURNS [resultStart, resultLen: INT]; DestSpanProc: TYPE ~ PROC [destRoot, sourceRoot: Node, dest: Node, destLoc: INT ¬ 0, source: Node, start: INT ¬ 0, len: INT ¬ MaxLen, event: Event ¬ NIL] RETURNS [resultStart, resultLen: INT]; OneSpanProc: TYPE ~ PROC [root: Node, text: Node, start: INT ¬ 0, len: INT ¬ MaxLen, event: Event ¬ NIL]; TransposeProc: TYPE ~ PROC [alphaRoot, betaRoot: Node, alpha: Node, alphaStart: INT ¬ 0, alphaLen: INT ¬ MaxLen, beta: Node, betaStart: INT ¬ 0, betaLen: INT ¬ MaxLen, event: Event ¬ NIL ] RETURNS [alphaResultStart, alphaResultLen, betaResultStart, betaResultLen: INT]; ReplaceText: TwoSpanProc; DeleteText: OneSpanProc; CopyText: DestSpanProc; MoveText: DestSpanProc; MoveTextOnto: TwoSpanProc; TransposeText: TransposeProc; ReplaceByRope: PROC [root: Node, dest: Node, start: INT ¬ 0, len: INT ¬ MaxLen, rope: ROPE, looks: Looks ¬ noLooks, charSet: CharSet ¬ 0, charProps: PropList ¬ NIL, event: Event ¬ NIL] RETURNS [resultStart, resultLen: INT]; ReplaceByContents: PROC [root: Node, dest: Node, destStart, destLen: INT, sourceRope: ROPE, sourceRuns, sourceCharSets, sourceCharProps: ROSARY, sourceStart, sourceLen: INT, event: Event ¬ NIL] RETURNS [resultStart, resultLen: INT]; ModifyCharsAction: TYPE ~ PROC [set: CharSet, char: CHAR] RETURNS [CHAR]; ModifyChars: PROC [root: Node, dest: Node, start: INT ¬ 0, len: INT ¬ MaxLen, action: ModifyCharsAction, event: Event ¬ NIL]; CapChange: TYPE ~ Tioga.CapChange; -- {allCaps, allLower, initCaps, firstCap} ChangeCaps: PROC [root: Node, dest: Node, start: INT ¬ 0, len: INT ¬ MaxLen, how: CapChange ¬ allCaps, event: Event ¬ NIL]; GetNewlineDelimiter: PROC [root: Node] RETURNS [ROPE]; PutNewlineDelimiter: PROC [root: Node, val: ROPE, event: Event ¬ NIL]; END. T TextEdit.mesa Copyright Σ 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved. written by Bill Paxton, February 1981 last edit by Bill Paxton, April 23, 1982 6:14 am last edit by Russ Atkinson, July 22, 1983 9:51 am Michael Plass, April 1, 1985 4:05:55 pm PST Doug Wyatt, February 27, 1992 12:49 pm PST This package provides editing, filing, and various other operations for text nodes Overview: a text node contains a rope and runs of looks looks are represented by a vector of 32 bits each character in a text node has looks vector associated with it run encoding is used to reduce the storage needed to represent the looks see Tioga.mesa for more details about node structure and looks Text editing operations are provided to edit the contents of text nodes unlike ropes or runs of looks, text nodes are mutable i.e., the edit changes the node rather than returning a new node the looks related command is ChangeLooks the text related commands are ReplaceText, DeleteText, CopyText, MoveText, MoveTextOnto, TransposeText in addition there is a command taking a rope as source ReplaceByRope a command is available for changing capitalization ChangeCaps Persistent addresses in text of a node You can associate an address with a character location in a text node the address persists with the same character even if the text is edited the address is an arbitrary REF ANY supplied by the client program see NodeAddrs.Mesa for the persistent addressing operations Property lists Each node includes a property list of key-value pairs The keys are ATOMs and the values are arbitrary REF ANYs Clients can register routines to read/write properties to files and to copy property values when nodes are copied see NodeProps.Mesa for the property list operations Character property lists Each character may include a property list of key-value pairs The keys are ATOMs and the values are arbitrary REF ANYs Filing There are operations to read and write files containing text nodes The characters go at the front of the file, followed by 0's then the information about looks, etc. and finally a password and a pointer to the end of the text. Thus programs that simply want to look at the characters can read up to 0's operations to read/write nodes to files are found in PutGet.Mesa Edit notification procedures Client's can register procedures to be called before/after edits the client procedure is called with the node(s) changed by the edit and a record describing the details of the edit see EditNotify.Mesa for more information Tree editing nodes can have children there is a set of tree editing operations available see EditSpan.Mesa for details General operations fetches the indexed character returns the looks for the character at the given location Private details of node contents Operations to create a text node create a text node from an ordinary rope returns root node which has one child child typically created by FromRope or FromString Operations to add or delete looks first remove then add in the given range Character Properties Places the value on the character property lists of the chars in the specified range. Use value = NIL to remove a character property. Replaces the character property lists of the chars in the specified range. Used for traversing all the properites attached to a particular character. Used for traversing and altering the values of a character property over a range of characters; the action procedure is called for runs of properties, but adjacent runs are not necessarily merged. Equivalent to Prop.Get, Prop.Put; retained here only for compatibility. Node Properties appends style to end of node prefix Editing Operations for text NOTE: edit operations do not create or delete addrs, but they can change their locations within the text replace the dest text by a copy of the source text addrs that are in the replaced text move to destStart addrs that are after the replaced text are adjusted delete the specified range of text addrs that are in the deleted section move to start copy the specified text add length of inserted text to addrs that are beyond destLoc move [start..start+len) in source to destLoc in dest no-op if dest=source and destLoc IN [start..start+len] addrs that are in the moved text do one of the following: move with the text if dest = source, or move to start if dest # source move [start..start+len) onto [destStart..destStart+destLen) implemented by appropriate calls on MoveText and DeleteText transpose the alpha text and the beta text addrs treated same as in Move move with the text if alpha = beta, or move to respective starts if alpha # beta all chars in the rope get the specifed looks, charSet and charProps replace with the specified rope and rosaries Caps and Lowercase Note that this can only modify the 8-bit CHAR, not the CharSet. General purpose routine for modifying a run of characters. ChangeCaps uses this. Newline Delimiter Κ ”–(cedarcode) style•NewlineDelimiter ™codešœ ™ Kšœ ΟeœC™NKšœ%™%Kšœ0™0Kšœ1™1Kšœ+™+K™*—K˜šœR™Ršœ ™ Kšœ-™-Kšœ,™,KšœA™AKšœH™HKšœ>™>K˜šœ ™ šœ:™:Kšœ5™5Kšœ@™@—šœ™Kšœ ™ —šœ™KšœH™H—šœ6™6Kšœ ™ —šœ2™2K™ K˜——šœ&™&KšœE™EKšœG™GKšœC™CKšœ;™;K˜—šœ™Kšœ5™5Kšœ8™8šœ?™?Kšœ1™1—Kšœ3™3K˜—šœ™Kšœ=™=Kšœ8™8K˜—šœ™KšœB™Bšœ;™;šœ&™&Kšœ<™<——KšœK™KKšœ@™@K˜—šœ™Kšœ@™@šœC™CKšœ/™/—Kšœ(™(K˜—šœ ™ Kšœ™Kšœ3™3Kšœ™K˜———K˜šΟk ˜ Kšœžœžœ˜Kšœžœžœ˜Kšœžœžœ˜KšœžœG˜R—K˜šΟnœžœž œž˜#K˜Kšœžœ˜Kšžœžœžœ˜Kšžœžœ žœ˜Kšžœžœžœ˜Kšœ žœ˜Kšœžœ˜Kšœ˜Kšœ!˜!Kšœ žœ˜ Kšœžœžœžœ˜Kšœžœžœžœ˜Kšœžœ˜Kšœžœ Οc˜&Kšœ žœ  ˜.Kšœžœžœ ˜(—headšœ™š Ÿ œžœžœžœžœ˜9Kšœ™K˜—šŸ œžœžœžœ ˜:Kšœ9™9K˜—šŸœžœžœžœ˜&K˜——™ šœžœ˜K˜—šŸ œžœ žœ˜+K˜—šŸ œžœžœ ˜+K˜—šŸœžœ žœ˜/K˜—šŸœžœžœ ˜/K˜—šŸœžœ žœ˜1K˜—šŸœžœžœ ˜1K˜——šœ ™ šŸœžœžœžœ˜+Kšœ(™(K˜—šŸ œžœžœ˜5Kšœ%™%Kšœ1™1K˜——šœ!™!š Ÿ œžœ@žœ žœžœ˜Kšœ(™(K˜——šœ™š Ÿ œžœžœžœžœ žœ˜LK˜—šŸ œžœžœžœ žœ žœžœžœ˜{KšœU™UKšœ/™/K˜—šŸœžœžœžœ ˜BK˜—š Ÿœžœžœžœžœžœ˜{KšœJ™JK˜—šœžœžœžœ žœžœžœžœ˜RK˜—š Ÿ œžœžœžœžœ˜YK™KK˜—šœžœžœ žœ žœ žœžœžœžœ žœ˜rK˜—šŸœžœžœ žœžœžœžœ,žœžœžœžœ˜­K™ΔK˜—Kš Ÿœžœžœžœ žœ˜Kš Ÿ œžœžœ žœžœ˜XK™G——™š Ÿœžœžœžœ žœ˜