-- NodeStyleImpl.mesa -- Written by Bill Paxton, January 1981 -- Last changed by Bill Paxton, 3-Jun-81 13:42:24 -- Implements JaM commands for style rules -- and commands to load styles DIRECTORY NodeStyle, NodeStyleExtra, TextNode, TextLooks, TiogaJaM, JaMFnsDefs, JaMOtherDefs; NodeStyleImpl: PROGRAM IMPORTS TiogaJaM, JaMFnsDefs, JaMOtherDefs, NodeStyleExtra EXPORTS NodeStyle = BEGIN OPEN NodeStyle, NodeStyleExtra, JaMFnsDefs, tjI:TiogaJaM, nodeI:TextNode, looksI:TextLooks; StyleError: PUBLIC ERROR = CODE; LoadProc: TYPE = PROC; SetRealProc: TYPE = PROC [amount:REAL]; AddRealProc: TYPE = PROC [inc:REAL]; PercentProc: TYPE = PROC [percent:REAL]; SetNameProc: TYPE = PROC [name:tjI.JaMName]; Ops: TYPE = REF OpsRec; OpsRec: TYPE = RECORD [ Load: LoadProc, SetReal: SetRealProc, AddReal: AddRealProc, Percent: PercentProc, SetName: SetNameProc ]; SetRealError: SetRealProc = { ERROR StyleError }; AddRealError: AddRealProc = { ERROR StyleError }; PercentError: PercentProc = { ERROR StyleError }; SetNameError: SetNameProc = { ERROR StyleError }; style: PUBLIC Ref; -- the current style parameters StyleParameter: PROC [ops: Ops] = BEGIN OPEN ops; nameflag: BOOLEAN; name: tjI.JaMName; amount: REAL; [nameflag, name, amount] _ PopNameOrReal[]; IF ~nameflag THEN SetReal[amount] ELSE SELECT name FROM the => Load[]; bigger => BEGIN [nameflag, name, amount] _ PopNameOrReal[]; IF ~nameflag THEN AddReal[amount] ELSE IF name=percent THEN Percent[PopReal[]] ELSE ERROR StyleError; END; smaller => BEGIN [nameflag, name, amount] _ PopNameOrReal[]; IF ~nameflag THEN AddReal[-amount] ELSE IF name=percent THEN Percent[-PopReal[]] ELSE ERROR StyleError; END; ENDCASE => SetName[name]; END; -- **** Font Face **** FontFaceOp: PROC = { StyleParameter[fontFaceOps] }; fontFaceOps: Ops _ NEW [OpsRec _ [FontFaceLoad, SetRealError, AddRealError, PercentError, FontFaceSetName]]; FontFaceLoad: LoadProc = { PushName[SELECT style.fontFace FROM Regular => regular, Bold => bold, Italic => italic, BoldItalic => bolditalic, ENDCASE => ERROR] }; FontFaceSetName: SetNameProc = { 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 StyleError }; -- **** Font Alphabets **** FontAlphabetsOp: PROC = { StyleParameter[fontAlphabetsOps] }; fontAlphabetsOps: Ops _ NEW [OpsRec _ [FontAlphabetsLoad, SetRealError, AddRealError, PercentError, FontAlphabetsSetName]]; FontAlphabetsLoad: LoadProc = { PushName[SELECT style.fontAlphabets FROM CapsAndLower => capsAndLower, CapsAndSmallCaps => capsAndSmallCaps, LowerOnly => lowerOnly, CapsOnly => capsOnly, ENDCASE => ERROR] }; FontAlphabetsSetName: SetNameProc = { style.fontAlphabets _ SELECT name FROM capsAndLower => CapsAndLower, capsAndSmallCaps => CapsAndSmallCaps, lowerOnly => LowerOnly, capsOnly => CapsOnly, ENDCASE => ERROR StyleError }; -- **** Underlining **** UnderliningOp: PROC = { StyleParameter[underliningOps] }; underliningOps: Ops _ NEW [OpsRec _ [UnderliningLoad, SetRealError, AddRealError, PercentError, UnderliningSetName]]; UnderliningLoad: LoadProc = { PushName[SELECT style.underlining FROM None => none, LettersAndDigits => lettersAndDigits, Visible => visible, All => all, ENDCASE => ERROR] }; UnderliningSetName: SetNameProc = { style.underlining _ SELECT name FROM none => None, lettersAndDigits => LettersAndDigits, visible => Visible, all => All, ENDCASE => ERROR StyleError }; -- **** Line Formatting **** FormattingOp: PROC = { name: tjI.JaMName; ok: BOOLEAN; [name, ok] _ TryToPopName[]; IF ok AND name # line THEN PushName[name]; StyleParameter[formattingOps] }; formattingOps: Ops _ NEW [OpsRec _ [FormattingLoad, SetRealError, AddRealError, PercentError, FormattingSetName]]; FormattingLoad: LoadProc = { PushName[SELECT style.lineFormatting FROM Justified => justified, FlushLeft => flushLeft, FlushRight => flushRight, Centered => centered, ENDCASE => ERROR] }; FormattingSetName: SetNameProc = { style.lineFormatting _ SELECT name FROM justified => Justified, flushLeft => FlushLeft, flushRight => FlushRight, centered => Centered, ENDCASE => ERROR StyleError }; -- **** Style Name **** StyleNameOp: PROC = { StyleParameter[styleOps] }; styleOps: Ops _ NEW [OpsRec _ [StyleNameLoad, SetRealError, AddRealError, PercentError, StyleNameSetName]]; StyleNameLoad: LoadProc = { PushName[tjI.StyleToJaM[style.styleName]] }; StyleNameSetName: SetNameProc = { style.styleName _ tjI.JaMToStyle[name] }; -- **** Font Family **** FontFamilyOp: PROC = { StyleParameter[fontFamilyOps] }; fontFamilyOps: Ops _ NEW [OpsRec _ [FontFamilyLoad, SetRealError, AddRealError, PercentError, FontFamilySetName]]; FontFamilyLoad: LoadProc = { PushName[style.fontFamily] }; FontFamilySetName: SetNameProc = { style.fontFamily _ name }; -- **** Font Size **** FontSizeOp: PROC = { StyleParameter[fontSizeOps] }; fontSizeOps: Ops _ NEW [OpsRec _ [FontSizeLoad, FontSizeSetReal, FontSizeAddReal, FontSizePercent, SetNameError]]; FontSizeLoad: LoadProc = { PushReal[style.fontSize] }; FontSizeSetReal: SetRealProc = { style.fontSize _ amount }; FontSizeAddReal: AddRealProc = { style.fontSize _ style.fontSize+inc }; FontSizePercent: PercentProc = { val: REAL _ style.fontSize; style.fontSize _ val+(percent/100)*val }; -- **** Indent **** IndentOp: PROC = { SELECT PopName[] FROM left => LeftIndentOp[]; right => RightIndentOp[]; first => FirstIndentOp[]; body => BodyIndentOp[]; top => TopIndentOp[]; bottom => BottomIndentOp[]; ENDCASE => ERROR StyleError }; -- **** Left Indent **** LeftIndentOp: PROC = { StyleParameter[leftIndentOps] }; leftIndentOps: Ops _ NEW [OpsRec _ [LeftIndentLoad, LeftIndentSetReal, LeftIndentAddReal, LeftIndentPercent, SetNameError]]; LeftIndentLoad: LoadProc = { PushReal[style.leftIndent] }; LeftIndentSetReal: SetRealProc = { style.leftIndent _ amount }; LeftIndentAddReal: AddRealProc = { style.leftIndent _ style.leftIndent+inc }; LeftIndentPercent: PercentProc = { val: REAL _ style.leftIndent; style.leftIndent _ val+(percent/100)*val }; -- **** Right Indent **** RightIndentOp: PROC = { StyleParameter[rightIndentOps] }; rightIndentOps: Ops _ NEW [OpsRec _ [RightIndentLoad, RightIndentSetReal, RightIndentAddReal, RightIndentPercent, SetNameError]]; RightIndentLoad: LoadProc = { PushReal[style.rightIndent] }; RightIndentSetReal: SetRealProc = { style.rightIndent _ amount }; RightIndentAddReal: AddRealProc = { style.rightIndent _ style.rightIndent+inc }; RightIndentPercent: PercentProc = { val: REAL _ style.rightIndent; style.rightIndent _ val+(percent/100)*val }; -- **** First Indent **** FirstIndentOp: PROC = { StyleParameter[firstIndentOps] }; firstIndentOps: Ops _ NEW [OpsRec _ [FirstIndentLoad, FirstIndentSetReal, FirstIndentAddReal, FirstIndentPercent, SetNameError]]; FirstIndentLoad: LoadProc = { PushReal[style.firstIndent] }; FirstIndentSetReal: SetRealProc = { style.firstIndent _ amount }; FirstIndentAddReal: AddRealProc = { style.firstIndent _ style.firstIndent+inc }; FirstIndentPercent: PercentProc = { val: REAL _ style.firstIndent; style.firstIndent _ val+(percent/100)*val }; -- **** Body Indent **** BodyIndentOp: PROC = { StyleParameter[bodyIndentOps] }; bodyIndentOps: Ops _ NEW [OpsRec _ [BodyIndentLoad, BodyIndentSetReal, BodyIndentAddReal, BodyIndentPercent, SetNameError]]; BodyIndentLoad: LoadProc = { PushReal[style.bodyIndent] }; BodyIndentSetReal: SetRealProc = { style.bodyIndent _ amount }; BodyIndentAddReal: AddRealProc = { style.bodyIndent _ style.bodyIndent+inc }; BodyIndentPercent: PercentProc = { val: REAL _ style.bodyIndent; style.bodyIndent _ val+(percent/100)*val }; -- **** Top Indent **** TopIndentOp: PROC = { StyleParameter[topIndentOps] }; topIndentOps: Ops _ NEW [OpsRec _ [TopIndentLoad, TopIndentSetReal, TopIndentAddReal, TopIndentPercent, SetNameError]]; TopIndentLoad: LoadProc = { PushReal[style.topIndent] }; TopIndentSetReal: SetRealProc = { style.topIndent _ amount }; TopIndentAddReal: AddRealProc = { style.topIndent _ style.topIndent+inc }; TopIndentPercent: PercentProc = { val: REAL _ style.topIndent; style.topIndent _ val+(percent/100)*val }; -- **** Bottom Indent **** BottomIndentOp: PROC = { StyleParameter[bottomIndentOps] }; bottomIndentOps: Ops _ NEW [OpsRec _ [BottomIndentLoad, BottomIndentSetReal, BottomIndentAddReal, BottomIndentPercent, SetNameError]]; BottomIndentLoad: LoadProc = { PushReal[style.bottomIndent] }; BottomIndentSetReal: SetRealProc = { style.bottomIndent _ amount }; BottomIndentAddReal: AddRealProc = { style.bottomIndent _ style.bottomIndent+inc }; BottomIndentPercent: PercentProc = { val: REAL _ style.bottomIndent; style.bottomIndent _ val+(percent/100)*val }; -- **** Leading **** LeadingOp: PROC = { name: tjI.JaMName; ok: BOOLEAN; [name, ok] _ TryToPopName[]; IF ~ok OR name=line THEN LineLeadingOp[] ELSE SELECT name FROM top => TopLeadingOp[]; bottom => BottomLeadingOp[]; ENDCASE => { PushName[name]; LineLeadingOp[] }; }; -- **** LineLeading **** LineLeadingOp: PROC = { StyleParameter[leadingOps] }; leadingOps: Ops _ NEW [OpsRec _ [LineLeadingLoad, LineLeadingSetReal, LineLeadingAddReal, LineLeadingPercent, SetNameError]]; LineLeadingLoad: LoadProc = { PushReal[style.leading] }; LineLeadingSetReal: SetRealProc = { style.leading _ amount }; LineLeadingAddReal: AddRealProc = { style.leading _ style.leading+inc }; LineLeadingPercent: PercentProc = { val: REAL _ style.leading; style.leading _ val+(percent/100)*val }; -- **** Top Leading **** TopLeadingOp: PROC = { StyleParameter[topLeadingOps] }; topLeadingOps: Ops _ NEW [OpsRec _ [TopLeadingLoad, TopLeadingSetReal, TopLeadingAddReal, TopLeadingPercent, SetNameError]]; TopLeadingLoad: LoadProc = { PushReal[style.topLeading] }; TopLeadingSetReal: SetRealProc = { style.topLeading _ amount }; TopLeadingAddReal: AddRealProc = { style.topLeading _ style.topLeading+inc }; TopLeadingPercent: PercentProc = { val: REAL _ style.topLeading; style.topLeading _ val+(percent/100)*val }; -- **** Bottom Leading **** BottomLeadingOp: PROC = { StyleParameter[bottomLeadingOps] }; bottomLeadingOps: Ops _ NEW [OpsRec _ [BottomLeadingLoad, BottomLeadingSetReal, BottomLeadingAddReal, BottomLeadingPercent, SetNameError]]; BottomLeadingLoad: LoadProc = { PushReal[style.bottomLeading] }; BottomLeadingSetReal: SetRealProc = { style.bottomLeading _ amount }; BottomLeadingAddReal: AddRealProc = { style.bottomLeading _ style.bottomLeading+inc }; BottomLeadingPercent: PercentProc = { val: REAL _ style.bottomLeading; style.bottomLeading _ val+(percent/100)*val }; -- **** VShift **** VShiftOp: PROC = { StyleParameter[vshiftOps] }; vshiftOps: Ops _ NEW [OpsRec _ [VShiftLoad, VShiftSetReal, VShiftAddReal, VShiftPercent, SetNameError]]; VShiftLoad: LoadProc = { PushReal[style.vshift] }; VShiftSetReal: SetRealProc = { style.vshift _ amount }; VShiftAddReal: AddRealProc = { style.vshift _ style.vshift+inc }; VShiftPercent: PercentProc = { val: REAL _ style.vshift; style.vshift _ val+(percent/100)*val }; -- **** MinGaps **** MinGapsOp: PROC = { StyleParameter[minGapsOps] }; minGapsOps: Ops _ NEW [OpsRec _ [MinGapsLoad, MinGapsSetReal, MinGapsAddReal, MinGapsPercent, SetNameError]]; MinGapsLoad: LoadProc = { PushReal[style.minGaps] }; MinGapsSetReal: SetRealProc = { style.minGaps _ amount }; MinGapsAddReal: AddRealProc = { style.minGaps _ style.minGaps+inc }; MinGapsPercent: PercentProc = { val: REAL _ style.minGaps; style.minGaps _ val+(percent/100)*val }; -- **** MinTabWidth **** MinTabWidthOp: PROC = { StyleParameter[minTabWidthOps] }; minTabWidthOps: Ops _ NEW [OpsRec _ [MinTabWidthLoad, MinTabWidthSetReal, MinTabWidthAddReal, MinTabWidthPercent, SetNameError]]; MinTabWidthLoad: LoadProc = { PushReal[style.minTabWidth] }; MinTabWidthSetReal: SetRealProc = { style.minTabWidth _ amount }; MinTabWidthAddReal: AddRealProc = { style.minTabWidth _ style.minTabWidth+inc }; MinTabWidthPercent: PercentProc = { val: REAL _ style.minTabWidth; style.minTabWidth _ val+(percent/100)*val }; -- **** Tab **** tabNumber: INTEGER; TabOp: PROC = { name: tjI.JaMName; ok: BOOLEAN; [name, ok] _ TryToPopName[]; IF ~ok THEN { IF (tabNumber _ PopInteger[]) ~IN [1..numTabs] THEN ERROR StyleError; TabStopOp[] } ELSE SELECT name FROM min => MinTabWidthOp[]; each => EachTabStopOp[]; ENDCASE => ERROR StyleError; }; -- **** TabStop **** TabStopOp: PROC = { StyleParameter[tabStopOps] }; tabStopOps: Ops _ NEW [OpsRec _ [TabStopLoad, TabStopSetReal, TabStopAddReal, TabStopPercent, SetNameError]]; TabStopLoad: LoadProc = { PushReal[style.tabs[tabNumber]] }; TabStopSetReal: SetRealProc = { style.tabs[tabNumber] _ amount }; TabStopAddReal: AddRealProc = { style.tabs[tabNumber] _ style.tabs[tabNumber]+inc }; TabStopPercent: PercentProc = { val: REAL _ style.tabs[tabNumber]; style.tabs[tabNumber] _ val+(percent/100)*val }; -- **** EachTabStop **** EachTabStopOp: PROC = { StyleParameter[eachTabStopOps] }; eachTabStopOps: Ops _ NEW [OpsRec _ [EachTabStopLoad, EachTabStopSetReal, EachTabStopAddReal, EachTabStopPercent, SetNameError]]; EachTabStopLoad: LoadProc = { ERROR StyleError }; EachTabStopSetReal: SetRealProc = { FOR i: INTEGER IN [1..numTabs] DO style.tabs[i] _ amount*i; ENDLOOP }; EachTabStopAddReal: AddRealProc = { FOR i: INTEGER IN [1..numTabs] DO style.tabs[i] _ style.tabs[i]+inc; ENDLOOP }; EachTabStopPercent: PercentProc = { frac: REAL _ percent/100; FOR i: INTEGER IN [1..numTabs] DO val: REAL _ style.tabs[i]; style.tabs[i] _ val+frac*val; ENDLOOP }; -- **** User Parameters **** UserParamOp: PROC = { userParam _ PopName[]; StyleParameter[userOps] }; userParam: tjI.JaMName; userOps: Ops _ NEW [OpsRec _ [UserLoad, UserSetReal, UserAddReal, UserPercent, UserSetName]]; UserLoad: LoadProc = { EvalName[userParam] }; UserSetReal: SetRealProc = { PushName[userParam]; PushReal[amount]; ExecuteCommand[assign] }; UserAddReal: AddRealProc = { PushName[userParam]; EvalName[userParam]; PushReal[PopReal[]+inc]; ExecuteCommand[assign] }; UserPercent: PercentProc = { val: REAL; EvalName[userParam]; val _ PopReal[]; UserSetReal[val+(percent/100)*val] }; UserSetName: SetNameProc = { PushName[userParam]; PushName[name]; ExecuteCommand[assign] }; -- Initialization the, smaller, bigger, percent, left, right, first, body, top, bottom, min, each, regular, bold, italic, bolditalic, plusbold, plusitalic, minusbold, minusitalic, capsAndLower, capsAndSmallCaps, lowerOnly, capsOnly, justified, none, lettersAndDigits, visible, all, flushLeft, flushRight, centered, line: tjI.JaMName; Start: PUBLIC PROCEDURE = BEGIN StyleCommand["size",FontSizeOp]; StyleCommand["face",FontFaceOp]; StyleCommand["alphabets",FontAlphabetsOp]; StyleCommand["underlining",UnderliningOp]; StyleCommand["formatting",FormattingOp]; StyleCommand["style",StyleNameOp]; StyleCommand["family",FontFamilyOp]; StyleCommand["indent",IndentOp]; StyleCommand["leading",LeadingOp]; StyleCommand["tab",TabOp]; StyleCommand["UserParam",UserParamOp]; the _ StyleLiteral["the"]; smaller _ StyleLiteral["smaller"]; bigger _ StyleLiteral["bigger"]; percent _ StyleLiteral["percent"]; left _ StyleLiteral["left"]; right _ StyleLiteral["right"]; first _ StyleLiteral["first"]; body _ StyleLiteral["body"]; top _ StyleLiteral["top"]; bottom _ StyleLiteral["bottom"]; min _ StyleLiteral["min"]; each _ StyleLiteral["each"]; regular _ StyleLiteral["Regular"]; bold _ StyleLiteral["Bold"]; italic _ StyleLiteral["Italic"]; bolditalic _ StyleLiteral["BoldItalic"]; plusbold _ StyleLiteral["+Bold"]; plusitalic _ StyleLiteral["+Italic"]; minusbold _ StyleLiteral["-Bold"]; minusitalic _ StyleLiteral["-Italic"]; capsAndLower _ StyleLiteral["CapsAndLower"]; capsAndSmallCaps _ StyleLiteral["CapsAndSmallCaps"]; lowerOnly _ StyleLiteral["LowerOnly"]; capsOnly _ StyleLiteral["CapsOnly"]; all _ StyleLiteral["All"]; visible _ StyleLiteral["Visible"]; lettersAndDigits _ StyleLiteral["LettersAndDigits"]; none _ StyleLiteral["None"]; justified _ StyleLiteral["Justified"]; flushLeft _ StyleLiteral["FlushLeft"]; flushRight _ StyleLiteral["FlushRight"]; centered _ StyleLiteral["Centered"]; line _ StyleLiteral["line"]; END; END. (635)\296b14B771b5B47b14B649b10B1033b15B656b13B585b12B714b11B335b12B310b10B476b8B256b12B517b13B534b13B533b12B516b11B503b14B545b9B278b13B500b12B519b15B560b8B448b9B468b13B546b5B313b9B517b13B664b11B1006b5B