NMosTextCommands.mesa (part of Chipndale)
Copyright © 1983 by Xerox Corporation. All rights reserved.
by Christian Jacobi June 24, 1983 5:03 pm
last edited Christian Jacobi November 23, 1983 9:41 am
DIRECTORY
CD,
CDApplications,
CDTexts,
CDOps,
CDSequencer,
TerminalIO,
Rope,
CDValue,
NMos,
CDPanel;
NMosTextCommands: CEDAR PROGRAM
IMPORTS CDApplications, CDOps, CDSequencer, TerminalIO, CDTexts, Rope, CDValue, CDPanel, NMos =
BEGIN
FontRec: TYPE = CDTexts.FontRec;
CreateTextComm: PROC [comm: CDSequencer.Command] =
BEGIN
ENABLE TerminalIO.UserAbort => GOTO userAbort;
fn: NATMIN[INT[fontNum]-1, CDValue.FetchInt[comm.design, $FontNumber]];
font: REF CDTexts.FontRec ← fontArray[fn];
r: Rope.ROPE ← TerminalIO.RequestRope["Create text\n", "please type: "];
ob: CD.ObPtr;
IF Rope.IsEmpty[r] THEN {
TerminalIO.WriteRope["empty text not included\n"];
RETURN
};
ob ← CDTexts.CreateText[r, font];
CDOps.AddAnObject[design: comm.design, ob: ob, location: comm.pos, orientation: 0];
EXITS
userAbort => {TerminalIO.WriteRope["discarded\n"]}
END;
ScaleTextComm: PROC [comm: CDSequencer.Command] =
BEGIN
ff: REAL = 1.2599;
fff: REAL = ff*ff*ff;
first: CD.ApplicationPtr;
multiple: BOOL;
TerminalIO.WriteRope["Scale text\n"];
[first, multiple] ← CDOps.SelectedApplication[comm.design];
IF multiple THEN TerminalIO.WriteRope["multiple selection; not done\n"]
ELSE IF first=NIL THEN TerminalIO.WriteRope["no selection; not done\n"]
ELSE IF NOT ISTYPE[first.ob.specificRef, CDTexts.TextPtr] THEN TerminalIO.WriteRope["not text; not done\n"]
ELSE {
factor: REAL𡤁.0;
n: INT ← TerminalIO.RequestSelection[
choice: LIST[" >>", " >", " <", " <<"],
label: "scale"
];
SELECT n FROM
1 => factor ← 1.0/fff;
2 => factor ← 1.0/ff;
3 => factor ← ff;
4 => factor ← fff;
ENDCASE => factor ← 1.0;
ScaleApp[comm.design, first, factor];
TerminalIO.WriteRope["done\n"]
};
END;
ScaleApp: PROC [design: CD.Design, aptr: CD.ApplicationPtr, factor: REAL] =
BEGIN
IF aptr#NIL AND aptr.ob#NIL THEN
WITH aptr.ob.specificRef SELECT FROM
tp: CDTexts.TextPtr => {
font: REF CDTexts.FontRec ~ tp.font;
scaledFont: REF CDTexts.FontRec ~ CDTexts.MakeFont[
name: font.name,
scale: font.scale*factor,
whiteBorder: font.whiteBorder,
scaleByReplacingFontAllowed: font.scaleByReplacingFontAllowed,
levelSubstitute: font.levelSubstitute
];
IF scaledFont#NIL THEN {
txt: CD.ObPtr ~ CDTexts.CreateText[tp.text, scaledFont, aptr.ob.level];
IF txt#NIL THEN {
CDOps.DelayedRedraw[design, CDApplications.ARectO[aptr]];
aptr.ob ← txt;
CDOps.DelayedRedraw[design, CDApplications.ARectO[aptr]];
};
};
};
ENDCASE => ERROR
END;
fontNum: NAT = 5;
FontRange: TYPE = [0..fontNum);
fontArray: ARRAY FontRange OF REF CDTexts.FontRec;
ImplCommands: PROC [] =
BEGIN
CDSequencer.ImplementCommand[$DrawText, CreateTextComm, NMos.nmos];
CDSequencer.ImplementCommand[$ScaleTextS, ScaleTextComm, NMos.nmos];
CDValue.EnregisterKey[$FontNumber, NMos.nmos];
CDPanel.DefineIntEntry[cdValueKey: $FontNumber, tech: NMos.nmos,
text: "Font:", min: 0, default: 0, max: fontNum-1];
CDPanel.DefineNewLine[NMos.nmos];
fontArray[0] ← CDTexts.GetFont[key: $CDxCompatibilityFont, technology: NMos.nmos];
fontArray[1] ← CDTexts.MakeFont[scale: 2, name: "Gates32.strike"];
fontArray[2] ← CDTexts.MakeFont[scale: 2, name: "MusicFont10.strike"];
fontArray[3] ← CDTexts.MakeFont[scale: 0.5, name: "OldEnglish18.strike"];
fontArray[4] ← CDTexts.MakeFont[scale: 0.5, name: "TimesRoman36.strike"];
IF fontArray[1]=NIL THEN
fontArray[1] ← CDTexts.MakeFont[scale: 2, name: "/ivy/jacobi/chipndale/Gates32.strike"];
--further fonts "Template64.strike" "/ivy/jacobi/chipndale/Template64.strike"
IF fontArray[2]=NIL THEN
fontArray[2] ← CDTexts.MakeFont[scale: 0.5, name: "/indigo/AltoFonts/Helvetica18.strike"];
IF fontArray[2]=NIL THEN
fontArray[2] ← CDTexts.GetFont[key: $CDxCompatibilityFont, technology: NMos.nmos];
IF fontArray[3]=NIL THEN
fontArray[3] ← CDTexts.MakeFont[scale: 0.5, name: "/indigo/AltoFonts/Logo18.strike"];
IF fontArray[3]=NIL THEN
fontArray[3] ← CDTexts.GetFont[key: $CDxCompatibilityFont, technology: NMos.nmos];
IF fontArray[4]=NIL THEN
fontArray[4] ← CDTexts.MakeFont[scale: 0.3, name: "/indigo/AltoFonts/TimesRoman36.strike"];
IF fontArray[4]=NIL THEN
fontArray[4] ← CDTexts.GetFont[key: $CDxCompatibilityFont, technology: NMos.nmos];
END;
ImplCommands[];
END.