DIRECTORY NodeStyle, NodeStyleExtra, NodeStyleObject, TextNode, TextLooks, NameSymbolTable, Real, SafeStorage, JaMOps, JaMBasic; NodeStyleImpl: CEDAR MONITOR IMPORTS SafeStorage, Real, NodeStyle, NodeStyleExtra, NodeStyleObject, JaMOps, TextNode EXPORTS NodeStyle, NodeStyleExtra, NodeStyleObject = BEGIN OPEN R:Real, NodeStyle, NodeStyleExtra, NodeStyleObject; StoreError: PUBLIC StoreProc = { ob: Object _ PopObject[frame]; PushName[frame,p.opName]; PushText[frame,"is not legal as value for"]; PushObject[frame,ob]; StyleError[frame,3] }; AddRealError: PUBLIC AddRealProc = { PushName[frame,p.opName]; PushText[frame,"Numbers are illegal as values for"]; StyleError[frame,2] }; PercentError: PUBLIC PercentProc = { PushName[frame,p.opName]; PushText[frame,"Numbers are illegal as values for"]; StyleError[frame,2] }; SetNameError: PUBLIC SetNameProc = { PushName[frame,p.opName]; PushText[frame,"Only numbers are legal as values for"]; StyleError[frame,2] }; qZone: PUBLIC ZONE _ SafeStorage.NewZone[quantized]; Create: PUBLIC PROC RETURNS [Ref] = { -- create a body RETURN [qZone.NEW[StyleBody]] }; Copy: PUBLIC PROC [dest, source: Ref] = { -- copy a body dest^ _ source^ }; s1, s2, s3: Ref; -- shared Alloc: PUBLIC ENTRY PROC RETURNS [s: Ref] = { -- get from a small cache ENABLE UNWIND => NULL; IF s3 # NIL THEN { s _ s3; s3 _ NIL } ELSE IF s2 # NIL THEN { s _ s2; s2 _ NIL } ELSE IF s1 # NIL THEN { s _ s1; s1 _ NIL } ELSE s _ Create[] }; Free: PUBLIC ENTRY PROC [s: Ref] = { -- don't free more than once or disaster ENABLE UNWIND => NULL; IF s3 = NIL THEN s3 _ s ELSE IF s2 = NIL THEN s2 _ s ELSE IF s1 = NIL THEN s1 _ s }; DoStyleOperation: PUBLIC PROC [frame: Frame, p: Param] = { nameflag: BOOLEAN; name: Name; style: Ref _ StyleForFrame[frame]; Error: PROC = { PushName[frame,p.opName]; PushText[frame,"illegal as qualifer for"]; PushName[frame,name]; StyleError[frame,3] }; [name, nameflag] _ TryToPopName[frame]; IF ~nameflag THEN p.ops.Store[frame,p,style] -- e.g., "10 pt leading" ELSE SELECT name FROM the => p.ops.Load[frame,p,style]; -- e.g., "the leading" bigger => BEGIN [name, nameflag] _ TryToPopName[frame]; IF ~nameflag THEN p.ops.AddReal[frame,PopReal[frame],p,style] ELSE IF name=percent THEN p.ops.Percent[frame,100+PopReal[frame],p,style] ELSE { Error; RETURN }; END; smaller => BEGIN [name, nameflag] _ TryToPopName[frame]; IF ~nameflag THEN p.ops.AddReal[frame,-PopReal[frame],p,style] ELSE IF name=percent THEN p.ops.Percent[frame,100-PopReal[frame],p,style] ELSE { Error; RETURN }; END; percent => BEGIN p.ops.Percent[frame,PopReal[frame],p,style]; END; ENDCASE => p.ops.SetName[frame,name,p,style]; -- e.g., "TimesRoman family" }; LoadNameParam: PUBLIC LoadProc = { PushName[frame,style.name[NARROW[p, REF ParamRec.name].param]]}; SetNameParam: PUBLIC SetNameProc = { style.name[NARROW[p, REF ParamRec.name].param] _ name}; StyleNameOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,styleParam] }; styleParam: PUBLIC Param; FontFamilyOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,fontFamilyParam] }; fontFamilyParam: PUBLIC Param; LineFormattingOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,lineFormattingParam] }; lineFormattingParam: PUBLIC Param; LineFormattingLoad: PUBLIC LoadProc = { PushName[frame, SELECT style.lineFormatting FROM Justified => justified, FlushLeft => flushLeft, FlushRight => flushRight, Centered => centered, ENDCASE => ERROR] }; LineFormattingSetName: PUBLIC SetNameProc = { Error: PROC RETURNS [LineFormatting] = { NameError[frame,name,p]; RETURN [FlushLeft] }; style.lineFormatting _ SELECT name FROM justified => Justified, flushLeft => FlushLeft, flushRight => FlushRight, centered => Centered, ENDCASE => Error[] }; FontFaceOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,fontFaceParam] }; fontFaceParam: PUBLIC Param; FontFaceLoad: PUBLIC LoadProc = { PushName[frame, SELECT style.fontFace FROM Regular => regular, Bold => bold, Italic => italic, BoldItalic => bolditalic, ENDCASE => ERROR] }; NameError: PUBLIC PROC [frame: Frame, name: Name, p: Param] = { PushName[frame, p.opName]; PushText[frame, "illegal as value for"]; PushName[frame, name]; StyleError[frame, 3] }; FontFaceSetName: PUBLIC SetNameProc = { Error: PROC RETURNS [FontFace] = { NameError[frame,name,p]; RETURN [Regular] }; FontFaceArray: TYPE = ARRAY FontFace OF FontFace; minusBold: FontFaceArray = [Regular, Regular, Italic, Italic]; minusItalic: FontFaceArray = [Regular, Bold, Regular, Bold]; plusBold: FontFaceArray = [Bold, Bold, BoldItalic, BoldItalic]; plusItalic: FontFaceArray = [Italic, BoldItalic, Italic, BoldItalic]; style.fontFace _ SELECT name FROM regular => Regular, bold => Bold, italic => Italic, bolditalic => BoldItalic, plusbold => plusBold[style.fontFace], plusitalic => plusItalic[style.fontFace], minusbold => minusBold[style.fontFace], minusitalic => minusItalic[style.fontFace], ENDCASE => Error[] }; RealOpLoad: PUBLIC LoadProc = { PushReal[frame,GetReal[style, NARROW[p, REF ParamRec.real].param]]}; RealOpSetReal: PUBLIC StoreProc = { SetReal[style,NARROW[p, REF ParamRec.real].param,PopReal[frame]]}; RealOpAddReal: PUBLIC AddRealProc = { x: REF ParamRec.real = NARROW[p]; SetReal[style,x.param,GetReal[style,x.param]+inc]}; RealOpPercent: PUBLIC PercentProc = { val: REAL _ GetReal[style,NARROW[p, REF ParamRec.real].param]; SetReal[style, NARROW[p, REF ParamRec.real].param, (percent/100)*val] }; realArray: PUBLIC REF ARRAY RealCode OF Real; -- array of distances intArray: PUBLIC REF ARRAY RealCode OF INTEGER; nextFree: RealCode _ 1; -- next free entry in realArray overflowCount: INT _ 0; realTableOverflow: PUBLIC ERROR = CODE; EnterReal: PUBLIC ENTRY PROC [value: Real] RETURNS [code: RealCode] = { ENABLE UNWIND => NULL; code _ nextFree; FOR c: RealCode IN [FIRST[RealCode]..nextFree) DO IF realArray[c]=value THEN { code _ c; EXIT }; ENDLOOP; SELECT code FROM < nextFree => NULL; -- already was in realArray = overflow => { -- realArray is full overflowCount _ overflowCount+1; ERROR realTableOverflow }; = nextFree => { -- enter in realArray nextFree _ nextFree+1; realArray[code] _ value; intArray[code] _ IntegerValue[value] }; ENDCASE => ERROR }; SetReal: PUBLIC PROC [ref: Ref, param: RealParam, value: Real] = { ref.real[param] _ EnterReal[value ! realTableOverflow => { ref.real[param] _ overflow; ref.dataList _ qZone.NEW[DataEntry _ [ ref.dataList, real[param, value, IntegerValue[value]]]]; CONTINUE }]; }; GetRealOverflow: PUBLIC PROC [ref: Ref, param: RealParam] RETURNS [value: Real] = { code: RealCode _ ref.real[param]; IF code # overflow THEN RETURN [realArray[code]]; FOR x: DataList _ ref.dataList, x.next UNTIL x=NIL DO xx: REF DataEntry.real = NARROW[x]; IF xx.param = param THEN RETURN [xx.value]; ENDLOOP; ERROR -- failed to find it on the data list -- }; GetIntOverflow: PUBLIC PROC [ref: Ref, param: RealParam] RETURNS [value: INTEGER] = { code: RealCode _ ref.real[param]; IF code # overflow THEN RETURN [intArray[code]]; FOR x: DataList _ ref.dataList, x.next UNTIL x=NIL DO xx: REF DataEntry.real = NARROW[x]; IF xx.param = param THEN RETURN [xx.valueI]; ENDLOOP; ERROR -- failed to find it on the data list -- }; FontSizeOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,fontSizeParam] }; fontSizeParam: PUBLIC Param; LeftIndentOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,leftIndentParam] }; leftIndentParam: PUBLIC Param; RightIndentOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,rightIndentParam] }; rightIndentParam: PUBLIC Param; FirstIndentOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,firstIndentParam] }; firstIndentParam: PUBLIC Param; RestIndentOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,restIndentParam] }; restIndentParam: PUBLIC Param; TopIndentOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,topIndentParam] }; topIndentParam: PUBLIC Param; BottomIndentOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,bottomIndentParam] }; bottomIndentParam: PUBLIC Param; LineLeadingSizeOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,lineLeadingSizeParam] }; lineLeadingSizeParam: PUBLIC Param; TopLeadingSizeOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,topLeadingSizeParam] }; topLeadingSizeParam: PUBLIC Param; BottomLeadingSizeOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,bottomLeadingSizeParam] }; bottomLeadingSizeParam: PUBLIC Param; VShiftOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,vshiftParam] }; vshiftParam: PUBLIC Param; MinLineGapOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,minLineGapParam] }; minLineGapParam: PUBLIC Param; TabStopsOp: PUBLIC PROC [frame: Frame] = { DoStyleOperation[frame,tabStopsParam] }; tabStopsParam: PUBLIC Param; IsComment: PUBLIC PROC [frame: Frame] = TRUSTED { style: Ref _ StyleForFrame[frame]; JaMOps.PushBoolean[frame.opstk, style.isComment] }; IsPrint: PUBLIC PROC [frame: Frame] = TRUSTED { style: Ref _ StyleForFrame[frame]; JaMOps.PushBoolean[frame.opstk, style.print] }; NestingLevel: PUBLIC PROC [frame: Frame] = TRUSTED { style: Ref _ StyleForFrame[frame]; JaMOps.PushInteger[frame.opstk, style.nestingLevel] }; PointsPerPica: PUBLIC REAL _ 12.0; PointsPerInch: PUBLIC REAL _ 1.0/0.0138370; -- 72.27 PointsPerCentimeter: PUBLIC REAL _ PointsPerInch/2.540; PointsPerMillimeter: PUBLIC REAL _ PointsPerCentimeter/10; PointsPerDidot: PUBLIC REAL _ PointsPerCentimeter/26.60; PointsPerFil: PUBLIC REAL _ 10000.0; PointsPerFill: PUBLIC REAL _ PointsPerFil*PointsPerFil; Points: PROC [frame: Frame] = { }; -- no change needed to convert to points Picas: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerPica] }; Inches: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerInch] }; Centimeters: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerCentimeter] }; Millimeters: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerMillimeter] }; DidotPoints: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerDidot] }; Ems: PROC [frame: Frame] = { oneEm: REAL = GetFontSize[StyleForFrame[frame]]; -- should really be width of "M" in current font PushReal[frame,PopReal[frame]*oneEm] }; Ens: PROC [frame: Frame] = { oneEn: REAL = GetFontSize[StyleForFrame[frame]]/2; -- should really be width of "N" in current font PushReal[frame,PopReal[frame]*oneEn] }; Spaces: PROC [frame: Frame] = { oneSp: REAL = GetFontSize[StyleForFrame[frame]]/2; -- should really be width of a standard space in current font --PushReal[frame,PopReal[frame]*oneSp]-- --for now, just leave the number of spaces on the stack-- }; Fil: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerFil] }; Fill: PROC [frame: Frame] = { PushReal[frame,PopReal[frame]*PointsPerFill] }; started: BOOLEAN _ FALSE; Start: PUBLIC PROCEDURE = BEGIN frame: Frame; IF started THEN RETURN; started _ TRUE; frame _ JaMOps.defaultFrame; realArray _ TextNode.pZone.NEW[ARRAY RealCode OF Real]; intArray _ TextNode.pZone.NEW[ARRAY RealCode OF INTEGER]; StartExtra; StartApply; StartImpl2; [] _ StyleCommand[frame,"pt",Points]; [] _ StyleCommand[frame,"pc",Picas]; [] _ StyleCommand[frame,"in",Inches]; [] _ StyleCommand[frame,"cm",Centimeters]; [] _ StyleCommand[frame,"mm",Millimeters]; [] _ StyleCommand[frame,"dd",DidotPoints]; [] _ StyleCommand[frame,"em",Ems]; [] _ StyleCommand[frame,"en",Ens]; [] _ StyleCommand[frame,"sp",Spaces]; [] _ StyleCommand[frame,"fil",Fil]; [] _ StyleCommand[frame,"fill",Fill]; [] _ LoadStyle[defaultStyleName]; END; Start; END... -- NodeStyleImpl.mesa -- Written by Bill Paxton, January 1981 -- Last changed by Bill Paxton, December 1, 1982 7:38 am -- Implements JaM commands for style rules -- and commands to load styles Last Edited by: Maxwell, January 6, 1983 8:46 am -- **** General **** -- quantized zone for allocating style records -- e.g., "2 pt bigger leading" -- e.g., "2 percent bigger leading" -- e.g., "2 pt smaller leading" -- e.g., "2 percent smaller leading" -- **** Name Params **** -- **** Style Name **** -- **** Font Family **** -- **** Line Formatting **** -- **** Font Face **** -- **** Real Parameters **** -- reserve entry 0 for 0.0 -- **** Font Size **** -- **** Left Indent **** -- **** Right Indent **** -- **** First Indent **** -- **** Rest Indent **** -- **** Top Indent **** -- **** Bottom Indent **** -- **** LineLeading **** -- **** Top Leading **** -- **** Bottom Leading **** -- **** VShift **** -- **** MinLineGap **** -- **** TabStops **** -- **** Readonly info **** -- ***** Dimensions -- ***** Initialization ʘJšÏc™Jš'™'Jš8™8J˜š*™*Jš™J™0—šÏk ˜ J˜ J˜J˜J˜ J˜ J˜J˜J˜ J˜J˜ J˜—šœž ˜JšžœP˜WJšžœ-˜4—Jšžœžœžœ2˜>J˜š™J˜šœ žœ˜ J˜J˜J˜,J˜J˜J˜—šœžœ˜%J˜J˜4J˜J˜—šœžœ˜%J˜J˜4J˜J˜—šœžœ˜%J˜J˜7J˜J˜—šœžœžœ"˜4Jš.™.J˜—š Ïnœžœžœžœ ˜6Jšžœžœ˜ J˜—šŸœžœžœ˜8J˜J˜—Jšœ ˜J˜š Ÿœžœžœžœžœ˜GJšžœžœžœ˜Jšžœžœžœžœ˜%Jš žœžœžœžœžœ˜*Jš žœžœžœžœžœ˜*Jšžœ˜J˜—š Ÿœžœžœžœ(˜MJšžœžœžœ˜Jšžœžœžœ˜Jšžœžœžœžœ˜Jšžœžœžœžœ ˜J˜—šŸœžœžœ˜:Jšœ žœ˜J˜ J˜"J˜šŸœžœ˜J˜J˜*J˜J˜—J˜'Jšžœ žœ˜Ešžœžœž˜Jšœ"˜8˜ Jšž˜J˜'šžœ žœ,˜=Jš™—šžœžœžœ0˜IJš#™#—Jšžœ žœ˜Jšžœ˜—˜ Jšž˜J˜'šžœ žœ-˜>Jš™—šžœžœžœ0˜IJš$™$—Jšžœ žœ˜Jšžœ˜—˜ Jšž˜J˜,Jšžœ˜—Jšžœ'˜J—J˜—J˜J˜—š™J˜šœžœ ˜"šœžœžœ˜@J˜——šœžœ˜$šœ žœžœ˜7J˜J˜———š™J˜JšŸ œžœžœ9˜QJ˜Jšœ žœ˜J˜J˜—š™J˜JšŸ œžœžœ>˜WJ˜Jšœžœ˜J˜J˜—š™J˜šŸœžœžœ˜1J˜.—Jšœžœ˜"J˜šœžœ ˜'šœžœž˜0J˜J˜J˜J˜Jšžœžœ˜J˜J˜——šœžœ˜-šŸœžœžœ˜&Jšœžœ˜0—šœžœž˜'J˜J˜J˜J˜Jšžœ˜J˜———š™J˜JšŸ œžœžœ<˜SJ˜Jšœžœ˜J˜šœžœ ˜!šœžœž˜*J˜J˜ J˜J˜Jšžœžœ˜J˜J˜——šŸ œžœžœ)˜?J˜J˜(J˜J˜J˜—šœžœ˜'šŸœžœžœ˜"Jšœžœ ˜,—Jšœžœžœ žœ ˜1J˜>J˜šœžœžœ,˜HJ˜——Jš œ žœžœžœ žœ˜CJš œ žœžœžœ žœžœ˜/šœ˜7Jš™—Jšœžœ˜J˜Jšœžœžœžœ˜'J˜š Ÿ œžœžœžœžœ˜GJšžœžœžœ˜J˜šžœ žœžœž˜1Jšžœžœ žœ˜.Jšžœ˜—šžœž˜Jšœžœ˜/šœ˜$Jšœ ˜ Jšžœ˜—šœ˜%J˜J˜J˜'—Jšžœžœ˜—J˜—šŸœžœžœ.˜Bšœ:˜:Jšœ˜šœžœ˜&J˜8—Jšžœ˜—J˜—šŸœžœžœ˜9Jšžœ˜J˜!Jšžœžœžœ˜1šžœ$žœžœž˜5Jšœžœžœ˜#Jšžœžœžœ ˜+Jšžœ˜—Jšžœ(œ˜1J˜—šŸœžœžœ˜8Jšžœ žœ˜J˜!Jšžœžœžœ˜0šžœ$žœžœž˜5Jšœžœžœ˜#Jšžœžœžœ ˜,Jšžœ˜—Jšžœ(œ˜1—J˜J˜—š™J˜JšŸ œžœžœ<˜SJ˜Jšœžœ˜J˜J˜—š™J˜JšŸ œžœžœ>˜WJ˜Jšœžœ˜J˜J˜—š™J˜JšŸ œžœžœ?˜YJ˜Jšœžœ˜J˜J˜—š™J˜JšŸ œžœžœ?˜YJ˜Jšœžœ˜J˜J˜—š™J˜JšŸ œžœžœ>˜WJ˜Jšœžœ˜J˜J˜—š™J˜JšŸ œžœžœ=˜UJ˜Jšœžœ˜J˜J˜—š™J˜JšŸœžœžœ@˜[J˜Jšœžœ˜ J˜J˜—š™J˜šŸœžœžœ˜1J˜/—Jšœžœ˜#J˜J˜—š™J˜šŸœžœžœ˜0J˜.—Jšœžœ˜"J˜—š™J˜šŸœžœžœ˜3J˜1—Jšœžœ˜%J˜J˜—š™J˜JšŸœžœžœ:˜OJ˜Jšœ žœ˜J˜J˜—š™J˜šŸ œžœžœ˜,J˜*—Jšœžœ˜J˜J˜—š™J˜šŸ œžœžœ˜*J˜(—Jšœžœ˜J˜J˜—š™J˜šŸ œžœžœžœ˜2J˜"J˜3J˜—šŸœžœžœžœ˜0J˜"J˜/J˜—šŸ œžœžœžœ˜5J˜"J˜6—J˜—šœ™J™Jšœžœžœ˜"Jšœžœžœ˜4Jšœžœžœ˜7Jšœžœžœ˜:Jšœžœžœ˜8Jšœžœžœ ˜$Jšœžœžœ˜7J˜JšŸœžœ(˜KJ˜JšŸœžœC˜NJ˜JšŸœžœC˜OJ˜JšŸ œžœI˜ZJ˜JšŸ œžœI˜ZJ˜JšŸ œžœD˜UJ˜šŸœžœ˜Jšœžœ&0˜aJ˜'J˜—šŸœžœ˜Jšœžœ(0˜cJ˜'J˜—šŸœžœ˜Jšœžœ(=˜pJš(œ9œ˜eJ˜—JšŸœžœB˜KJ˜JšŸœžœC˜MJ˜J˜—š™J˜Jšœ žœžœ˜šŸœžœž œ˜Jšž˜Jšœ ˜ J˜Jšžœ žœžœ žœ˜'J˜J˜Jšœžœžœ žœ˜7Jš œžœžœ žœžœ˜9J˜J˜$J˜J˜%J˜$J˜%J˜*J˜*J˜*J˜"J˜"J˜%J˜#J˜%J™Jšœ!˜!J˜Jšžœ˜J˜—J˜J˜—Jšžœ˜—…—-~?“