TEditProfileImpl.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Doug Wyatt, March 3, 1985 12:42:22 pm PST
Michael Plass, March 29, 1985 3:35:06 pm PST
Russ Atkinson (RRA) January 22, 1986 11:48:09 pm PST
DIRECTORY
Rope USING [Concat, Equal, Fetch, ROPE, Size, SkipTo, Substr],
TEditInputOps USING [LoadAbbreviations, ReloadStyleName],
NodeStyleOps USING [SetDefaultStyle, SetExtensionStyles],
TEditProfile USING [CategoryOfUser, DefaultMenuChoice, SelectionCaret],
UserProfile USING [Boolean, Line, ListOfTokens, Number, Token];
TEditProfileImpl:
CEDAR PROGRAM
IMPORTS Rope, UserProfile, TEditInputOps, NodeStyleOps
EXPORTS TEditProfile
= {
ROPE: TYPE = Rope.ROPE;
CategoryOfUser: TYPE = TEditProfile.CategoryOfUser;
DefaultMenuChoice: TYPE = TEditProfile.DefaultMenuChoice;
SelectionCaret: TYPE = TEditProfile.SelectionCaret;
menu1, menu2, menu3: PUBLIC DefaultMenuChoice ← none;
openFirstLevelOnly: PUBLIC BOOL;
wordPunctuation: PUBLIC BOOL;
editTypeScripts: PUBLIC BOOL;
scrollTopOffset: PUBLIC INTEGER ;
scrollBottomOffset: PUBLIC INTEGER ;
ySelectFudge: PUBLIC INTEGER ;
showUnsavedDocumentsList: PUBLIC BOOL;
unsavedDocumentCacheSize: PUBLIC INTEGER ;
selectionCaret: PUBLIC SelectionCaret;
userCategory: PUBLIC CategoryOfUser;
sourceExtensions, implExtensions: PUBLIC LIST OF ROPE; -- without leading "."
tryVersionMap: PUBLIC BOOL;
ReadProfile:
PUBLIC
PROC = {
wordPunctuation ← UserProfile.Boolean["Tioga.SelectDelimitingSpaces", FALSE];
editTypeScripts ← UserProfile.Boolean["Tioga.EditTypeScripts", TRUE];
openFirstLevelOnly ← UserProfile.Boolean["Tioga.OpenFirstLevelOnly", FALSE];
scrollTopOffset ← UserProfile.Number["Tioga.ScrollTopOffset", 2];
scrollBottomOffset ← UserProfile.Number["Tioga.ScrollBottomOffset", 2];
ySelectFudge ← UserProfile.Number["Tioga.YSelectFudge", 2];
showUnsavedDocumentsList ← UserProfile.Boolean["Tioga.ShowUnsavedDocumentsList", TRUE];
unsavedDocumentCacheSize ← UserProfile.Number["Tioga.UnsavedDocumentsCacheSize", 4];
SetUserCategory[UserProfile.Token["Tioga.UserCategory", "Advanced"]];
SetSelectionCaret[UserProfile.Token["Tioga.SelectionCaret", "balance"]];
ReadExtensions[];
ReadMenuDefaults[];
NodeStyleOps.SetDefaultStyle[UserProfile.Token["Tioga.DefaultStyle", "Cedar"]];
NodeStyleOps.SetExtensionStyles[UserProfile.ListOfTokens["Tioga.ExtensionStyles"]];
tryVersionMap ← UserProfile.Boolean["Tioga.TryVersionMap", TRUE];
};
ReadMenuDefaults:
PROC = {
num: INTEGER ← 1;
DefaultMenu:
PROC [rope:
ROPE] = {
which: DefaultMenuChoice ←
SELECT
TRUE
FROM
Rope.Equal[rope,"Places",FALSE] => places,
Rope.Equal[rope,"Levels",FALSE] => levels,
ENDCASE => none;
IF which=none THEN RETURN;
SELECT num
FROM
1 => menu1 ← which;
2 => menu2 ← which;
3 => menu3 ← which;
ENDCASE => RETURN;
num ← num+1 };
menu1 ← menu2 ← menu3 ← none;
DoList["Tioga.DefaultTiogaMenus", DefaultMenu, "places"];
};
ReadExtensions:
PROC = {
RemoveLeadingDot:
PROC[ext:
ROPE]
RETURNS[
ROPE] = {
RETURN[IF ext.Size[]>0 AND ext.Fetch[0]='. THEN ext.Substr[start: 1] ELSE ext];
};
AddExt:
PROC [ext:
ROPE] = {
ext ← RemoveLeadingDot[ext];
IF sourceExtensions=NIL THEN sourceExtensions ← LIST[ext]
ELSE
FOR lst:
LIST
OF
ROPE ← sourceExtensions, lst.rest
DO
IF lst.rest = NIL THEN { lst.rest ← LIST[ext]; RETURN };
ENDLOOP;
};
AddImplExt:
PROC [ext:
ROPE] = {
ext ← RemoveLeadingDot[ext];
IF implExtensions=NIL THEN implExtensions ← LIST[ext]
ELSE
FOR lst:
LIST
OF
ROPE ← implExtensions, lst.rest
DO
IF lst.rest = NIL THEN { lst.rest ← LIST[ext]; RETURN };
ENDLOOP;
};
sourceExtensions ← implExtensions ← NIL;
DoList["Tioga.SourceFileExtensions", AddExt, "mesa tioga df cm config style"];
DoList["Tioga.ImplFileExtensions", AddImplExt, "mesa"];
AddExt[""];
Always add the null extension since "Foo" is a different file than "Foo."
};
SetSelectionCaret:
PROC [rope:
ROPE] = {
selectionCaret ←
SELECT
TRUE
FROM
Rope.Equal[rope,"before",FALSE] => before,
Rope.Equal[rope,"after",FALSE] => after,
ENDCASE => balance;
SetUserCategory:
PROC [rope:
ROPE] = {
userCategory ←
SELECT
TRUE
FROM
Rope.Equal[rope,"Expert",FALSE] => expert,
Rope.Equal[rope,"Advanced",FALSE] => advanced,
Rope.Equal[rope,"Intermediate",FALSE] => intermediate,
Rope.Equal[rope,"Beginner",FALSE] => beginner,
ENDCASE => intermediate;
PreloadStyles:
PROC = {
DoList["Tioga.Styles", TEditInputOps.ReloadStyleName];
};
PreloadAbbreviations:
PROC = {
DoList["Tioga.Abbreviations", TEditInputOps.LoadAbbreviations];
};
GetToken:
PUBLIC
PROC [rope:
ROPE, offset:
INT ← 0, thruEnd:
BOOL ←
FALSE]
RETURNS [token:
ROPE, newOffset:
INT] = {
size: INT = Rope.Size[rope];
start: INT;
Sep:
PROC [c:
CHAR]
RETURNS [
BOOL] = {
RETURN[
SELECT c
FROM
' , ',, 11C, 15C, 0C => TRUE,
ENDCASE => FALSE];
};
IF offset>=size THEN RETURN["", offset];
WHILE offset<size
AND Sep[Rope.Fetch[rope, offset]]
DO
offset ← offset+1;
ENDLOOP;
start ← offset;
WHILE offset < size
DO
IF Sep[Rope.Fetch[rope, offset]] THEN EXIT;
offset ← offset+1;
ENDLOOP;
RETURN[Rope.Substr[rope, start, IF thruEnd THEN size ELSE offset-start], offset];
};
DoList:
PUBLIC
PROC [key:
ROPE, proc:
PROC [
ROPE], defaultKey:
ROPE ←
NIL] = {
names: ROPE ← defaultKey;
offset: INT ← 0;
sKey: INT ← Rope.Size[key];
IF sKey # 0
THEN {
IF sKey = Rope.SkipTo[key, 0, "."] THEN key ← Rope.Concat["Tioga.", key];
names ← UserProfile.Line[key, defaultKey];
};
DO
name: ROPE;
[name, offset] ← GetToken[names, offset];
IF Rope.Size[name] = 0 THEN EXIT;
proc[name];
ENDLOOP;
};
ReadProfile[];
PreloadStyles[];
PreloadAbbreviations[];
}.