NodeStyle2Impl.mesa
Written by Bill Paxton, January 1981
Last changed by Bill Paxton, June 7, 1983 2:49 pm
Implements JaM commands for style rules
and commands to load styles
DIRECTORY
NodeStyle,
NodeStyleExtra,
NodeStyleObject,
TiogaNode,
NameSymbolTable,
Real,
JaMOps,
JaMBasic;
NodeStyle2Impl: CEDAR MONITOR
IMPORTS JaMOps, NameSymbolTable, NodeStyle, NodeStyleExtra, NodeStyleObject, Real
EXPORTS NodeStyleExtra, NodeStyleObject =
BEGIN OPEN R:Real, NodeStyle, NodeStyleExtra, NodeStyleObject;
**** Text Rotation ****
TextRotationOp: PROC [frame: Frame] = {
DoStyleOperation[frame,textRotationParam] };
textRotationParam: Param;
**** Line Weight ****
LineWeightOp: PROC [frame: Frame] = {
DoStyleOperation[frame,lineWeightParam] };
lineWeightParam: Param;
**** Page Width ****
PageWidthOp: PROC [frame: Frame] = {
DoStyleOperation[frame,pageWidthParam] };
pageWidthParam: Param;
**** Page Length ****
PageLengthOp: PROC [frame: Frame] = {
DoStyleOperation[frame,pageLengthParam] };
pageLengthParam: Param;
**** Left Margin ****
LeftMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,leftMarginParam] };
leftMarginParam: Param;
**** Right Margin ****
RightMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,rightMarginParam] };
rightMarginParam: Param;
**** Top Margin ****
TopMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,topMarginParam] };
topMarginParam: Param;
**** Bottom Margin ****
BottomMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,bottomMarginParam] };
bottomMarginParam: Param;
**** Header Margin ****
HeaderMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,headerMarginParam] };
headerMarginParam: Param;
**** Footer Margin ****
FooterMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,footerMarginParam] };
footerMarginParam: Param;
**** Binding Margin ****
BindingMarginOp: PROC [frame: Frame] = {
DoStyleOperation[frame,bindingMarginParam] };
bindingMarginParam: Param;
**** Line Length ****
LineLengthOp: PROC [frame: Frame] = {
DoStyleOperation[frame,lineLengthParam] };
lineLengthParam: Param;
**** Column ****
ColumnOp: PROC [frame: Frame] = {
DoStyleOperation[frame,columnParam] };
columnParam: Param;
**** Area Color ****
AreaHueOp: PROC [frame: Frame] = {
DoStyleOperation[frame,areaHueParam] };
areaHueParam: Param;
AreaSaturationOp: PROC [frame: Frame] = {
DoStyleOperation[frame,areaSaturationParam] };
areaSaturationParam: Param;
AreaBrightnessOp: PROC [frame: Frame] = {
DoStyleOperation[frame,areaBrightnessParam] };
areaBrightnessParam: Param;
AreaColorOp: PROC [frame: Frame] = {
DoStyleOperation[frame,areaColorParam] };
areaColorParam: Param;
**** Outline Color ****
OutlineHueOp: PROC [frame: Frame] = {
DoStyleOperation[frame,outlineHueParam] };
outlineHueParam: Param;
OutlineSaturationOp: PROC [frame: Frame] = {
DoStyleOperation[frame,outlineSaturationParam] };
outlineSaturationParam: Param;
OutlineBrightnessOp: PROC [frame: Frame] = {
DoStyleOperation[frame,outlineBrightnessParam] };
outlineBrightnessParam: Param;
OutlineColorOp: PROC [frame: Frame] = {
DoStyleOperation[frame,outlineColorParam] };
outlineColorParam: Param;
**** Text Color ****
TextHueOp: PROC [frame: Frame] = {
DoStyleOperation[frame,textHueParam] };
textHueParam: Param;
TextSaturationOp: PROC [frame: Frame] = {
DoStyleOperation[frame,textSaturationParam] };
textSaturationParam: Param;
TextBrightnessOp: PROC [frame: Frame] = {
DoStyleOperation[frame,textBrightnessParam] };
textBrightnessParam: Param;
TextColorOp: PROC [frame: Frame] = {
DoStyleOperation[frame,textColorParam] };
textColorParam: Param;
**** Penalty Parameters
PageBreakPenaltyOp: PROC [frame: Frame] = {
DoStyleOperation[frame,pageBreakPenaltyParam] };
pageBreakPenaltyParam: Param;
PageBreakPenalty2Op: PROC [frame: Frame] = {
DoStyleOperation[frame,pageBreakPenalty2Param] };
pageBreakPenalty2Param: Param;
PageBreakPenalty3Op: PROC [frame: Frame] = {
DoStyleOperation[frame,pageBreakPenalty3Param] };
pageBreakPenalty3Param: Param;
PageBreakPenalty4Op: PROC [frame: Frame] = {
DoStyleOperation[frame,pageBreakPenalty4Param] };
pageBreakPenalty4Param: Param;
PageBreakPenalty5Op: PROC [frame: Frame] = {
DoStyleOperation[frame,pageBreakPenalty5Param] };
pageBreakPenalty5Param: Param;
**** Font Alphabets ****
FontAlphabetsOp: PROC [frame: Frame] = { DoStyleOperation[frame,fontAlphabetsParam] };
fontAlphabetsOps: Ops;
fontAlphabetsParam: Param;
FontAlphabetsLoad: LoadProc = {
PushName[frame, SELECT style.fontAlphabets FROM
CapsAndLower => capsAndLower,
CapsAndSmallCaps => capsAndSmallCaps,
LowerOnly => lowerOnly,
CapsOnly => capsOnly,
ENDCASE => ERROR]
};
FontAlphabetsSetName: SetNameProc = {
Error: PROC RETURNS [FontAlphabets] =
{ NameError[frame,name,p]; RETURN [CapsAndLower] };
style.fontAlphabets ← SELECT name FROM
capsAndLower => CapsAndLower,
capsAndSmallCaps => CapsAndSmallCaps,
lowerOnly => LowerOnly,
capsOnly => CapsOnly,
ENDCASE => Error[] };
**** Strikeout ****
StrikeoutOp: PROC [frame: Frame] = { DoStyleOperation[frame,strikeoutParam] };
strikeoutOps: Ops;
strikeoutParam: Param;
StrikeoutLoad: LoadProc = {
PushName[frame, SELECT style.strikeout FROM
None => none,
LettersAndDigits => lettersAndDigits,
Visible => visible,
All => all,
ENDCASE => ERROR]
};
StrikeoutSetName: SetNameProc = {
Error: PROC RETURNS [FontUnderlining] =
{ NameError[frame,name,p]; RETURN [None] };
style.strikeout ← SELECT name FROM
none => None,
lettersAndDigits => LettersAndDigits,
visible => Visible,
all => All,
ENDCASE => Error[] };
**** Underlining ****
UnderliningOp: PROC [frame: Frame] = { DoStyleOperation[frame,underliningParam] };
underliningOps: Ops;
underliningParam: Param;
UnderliningLoad: LoadProc = {
PushName[frame, SELECT style.underlining FROM
None => none,
LettersAndDigits => lettersAndDigits,
Visible => visible,
All => all,
ENDCASE => ERROR]
};
UnderliningSetName: SetNameProc = {
Error: PROC RETURNS [FontUnderlining] =
{ NameError[frame,name,p]; RETURN [None] };
style.underlining ← SELECT name FROM
none => None,
lettersAndDigits => LettersAndDigits,
visible => Visible,
all => All,
ENDCASE => Error[] };
**** Force Break ****
ForceBreakOp: PROC [frame: Frame] = {
DoStyleOperation[frame,forceBreakParam] };
forceBreakOps: Ops;
forceBreakParam: Param;
ForceBreakLoad: LoadProc = {
PushName[frame, SELECT style.forceBreak FROM
No => no,
Before => before,
After => after,
Around => around,
ENDCASE => ERROR]
};
ForceBreakSetName: SetNameProc = {
Error: PROC RETURNS [ForceBreak] =
{ NameError[frame,name,p]; RETURN [Around] };
style.forceBreak ← SELECT name FROM
no => No,
before => Before,
after => After,
around => Around,
ENDCASE => Error[] };
**** Path Type ****
PathTypeOp: PROC [frame: Frame] = {
DoStyleOperation[frame,pathTypeParam] };
pathTypeOps: Ops;
pathTypeParam: Param;
PathTypeLoad: LoadProc = {
PushName[frame, SELECT style.pathType FROM
Filled => filled,
Outlined => outlined,
FilledAndOutlined => filledAndOutlined,
ENDCASE => ERROR]
};
PathTypeSetName: SetNameProc = {
Error: PROC RETURNS [PathType] =
{ NameError[frame,name,p]; RETURN [Filled] };
style.pathType ← SELECT name FROM
filled => Filled,
outlined => Outlined,
filledAndOutlined => FilledAndOutlined,
ENDCASE => Error[] };
**** Color Parameters ****
colorOps: Ops;
ColorOpLoad: LoadProc = {
Get: PROC [param: RealParam] = {
PushReal[frame,GetReal[style,param]] };
x: REF ParamRec.color = NARROW[p];
Get[x.hue]; Get[x.saturation]; Get[x.brightness] };
ColorOpSetReal: StoreProc = {
Set: PROC [param: RealParam] = {
SetReal[style,param,PopReal[frame]] };
x: REF ParamRec.color = NARROW[p];
Set[x.brightness]; Set[x.saturation]; Set[x.hue] };
ColorOpAddReal: AddRealProc = {
Add: PROC [param: RealParam] = {
SetReal[style,param,GetReal[style,param]+inc] };
x: REF ParamRec.color = NARROW[p];
Add[x.hue]; Add[x.saturation]; Add[x.brightness] };
ColorOpPercent: PercentProc = {
Set: PROC [param: RealParam] = {
val: REAL ← GetReal[style,param];
SetReal[style, param, (percent/100)*val] };
x: REF ParamRec.color = NARROW[p];
Set[x.hue]; Set[x.saturation]; Set[x.brightness] };
**** Glue Parameters ****
glueOps: Ops;
GlueOpLoad: LoadProc = {
Get: PROC [param: RealParam] = {
PushReal[frame,GetReal[style,param]] };
x: REF ParamRec.glue = NARROW[p];
Get[x.size]; Get[x.stretch]; Get[x.shrink] };
GlueOpSetReal: StoreProc = {
Set: PROC [param: RealParam] = {
SetReal[style,param,PopReal[frame]] };
x: REF ParamRec.glue = NARROW[p];
Set[x.shrink]; Set[x.stretch]; Set[x.size] };
GlueOpAddReal: AddRealProc = {
Add: PROC [param: RealParam] = {
SetReal[style,param,GetReal[style,param]+inc] };
x: REF ParamRec.glue = NARROW[p];
Add[x.size]; Add[x.stretch]; Add[x.shrink] };
GlueOpPercent: PercentProc = {
Set: PROC [param: RealParam] = {
val: REAL ← GetReal[style,param];
SetReal[style, param, (percent/100)*val] };
x: REF ParamRec.glue = NARROW[p];
Set[x.size]; Set[x.stretch]; Set[x.shrink] };
**** LineLeading ****
LineLeadingStretchOp: PROC [frame: Frame] = {
DoStyleOperation[frame,lineLeadingStretchParam] };
lineLeadingStretchParam: Param;
LineLeadingShrinkOp: PROC [frame: Frame] = {
DoStyleOperation[frame,lineLeadingShrinkParam] };
lineLeadingShrinkParam: Param;
LineLeadingGlueOp: PROC [frame: Frame] = {
DoStyleOperation[frame,lineLeadingGlueParam] };
lineLeadingGlueParam: Param;
**** Top Leading ****
TopLeadingStretchOp: PROC [frame: Frame] = {
DoStyleOperation[frame,topLeadingStretchParam] };
topLeadingStretchParam: Param;
TopLeadingShrinkOp: PROC [frame: Frame] = {
DoStyleOperation[frame,topLeadingShrinkParam] };
topLeadingShrinkParam: Param;
TopLeadingGlueOp: PROC [frame: Frame] = {
DoStyleOperation[frame,topLeadingGlueParam] };
topLeadingGlueParam: Param;
**** Bottom Leading ****
BottomLeadingStretchOp: PROC [frame: Frame] = {
DoStyleOperation[frame,bottomLeadingStretchParam] };
bottomLeadingStretchParam: Param;
BottomLeadingShrinkOp: PROC [frame: Frame] = {
DoStyleOperation[frame,bottomLeadingShrinkParam] };
bottomLeadingShrinkParam: Param;
BottomLeadingGlueOp: PROC [frame: Frame] = {
DoStyleOperation[frame,bottomLeadingGlueParam] };
bottomLeadingGlueParam: Param;
**** Free Variables ****
styleFreeVarName: Name; -- for the first REAL valued free variable
realFreeVars: LIST OF RealFreeVarRec;
RealFreeVarRec: TYPE = RECORD [
key: Name, eval: PROC [node: TiogaNode.Ref] RETURNS [REAL]];
objFreeVars: LIST OF ObjFreeVarRec;
ObjFreeVarRec: TYPE = RECORD [
key: Name, eval: PROC [node: TiogaNode.Ref] RETURNS [JaMBasic.Object]];
EvalFreeVars: PUBLIC PROC [style: Ref, node: TiogaNode.Ref] = {
key: Name;
SetVal: PROC [value: JaMBasic.Object] = {
FOR x: DataList ← style.dataList, x.next UNTIL x=NIL DO -- see if already has this value
xx: REF DataEntry.object = NARROW[x];
IF xx.name=key THEN {
ob: NameSymbolTable.Object ← LOOPHOLE[value];
IF xx.object=ob THEN RETURN ELSE EXIT };
ENDLOOP;
style.dataList ← NEW[DataEntry ← [style.dataList, object[key,LOOPHOLE[value]]]] };
FOR lst: LIST OF RealFreeVarRec ← realFreeVars, lst.rest UNTIL lst=NIL DO
value: Real ← lst.first.eval[node];
key ← lst.first.key;
IF key=styleFreeVarName THEN SetReal[style,freeVar,value] -- this one is special
ELSE SetVal[[L, real[value]]];
ENDLOOP;
FOR lst: LIST OF ObjFreeVarRec ← objFreeVars, lst.rest UNTIL lst=NIL DO
key ← lst.first.key;
SetVal[lst.first.eval[node]];
ENDLOOP;
};
UnregisterStyleFreeVar: PROC [name: Name] = {
prev: LIST OF RealFreeVarRec ← realFreeVars;
prevObj: LIST OF ObjFreeVarRec ← objFreeVars;
key: Name ← StyleParamKey[name];
IF styleFreeVarName=key THEN styleFreeVarName ← NameSymbolTable.nullName;
IF realFreeVars=NIL THEN NULL
ELSE IF realFreeVars.first.key=key THEN realFreeVars ← realFreeVars.rest
ELSE FOR lst: LIST OF RealFreeVarRec ← realFreeVars, lst.rest UNTIL lst=NIL DO
IF lst.first.key=key THEN { prev.rest ← lst.rest; EXIT };
prev ← lst;
ENDLOOP;
IF objFreeVars=NIL THEN NULL
ELSE IF objFreeVars.first.key=key THEN objFreeVars ← objFreeVars.rest
ELSE FOR lst: LIST OF ObjFreeVarRec ← objFreeVars, lst.rest UNTIL lst=NIL DO
IF lst.first.key=key THEN { prevObj.rest ← lst.rest; EXIT };
prevObj ← lst;
ENDLOOP };
GetFreeVarOp: PROC [frame: Frame] = {
style: Ref ← StyleForFrame[frame];
key: Name ← PopName[frame]; -- key name for the free var
IF key=styleFreeVarName THEN { PushReal[frame, GetReal[style, freeVar]]; RETURN };
PushFreeVar[frame, style, key] };
GetFreeVarObjOp: PROC [frame: Frame] = {
style: Ref ← StyleForFrame[frame];
key: Name ← PopName[frame]; -- key name for the free var
PushFreeVar[frame, style, key] };
PushFreeVar: PROC [frame: Frame, style: Ref, key: Name] = {
FOR x: DataList ← style.dataList, x.next UNTIL x=NIL DO
xx: REF DataEntry.object = NARROW[x];
IF xx.name = key THEN { PushObject[frame, LOOPHOLE[xx.object]]; RETURN };
ENDLOOP;
PushText[frame,"not defined as a free variable?"];
PushName[frame,key];
StyleError[frame,3] };
getFreeVarOp, getFreeVarObjOp: Object;
RegisterStyleFreeVar: PUBLIC PROC [
name: Name, eval: PROC [node: TiogaNode.Ref] RETURNS [REAL]] = TRUSTED {
key: Name;
array: array Object;
[key, array] ← SpecialOpArray[name, getFreeVarOp];
JaMOps.Put[styledict,NameToObject[name],array]; -- store the definition
UnregisterStyleFreeVar[name];
IF styleFreeVarName=NameSymbolTable.nullName THEN styleFreeVarName ← key;
realFreeVars ← CONS[[key, eval], realFreeVars] };
RegisterStyleFreeObjVar: PUBLIC PROC [
name: Name, eval: PROC [node: TiogaNode.Ref] RETURNS [JaMBasic.Object]] = TRUSTED {
key: Name;
array: array Object;
[key, array] ← SpecialOpArray[name, getFreeVarObjOp];
JaMOps.Put[styledict,NameToObject[name],array]; -- store the definition
UnregisterStyleFreeVar[name];
objFreeVars ← CONS[[key, eval], objFreeVars] };
**** Special Parameters
DefineSpecial: PUBLIC PROC [name: Name, initialValue: Real] = {
DefineSpecialObj[name, [L,real[initialValue]]] };
DefineSpecialObj: PUBLIC PROC [name: Name, initialValue: JaMBasic.Object] = TRUSTED {
key: Name;
array: array Object;
[key, array] ← SpecialOpArray[name, specialOp];
JaMOps.Put[styledict,NameToObject[name],array]; -- store the definition
JaMOps.Put[styledict,NameToObject[key],initialValue]; -- store the initial value
};
nonNumeric: PUBLIC ERROR = CODE;
GetSpecial: PUBLIC PROC [s: Ref, name: Name] RETURNS [r: Real] = {
obj: Object = GetSpecialObj[s, name];
WITH x:obj SELECT FROM
real => r ← x.rvalue;
integer => r ← x.ivalue;
ENDCASE => ERROR nonNumeric };
GetSpecialI: PUBLIC PROC [s: Ref, name: Name] RETURNS [val: INTEGER] = {
obj: Object = GetSpecialObj[s, name];
WITH x:obj SELECT FROM
real => val ← R.RoundI[x.rvalue];
integer => val ← x.ivalue;
ENDCASE => ERROR nonNumeric };
GetSpecialObj: PUBLIC PROC [s: Ref, name: Name] RETURNS [obj: Object] = TRUSTED {
key: Name ← StyleParamKey[name];
FOR x: DataList ← s.dataList, x.next UNTIL x=NIL DO
xx: REF DataEntry.object = NARROW[x];
IF xx.name = key THEN RETURN [LOOPHOLE[xx.object]];
ENDLOOP;
RETURN [JaMOps.Get[styledict,NameToObject[key]]] };
**** Special Parameters
SpecialOpArray: PROC [name: Name, op: Object]
RETURNS [key: Name, array: array Object] = TRUSTED {
key ← StyleParamKey[name];
array ← JaMOps.Array[2]; -- create a 2 element array
array.tag ← X; -- make it executable
JaMOps.APut[array,0,CVLit[NameToObject[key]]];
JaMOps.APut[array,1,CVX[op]];
};
text: REF TEXTNEW[TEXT[64]]; -- to hold the name for StyleParamKey
StyleParamKey: ENTRY PROC [name: Name] RETURNS [key: Name] = TRUSTED {
ENABLE UNWIND => NULL;
text.length ← 0;
NameSymbolTable.FromName[name, text];
FOR i:NAT DECREASING IN [0..text.length) DO -- make room for prefix
text[i+2] ← text[i]; ENDLOOP;
text[0] ← text[1] ← '!; -- prefix for keys is double bang
text.length ← text.length+2;
key ← MakeName[LOOPHOLE[text, REF READONLY TEXT]];
};
StyleParam: PROC [frame: Frame] = TRUSTED { -- called to declare a special style parameter
object: Object ← PopObject[frame]; -- the initial value
name: Name ← PopName[frame]; -- the parameter name
key: Name;
array: array Object;
[key, array] ← SpecialOpArray[name, specialOp];
JaMOps.Def[frame,NameToObject[name],array]; -- store the definition
JaMOps.Def[frame,NameToObject[key],object]; -- store the initial value
};
GetStyleParam: PUBLIC PROC [s: Ref, name: Name, styleName: Name, kind: OfStyle]
RETURNS [obj: Object] = TRUSTED {
frame: Frame;
key: Name ← StyleParamKey[name];
FOR x: DataList ← s.dataList, x.next UNTIL x=NIL DO
xx: REF DataEntry.object = NARROW[x];
IF xx.name = key THEN RETURN [LOOPHOLE[xx.object]];
ENDLOOP;
frame ← GetFrame[s, styleName, kind];
PushName[frame,key];
JaMOps.Execute[frame,load]; -- get the initial value
obj ← LOOPHOLE[PopObject[frame]];
FreeFrame[frame, styleName, kind];
RETURN [obj] };
SpecialOp: PROC [frame: Frame] = { -- like DoStyleOperation, but for special parameters
nameflag: BOOLEAN;
name: Name;
var: Name;
style: Ref ← StyleForFrame[frame];
Error: PROC = {
PushName[frame,name];
PushText[frame,"has illegal qualifier:"];
PushName[frame,var];
StyleError[frame,3] };
FindObject: PROC RETURNS [NameSymbolTable.Object] = TRUSTED {
FOR x: DataList ← style.dataList, x.next UNTIL x=NIL DO
xx: REF DataEntry.object = NARROW[x];
IF xx.name = var THEN RETURN [xx.object];
ENDLOOP;
PushName[frame,var];
JaMOps.Execute[frame,load]; -- get the initial value
RETURN [LOOPHOLE[PopObject[frame]]] };
Store: PROC [ob: NameSymbolTable.Object] = {
style.dataList ← NEW[DataEntry ← [
style.dataList, object[var,ob]]] };
Load: PROC = { PushObject[frame,LOOPHOLE[FindObject[]]] };
AddReal: PROC [inc: REAL] = {
value: REAL;
Load; value ← PopReal[frame];
SetReal[value+inc] };
SetReal: PROC [x: REAL] = {
PushReal[frame,x]; Store[LOOPHOLE[PopObject[frame]]] };
SetName: PROC [n: Name] = {
PushName[frame,n]; Store[LOOPHOLE[PopObject[frame]]] };
Percent: PROC [percent: REAL] = {
value: REAL;
Load; value ← PopReal[frame];
SetReal[(percent/100)*value] };
var ← PopName[frame]; -- the name of the special parameter
[name, nameflag] ← TryToPopName[frame];
IF ~nameflag THEN Store[LOOPHOLE[PopObject[frame]]]
store the object as new value
ELSE SELECT name FROM
the => Load[];
bigger =>
BEGIN
[name, nameflag] ← TryToPopName[frame];
IF ~nameflag THEN AddReal[PopReal[frame]]
ELSE IF name=percent THEN Percent[100+PopReal[frame]]
ELSE { Error; RETURN };
END;
smaller =>
BEGIN
[name, nameflag] ← TryToPopName[frame];
IF ~nameflag THEN AddReal[-PopReal[frame]]
ELSE IF name=percent THEN Percent[100-PopReal[frame]]
ELSE { Error; RETURN };
END;
percent => Percent[PopReal[frame]];
ENDCASE => SetName[name];
};
Initialization
DefineSpecialOp: PROC [
frame: Frame, text: REF READONLY TEXT, proc: PROC [Frame]] RETURNS [op: Object] = TRUSTED {
JaMOps.RegisterExplicit[frame,LOOPHOLE[text, LONG STRING],proc];
PushName[frame,MakeName[text]];
JaMOps.Execute[frame,load];
op ← PopObject[frame] };
specialOp: Object;
DefineColorOp: PROC [
frame: Frame, text: REF READONLY TEXT,
proc: PROC [Frame], hue, saturation, brightness: RealParam]
RETURNS [Param] = {
name: Name = StyleCommand[frame,text,proc];
RETURN [NEW [color ParamRec ←
[colorOps, name, color[hue, saturation, brightness]]]] };
DefineGlueOp: PROC [
frame: Frame, text: REF READONLY TEXT,
proc: PROC [Frame], size, stretch, shrink: RealParam]
RETURNS [Param] = {
name: Name = StyleCommand[frame,text,proc];
RETURN [NEW [glue ParamRec ←
[glueOps, name, glue[size, stretch, shrink]]]] };
DefineRealOp: PROC [
frame: Frame, text: REF READONLY TEXT,
proc: PROC [Frame], param: RealParam]
RETURNS [Param] = {
name: Name = StyleCommand[frame,text,proc];
RETURN [NEW [real ParamRec ← [realOps, name, real[param]]]] };
nameOps: Ops;
DefineNameOp: PROC [
frame: Frame, text: REF READONLY TEXT,
proc: PROC [Frame], param: NameParam]
RETURNS [Param] = {
name: Name = StyleCommand[frame,text,proc];
RETURN [NEW [name ParamRec ← [nameOps, name, name[param]]]] };
realOps: Ops;
fontFaceOps: Ops;
lineFormattingOps: Ops;
the, smaller, bigger, percent, regular, bold, italic, bolditalic,
plusbold, plusitalic, minusbold, minusitalic,
capsAndLower, capsAndSmallCaps, lowerOnly, capsOnly,
none, lettersAndDigits, visible, all,
flush, centered, flushLeft, flushRight, justified,
no, before, after, around,
filled, outlined, filledAndOutlined,
fixed, relative, looks, breakIfPast, spaceIfPast,
blank, leaders, rule, rules, aligned, congruent: PUBLIC Name;
StartImpl2: PUBLIC PROCEDURE =
TRUSTED BEGIN
frame: Frame;
PointsPerInch: REAL = 1.0/0.0138370;
frame ← JaMOps.defaultFrame;
defaultStyle.name[style] ← defaultStyleName;
defaultStyle.name[fontFamily] ← MakeName["Helvetica"];
SetReal[defaultStyle,fontSize,10];
SetReal[defaultStyle,leading,12];
SetReal[defaultStyle,tabStops,4];
SetReal[defaultStyle,pageWidth,8.5*PointsPerInch];
SetReal[defaultStyle,pageLength,11*PointsPerInch];
SetReal[defaultStyle,leftMargin,1*PointsPerInch];
SetReal[defaultStyle,rightMargin,1*PointsPerInch];
SetReal[defaultStyle,topMargin,1*PointsPerInch];
SetReal[defaultStyle,bottomMargin,1*PointsPerInch];
SetReal[defaultStyle,lineLength,6.5*PointsPerInch];
specialOp ← DefineSpecialOp[frame,"SpecialOp",SpecialOp];
getFreeVarOp ← DefineSpecialOp[frame,"GetFreeVarOp",GetFreeVarOp];
getFreeVarObjOp ← DefineSpecialOp[frame,"GetFreeVarObjOp",GetFreeVarObjOp];
JaMOps.RegisterExplicit[frame,"StyleParam",StyleParam];
JaMOps.RegisterExplicit[frame,"isComment",IsComment];
JaMOps.RegisterExplicit[frame,"isPrint",IsPrint];
JaMOps.RegisterExplicit[frame,"nestingLevel",NestingLevel];
the ← StyleLiteral[frame,"the"];
smaller ← StyleLiteral[frame,"smaller"];
bigger ← StyleLiteral[frame,"bigger"];
percent ← StyleLiteral[frame,"percent"];
regular ← StyleLiteral[frame,"regular"];
bold ← StyleLiteral[frame,"bold"];
italic ← StyleLiteral[frame,"italic"];
bolditalic ← StyleLiteral[frame,"bold+italic"];
plusbold ← StyleLiteral[frame,"+bold"];
plusitalic ← StyleLiteral[frame,"+italic"];
minusbold ← StyleLiteral[frame,"-bold"];
minusitalic ← StyleLiteral[frame,"-italic"];
capsAndLower ← StyleLiteral[frame,"caps+lowercase"];
capsAndSmallCaps ← StyleLiteral[frame,"caps+smallcaps"];
lowerOnly ← StyleLiteral[frame,"lowercase"];
capsOnly ← StyleLiteral[frame,"caps"];
all ← StyleLiteral[frame,"all"];
visible ← StyleLiteral[frame,"visible"];
lettersAndDigits ← StyleLiteral[frame,"letters+digits"];
none ← StyleLiteral[frame,"none"];
justified ← StyleLiteral[frame,"justified"];
flush ← StyleLiteral[frame,"flush"];
flushLeft ← StyleLiteral[frame,"flushLeft"];
flushRight ← StyleLiteral[frame,"flushRight"];
filled ← StyleLiteral[frame,"filled"];
outlined ← StyleLiteral[frame,"outlined"];
filled ← StyleLiteral[frame,"filled"];
filledAndOutlined ← StyleLiteral[frame,"filled+outlined"];
centered ← StyleLiteral[frame,"centered"];
no ← StyleLiteral[frame,"no"];
before ← StyleLiteral[frame,"before"];
after ← StyleLiteral[frame,"after"];
fixed ← StyleLiteral[frame,"fixed"];
around ← StyleLiteral[frame,"around"];
relative ← StyleLiteral[frame,"relative"];
looks ← StyleLiteral[frame,"looks"];
breakIfPast ← StyleLiteral[frame,"breakIfPast"];
spaceIfPast ← StyleLiteral[frame,"spaceIfPast"];
blank ← StyleLiteral[frame,"blank"];
leaders ← StyleLiteral[frame,"leaders"];
rule ← StyleLiteral[frame,"rule"];
rules ← StyleLiteral[frame,"rules"];
aligned ← StyleLiteral[frame,"aligned"];
congruent ← StyleLiteral[frame,"congruent"];
initialize the params
fontFaceOps ← NEW [OpsRec ← [FontFaceLoad, StoreError,
AddRealError, PercentError, FontFaceSetName]];
fontFaceParam ← NEW[misc ParamRec ← [fontFaceOps,
StyleCommand[frame,"face",FontFaceOp], misc[]]];
fontAlphabetsOps ← NEW [OpsRec ← [FontAlphabetsLoad, StoreError,
AddRealError, PercentError, FontAlphabetsSetName]];
fontAlphabetsParam ← NEW[misc ParamRec ← [fontAlphabetsOps,
StyleCommand[frame,"alphabets",FontAlphabetsOp], misc[]]];
underliningOps ← NEW [OpsRec ← [UnderliningLoad, StoreError,
AddRealError, PercentError, UnderliningSetName]];
underliningParam ← NEW [misc ParamRec ← [underliningOps,
StyleCommand[frame,"underlining",UnderliningOp], misc[]]];
strikeoutOps ← NEW [OpsRec ← [StrikeoutLoad, StoreError,
AddRealError, PercentError, StrikeoutSetName]];
strikeoutParam ← NEW [misc ParamRec ← [strikeoutOps,
StyleCommand[frame,"strikeout",StrikeoutOp], misc[]]];
lineFormattingOps ← NEW [OpsRec ← [LineFormattingLoad, StoreError,
AddRealError, PercentError, LineFormattingSetName]];
lineFormattingParam ← NEW [misc ParamRec ← [lineFormattingOps,
StyleCommand[frame,"lineFormatting",LineFormattingOp], misc[]]];
pathTypeOps ← NEW [OpsRec ← [PathTypeLoad, StoreError,
AddRealError, PercentError, PathTypeSetName]];
pathTypeParam ← NEW [misc ParamRec ← [pathTypeOps,
StyleCommand[frame,"pathType",PathTypeOp], misc[]]];
forceBreakOps ← NEW [OpsRec ← [ForceBreakLoad, StoreError,
AddRealError, PercentError, ForceBreakSetName]];
forceBreakParam ← NEW [misc ParamRec ← [forceBreakOps,
StyleCommand[frame,"forceBreak",ForceBreakOp], misc[]]];
nameOps ← NEW [OpsRec ← [LoadNameParam, StoreError,
AddRealError, PercentError, SetNameParam]];
styleParam ← DefineNameOp[frame, "style", StyleNameOp, style];
fontFamilyParam ← DefineNameOp[frame, "family", FontFamilyOp, fontFamily];
realOps ← NEW [OpsRec ←
[RealOpLoad, RealOpSetReal, RealOpAddReal, RealOpPercent, SetNameError]];
glueOps ← NEW [OpsRec ←
[GlueOpLoad, GlueOpSetReal, GlueOpAddReal, GlueOpPercent, SetNameError]];
colorOps ← NEW [OpsRec ←
[ColorOpLoad, ColorOpSetReal, ColorOpAddReal, ColorOpPercent, SetNameError]];
fontSizeParam ← DefineRealOp[frame, "size", FontSizeOp, fontSize];
leftIndentParam ← DefineRealOp[frame, "leftIndent", LeftIndentOp, leftIndent];
rightIndentParam ← DefineRealOp[frame, "rightIndent", RightIndentOp, rightIndent];
firstIndentParam ← DefineRealOp[frame, "firstIndent", FirstIndentOp, firstIndent];
restIndentParam ← DefineRealOp[frame, "restIndent", RestIndentOp, restIndent];
topIndentParam ← DefineRealOp[frame, "topIndent", TopIndentOp, topIndent];
bottomIndentParam ←
DefineRealOp[frame, "bottomIndent", BottomIndentOp, bottomIndent];
lineLeadingSizeParam ←
DefineRealOp[frame, "leading", LineLeadingSizeOp, leading];
lineLeadingStretchParam ←
DefineRealOp[frame, "leadingStretch", LineLeadingStretchOp, leadingStretch];
lineLeadingShrinkParam ←
DefineRealOp[frame, "leadingShrink", LineLeadingShrinkOp, leadingShrink];
lineLeadingGlueParam ← DefineGlueOp[frame, "leadingGlue",
LineLeadingGlueOp, leading, leadingStretch, leadingShrink];
topLeadingSizeParam ←
DefineRealOp[frame, "topLeading", TopLeadingSizeOp, topLeading];
topLeadingStretchParam ←
DefineRealOp[frame, "topLeadingStretch", TopLeadingStretchOp, topLeadingStretch];
topLeadingShrinkParam ←
DefineRealOp[frame, "topLeadingShrink", TopLeadingShrinkOp, topLeadingShrink];
topLeadingGlueParam ← DefineGlueOp[frame, "topLeadingGlue",
TopLeadingGlueOp, topLeading, topLeadingStretch, topLeadingShrink];
bottomLeadingSizeParam ←
DefineRealOp[frame, "bottomLeading", BottomLeadingSizeOp, bottomLeading];
bottomLeadingStretchParam ←
DefineRealOp[frame, "bottomLeadingStretch",
BottomLeadingStretchOp, bottomLeadingStretch];
bottomLeadingShrinkParam ←
DefineRealOp[frame, "bottomLeadingShrink",
BottomLeadingShrinkOp, bottomLeadingShrink];
bottomLeadingGlueParam ← DefineGlueOp[frame, "bottomLeadingGlue",
BottomLeadingGlueOp, bottomLeading, bottomLeadingStretch, bottomLeadingShrink];
vshiftParam ←
DefineRealOp[frame, "vShift", VShiftOp, vshift];
tabStopsParam ←
DefineRealOp[frame, "tabStops", TabStopsOp, tabStops];
minLineGapParam ←
DefineRealOp[frame, "minLineGap", MinLineGapOp, minLineGap];
lineWeightParam ←
DefineRealOp[frame, "lineWeight", LineWeightOp, lineWeight];
pageWidthParam ←
DefineRealOp[frame, "pageWidth", PageWidthOp, pageWidth];
pageLengthParam ←
DefineRealOp[frame, "pageLength", PageLengthOp, pageLength];
leftMarginParam ←
DefineRealOp[frame, "leftMargin", LeftMarginOp, leftMargin];
rightMarginParam ←
DefineRealOp[frame, "rightMargin", RightMarginOp, rightMargin];
topMarginParam ←
DefineRealOp[frame, "topMargin", TopMarginOp, topMargin];
bottomMarginParam ←
DefineRealOp[frame, "bottomMargin", BottomMarginOp, bottomMargin];
headerMarginParam ←
DefineRealOp[frame, "headerMargin", HeaderMarginOp, headerMargin];
footerMarginParam ←
DefineRealOp[frame, "footerMargin", FooterMarginOp, footerMargin];
bindingMarginParam ←
DefineRealOp[frame, "bindingMargin", BindingMarginOp, bindingMargin];
lineLengthParam ←
DefineRealOp[frame, "lineLength", LineLengthOp, lineLength];
columnParam ←
DefineRealOp[frame, "column", ColumnOp, column];
textRotationParam ←
DefineRealOp[frame, "textRotation", TextRotationOp, textRotation];
areaHueParam ←
DefineRealOp[frame, "areaHue", AreaHueOp, areaHue];
areaSaturationParam ←
DefineRealOp[frame, "areaSaturation", AreaSaturationOp, areaSaturation];
areaBrightnessParam ←
DefineRealOp[frame, "areaBrightness", AreaBrightnessOp, areaBrightness];
areaColorParam ← DefineColorOp[frame, "areaColor",
AreaColorOp, areaHue, areaSaturation, areaBrightness];
outlineHueParam ←
DefineRealOp[frame, "outlineHue", OutlineHueOp, outlineHue];
outlineSaturationParam ←
DefineRealOp[frame, "outlineSaturation", OutlineSaturationOp, outlineSaturation];
outlineBrightnessParam ←
DefineRealOp[frame, "outlineBrightness", OutlineBrightnessOp, outlineBrightness];
outlineColorParam ← DefineColorOp[frame, "outlineColor",
OutlineColorOp, outlineHue, outlineSaturation, outlineBrightness];
textHueParam ←
DefineRealOp[frame, "textHue", TextHueOp, textHue];
textSaturationParam ←
DefineRealOp[frame, "textSaturation", TextSaturationOp, textSaturation];
textBrightnessParam ←
DefineRealOp[frame, "textBrightness", TextBrightnessOp, textBrightness];
textColorParam ← DefineColorOp[frame, "textColor",
TextColorOp, textHue, textSaturation, textBrightness];
pageBreakPenaltyParam ← DefineRealOp[frame, "pageBreakPenalty",
PageBreakPenaltyOp, pageBreakPenalty];
pageBreakPenalty2Param ← DefineRealOp[frame, "pageBreakAfterFirstLinePenalty",
PageBreakPenalty2Op, pageBreakAfterFirstLinePenalty];
pageBreakPenalty3Param ← DefineRealOp[frame, "pageBreakAfterLastLinePenalty",
PageBreakPenalty3Op, pageBreakAfterLastLinePenalty];
pageBreakPenalty4Param ← DefineRealOp[frame, "pageBreakBeforeFirstLinePenalty",
PageBreakPenalty4Op, pageBreakBeforeFirstLinePenalty];
pageBreakPenalty5Param ← DefineRealOp[frame, "pageBreakBeforeLastLinePenalty",
PageBreakPenalty5Op, pageBreakBeforeLastLinePenalty];
JaMOps.End[frame]; -- replace sysdict by userdict
JaMOps.Begin[frame,userdict];
END;
END.