RopeEdit.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by Bill Paxton, February 1981
Paxton, August 24, 1982 9:53 am
Maxwell, January 5, 1983 11:51 am
Russ Atkinson, July 21, 1983 7:27 pm
Michael Plass, March 1, 1985 3:00:28 pm PST
This module provides editing operations for ropes.
DIRECTORY Rope USING [ROPE];
RopeEdit: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
MaxLen: INT = LAST[INT];
MaxNat: NAT = LAST[NAT];
**** Rope Editing Operations ****
Substr: PROC [base: ROPE, start: INT ← 0, len: INT ← MaxLen] RETURNS [ROPE];
... returns a subrope of the base
Concat: PROC [base, rest: ROPE, baseLen, restLen: INT ← MaxLen] RETURNS [ROPE];
... returns the concatenation of two ropes
Replace: PROC
[base: ROPE, start: INT ← 0, len: INT ← MaxLen, replace: ROPENIL, baseSize, repSize: INT ← MaxLen]
RETURNS [ROPE];
... returns a new rope with the given range replaced
Delete: PROC [base: ROPE, start, len, baseSize: INT] RETURNS [ROPE];
Insert: PROC [dest: ROPE, destLoc: INT ← 0, source: ROPE, destSize, sourceSize: INT ← MaxLen] RETURNS [ROPE];
Copy: PROC [dest: ROPE, destLoc: INT ← 0, source: ROPE, start: INT ← 0, len: INT ← MaxLen, destSize: INT ← MaxLen] RETURNS [ROPE];
ReplaceByChar: PROC [base: ROPE, char: CHAR, start: INT ← 0, len, baseSize: INT ← MaxLen] RETURNS [ROPE];
InsertChar: PROC [base: ROPE, char: CHAR, loc: INT ← 0, baseSize: INT ← MaxLen] RETURNS [ROPE];
AppendChar: PROC [base: ROPE, char: CHAR, baseSize: INT ← MaxLen] RETURNS [ROPE];
AppendByte: PROC [base: ROPE, x: [0..256), baseSize: INT ← MaxLen] RETURNS [ROPE]
= INLINE { RETURN [AppendChar[base, VAL[x], baseSize]] };
ReplaceByTEXT: PROC [base: ROPE, text: REF READONLY TEXT, textStart: NAT ← 0, textSize: NAT ← MaxNat, start: INT ← 0, len, baseSize: INT ← MaxLen] RETURNS [new: ROPE];
Depth: PROC [rope: ROPE] RETURNS [depth: INTEGER];
***** Character property information
CharProperty: TYPE = {white, alphaNumeric, punctuation, illegal};
CharPropertyTable: TYPE = PACKED ARRAY CHAR OF CharProperty;
charPropertyTable: REF READONLY CharPropertyTable;
BlankChar: PROC [char: CHAR] RETURNS [BOOLEAN]
Returns TRUE iff char has property=white.
= INLINE { RETURN [charPropertyTable[char] = white] };
AlphaNumericChar: PROC [char: CHAR] RETURNS [BOOLEAN]
Returns TRUE iff char has property=alphaNumeric.
= INLINE { RETURN [charPropertyTable[char] = alphaNumeric] };
PunctuationChar: PROC [char: CHAR] RETURNS [BOOLEAN]
Returns TRUE iff char has property=punctuation.
= INLINE { RETURN [charPropertyTable[char] = punctuation] };
IllegalChar: PROC [char: CHAR] RETURNS [BOOLEAN]
Returns TRUE iff char has property=illegal.
= INLINE { RETURN [charPropertyTable[char] = illegal] };
TestCharProp: PROC [char: CHAR, property: CharProperty] RETURNS [BOOLEAN]
Returns TRUE iff char has property.
= INLINE { RETURN [charPropertyTable[char] = property] };
GetCharProp: PROC [char: CHAR] RETURNS[property: CharProperty]
Returns property {white, alphaNumeric, punctuation, illegal} for char.
= INLINE { RETURN [charPropertyTable[char]] };
UpperCase: PROC [c: CHAR] RETURNS [CHAR]
= INLINE { RETURN [IF c IN ['a..'z] THEN c-40B ELSE c] };
LowerCase: PROC [c: CHAR] RETURNS [CHAR]
= INLINE { RETURN [IF c IN ['A..'Z] THEN c+40B ELSE c] };
END.