<> <> <> <> DIRECTORY Ascii, Atom, CD, CDEnvironment, CDMenus, CDMenusExtras, Commander, FS, IO, Rope, TEditProfile USING [DoList]; CDMakeMenusImpl: CEDAR MONITOR IMPORTS Atom, CDEnvironment, CDMenus, CDMenusExtras, Commander, FS, IO, Rope, TEditProfile = BEGIN InitMenus: PROC [] = { MakeMenu: PROC [text: Rope.ROPE, nameAndCommand: ATOM, doc: Rope.ROPE_NIL] = { [] _ CDMenusExtras.CreateMenuExtra[text, nameAndCommand, doc]; CDMenus.ImplementCommandToCallMenu[nameAndCommand, nameAndCommand]; }; MakeMenu["Global menu", $GlobalMenu, "all entries are menus again"]; MakeMenu["Global on rects", $RectGlobalMenu, "all entries are menus again"]; MakeMenu["Additional Programs", $ProgramMenu]; MakeMenu["Programs on Rects", $RectProgramMenu]; MakeMenu["Other Programs", $OtherProgramMenu]; MakeMenu["Cell (s)", $CellMenu]; MakeMenu["Input / Output", $IOMenu]; MakeMenu["Directory options", $DirectoryMenu]; MakeMenu["Viewer options", $ViewerMenu]; MakeMenu["Special commands", $SpecialMenu]; MakeMenu["Special on rects", $RectSpecialMenu]; MakeMenu["Hard copy", $HardCopyMenu]; MakeMenu["Display options", $DisplayMenu]; MakeMenu["Import and remote", $ImportMenu]; MakeMenu["Generator options", $GeneratorMenu]; MakeMenu["Text & Properties", $TextPropertyMenu]; MakeMenu["Polygons & Splines", $PolygonMenu]; MakeMenu["Operators", $OperatorMenu, "Operations on the current selection"]; MakeMenu["Operators on rects", $RectOperatorMenu]; MakeMenu["DRC and friends", $DRCMenu, "Design rule checks and extractions"]; MakeMenu["DRC ... on rects", $RectDRCMenu]; MakeMenu["Selections", $SelectionMenu]; MakeMenu["Selections on rects", $RectSelectionMenu]; MakeMenu["Draw", $RectDrawMenu, "draw certain types of objects"]; }; SkipLeading: PROC [line: Rope.ROPE, start: INT_0] RETURNS [Rope.ROPE] = { <> <> leng: INT _ Rope.Length[line]; WHILE start start _ start+1; '/ => {start _ start+1; EXIT}; ENDCASE => EXIT; ENDLOOP; RETURN [ Rope.Substr[line, start] ]; }; SkipTrailing: PROC [line: Rope.ROPE, last: INT_-1] RETURNS [Rope.ROPE] = { <> <> IF last<0 THEN last _ Rope.Length[line]-1; WHILE last>0 DO SELECT Rope.Fetch[line, last] FROM Ascii.SP, Ascii.TAB => last _ last-1; '/ => {last _ last-1; EXIT}; ENDCASE => EXIT; ENDLOOP; RETURN [ Rope.Substr[line, 0, last+1] ]; }; SplitText: PROC [line: Rope.ROPE] RETURNS [first, rest: Rope.ROPE_NIL] = { <> <> <> <> <> nextPos: INT _ 0; leng: INT _ Rope.Length[line]; WHILE nextPos> <> <> <<"/" adjacent to a | are ignored>> <> menuR, keyR, textR, restR, docR: Rope.ROPE _ NIL; key: ATOM_NIL; line _ SkipLeading[line]; IF Rope.IsEmpty[line] THEN RETURN; [menuR, restR] _ SplitText[line]; IF Rope.IsEmpty[menuR] OR Rope.Fetch[menuR, 0]='- THEN RETURN; [keyR, textR] _ SplitText[restR]; IF Rope.IsEmpty[keyR] THEN RETURN; IF ~Rope.IsEmpty[textR] THEN [textR, docR] _ SplitText[textR]; IF ~Rope.Equal[keyR, "NIL"] THEN key _ Atom.MakeAtom[keyR]; CDMenusExtras.CreateEntryExtra[Atom.MakeAtom[menuR], textR, key, docR]; }; InstallOneMenuFile: PROC [fileName: Rope.ROPE] = { file: IO.STREAM; line: Rope.ROPE; file _ FS.StreamOpen[fileName ! FS.Error => GOTO finish]; DO line _ IO.GetLineRope[file ! IO.EndOfStream => GOTO finish]; IF ~Rope.IsEmpty[line] THEN MakeMenuLine[line]; ENDLOOP; EXITS finish => NULL; }; ReInstallMenus: PROC = { <<--Menu entries are installed in opposite order as found in user profile>> <<--to allow client installations overwrite standard installation. >> <<--Menu entries are not removed if not explicitely requested to allow permanent>> <<--installation of menu entries by programs.>> list: LIST OF Rope.ROPE _ NIL; Each: PROC [r: Rope.ROPE] = { IF Rope.Equal[r, "Default"] THEN r _ CDEnvironment.MakeName["ChipNDale", "MenuTable", CDEnvironment.GetWorkingDirectory[NIL]]; list _ CONS[r, list]; }; TEditProfile.DoList["ChipNDale.MenuTable", Each, "Default"]; WHILE list#NIL DO InstallOneMenuFile[list.first]; list _ list.rest ENDLOOP }; ReInstallMenusCommand: Commander.CommandProc = { ReInstallMenus[]; }; InitMenus[]; Commander.Register["///Commands/CDReInstallMenus", ReInstallMenusCommand, "re-read the ChipNDale menus"]; ReInstallMenus[]; END.