-- TEditProfileImpl.mesa; Edited by Paxton on January 11, 1983 10:15 am
Edited by McGregor on October 27, 1982 4:42 pm
DIRECTORY
Rope USING [Concat, Equal, Fetch, ROPE, Size, Substr],
TEditInputOps USING [LoadAbbreviations, ReloadStyleName],
NodeStyleExtra USING [SetDefaultStyle, SetExtensionStyles],
TEditProfile,
UserProfile USING [Boolean, Line, ListOfTokens, Number, Token];
TEditProfileImpl: CEDAR PROGRAM
IMPORTS Rope, UserProfile, TEditInputOps, NodeStyleExtra
EXPORTS TEditProfile =
BEGIN OPEN UserProfile, TEditProfile;
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.ROPE; -- the extensions all start with "."
ReadProfile:
PUBLIC
PROC =
BEGIN
wordPunctuation ← Boolean["SelectDelimitingSpaces", FALSE];
editTypeScripts ← Boolean["EditTypeScripts", TRUE];
openFirstLevelOnly ← Boolean["OpenFirstLevelOnly", FALSE];
scrollTopOffset ← Number["ScrollTopOffset", 2];
scrollBottomOffset ← Number["ScrollBottomOffset", 2];
ySelectFudge ← Number["YSelectFudge", 2];
showUnsavedDocumentsList ← Boolean["ShowUnsavedDocumentsList", TRUE];
unsavedDocumentCacheSize ← Number["UnsavedDocumentsCacheSize", 4];
SetUserCategory[Token["UserCategory", "Intermediate"]];
SetSelectionCaret[Token["SelectionCaret", "balance"]];
ReadExtensions[];
ReadMenuDefaults[];
NodeStyleExtra.SetDefaultStyle[Token["DefaultStyle", "Cedar"]];
NodeStyleExtra.SetExtensionStyles[ListOfTokens["ExtensionStyles"]];
END;
ReadMenuDefaults:
PROC =
BEGIN
num: INTEGER ← 1;
DefaultMenu:
PROC [rope: 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
AddExt:
PROC [ext: Rope.
ROPE] = {
IF Rope.Fetch[ext, 0] # '. THEN ext ← Rope.Concat[".", ext];
IF sourceExtensions=NIL THEN sourceExtensions ← LIST[ext]
ELSE
FOR lst:
LIST
OF Rope.
ROPE ← sourceExtensions, lst.rest
DO
IF lst.rest = NIL THEN { lst.rest ← LIST[ext]; RETURN };
ENDLOOP };
AddImplExt:
PROC [ext: Rope.
ROPE] = {
IF Rope.Fetch[ext, 0] # '. THEN ext ← Rope.Concat[".", ext];
IF implExtensions=NIL THEN implExtensions ← LIST[ext]
ELSE
FOR lst:
LIST
OF Rope.
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"];
sourceExtensions ←
CONS[".", sourceExtensions];
Always add the null extension since "Foo" is a different file than "Foo."
END;
SetSelectionCaret:
PROC [rope: Rope.
ROPE] = {
selectionCaret ←
SELECT
TRUE
FROM
Rope.Equal[rope,"before",FALSE] => before,
Rope.Equal[rope,"after",FALSE] => after,
ENDCASE => balance };
SetUserCategory:
PROC [rope: 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.
ROPE, offset:
INT ← 0, thruEnd:
BOOL ←
FALSE]
RETURNS [token: Rope.
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.
ROPE, proc:
PROC [Rope.
ROPE], defaultKey: Rope.
ROPE ←
NIL] =
BEGIN
names: Rope.ROPE ← Line[key, defaultKey];
name: Rope.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.