CDVInit.mesa
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi August 5, 1983 11:07 am
last edited by Christian Jacobi September 20, 1984 10:50:16 am PDT
DIRECTORY
CD,
CDValue,
CDVPrivate,
CDVScale,
CDColors,
UserProfile;
CDVInit:
CEDAR
MONITOR
IMPORTS 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
scale, grid: INT;
me: MyGraphicRef ~ NEW[MyGraphicRec];
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: CD.lambda];
grid ← MIN[MAX[grid, 0], 256];
me.scale ← CDVScale.MakeScale[nscale: scale, grid: grid, off: [0,0]];
me.stoprequest ← NEW[BOOLEAN];
linkBase ← me;
me.suppressOutsidePushedCell ← CDValue.FetchInt[design.technology, $CDxDrawMode, global]=1;
me.personalColors ← CDColors.globalColors;
RETURN [me]
END;
UnLink:
PUBLIC
ENTRY
PROC [me: MyGraphicRef] =
BEGIN
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] = {
catchAny𡤋
IF catchAny THEN catchAnyWhichDeadlock←TRUE
};
CatchAnyWhichDeadlock:
PROC [b:
BOOL] = {
catchAnyWhichDeadlock𡤋
IF ~catchAnyWhichDeadlock THEN catchAny←FALSE
};
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 [] = {
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];
};
InitShades[];
UserProfile.CallWhenProfileChanges[NoteProfileChange];
CDValue.StoreInt[boundTo: NIL, key: $CDxInitGrid, value: CD.lambda];
END.