CDCountCommands.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
by: Ch. Jacobi, February 20, 1985 10:41:19 am PST
Last Edited by: Ch. Jacobi, March 19, 1986 4:49:25 pm PST
DIRECTORY
TerminalIO,
CD,
CDSequencer,
CDOps,
CDCommandOps,
CDBasics,
CDMenus USING [CreateEntry],
IO;
CDCountCommands:
CEDAR
PROGRAM
IMPORTS TerminalIO, CD, CDMenus, CDSequencer, CDOps, CDCommandOps, IO =
BEGIN
--the global variables mare monitored using CDCommandOps.CallWithResource;
--these variables are global so they can be used by MyDrawChild
stopFlag: REF BOOLEAN = NEW[BOOLEAN];
rectCounter: INT;
childCounter: INT;
MyDrawChild:
CD.DrawProc =
BEGIN
childCounter ← childCounter+1;
inst.ob.class.drawMe[inst: inst, pos: inst.location, orient: inst.orientation, pr: pr];
END;
MyDrawRect:
CD.DrawRectProc =
BEGIN
rectCounter ← rectCounter+1;
END;
ProtectedCount:
PROCEDURE [comm: CDSequencer.Command] =
BEGIN
myDrawRef:
CD.DrawRef ←
CD.CreateDrawRef[[
interestClip: CDBasics.universe,
drawChild: MyDrawChild,
drawRect: MyDrawRect,
design: comm.design
]];
rectCounter ← childCounter ← 0;
CDOps.DrawDesign[design: comm.design, pr: myDrawRef];
myDrawRef ← NIL;
TerminalIO.WriteRope[
IO.PutFR["rectangles %g objects %g\n",
IO.int[rectCounter],
IO.int[childCounter]
]];
END;
CountComm:
PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["Count rectangles\n"];
[] ← CDCommandOps.CallWithResource[ProtectedCount, comm, $myDrawRef, stopFlag];
END;
CDMenus.CreateEntry[menu: $ProgramMenu, entry: "count rectangles", key: $CountRects];
CDSequencer.ImplementCommand[$CountRects, CountComm,, dontQueue];
END.