CDVInit.mesa
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, August 5, 1983 11:07 am
last edited by Christian Jacobi, December 20, 1985 4:03:55 pm PST
DIRECTORY
CedarProcess,
CD,
CDProperties,
CDValue,
CDVPrivate,
CDVScale,
CDColors,
UserProfile;
CDVInit:
CEDAR
MONITOR
IMPORTS CedarProcess, CD, CDProperties, CDValue, CDVPrivate, CDVScale, UserProfile, CDColors
EXPORTS CDVPrivate =
BEGIN
MyGraphicRef: TYPE = CDVPrivate.MyGraphicRef;
MyGraphicRec: TYPE = CDVPrivate.MyGraphicRec;
notSupportedColorMode: PUBLIC ERROR = CODE;
linkBase: PUBLIC MyGraphicRef ← NIL;
InitDesignRec:
PROC [me: MyGraphicRef] =
BEGIN
FOR l: MyGraphicRef ← linkBase, l.link
WHILE l#
NIL
DO
IF me.actualDesign=l.actualDesign
THEN {
me.designRec ← l.designRec;
RETURN
};
ENDLOOP;
me.designRec ← NEW[CDVPrivate.PrivatePerDesign];
CDVPrivate.SetCursorMode[me, NIL];
END;
NewAndLink:
PUBLIC
ENTRY
PROC [design:
CD.Design]
RETURNS [MyGraphicRef] =
BEGIN
ENABLE UNWIND => NULL;
scale, grid: INT;
me: MyGraphicRef ~ NEW[MyGraphicRec];
me.properties ← CD.InitPropRef[];
me.link ← linkBase;
me.actualDesign ← design;
-----
InitDesignRec[me];
--further initializations
scale ← CDValue.FetchInt[boundTo: design, key: $CDxInitScale, propagation: global, ifNotFound: 6];
IF NOT scale IN CDVScale.ScaleRange THEN scale ← 6;
grid ← CDValue.FetchInt[boundTo: design, key: $CDxInitGrid, propagation: global, ifNotFound: design.technology.lambda];
grid ← MIN[MAX[grid, 0], 512];
me.scale ← CDVScale.MakeScale[nscale: scale, grid: grid, off: [0,0]];
me.stoprequest ← NEW[BOOLEAN];
linkBase ← me;
me.environment ← CDValue.FetchInt[design.technology, $CDxDrawMode, global]#1;
me.symbolics ← CDProperties.GetPropFromDesign[design, $CDxDrawSymbolics]#$FALSE;
me.personalColors ← CDColors.globalColors;
RETURN [me]
END;
UnLink:
PUBLIC
ENTRY
PROC [me: MyGraphicRef] =
BEGIN
ENABLE UNWIND => NULL;
IF linkBase=NIL THEN ERROR;
IF me=linkBase THEN {linkBase←linkBase.link; RETURN};
FOR l: MyGraphicRef ← linkBase, l.link
WHILE l#
NIL
DO
IF l.link=me THEN {l.link←l.link.link; RETURN}
ENDLOOP;
ERROR
END;
--------------------------------
IncludeAPainterRec:
PUBLIC ENTRY PROC [me: CDVPrivate.MyGraphicRef, pr:
REF CDVPrivate.PainterRec] =
BEGIN
ENABLE UNWIND => NULL;
FOR list: CDVPrivate.PainterList ← me.painterList, list.rest
WHILE list#
NIL
DO
IF list.first=pr THEN RETURN
ENDLOOP;
me.painterList ← CONS[pr, me.painterList]
END;
RemoveAPainterRec:
PUBLIC ENTRY PROC [me: CDVPrivate.MyGraphicRef, pr:
REF CDVPrivate.PainterRec] =
BEGIN
ENABLE UNWIND => NULL;
IF me.painterList#
NIL
THEN {
IF me.painterList.first=pr THEN me.painterList ← me.painterList.rest
ELSE {
FOR list: CDVPrivate.PainterList ← me.painterList, list.rest
WHILE list.rest#
NIL
DO
IF list.rest.first=pr THEN {list.rest ← list.rest.rest; RETURN}
ENDLOOP;
}
};
END;
--------------------------------
CatchAny:
PROC [b:
BOOL] =
BEGIN
catchAny𡤋
IF catchAny THEN catchAnyWhichDeadlock←TRUE
END;
CatchAnyWhichDeadlock:
PROC [b:
BOOL] =
BEGIN
catchAnyWhichDeadlock𡤋
IF ~catchAnyWhichDeadlock THEN catchAny←FALSE
END;
catchAny: PUBLIC BOOL ← TRUE;
catchAnyWhichDeadlock: PUBLIC BOOL ← TRUE;
NoteProfileChange: UserProfile.ProfileChangedProc =
-- PROC [reason: ProfileChangeReason]
BEGIN
catchAny ← UserProfile.Boolean["ChipNDale.CatchLowLevelErrors", TRUE];
catchAnyWhichDeadlock ← catchAny OR UserProfile.Boolean["ChipNDale.CatchErrorsWhichCauseDeadlock", TRUE]
END;
InitShades:
PROC [] =
BEGIN
CDColors.DefineColor[CD.highLightShade, NEW[CDColors.Brick←[101H,0,0,0]], bw];
CDColors.DefineColor[CD.highLightShade, NEW[CDColors.Brick←[0,0F0FH,0,0]], bit4];
CDColors.DefineColor[CD.highLightShade, NEW[CDColors.Brick←[0,255,0,255]], bit8];
CDColors.DefineColor[CD.highLightError, NEW[CDColors.Brick←[101H,0,101H,0]], bw];
CDColors.DefineColor[CD.highLightError, NEW[CDColors.Brick←[0,0F0FH,0,0F0FH]], bit4];
CDColors.DefineColor[CD.highLightError, NEW[CDColors.Brick←[0,255,255,255]], bit8];
END;
CheckPriority:
PUBLIC
CD.CheckPriorityProc =
BEGIN
IF pr.checkPriority
THEN {
WITH pr.devicePrivate
SELECT
FROM
me: CDVPrivate.MyGraphicRef => {
IF me.slowDown
THEN {
CedarProcess.SetPriority[CedarProcess.Priority[background]];
me.slowDown ← FALSE;
};
IF me.hurryUp
THEN {
--this will be executed only after the other slowed down ...
CedarProcess.SetPriority[CedarProcess.Priority[normal]];
me.hurryUp ← FALSE;
};
me.check ← FALSE;
};
ENDCASE => NULL;
pr.checkPriority ← FALSE;
};
END;
InitShades[];
UserProfile.CallWhenProfileChanges[NoteProfileChange];
END.