TEditProfileImpl.mesa
Edited by Paxton on January 11, 1983 10:15 am
Edited by McGregor on October 27, 1982 4:42 pm
Doug Wyatt, February 11, 1984 12:46:57 pm PST
DIRECTORY
Rope USING [Equal, Fetch, ROPE, Size, Substr],
TEditInputOps USING [LoadAbbreviations, ReloadStyleName],
NodeStyleExtra USING [SetDefaultStyle, SetExtensionStyles],
TEditProfile USING [CategoryOfUser, DefaultMenuChoice, SelectionCaret],
TEditProfileExtras USING [],
UserProfile USING [Boolean, Line, ListOfTokens, Number, Token];
TEditProfileImpl: CEDAR PROGRAM
IMPORTS Rope, UserProfile, TEditInputOps, NodeStyleExtra
EXPORTS TEditProfile, TEditProfileExtras
= BEGIN
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 = BEGIN
wordPunctuation ← UserProfile.Boolean["SelectDelimitingSpaces", FALSE];
editTypeScripts ← UserProfile.Boolean["EditTypeScripts", TRUE];
openFirstLevelOnly ← UserProfile.Boolean["OpenFirstLevelOnly", FALSE];
scrollTopOffset ← UserProfile.Number["ScrollTopOffset", 2];
scrollBottomOffset ← UserProfile.Number["ScrollBottomOffset", 2];
ySelectFudge ← UserProfile.Number["YSelectFudge", 2];
showUnsavedDocumentsList ← UserProfile.Boolean["ShowUnsavedDocumentsList", TRUE];
unsavedDocumentCacheSize ← UserProfile.Number["UnsavedDocumentsCacheSize", 4];
SetUserCategory[UserProfile.Token["UserCategory", "Intermediate"]];
SetSelectionCaret[UserProfile.Token["SelectionCaret", "balance"]];
ReadExtensions[];
ReadMenuDefaults[];
NodeStyleExtra.SetDefaultStyle[UserProfile.Token["DefaultStyle", "Cedar"]];
NodeStyleExtra.SetExtensionStyles[UserProfile.ListOfTokens["ExtensionStyles"]];
tryVersionMap ← UserProfile.Boolean["Tioga.TryVersionMap", FALSE];
END;
ReadMenuDefaults: PROC = BEGIN
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["DefaultTiogaMenus", DefaultMenu, "places"];
END;
ReadExtensions: PROC = BEGIN
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["SourceFileExtensions", AddExt, "mesa tioga df cm config style"];
DoList["ImplFileExtensions", AddImplExt, "mesa"];
AddExt[""];
Always add the null extension since "Foo" is a different file than "Foo."
END;
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 = BEGIN
DoList["Styles", TEditInputOps.ReloadStyleName];
END;
PreloadAbbreviations: PROC = BEGIN
DoList["Abbreviations", TEditInputOps.LoadAbbreviations];
END;
GetToken: PUBLIC PROC [rope: ROPE, offset: INT ← 0, thruEnd: BOOLFALSE]
RETURNS [token: ROPE, newOffset: INT] = BEGIN
size: INT = Rope.Size[rope];
start: INT;
Sep: PROC [c: CHARACTER] RETURNS [BOOL] = INLINE BEGIN
RETURN[SELECT c FROM
' , ',, 11C, 15C, 0C => TRUE,
ENDCASE => FALSE];
END;
IF offset>=size THEN RETURN["", offset];
WHILE offset<size AND Sep[Rope.Fetch[rope, offset]] DO
offset ← offset+1;
ENDLOOP;
start ← offset;
DO IF offset>=size THEN EXIT;
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];
END;
DoList: PUBLIC PROC [key: ROPE, proc: PROC [ROPE], defaultKey: ROPENIL] = BEGIN
names: ROPE ← UserProfile.Line[key, defaultKey];
name: ROPE;
offset: INT ← 0;
DO
[name, offset] ← GetToken[names, offset];
IF Rope.Size[name]=0 THEN EXIT;
proc[name];
ENDLOOP;
END;
ReadProfile[];
PreloadStyles[];
PreloadAbbreviations[];
END.