CDCommandOps.mesa (part of ChipNDale)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, July 12, 1984 3:46:45 pm PDT
Last edited by: Christian Jacobi, October 23, 1986 10:28:18 am PDT
DIRECTORY
CD,
CDSequencer,
Rope USING [ROPE];
CDCommandOps: CEDAR DEFINITIONS =
BEGIN
Various procedures to ease implementing commands.
CommandProc: TYPE = CDSequencer.CommandProc;
Command: TYPE = CDSequencer.Command;
DoWithResource: PROC [proc: CDSequencer.CommandProc, comm: CDSequencer.Command, resource: REFNIL, waitIfBusy: BOOLFALSE, messageIfSkipped: BOOLTRUE] RETURNS [skipped: BOOL];
--Monitoring commands using global resources
--proc will be called with comm as parameter
--resource: typically atom; every resource is called only once at a time
--waitIfBusy
--  TRUE: proc waits if resource is occupied
--  FALSE: proc is skipped if resource is occupied
--messageIfSkipped: The procedure message on Terminal if it skipped the call
RegisterWithMenu: PROC [menu: REF←NIL, entry: Rope.ROPE←NIL, doc: Rope.ROPE←NIL, key: ATOMNIL, proc: CDSequencer.CommandProc←NIL, queue: CDSequencer.QueueMethod𡤍oQueue, tech: CD.Technology←NIL];
--Pure conveniance
--Fetches a menu, installs an entry and implements a command with CDSequencer
--menu: pop-up menu, or NIL
--entry: entry line for pop up menu
--doc: documentation
--key: command key (as in tip table, pop-up menu)
--proc #NIL: registers proc with CDSequencer
--proc NIL: registration of menu entry only
--queue: method how proc is called
--tech: (NIL for all technologies); used for command registration but not for menu
--There are two classes of tools
-- Standard tools register commands with CDSequencer,
-- they do not make PopUp menus themself  
-- Fancy tools might not be included in the PopUp menu table file
-- they might consider registering a menu themself, after they are loaded  
RegisterCurrentLayerCommand: PROC [key: ATOM, layer: CD.Layer, tech: CD.Technology←NIL, w: CD.Number←-1];
--Registers a command to set layer current layer
IncludeOb: PROC [comm: CDSequencer.Command, ob: CD.Object, failMessage: Rope.ROPENIL];
--Includes object into design and makes (always!) a message
--failMessage: output if ob is NIL
--Trivial procedure, but used often enough
END.