DIRECTORY ChoiceButtons USING [EnumTypeRef, GetSelectedButton], IO USING [EndOfStream, GetTokenRope, RIS, PutFR, real], MessageWindow USING [Append, Blink], NodeStyle USING [FontFace, GetBindingMargin, GetBottomIndent, GetBottomLeading, GetBottomLeadingShrink, GetBottomLeadingStretch, GetBottomMargin, GetFirstIndent, GetFontSize, GetLeading, GetLeadingStretch, GetLeadingShrink, GetLeftIndent, GetLeftMargin, GetMinLineGap, GetPageLength, GetPageWidth, GetRestIndent, GetRightIndent, GetRightMargin, GetTabStops, GetTopIndent, GetTopLeading, GetTopLeadingStretch, GetTopLeadingShrink, GetTopMargin, GetVShift, GetReal, RealParam, Ref], Real USING [FixC], Rope USING [ROPE, Cat, Equal, Size], StyleToolDefs, StyleToolConvert USING [BadNumber, ConvertUnits, FontAlphChoiceToJaM, GetFontFamily, GetFontFaceJaM, GetFontAlphabetsChoice, GetFontUnderliningChoice, FontUndChoiceToJaM, GetLineFormattingChoice, LineChoiceToJaM, GetRealFromViewer], StyleToolToJaM, VFonts USING [Error, EstablishFont], ViewerClasses USING [Viewer], ViewerTools USING [GetContents, SetContents, SetSelection]; StyleToolToJaMImpl: CEDAR PROGRAM IMPORTS ChoiceButtons, IO, MessageWindow, NodeStyle, Real, Rope, StyleToolConvert, StyleToolDefs, VFonts, ViewerTools EXPORTS StyleToolToJaM = BEGIN OPEN StyleToolDefs, StyleToolToJaM; NoName: SIGNAL = CODE; GetNameFromViewer: PRIVATE PROCEDURE [viewer: ViewerClasses.Viewer] RETURNS [nameRope: Rope.ROPE] = { nameRope _ ViewerTools.GetContents[viewer]; IF Rope.Size[nameRope] = 0 THEN SIGNAL NoName ELSE { nameRope _ GetEssentialsOfName[nameRope]; IF Rope.Size[nameRope] = 0 THEN SIGNAL NoName; }; }; GetEssentialsOfName: PRIVATE PROC [name: Rope.ROPE] RETURNS [realName: Rope.ROPE] = { realName _ IO.GetTokenRope[IO.RIS[name] ! IO.EndOfStream => CONTINUE].token; }; WriteDisplayInfo: PUBLIC PROCEDURE [handle: StyleToolHandle, info: NodeStyle.Ref, format: BOOLEAN] = BEGIN displayRope: Rope.ROPE _ ""; nameRope: Rope.ROPE _ GetNameFromViewer[handle.styleNameData.textViewer ! NoName => GOTO CouldntWriteStyleName]; formatNameRope, looksRope, ruleRope: Rope.ROPE; found: BOOLEAN; ViewerTools.SetContents[handle.swap.jamCodeInfo.text, NIL]; ruleRope _ ChoiceButtons.GetSelectedButton[handle.ruleType]; IF ~ handle.changesMode THEN { IF format THEN { formatNameRope _ GetNameFromViewer[handle.formatNameData.textViewer ! NoName => GOTO CouldntWriteFormat]; displayRope _ Rope.Cat[displayRope, "(", formatNameRope, ") {\n"]; } ELSE { looksRope _ GetNameFromViewer[handle.looksData.textViewer ! NoName => GOTO CouldntWriteLook]; displayRope _ Rope.Cat[displayRope, "(look.", looksRope, ") {\n"]; }; }; [displayRope, found] _ AppendFontInfoRope[handle, info, displayRope]; IF found THEN { displayRope _ AppendIndentInfoRope[handle, info, displayRope]; displayRope _ AppendLeadingInfoRope[handle, info, displayRope]; displayRope _ AppendMiscInfoRope[handle, info, displayRope]; IF ~Rope.Equal[ruleRope, "ScreenRule", FALSE] THEN { displayRope _ AppendPenaltyInfoRope[handle, info, displayRope]; displayRope _ AppendPageInfoRope[handle, info, displayRope]; }; IF ~ handle.changesMode THEN displayRope _ Rope.Cat[displayRope, "} ", ruleRope, "\n"]; ViewerTools.SetContents[handle.swap.jamCodeInfo.text, displayRope]; }; EXITS CouldntWriteStyleName => {OPEN MessageWindow; Append["Couldn't write style. No valid style name given.", TRUE]; Blink[]; ViewerTools.SetSelection[handle.styleNameData.textViewer]; }; CouldntWriteFormat => {OPEN MessageWindow; Append["Couldn't write style. No valid Format name given.", TRUE]; Blink[]; ViewerTools.SetSelection[handle.formatNameData.textViewer]; }; CouldntWriteLook => {OPEN MessageWindow; Append["Couldn't write style. No valid Look name given.", TRUE]; Blink[]; ViewerTools.SetSelection[handle.looksData.textViewer]; }; END; RopeDifferences: PRIVATE PROC[handle: StyleToolHandle, selection, default, nodeInfo: Rope.ROPE] RETURNS [BOOLEAN] = { IF handle.changesMode THEN { IF ~Rope.Equal[selection, default, FALSE] AND ~Rope.Equal[selection, nodeInfo, FALSE] THEN RETURN [TRUE] ELSE RETURN [FALSE]; } ELSE { IF ~Rope.Equal[selection, default, FALSE] THEN RETURN [TRUE] ELSE RETURN [FALSE]; }; }; RealDifferences: PRIVATE PROC[handle: StyleToolHandle, selection, default, nodeInfo: REAL] RETURNS [BOOLEAN] = { IF handle.changesMode THEN { IF (selection # default) AND (selection # nodeInfo) THEN RETURN [TRUE] ELSE RETURN [FALSE]; } ELSE { IF (selection # default) THEN RETURN [TRUE] ELSE RETURN [FALSE]; }; }; IntDifferences: PRIVATE PROC[handle: StyleToolHandle, selection, default, nodeInfo: INTEGER] RETURNS [BOOLEAN] = { IF handle.changesMode THEN { IF (selection # default) AND (selection # nodeInfo) THEN RETURN [TRUE] ELSE RETURN [FALSE]; } ELSE { IF (selection # default) THEN RETURN [TRUE] ELSE RETURN [FALSE]; }; }; AppendUnits: PRIVATE PROCEDURE [displayRope, units: Rope.ROPE] RETURNS [Rope.ROPE] = { SELECT TRUE FROM Rope.Equal[units, "points", FALSE] => displayRope _ Rope.Cat[displayRope, " pt"]; Rope.Equal[units, "picas", FALSE] => displayRope _ Rope.Cat[displayRope, " pc"]; Rope.Equal[units, "inches", FALSE] => displayRope _ Rope.Cat[displayRope, " in"]; Rope.Equal[units, "centimeters", FALSE] => displayRope _ Rope.Cat[displayRope, " cm"]; Rope.Equal[units, "millimeters", FALSE] => displayRope _ Rope.Cat[displayRope, " mm"]; Rope.Equal[units, "didot points", FALSE] => displayRope _ Rope.Cat[displayRope, " dd"]; Rope.Equal[units, "ems", FALSE] => displayRope _ Rope.Cat[displayRope, " em"]; Rope.Equal[units, "ens", FALSE] => displayRope _ Rope.Cat[displayRope, " en"]; Rope.Equal[units, "spaces", FALSE] => displayRope _ Rope.Cat[displayRope, " sp"]; ENDCASE; RETURN[displayRope]; }; AppendValueAndUnits: PRIVATE PROCEDURE [handle: StyleToolHandle, displayRope: Rope.ROPE, selection, default, nodeInfo: REAL, addOn: Rope.ROPE, units: ChoiceButtons.EnumTypeRef] RETURNS [Rope.ROPE] = { IF RealDifferences[handle, selection, default, nodeInfo] THEN { displayRope _ Rope.Cat[displayRope, IO.PutFR[realNumberFormat, IO.real[selection]]]; displayRope _ AppendUnits[displayRope, units.flipLabel.name]; displayRope _ Rope.Cat[displayRope, " ", addOn, "\n"]; } ELSE { selectionOnRope: Rope.ROPE _ ChoiceButtons.GetSelectedButton[units]; IF ~Rope.Equal[selectionOnRope, "points", FALSE] THEN { displayRope _ Rope.Cat[displayRope," ", IO.PutFR[realNumberFormat, IO.real[selection]]]; displayRope _ AppendUnits[displayRope,units.flipLabel.name]; displayRope _ Rope.Cat[displayRope, " ", addOn, "\n"]; }; }; RETURN [displayRope]; }; GetReal: PRIVATE PROCEDURE [valueAndUnits: ValueAndUnitsRef] RETURNS [num: REAL] = BEGIN num _ 0; -- default to zero in case there's a bad number in the viewer. We want to return IF valueAndUnits.valueData.textViewer.newVersion THEN num _ StyleToolConvert.GetRealFromViewer[valueAndUnits.valueData.textViewer ! StyleToolConvert.BadNumber => CONTINUE] ELSE { num _ valueAndUnits.originalValue; num _ StyleToolConvert.ConvertUnits[num, valueAndUnits.originalUnits, valueAndUnits.units.flipLabel.name]; }; END; AppendFontInfoRope: PUBLIC PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [returnRope: Rope.ROPE, found: BOOLEAN] = BEGIN selectionOnRope, nodeInfoRope, defaultRope: Rope.ROPE; selectionReal, nodeInfoReal, defaultReal: REAL; bold, italic: BOOLEAN; fontFamily: Rope.ROPE _ NIL; fontSize: CARDINAL; found _ TRUE; selectionOnRope _ ChoiceButtons.GetSelectedButton[handle.display.fontFamilyChoice]; IF ~Rope.Equal[selectionOnRope, "none", FALSE] THEN { IF Rope.Equal[selectionOnRope, "other", FALSE] THEN { selectionOnRope _ GetNameFromViewer[handle.display.fontFamilyOtherViewer]; defaultRope _ StyleToolConvert.GetFontFamily[default.name[fontFamily]].text; nodeInfoRope _ StyleToolConvert.GetFontFamily[handle.nodeInfo.name[fontFamily]].text; } ELSE { defaultRope _ StyleToolConvert.GetFontFamily[default.name[fontFamily]].name; nodeInfoRope _ StyleToolConvert.GetFontFamily[handle.nodeInfo.name[fontFamily]].name; }; fontFamily _ selectionOnRope; IF RopeDifferences[handle, selectionOnRope, defaultRope, nodeInfoRope] THEN displayRope _ Rope.Cat[displayRope, """", selectionOnRope, """", " family\n"]; }; defaultRope _ StyleToolConvert.GetFontFaceJaM[default.fontFace]; nodeInfoRope _ StyleToolConvert.GetFontFaceJaM[handle.nodeInfo.fontFace]; IF RopeDifferences[handle, selectionOnRope, defaultRope, nodeInfoRope] THEN displayRope _ Rope.Cat[displayRope, selectionOnRope, " face\n"]; [displayRope, bold, italic] _ AppendFontFace[handle, default, displayRope]; selectionReal_ GetReal[handle.display.fontSizeInfo]; defaultReal _ NodeStyle.GetFontSize[default]; nodeInfoReal _ NodeStyle.GetFontSize[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "size", handle.display.fontSizeInfo.units]; fontSize _ Real.FixC[selectionReal]; IF fontFamily # NIL THEN { [] _ VFonts.EstablishFont[fontFamily, fontSize, bold, italic, FALSE ! VFonts.Error => SELECT code FROM illegalFormat => CONTINUE; fontNotFound => { -- Try again with bold and italic turned off because those will be synthesized [] _ VFonts.EstablishFont[fontFamily, fontSize, FALSE, FALSE, FALSE ! VFonts.Error => { MessageWindow.Append["Font specified cannot be found", TRUE]; MessageWindow.Blink[]; found _ FALSE; CONTINUE; } ]; CONTINUE; }; ENDCASE => ERROR; ] }; selectionOnRope _ ChoiceButtons.GetSelectedButton[handle.display.fontAlphabetsChoice]; defaultRope _ StyleToolConvert.GetFontAlphabetsChoice[default.fontAlphabets]; nodeInfoRope _ StyleToolConvert.GetFontAlphabetsChoice[handle.nodeInfo.fontAlphabets]; IF RopeDifferences[handle, selectionOnRope, defaultRope, nodeInfoRope] THEN displayRope _ Rope.Cat[displayRope, StyleToolConvert.FontAlphChoiceToJaM[selectionOnRope], " alphabets\n"]; selectionOnRope _ ChoiceButtons.GetSelectedButton[handle.display.fontUnderliningChoice]; defaultRope _ StyleToolConvert.GetFontUnderliningChoice[default.underlining]; nodeInfoRope _ StyleToolConvert.GetFontUnderliningChoice[handle.nodeInfo.underlining]; IF RopeDifferences[handle, selectionOnRope, defaultRope, nodeInfoRope] THEN displayRope _ Rope.Cat[displayRope, StyleToolConvert.FontUndChoiceToJaM[selectionOnRope], " underlining\n"]; returnRope _ displayRope; END; AppendFontFace: PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [returnRope: Rope.ROPE, bold, italic: BOOLEAN] = BEGIN face: NodeStyle.FontFace; bold _ italic _ FALSE; IF (handle.display.boldFontFace.state=default AND handle.display.italicFontFace.state=default) OR (handle.display.boldFontFace.state=default AND handle.display.italicFontFace.state=off) OR (handle.display.boldFontFace.state=off AND handle.display.italicFontFace.state=default) THEN RETURN[displayRope, bold, italic] -- dont do anything if default and off ELSE IF handle.display.boldFontFace.state = off AND handle.display.italicFontFace.state = off THEN face _ Regular ELSE IF handle.display.boldFontFace.state = on AND handle.display.italicFontFace.state # on THEN {face _ Bold; bold _ TRUE} ELSE IF handle.display.boldFontFace.state # on AND handle.display.italicFontFace.state = on THEN {face _ Italic; italic _ TRUE} ELSE IF handle.display.boldFontFace.state = on AND handle.display.italicFontFace.state = on THEN {face _ BoldItalic; bold _ TRUE; italic _ TRUE}; IF default.fontFace # face AND handle.nodeInfo.fontFace # face THEN displayRope _ Rope.Cat[displayRope, StyleToolConvert.GetFontFaceJaM[face], " face\n"]; returnRope _ displayRope; END; AppendIndentInfoRope: PUBLIC PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [Rope.ROPE] = BEGIN selectionReal, nodeInfoReal, defaultReal: REAL; selectionReal _ GetReal[handle.display.leftIndentInfo]; defaultReal _ NodeStyle.GetLeftIndent[default]; nodeInfoReal _ NodeStyle.GetLeftIndent[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "leftIndent", handle.display.leftIndentInfo.units]; selectionReal _ GetReal[handle.display.rightIndentInfo]; defaultReal _ NodeStyle.GetRightIndent[default]; nodeInfoReal _ NodeStyle.GetRightIndent[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "rightIndent", handle.display.rightIndentInfo.units]; selectionReal _ GetReal[handle.display.firstIndentInfo]; defaultReal _ NodeStyle.GetFirstIndent[default]; nodeInfoReal _ NodeStyle.GetFirstIndent[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "firstIndent", handle.display.firstIndentInfo.units]; selectionReal _ GetReal[handle.display.restIndentInfo]; defaultReal _ NodeStyle.GetRestIndent[default]; nodeInfoReal _ NodeStyle.GetRestIndent[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "restIndent", handle.display.restIndentInfo.units]; selectionReal _ GetReal[handle.display.topIndentInfo]; defaultReal _ NodeStyle.GetTopIndent[default]; nodeInfoReal _ NodeStyle.GetTopIndent[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "topIndent", handle.display.topIndentInfo.units]; selectionReal _ GetReal[handle.display.bottomIndentInfo]; defaultReal _ NodeStyle.GetBottomIndent[default]; nodeInfoReal _ NodeStyle.GetBottomIndent[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "bottomIndent", handle.display.bottomIndentInfo.units]; RETURN[displayRope]; END; AppendLeadingInfoRope: PUBLIC PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [Rope.ROPE] = BEGIN leadingReal, stretchReal, shrinkReal, nodeInfoReal, defaultReal: REAL; AppendGlue: PROCEDURE [displayRope: Rope.ROPE, units: ChoiceButtons.EnumTypeRef, addOn: Rope.ROPE] RETURNS [Rope.ROPE] = { measure: Rope.ROPE _ ChoiceButtons.GetSelectedButton[units]; leadingReal _ StyleToolConvert.ConvertUnits[leadingReal, measure, "points"]; stretchReal _ StyleToolConvert.ConvertUnits[stretchReal, measure, "points"]; shrinkReal _ StyleToolConvert.ConvertUnits[shrinkReal, measure, "points"]; displayRope _ Rope.Cat[displayRope, IO.PutFR[realNumberFormat, IO.real[leadingReal]], " "]; displayRope _ Rope.Cat[displayRope, IO.PutFR[realNumberFormat, IO.real[stretchReal]], " ", IO.PutFR[realNumberFormat, IO.real[shrinkReal]]]; displayRope _ Rope.Cat[displayRope, " ", addOn, "\n"]; RETURN[displayRope]; }; GetStretchShrink: PROC [leadingInfo: LeadingRef] RETURNS [stretch, shrink: REAL] = { stretch _ shrink _ 0; IF leadingInfo.stretch.textViewer.newVersion THEN stretch _ StyleToolConvert.GetRealFromViewer[leadingInfo.stretch.textViewer ! StyleToolConvert.BadNumber => CONTINUE] ELSE stretch _ leadingInfo.originalStretch; IF leadingInfo.shrink.textViewer.newVersion THEN shrink _ StyleToolConvert.GetRealFromViewer[leadingInfo.shrink.textViewer ! StyleToolConvert.BadNumber => CONTINUE] ELSE shrink _ leadingInfo.originalShrink; }; leadingReal _ GetReal[handle.display.leadingInfo.leading]; [stretchReal, shrinkReal] _ GetStretchShrink[handle.display.leadingInfo]; defaultReal _ NodeStyle.GetLeadingStretch[default]; nodeInfoReal _ NodeStyle.GetLeadingStretch[handle.nodeInfo]; IF RealDifferences[handle, stretchReal, defaultReal, nodeInfoReal] THEN displayRope _ AppendGlue[displayRope, handle.display.leadingInfo.leading.units, "leadingGlue"] ELSE { defaultReal _ NodeStyle.GetLeadingShrink[default]; nodeInfoReal _ NodeStyle.GetLeadingShrink[handle.nodeInfo]; IF RealDifferences[handle, shrinkReal, defaultReal, nodeInfoReal] THEN displayRope _ AppendGlue[displayRope, handle.display.leadingInfo.leading.units, "leadingGlue"] ELSE { defaultReal _ NodeStyle.GetLeading[default]; nodeInfoReal _ NodeStyle.GetLeading[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, leadingReal, defaultReal, nodeInfoReal, "leading", handle.display.leadingInfo.leading.units]; }; }; leadingReal _ GetReal[handle.display.topLeadingInfo.leading]; [stretchReal, shrinkReal] _ GetStretchShrink[handle.display.topLeadingInfo]; defaultReal _ NodeStyle.GetTopLeadingStretch[default]; nodeInfoReal _ NodeStyle.GetTopLeadingStretch[handle.nodeInfo]; IF RealDifferences[handle, stretchReal, defaultReal, nodeInfoReal] THEN displayRope _ AppendGlue[displayRope, handle.display.topLeadingInfo.leading.units, "topLeadingGlue"] ELSE { defaultReal _ NodeStyle.GetTopLeadingShrink[default]; nodeInfoReal _ NodeStyle.GetTopLeadingShrink[handle.nodeInfo]; IF RealDifferences[handle, shrinkReal, defaultReal, nodeInfoReal] THEN displayRope _ AppendGlue[displayRope, handle.display.topLeadingInfo.leading.units, "topLeadingGlue"] ELSE { defaultReal _ NodeStyle.GetTopLeading[default]; nodeInfoReal _ NodeStyle.GetTopLeading[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, leadingReal, defaultReal, nodeInfoReal, "topLeading", handle.display.topLeadingInfo.leading.units]; }; }; leadingReal _ GetReal[handle.display.bottomLeadingInfo.leading]; [stretchReal, shrinkReal] _ GetStretchShrink[handle.display.bottomLeadingInfo]; defaultReal _ NodeStyle.GetBottomLeadingStretch[default]; nodeInfoReal _ NodeStyle.GetBottomLeadingStretch[handle.nodeInfo]; IF RealDifferences[handle, stretchReal, defaultReal, nodeInfoReal] THEN displayRope _ AppendGlue[displayRope, handle.display.bottomLeadingInfo.leading.units, "bottomLeadingGlue"] ELSE { defaultReal _ NodeStyle.GetBottomLeadingShrink[default]; nodeInfoReal _ NodeStyle.GetBottomLeadingShrink[handle.nodeInfo]; IF RealDifferences[handle, shrinkReal, defaultReal, nodeInfoReal] THEN displayRope _ AppendGlue[displayRope, handle.display.bottomLeadingInfo.leading.units, "bottomLeadingGlue"] ELSE { defaultReal _ NodeStyle.GetBottomLeading[default]; nodeInfoReal _ NodeStyle.GetBottomLeading[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, leadingReal, defaultReal, nodeInfoReal, "bottomLeading", handle.display.bottomLeadingInfo.leading.units]; }; }; RETURN[displayRope]; END; AppendMiscInfoRope: PUBLIC PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [Rope.ROPE] = BEGIN selectionOnRope, nodeInfoRope, defaultRope: Rope.ROPE; selectionReal, defaultReal, nodeInfoReal: REAL; selectionReal _ GetReal[handle.display.vshiftInfo]; defaultReal _ NodeStyle.GetVShift[default]; nodeInfoReal _ NodeStyle.GetVShift[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "vShift", handle.display.vshiftInfo.units]; selectionReal _ GetReal[handle.display.minLineGapInfo]; defaultReal _ NodeStyle.GetMinLineGap[default]; nodeInfoReal _ NodeStyle.GetMinLineGap[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "minLineGap", handle.display.minLineGapInfo.units]; selectionReal _ StyleToolConvert.GetRealFromViewer[ handle.display.tabStopsViewer ! StyleToolConvert.BadNumber => CONTINUE]; defaultReal _ NodeStyle.GetTabStops[default]; nodeInfoReal _ NodeStyle.GetTabStops[handle.nodeInfo]; IF RealDifferences[handle, selectionReal, defaultReal, nodeInfoReal] THEN displayRope _ Rope.Cat[displayRope,ViewerTools.GetContents[handle.display.tabStopsViewer], " sp tabStops\n"]; selectionOnRope _ ChoiceButtons.GetSelectedButton[handle.display.lineFormattingChoice]; defaultRope _ StyleToolConvert.GetLineFormattingChoice[default.lineFormatting]; nodeInfoRope _ StyleToolConvert.GetLineFormattingChoice[handle.nodeInfo.lineFormatting]; IF RopeDifferences[handle, selectionOnRope, defaultRope, nodeInfoRope] THEN displayRope _ Rope.Cat[displayRope, StyleToolConvert.LineChoiceToJaM[selectionOnRope], " lineFormatting\n"]; RETURN[displayRope]; END; AppendPenaltyInfoRope: PUBLIC PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [Rope.ROPE] = BEGIN selectionReal, defaultReal, nodeInfoReal: REAL; selectionReal _ StyleToolConvert.GetRealFromViewer[ handle.swap.penalty.pageBreakPenalty ! StyleToolConvert.BadNumber => CONTINUE]; defaultReal _ NodeStyle.GetReal[default, pageBreakPenalty]; nodeInfoReal _ NodeStyle.GetReal[handle.nodeInfo, pageBreakPenalty]; IF RealDifferences[handle, selectionReal, defaultReal, nodeInfoReal] THEN displayRope _ Rope.Cat[displayRope, ViewerTools.GetContents[handle.swap.penalty.pageBreakPenalty]," pageBreakPenalty\n"]; selectionReal _ StyleToolConvert.GetRealFromViewer[ handle.swap.penalty.afterFirstLinePenalty ! StyleToolConvert.BadNumber => CONTINUE]; defaultReal _ NodeStyle.GetReal[default, pageBreakAfterFirstLinePenalty]; nodeInfoReal _ NodeStyle.GetReal[handle.nodeInfo, pageBreakAfterFirstLinePenalty]; IF RealDifferences[handle, selectionReal, defaultReal, nodeInfoReal] THEN displayRope _ Rope.Cat[displayRope, ViewerTools.GetContents[handle.swap.penalty.afterFirstLinePenalty], " pageBreakAfterFirstLinePenalty\n"]; selectionReal _ StyleToolConvert.GetRealFromViewer[ handle.swap.penalty.beforeLastLinePenalty ! StyleToolConvert.BadNumber => CONTINUE]; defaultReal _ NodeStyle.GetReal[default, pageBreakBeforeLastLinePenalty]; nodeInfoReal _ NodeStyle.GetReal[handle.nodeInfo, pageBreakBeforeLastLinePenalty]; IF RealDifferences[handle, selectionReal, defaultReal, nodeInfoReal] THEN displayRope _ Rope.Cat[displayRope, ViewerTools.GetContents[handle.swap.penalty.beforeLastLinePenalty], " pageBreakBeforeLastLinePenalty\n"]; selectionReal _ StyleToolConvert.GetRealFromViewer[ handle.swap.penalty.beforeFirstLinePenalty ! StyleToolConvert.BadNumber => CONTINUE]; defaultReal _ NodeStyle.GetReal[default, pageBreakBeforeFirstLinePenalty]; nodeInfoReal _ NodeStyle.GetReal[handle.nodeInfo, pageBreakBeforeFirstLinePenalty]; IF RealDifferences[handle, selectionReal, defaultReal, nodeInfoReal] THEN displayRope _ Rope.Cat[displayRope, ViewerTools.GetContents[handle.swap.penalty.beforeFirstLinePenalty], " pageBreakBeforeFirstLinePenalty\n"]; selectionReal _ StyleToolConvert.GetRealFromViewer[ handle.swap.penalty.afterLastLinePenalty ! StyleToolConvert.BadNumber => CONTINUE]; defaultReal _ NodeStyle.GetReal[default, pageBreakAfterLastLinePenalty]; nodeInfoReal _ NodeStyle.GetReal[handle.nodeInfo, pageBreakAfterLastLinePenalty]; IF RealDifferences[handle, selectionReal, defaultReal, nodeInfoReal] THEN displayRope _ Rope.Cat[displayRope, ViewerTools.GetContents[handle.swap.penalty.afterLastLinePenalty], " pageBreakAfterLastLinePenalty\n"]; RETURN[displayRope]; END; AppendPageInfoRope: PUBLIC PROCEDURE [handle: StyleToolHandle, default: NodeStyle.Ref, displayRope: Rope.ROPE] RETURNS [Rope.ROPE] = BEGIN selectionReal, defaultReal, nodeInfoReal: REAL; selectionReal _ GetReal[handle.swap.layout.pageWidth]; defaultReal _ NodeStyle.GetPageWidth[default]; nodeInfoReal _ NodeStyle.GetPageWidth[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "pageWidth", handle.swap.layout.pageWidth.units]; selectionReal _ GetReal[handle.swap.layout.pageLength]; defaultReal _ NodeStyle.GetPageLength[default]; nodeInfoReal _ NodeStyle.GetPageLength[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "pageLength", handle.swap.layout.pageLength.units]; selectionReal _ GetReal[handle.swap.layout.leftMargin]; defaultReal _ NodeStyle.GetLeftMargin[default]; nodeInfoReal _ NodeStyle.GetLeftMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "leftMargin", handle.swap.layout.leftMargin.units]; selectionReal _ GetReal[handle.swap.layout.rightMargin]; defaultReal _ NodeStyle.GetRightMargin[default]; nodeInfoReal _ NodeStyle.GetRightMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "rightMargin", handle.swap.layout.rightMargin.units]; selectionReal _ GetReal[handle.swap.layout.topMargin]; defaultReal _ NodeStyle.GetTopMargin[default]; nodeInfoReal _ NodeStyle.GetTopMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "topMargin", handle.swap.layout.topMargin.units]; selectionReal _ GetReal[handle.swap.layout.bottomMargin]; defaultReal _ NodeStyle.GetBottomMargin[default]; nodeInfoReal _ NodeStyle.GetBottomMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "bottomMargin", handle.swap.layout.bottomMargin.units]; selectionReal _ GetReal[handle.swap.layout.bindingMargin]; defaultReal _ NodeStyle.GetBindingMargin[default]; nodeInfoReal _ NodeStyle.GetBindingMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "bindingMargin", handle.swap.layout.bindingMargin.units]; RETURN[displayRope]; END; END. zStyleToolToJaMImpl.mesa Written by Linda Gass on August 9, 1982 1:22 pm Last Edit by Linda Gass on November 4, 1982 2:29 pm Last Edited by: Plass, March 28, 1983 3:04 pm Last Edited by: Beach, February 22, 1984 3:39:35 pm PST Pavel, June 26, 1985 5:15:28 pm PDT strips off leading SP, CR, ESC, LF, TAB, COMMA, SEMICOLON if they exist and returns the alpha-numeric name. the name might not have any trailing SP, CR, ESC, LF, TAB, COMMA, SEMICOLON causing an EndOfStream error to be raised. We can safely igonore this. write out everything that doesn't correspond to the default first clear out the WriteOutViewer, in case it contains any information (we don't want the user to get confused; any old information should be discarded. dont bother writing out this information if the user is just interested in changes displayRope _ AppendArtworkInfoRope[handle, info, displayRope]; force selection into Style Name viewer NOTE: the ropes in the left column "points", "picas", etc correspond to the ropes in the UnitsList in StyleToolBuilers. something reasonable rather than giving an error. make sure we return the number converted to the current units If no font family was selected then don't bother to append anything selectionOnRope _ ChoiceButtons.GetSelectedButton[handle.display.fontFaceChoice]; Check that the font given exists and put a message up if it doesn't selectionInt: INTEGER; selectionReal _ GetReal[handle.swap.layout.headerMargin]; defaultReal _ NodeStyle.GetHeaderMargin[default]; nodeInfoReal _ NodeStyle.GetHeaderMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "headerMargin", handle.swap.layout.headerMargin.units]; selectionReal _ GetReal[handle.swap.layout.footerMargin]; defaultReal _ NodeStyle.GetFooterMargin[default]; nodeInfoReal _ NodeStyle.GetFooterMargin[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "footerMargin", handle.swap.layout.footerMargin.units]; selectionReal _ GetReal[handle.swap.layout.lineLength]; defaultReal _ NodeStyle.GetLineLength[default]; nodeInfoReal _ NodeStyle.GetLineLength[handle.nodeInfo]; displayRope _ AppendValueAndUnits[handle, displayRope, selectionReal, defaultReal, nodeInfoReal, "lineLength", handle.swap.layout.lineLength.units]; selectionInt _ StyleToolConvert.GetIntegerFromViewer[handle.swap.layout.column ! StyleToolConvert.BadNumber => CONTINUE]; IF IntDifferences[handle, selectionInt, NodeStyle.GetColumns[default], NodeStyle.GetColumns[handle.nodeInfo]] THEN displayRope _ Rope.Cat[displayRope, IO.PutFR[integerFormat, IO.int[selectionInt]], " column\n"]; ÊM˜Icodešœ™K™/K™3Kšœ-™-šœ7™7K™#—K˜šÏk ˜ Kšœœ"˜5Kšœœœ˜7Kšœœ˜$Kšœ œÑ˜àKšœœ˜Kšœœœ˜$K˜KšœœÒ˜èK˜Kšœœ˜$Kšœœ ˜Kšœ œ*˜;—K˜K˜KšÐbxœœ˜!Kšœœ\˜uKšœ˜Kšœœ˜)Kšœœœ˜š Ïnœœ œ œœ˜eK˜+—Kšœœœ˜-šœ˜K˜)Kšœœœ˜.K˜—K˜š Ÿœœœ œœœ˜UKšœk™kKš œ œœœ œœ˜LKšœ“™“K˜—š Ÿœœ œ8œ˜jšœ;™;Kšœœ˜——šœœA˜TKšœ˜—Kšœ*œ˜/šœœ˜šœ™™™Kšœ6œ˜;—K˜—K˜<šœœ˜KšœR™Ršœœ˜˜PKšœ˜—K˜CK˜—šœ˜˜EKšœ˜—K˜CK˜—K˜—K˜Ešœœ˜K˜>—K˜?K˜<šœ%œœ˜4K˜?K˜œ˜Ešœ˜šœ˜Kšœœ˜šœ˜šœ N˜Qšœ0œœœ˜Ešœ˜šœ˜Kšœ7œ˜=K˜Kšœœ˜Kšœ˜ —K˜—K˜—Kšœ˜ —K˜—Kšœœ˜——Kšœ˜——K˜K˜K˜VK˜MK˜VšœE˜KK˜k—K˜K˜XK˜MK˜VšœE˜KKšœl˜lK˜—K˜—Kšœ˜—K˜šŸœ œ2˜Kš œœœœœ˜VK˜——Kšœœ˜šœ,œ-˜^Kšœ,œ)˜ZKšœ(œ-˜ZKšœœ &˜M—šœœ)œ*˜]Kšœ˜—šœœ(œ)˜[Kšœœ˜—šœœ(œ)˜[Kšœœ˜#—šœœ(œ)˜[Kšœœ œ˜5—šœœ!œ˜DK˜V—K˜Kšœ˜š Ÿœœ œEœœœ˜ŒKšœ*œ˜/—K˜K˜7K˜/K˜8˜RK˜A—K˜K˜8K˜0K˜9˜RK˜FK˜—K˜8K˜0K˜9˜RK˜F—K˜K˜7K˜/K˜8˜RK˜DK˜—K˜6K˜.K˜7˜RK˜@—K˜K˜9K˜1K˜:˜R˜HK˜——Kšœ˜Kšœ˜K˜š Ÿœœ œEœœœ˜KšœAœ˜FK˜š Ÿ œ œœ0œœœ˜xšœ˜Kšœœ*˜šœ@˜F˜RK˜——šœ˜K˜/K˜8˜PK˜I—K˜—K˜K˜—K˜@K˜OK˜9K˜BšœAœ˜H˜UK˜——šœ˜K˜8K˜Ašœ@˜F˜UK˜——šœ˜K˜2K˜;˜PK˜O—K˜—˜K˜——Kšœ˜Kšœ˜š Ÿœœ œEœœœ˜ŠKšœ1œ˜6—Kšœ*œ˜/K˜K˜3K˜+K˜4˜RK˜9—K˜K˜7K˜/K˜8˜RK˜D—K˜˜3Kšœ>œ˜H—K˜-K˜6šœCœ˜J˜ZK˜K˜——K˜WK˜OK˜XšœE˜K˜VK˜K˜——Kšœ˜Kšœ˜š Ÿœœ œEœœœ˜Kšœ*œ˜/—K˜˜3KšœEœ˜O—Kšœ;˜;KšœD˜DšœC˜I˜#K˜U——K˜˜3KšœJœ˜T—KšœI˜IKšœR˜RšœC˜I˜#K˜CK˜%——K˜˜3KšœJœ˜T—KšœI˜IKšœR˜RšœC˜I˜#K˜CK˜%——K˜˜3KšœKœ˜U—KšœJ˜JKšœS˜SšœC˜I˜#K˜DK˜&——K˜˜3KšœIœ˜S—KšœH˜HKšœQ˜QšœC˜I˜#K˜B˜$K˜———Kšœ˜Kšœ˜K˜š Ÿœœ œEœœœ˜„š˜Kšœ*œ˜/šœ™K˜—K˜6K˜.K˜7K˜R˜?K˜—K˜7K˜/K˜8K˜R˜AK˜—K˜7K˜/K˜8K˜R˜AK˜—K˜8K˜0K˜9K˜RK˜CK˜K˜6K˜.K˜7K˜RK˜?K˜K˜9K˜1K˜:K˜RK˜EK˜Kšœ9™9K™1K™:K™RK™EK˜K™9K™1K™:K™RK™EK˜K˜:K˜2K˜;K˜RK˜GK˜Kšœ7™7K™/K™8K™RK™AK˜Kšœoœ™yšœl™rKšœ$œœ"™`—K˜Kšœ˜—Kšœ˜—Kšœ˜—…—aÊ|‘