TextEdit.mesa
Copyright Ó 1985, 1986, 1988 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 17, 1988 4:18:07 pm PST
=
BEGIN
Node: TYPE = TextNode.Node;
ROPE: TYPE = Rope.ROPE;
XChar: TYPE ~ ImagerFont.XChar; -- [set: BYTE, code: BYTE]
CharSet:
TYPE ~
BYTE;
Note: Character sets are implemented using a ROSARY (an immutable sequence of REFs; see Rosary.mesa). The values in this ROSARY are of type REF CharSet.
Looks: TYPE = TextLooks.Looks;
noLooks: Looks = TextLooks.noLooks;
allLooks: Looks = TextLooks.allLooks;
MaxLen: INT = LAST[INT];
MaxNat: NAT = LAST[NAT];
Event: TYPE = UndoEvent.Event;
General operations
Size:
PROC [node: Node]
RETURNS [
INT];
FetchChar:
PROC [node: Node, index:
INT]
RETURNS [XChar];
fetches the indexed 16-bit character
FetchLooks:
PROC [node: Node, index:
INT]
RETURNS [Looks];
returns the looks for the character at the given location
FetchCharPropList:
PROC [node: Node, index:
INT]
RETURNS [PropList];
returns the property list for the character at the given location
CharSetRun: TYPE ~ RECORD [charSet: CharSet, start, end: INT];
FetchCharSetRun: PROC [node: Node, index: INT] RETURNS [CharSetRun];
LooksRun: TYPE ~ RECORD [looks: Looks, start, end: INT];
FetchLooksRun: PROC [node: Node, index: INT] RETURNS [LooksRun];
PropListRun: TYPE ~ RECORD [propList: PropList, start, end: INT];
FetchCharPropListRun: PROC [node: Node, index: INT] RETURNS [PropListRun];
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.
MapCharProps:
PROC [node: Node, index:
INT, action: MapPropsAction]
RETURNS [quit:
BOOL];
Used for traversing all the properites attached to a particular character.
MapPropsAction:
TYPE ~
PROC [name:
ATOM, value:
REF]
RETURNS [quit:
BOOL ←
FALSE];
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 ofer a range of characters; the action procedure is called for runs of properties, but adjacent runs are not necessarily merged.
ModifyPropsAction:
TYPE ~
PROC [value:
REF, index:
INT, nChars:
INT]
RETURNS [quit:
BOOL ←
FALSE, newValue:
REF];
PropList:
TYPE ~ Atom.PropList;
This property list mechanism regards a PropList as an immutable value.
PutCharPropList:
PROC [node: Node, index:
INT, propList: PropList, nChars:
INT ← 1, event: Event ←
NIL, root: Node ←
NIL];
GetPropFromList: PROC [propList: PropList, key: ATOM] RETURNS [value: REF];
PutPropOnList: PROC [propList: PropList, key: ATOM, value: REF] RETURNS [new: PropList];
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,
node: 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
ReplaceByChar:
PROC [root: Node, dest: Node, char:
CHAR,
start:
INT ← 0, len:
INT ← MaxLen,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
replacement characters don't get any character properties
if inherit is false, char gets specifed looks
if inherit is true, char gets looks in following manner:
if dest length is 0, then gets looks from argument list, else
if start > 0, then gets looks from previous char,
else gets looks from char following replacement
ReplaceByString:
PROC [root: Node, dest: Node, string:
REF
READONLY
TEXT,
stringStart:
NAT ← 0, stringNum:
NAT ← MaxNat,
start:
INT ← 0, len:
INT ← MaxLen,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
ReplaceByRope:
PROC [root: Node, dest: Node, rope:
ROPE,
start:
INT ← 0, len:
INT ← MaxLen,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
InsertChar:
PROC [root: Node, dest: Node, char:
CHAR, destLoc:
INT ← 0,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
AppendChar:
PROC [root: Node, dest: Node, char:
CHAR,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
InsertString:
PROC [root: Node, dest: Node, string:
REF
READONLY
TEXT,
stringStart:
NAT ← 0, stringNum:
NAT ← MaxNat, destLoc:
INT ← 0,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
AppendString:
PROC [root: Node, dest: Node, string:
REF
READONLY
TEXT,
stringStart:
NAT ← 0, stringNum:
NAT ← MaxNat,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
InsertRope:
PROC [root: Node, dest: Node, rope:
ROPE, destLoc:
INT ← 0,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];
AppendRope:
PROC [root: Node, dest: Node, rope:
ROPE,
inherit:
BOOL ←
TRUE, looks: Looks ← noLooks,
charSet: CharSet ← 0,
event: Event ←
NIL]
RETURNS [resultStart, resultLen:
INT];