-- Compiler Caret/n
-- Tiberi October 31, 1979 8:47 PM
--Maureen Stone December 28, 1983 5:19 pm

DIRECTORY
 CaretDefs: FROM "CaretDefs",
 GriffinViewer USING [GetViewer],
 ViewerOps USING [Top2Bottom],
 ViewerClasses USING [Viewer],
 PointDefs USING [ScrPt, X, Y],
 Carets;

GriffinCaret: PROGRAM IMPORTS Carets, GriffinViewer, ViewerOps EXPORTS CaretDefs =
BEGIN
caretOn: BOOLEANFALSE;
caretPt: PointDefs.ScrPt ← [0,0];
viewer: ViewerClasses.Viewer ← NIL;
X: INTEGER ← PointDefs.X;
Y: INTEGER ← PointDefs.Y;

CaretAt: PUBLIC PROCEDURE[pt: PointDefs.ScrPt] =
BEGIN
IF caretOn AND caretPt=pt THEN RETURN;
IF caretOn THEN Carets.StopCaret[primary];
caretOn ← TRUE;
caretPt ← pt;
Carets.StartCaret[viewer,pt[X],ViewerOps.Top2Bottom[viewer,pt[Y]],primary];
END;

CaretOff: PUBLIC PROCEDURE =
BEGIN
caretOn ← FALSE;
Carets.StopCaret[primary];
END;

WithCaretOff: PUBLIC PROCEDURE [do: PROCEDURE] =
BEGIN
Carets.SuspendCarets[];
do[];
Carets.ResumeCarets[];
END;

Initialize: PUBLIC PROC = { viewer ← GriffinViewer.GetViewer[]};

END.