CDMenus.mesa (a ChipNDale module)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Created by: Ch. Jacobi, September 18, 1984 3:24:53 pm PDT
Last Edited by: Ch. Jacobi, September 19, 1985 3:20:27 am PDT
DIRECTORY
CD USING [Technology],
CDSequencer USING [Command, CommandProc, QueueMethod],
Rope USING [ROPE];
CDMenus: CEDAR DEFINITIONS =
BEGIN
Implements pop up menus.
CreateMenu:
PROC [label: Rope.
ROPE←
NIL, globalKey:
ATOM ←
NIL]
RETURNS [menu:
REF];
--Creates a new menu
--label: its header line
--globalKey: If not NIL, the menu may be fetched (GetMenu) using this atom
GetMenu:
PROC [globalKey:
ATOM]
RETURNS [menu:
REF];
--Fetches a menu which had been created with a globalKey
--NIL if not found
CreateEntry:
PROC [menu:
REF, entry: Rope.
ROPE ←
NIL, key:
REF];
--Makes an entry line in a menu (overwrite if ropes are equal, remove if NIL)
--menu: a menu => use this menu
-- an ATOM => fetch for menu with globalKey
--key: a menu => use the key menu recursively
-- an ATOM => return this as result (does NOT search for a menu) /
-- use CDSequencer
-- others => return as result / error message
CallMenu:
PROC [menu:
REF]
RETURNS [key:
REF];
--Calls a menu and return the selected key
--(recursively, until returned key is not of type menu)
CallCommand:
PROC [menu:
REF, comm: CDSequencer.Command];
--Calls a menu and replace the "comm" key with the selected key
--then "comm" is executed
ImplementMenuCommand:
PROC[a:
ATOM, menu:
REF, technology:
CD.Technology ←
NIL];
--Implements a CDSequencer command "a" which shows the "menu" and after
--selection executes the selected entry
ImplementEntryCommand:
PROC [menu:
REF, entry: Rope.
ROPE ←
NIL, p: CDSequencer.CommandProc, key:
ATOM ←
NIL, queue: CDSequencer.QueueMethod ← doQueue];
--For conveniance only; in all technologies.
--Creates an entry line into the menu and sets it up to call the command p.
--key: key of the command; is made up if NIL.
END.