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
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
Character Properties
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];
Places the value on the character property lists of the chars in the specified range.
Use value = NIL to remove a character property.
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];
Replaces the character property lists of the chars in the specified range.
MapPropsAction:
TYPE ~
PROC [name:
ATOM, value:
REF]
RETURNS [quit:
BOOL ¬
FALSE];
MapCharProps:
PROC [node: Node, index:
INT, action: MapPropsAction]
RETURNS [quit:
BOOL];
Used for traversing all the properites attached to a particular character.
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];
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.
GetPropFromList: PROC [propList: PropList, key: ATOM] RETURNS [value: REF];
PutPropOnList:
PROC [propList: PropList, key:
ATOM, value:
REF]
RETURNS [new: PropList];
Equivalent to Prop.Get, Prop.Put; retained here only for compatibility.
Editing Operations for text
NOTE: edit operations do not create or delete addrs,
but they can change their locations within the text
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;
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
DeleteText: OneSpanProc;
delete the specified range of text
addrs that are in the deleted section move to start
CopyText: DestSpanProc;
copy the specified text
add length of inserted text to addrs that are beyond destLoc
MoveText: DestSpanProc;
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
MoveTextOnto: TwoSpanProc;
move [start..start+len) onto [destStart..destStart+destLen)
implemented by appropriate calls on MoveText and DeleteText
TransposeText: TransposeProc;
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
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];
all chars in the rope get the specifed looks, charSet and charProps
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];
replace with the specified rope and rosaries
Caps and Lowercase
ModifyCharsAction:
TYPE ~
PROC [set: CharSet, char:
CHAR]
RETURNS [
CHAR];
Note that this can only modify the 8-bit CHAR, not the CharSet.
ModifyChars:
PROC [root: Node, dest: Node, start:
INT ¬ 0, len:
INT ¬ MaxLen,
action: ModifyCharsAction, event: Event ¬
NIL];
General purpose routine for modifying a run of characters. ChangeCaps uses this.
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];