SpellingLooksImpl.Mesa
Copyright Ó 1987, 1992 by Xerox Corporation. All rights reserved.
Spreitzer, February 27, 1985 9:03:31 pm PST
Tim Diebert: January 26, 1987 5:03:15 pm PST
DIRECTORY Rope, SpellingLooks, TextLooks, UserProfile;
SpellingLooksImpl: CEDAR PROGRAM IMPORTS Rope, UserProfile EXPORTS SpellingLooks = {
ROPE: TYPE = Rope.ROPE;
ROPEList: TYPE = LIST OF ROPE;
Looks: TYPE = TextLooks.Looks;
StyleNote: TYPE = RECORD [
style: ROPE,
unwordlich: Looks ¬ TextLooks.noLooks];
StyleNotes: TYPE = LIST OF StyleNote;
styleNotes: StyleNotes ¬ NIL;
globalVerboten: Looks ¬ TextLooks.noLooks;
Wordlich: PUBLIC PROC [style: ROPE, looks: Looks] RETURNS [wordlich: BOOL] = {
perThisStyle: StyleNotes;
IF Intersects[globalVerboten, looks] THEN RETURN [FALSE];
perThisStyle ¬ FindStyle[style];
IF perThisStyle # NIL AND Intersects[perThisStyle.first.unwordlich, looks] THEN RETURN [FALSE];
wordlich ¬ TRUE;
};
FindStyle: PROC [style: ROPE] RETURNS [styleNote: StyleNotes] = {
FOR styleNote ¬ styleNotes, styleNote.rest WHILE styleNote # NIL DO
IF Rope.Equal[styleNote.first.style, style, FALSE] THEN RETURN;
ENDLOOP;
};
Intersects: PROC [l1, l2: Looks] RETURNS [intersects: BOOL] = INLINE {
FOR l: TextLooks.Look IN TextLooks.Look DO
IF l1[l] AND l2[l] THEN RETURN [TRUE];
ENDLOOP;
intersects ¬ FALSE};
NoteProfile: PROC [reason: UserProfile.ProfileChangeReason] --UserProfile.ProfileChangedProc-- = {
profileNotes: ROPEList ¬ UserProfile.ListOfTokens[key: "SpellingTool.NonWordLooks", default: LIST ["cedar~dugm"]];
globalVerboten ¬ TextLooks.noLooks;
styleNotes ¬ NIL;
FOR rl: ROPEList ¬ profileNotes, rl.rest WHILE rl # NIL DO
spec: ROPE ¬ rl.first;
style, looks: ROPE;
sep: INT ¬ spec.Find["~"];
IF sep >= 0
THEN {style ¬ spec.Substr[len: sep]; looks ¬ spec.Substr[start: sep+1]}
ELSE {style ¬ NIL; looks ¬ spec};
IF style.Equal["*"] OR style.Length[] = 0
THEN globalVerboten ¬ ORLooks[globalVerboten, looks]
ELSE {
perThisStyle: StyleNotes ¬ FindStyle[style];
IF perThisStyle = NIL THEN perThisStyle ¬ styleNotes ¬ CONS[[style], styleNotes];
perThisStyle.first.unwordlich ¬ ORLooks[perThisStyle.first.unwordlich, looks];
};
ENDLOOP;
};
ORLooks: PROC [urLooks: Looks, inRope: ROPE] RETURNS [moreLooks: Looks] = {
moreLooks ¬ urLooks;
FOR i: INT IN [0 .. inRope.Length[]) DO
c: CHAR ¬ inRope.Fetch[i];
IF c IN TextLooks.Look THEN moreLooks[c] ¬ TRUE;
ENDLOOP;
};
UserProfile.CallWhenProfileChanges[NoteProfile];
}.