DIRECTORY Ascii, Atom, CD, CDEnvironment, CDEnvironmentExtras, CDPopUpMenus, CDSequencer, Commander, FS, IO, PopUpMenus, RefTab, Rope, SymTab, TEditProfile USING [DoList], TerminalIO; CDPopUpMenusImpl: CEDAR PROGRAM IMPORTS Atom, CDEnvironment, CDEnvironmentExtras, CDSequencer, Commander, FS, IO, PopUpMenus, RefTab, Rope, SymTab, TEditProfile, TerminalIO EXPORTS CDPopUpMenus SHARES PopUpMenus = BEGIN UnknownMenu: PUBLIC SIGNAL = CODE; menuTab: RefTab.Ref ~ RefTab.Create[]; garbageMenu: PopUpMenus.Menu ~ MakeMenu[$GarbageMenu, "garbage menu", "used if command is registered with unknown menu"]; GetMenu: PUBLIC PROC [key: REF, check: BOOL_FALSE] RETURNS [PopUpMenus.Menu] = { WITH key SELECT FROM pm: PopUpMenus.Menu => RETURN [pm]; ENDCASE => NULL; WITH RefTab.Fetch[menuTab, key].val SELECT FROM pm: PopUpMenus.Menu => RETURN [pm]; ENDCASE => NULL; IF check THEN SIGNAL UnknownMenu; RETURN [garbageMenu]; }; MakeMenu: PUBLIC PROC [key: ATOM, header, doc: Rope.ROPE, tech: CD.Technology_NIL] RETURNS [menu: PopUpMenus.Menu] = { IF key=NIL THEN RETURN [garbageMenu]; WITH RefTab.Fetch[menuTab, key].val SELECT FROM pm: PopUpMenus.Menu => NULL; --sorry we can not change its header... ENDCASE => { menu _ PopUpMenus.Create[header, doc]; [] _ RefTab.Store[menuTab, key, menu]; }; CDSequencer.ImplementCommand[key, CallMenuComm, tech, dontQueue]; }; CallMenuComm: PROC [comm: CDSequencer.Command] = { menu: PopUpMenus.Menu _ GetMenu[comm.key]; WITH PopUpMenus.Call[menu, comm] SELECT FROM a: ATOM => CDSequencer.ExecuteCommand[comm: comm, key: a]; ENDCASE => NULL; }; InitMenus: PROC [] = { [] _ MakeMenu[$GlobalMenu, "Global menu", "all entries are menus again"]; [] _ MakeMenu[$RectGlobalMenu, "Global on rects", "all entries are menus again"]; [] _ MakeMenu[$ProgramMenu, "Additional Programs", "additional programs"]; [] _ MakeMenu[$RectProgramMenu, "Programs on Rects", "additional programs using coordinates"]; [] _ MakeMenu[$OtherProgramMenu, "Other Programs", "additional programs"]; [] _ MakeMenu[$CellMenu, "Cell (s)", ""]; [] _ MakeMenu[$IOMenu, "Input / Output", ""]; [] _ MakeMenu[$DirectoryMenu, "Directory options", ""]; [] _ MakeMenu[$ViewerMenu, "Viewer options", ""]; [] _ MakeMenu[$DrawModeMenu, "Draw Modes", "set drawing modes for the viewer"]; [] _ MakeMenu[$SpecialMenu, "Special commands", ""]; [] _ MakeMenu[$RectSpecialMenu, "Special on rects", ""]; [] _ MakeMenu[$DisplayMenu, "Display options", ""]; [] _ MakeMenu[$ImportMenu, "Import and remote", ""]; [] _ MakeMenu[$GeneratorMenu, "Generator options", ""]; [] _ MakeMenu[$TextPropertyMenu, "Text & Properties", ""]; [] _ MakeMenu[$PolygonMenu, "Polygons & Splines", ""]; [] _ MakeMenu[$OperatorMenu, "Operators", "Operations on the current selection"]; [] _ MakeMenu[$RectOperatorMenu, "Operators on rects", ""]; [] _ MakeMenu[$SelectionMenu, "Selections", ""]; [] _ MakeMenu[$RectSelectionMenu, "Selections on rects", ""]; [] _ MakeMenu[$RectDrawMenu, "Draw", "draw certain types of objects"]; [] _ MakeMenu[$CommentLayerMenu, "set current layer comment", "select color or discard"]; }; 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 RETURN [TRUE]; ENDCASE => RETURN [FALSE]; }; ReInstallMenus: PROC = { doneFiles: SymTab.Ref _ SymTab.Create[case: FALSE]; mustFiles: SymTab.Ref _ SymTab.Create[]; EachProfileEntry: PROC [r: Rope.ROPE] = { IF Rope.Equal[r, "Default"] THEN r _ CDEnvironment.MakeName["ChipNDale", "MenuTable", CDEnvironment.GetWorkingDirectory[NIL]]; [] _ SymTab.Insert[mustFiles, r, $x] }; EachSymTabEntry: SymTab.EachPairAction = {quit_FALSE; HandleMenuFile[key, doneFiles]; }; TEditProfile.DoList[Rope.Concat[CDEnvironmentExtras.prefix, "MenuTable"], EachProfileEntry, "Default"]; [] _ SymTab.Pairs[mustFiles, EachSymTabEntry] }; ReInstallMenusCommand: Commander.CommandProc = { ReInstallMenus[]; }; InitMenus[]; Commander.Register["///Commands/CDReInstallMenus", ReInstallMenusCommand, "re-read the ChipNDale menus"]; ReInstallMenus[]; END. bCDPopUpMenusImpl.mesa (a ChipNDale module) Copyright c 1986 by Xerox Corporation. All rights reserved. Created by: Christian Jacobi, September 18, 1984 3:24:53 pm PDT Last edited by: Christian Jacobi, December 18, 1986 1:41:38 pm PST --==================================== removes leading spaces spaces and tabs ignores one leading ! removes trailing spaces spaces and tabs ignores one trailing / Split line according to the following syntax first | rest represent | as || removes spaces and tabs adjacent to the | ignores one ! adjacent the | --doneFiles: SymTab of files already handled; stops infinite recursion! Syntax of menu lines menuKey | entryKey | entryText | doc lines starting with "-" are comment lines and ignored "!" adjacent to a | are ignored entryKey = "NIL": removes the entry --Make a menu --Include a file --Regular menu entry --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. Κ£˜codešœ+™+Kšœ Οmœ1™Kšœ"˜"Kšžœžœžœ˜"Kšžœžœ"˜>šžœ!žœžœ˜1K™ Kšžœžœ˜;Kšœ žœ˜$K˜—šžœžœ"žœžœ˜6K™Kšœ˜K˜—šžœ˜K™Kšžœžœ˜;šœ˜Kšœ%˜%Kšœ'˜'Kšœ˜—K˜—K˜—š  œžœžœ˜+Kšœžœžœ žœ˜!šœžœ˜šœžœ ˜KšœK˜KKšžœ˜ K˜—Kšœ˜—šž˜Kš œžœΟrΠkr’ œžœ ˜