DIRECTORY Ascii, CD, CDCallSpecific, CDCommandOps, CDLayers, CDPanel, CDPanelFonts, CDPanelFontsExtras, CDPrivate, CDSequencer, CDTexts, CDTextsExtras, CDValue, Convert, FileNames, IO, Rope, TerminalIO, UserProfile; CDPanelFontsImpl: CEDAR MONITOR IMPORTS Ascii, CDCallSpecific, CDCommandOps, IO, CDLayers, CDPanel, CDTexts, CDTextsExtras, CDValue, Convert, FileNames, Rope, TerminalIO, UserProfile EXPORTS CDPanelFonts, CDPanelFontsExtras SHARES CDTexts = BEGIN fontNum: NAT = 20; FontRange: TYPE = [0..fontNum); FontArray: TYPE = ARRAY FontRange OF CDTexts.CDFont _ ALL[NIL]; LProc: TYPE = PROC [CD.Layer] RETURNS [CD.Layer]; tList: LIST OF CD.Technology _ NIL; myKey: REF _ NEW[INT]; myKey2: REF _ NEW[INT]; NoteTechnology: ENTRY PROC [tech: CD.Technology] RETURNS [first: BOOL] = { ENABLE UNWIND => NULL; FOR l: LIST OF CD.Technology _ tList, l.rest WHILE l#NIL DO IF l.first=tech THEN RETURN [FALSE]; ENDLOOP; tList _ CONS[tech, tList]; RETURN [TRUE] }; ChangeLayer: CDCallSpecific.CallProc = { layer: CD.Layer _ WITH x SELECT FROM lr: CDPrivate.LayerRef => lr.number, ENDCASE => CDLayers.CurrentLayer[design]; repaintMe _ TRUE; inst.ob _ CDTextsExtras.Create[ text: NARROW [inst.ob.specificRef, CDTexts.TextPtr].text, font: NARROW [inst.ob.specificRef, CDTexts.TextPtr].cdFont, layer: layer, flip: CDTextsExtras.IsFlipText[inst.ob] ]; }; ImplementIt: PUBLIC PROC [tech: CD.Technology, installCommands: BOOL, defaultFonts: LIST OF Rope.ROPE, layerProc: PROC [CD.Layer] RETURNS [CD.Layer]] = { CDValue.Store[tech, $defaultFontList, defaultFonts]; CDValue.Store[tech, myKey2, NEW[LProc_layerProc]]; IF NoteTechnology[tech].first THEN { CDPanel.DefineButton[tech: tech, name: "font:", proc: ChangeDefaultFont]; CDPanel.DefineLabel[tech: tech, name: " ", cdValueKey: $panelFontRope ]; CDPanel.DefineNewLine[tech]; }; Setup[tech]; }; CurrentFont: PUBLIC PROC [d: CD.Design] RETURNS [CDTexts.CDFont] = { WITH CDValue.Fetch[d, $currentFont, technology] SELECT FROM f: CDTexts.CDFont => RETURN [f]; ENDCASE => RETURN [NIL]; }; FArray: PROC [t: CD.Technology] RETURNS [REF FontArray] = { ENABLE UNWIND => NULL; WITH CDValue.Fetch[t, myKey] SELECT FROM fa: REF FontArray => RETURN [fa]; ENDCASE => { [] _ CDValue.StoreConditional[t, myKey, NEW[FontArray_ALL[NIL]]]; RETURN [FArray[t]]; } }; SetCurrentFont: PUBLIC PROC [design: REF, font: CDTexts.CDFont, name: Rope.ROPE_NIL] = { IF font=NIL THEN RETURN; IF name=NIL THEN name _ font.supposedName; CDValue.Store[design, $panelFontRope, name]; TRUSTED { CDValue.Store[design, $currentFont, LOOPHOLE[font]]; }; WITH design SELECT FROM d: CD.Design => CDPanel.RedisplayLabels[d]; ENDCASE => NULL; }; NoteProfileChange: UserProfile.ProfileChangedProc = { FOR tl: LIST OF CD.Technology _ tList, tl.rest WHILE tl#NIL DO Setup[tl.first]; ENDLOOP; }; SupposedFontName: PROC [t: CD.Technology, fn: INT] RETURNS [fontName: Rope.ROPE, scale: INT] = { DefaultFontName: PROC [fn: INT] RETURNS [name: Rope.ROPE_NIL, scale: INT_-1] = { rnl: LIST OF Rope.ROPE; WITH CDValue.Fetch[t, $defaultFontList, global] SELECT FROM rl: LIST OF Rope.ROPE => rnl _ rl; ENDCASE => rnl _ fontNameList; FOR l: LIST OF Rope.ROPE _ rnl, l.rest WHILE l#NIL DO IF fn<=0 THEN {name _ l.first; EXIT}; fn _ fn-1; ENDLOOP; IF name#NIL THEN { [name, scale] _ Scan[name]; name _ Rope.Concat["Xerox/TiogaFonts/", name]; } }; SkipSpaces: PROC [r: Rope.ROPE] RETURNS [Rope.ROPE] = { n: INT _ 0; l: INT _ Rope.Length[r]; WHILE n GOTO exit; name _ SkipSpaces[r]; IF ~Rope.IsEmpty[name] THEN { s: IO.STREAM _ IO.RIS[name]; IF Ascii.Digit[Rope.Fetch[name]] THEN scale _ IO.GetInt[s]; name _ SkipSpaces[IO.GetLineRope[s]]; }; EXITS exit => NULL }; num: Rope.ROPE = Convert.RopeFromInt[fn]; [fontName, scale] _ Scan[UserProfile.Line[key: Rope.Cat["ChipNDale.", t.name, ".Font", num]]]; IF ~Rope.IsEmpty[fontName] AND scale<1 THEN scale _ UserProfile.Number[key: Rope.Cat["ChipNDale.", t.name, ".ScaleFont", num], default: t.lambda]; IF Rope.IsEmpty[fontName] THEN [fontName, scale] _ DefaultFontName[fn]; IF scale<1 THEN scale _ t.lambda; }; Setup: PROC [t: CD.Technology] = { FontForIndex: PROC [t: CD.Technology, fn: FontRange, fontArray: REF FontArray] = { fontName: Rope.ROPE; scale: INT; [fontName, scale] _ SupposedFontName[t, fn]; IF fontArray[fn]#NIL AND Rope.Equal[fontName, fontArray[fn].supposedName, FALSE] AND scale=fontArray[fn].scaleI THEN RETURN; IF Rope.IsEmpty[fontName] THEN fontArray[fn] _ NIL ELSE fontArray[fn] _ CDTexts.MakeFont[name: fontName, scale: scale]; }; lastFont: CDTexts.CDFont_NIL; far: REF FontArray _ FArray[t]; IF far#NIL THEN FOR fn: FontRange IN [0..fontNum) DO FontForIndex[t, fn, far]; IF far[fn]#NIL THEN lastFont _ far[fn] ENDLOOP; IF lastFont#NIL THEN SetCurrentFont[t, lastFont, UseName[lastFont, t.lambda]]; }; UseName: PROC [f: CDTexts.CDFont, lambda: INT, full: BOOL_FALSE] RETURNS [name: Rope.ROPE_NIL] = { IF f#NIL THEN { name _ f.supposedName; IF ~full THEN name _ FileNames.GetShortName[name]; IF f.scaleI#lambda THEN name _ name.Concat[CDCommandOps.LambdaRope[f.scaleI, lambda]] }; IF Rope.IsEmpty[name] THEN name _ " ?? "; }; ChangeDefaultFont: PROC [comm: CDSequencer.Command] = { n: INT _ 0; lambda: CD.Number _ comm.design.technology.lambda; selected: CDTexts.CDFont_NIL; fa: REF FontArray _ FArray[comm.design.technology]; list: LIST OF Rope.ROPE _ NIL; TerminalIO.WriteRope["change font\n"]; FOR i: INT IN FontRange DO IF fa[i]#NIL THEN list _ CONS[UseName[fa[i], lambda, FALSE], list] ENDLOOP; IF list#NIL THEN n _ TerminalIO.RequestSelection[label: "change font", choice: list]; IF n>0 THEN FOR i: INT DECREASING IN FontRange DO IF fa[i]#NIL THEN { n_n-1; IF n<=0 THEN {selected_fa[i]; EXIT}; }; ENDLOOP; IF selected=NIL THEN TerminalIO.WriteRope["discarded\n"] ELSE { SetCurrentFont[comm.design, selected, UseName[selected, lambda, FALSE]]; TerminalIO.WriteRopes[" ", UseName[selected, lambda, TRUE], " for text inputs\n"]; }; }; LayerForText: PUBLIC PROC [layer: CD.Layer, technology: REF_NIL] RETURNS [lay: CD.Layer] = { layerProc: REF LProc; WITH technology SELECT FROM t: CD.Technology => layerProc _ NARROW[CDValue.Fetch[t, myKey2]]; ENDCASE => NULL; lay _ layer; IF layerProc#NIL AND layerProc^#NIL THEN lay _ layerProc[lay]; }; fontNameList: LIST OF Rope.ROPE = LIST["Template64", "Gates32", "Helvetica18", "Helvetica14", "Helvetica12", "Helvetica10I", "Helvetica10", "Helvetica8I", "Helvetica8", "Helvetica7"]; CDValue.RegisterKey[$defaultFontList, NIL, $chj]; CDValue.RegisterKey[$currentFont, NIL, $chj]; CDValue.RegisterKey[$panelFontRope, NIL, $chj]; CDValue.Store[NIL, $defaultFontList, fontNameList]; UserProfile.CallWhenProfileChanges[NoteProfileChange]; CDCallSpecific.Register[$ChangeLayer, CDTexts.textClass, ChangeLayer]; END. ‚CDPanelFontsImpl.mesa (part of ChipNDale) Copyright c 1983, 1985, 1986 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, June 24, 1983 5:03 pm Last Edited by: Christian Jacobi, September 2, 1986 11:54:48 am PDT --gets a font name and a scale from user profile or default --for limitted time --(re)reads font names for one technology (from user profile) Κ ž˜codešœ*™*Kšœ Οmœ=™HKšœ3™3K™C—K˜šΟk ˜ Kšœ˜Kšžœ˜Kšœ˜Kšœ ˜ K˜ K˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ ˜ K˜K˜K˜K˜Kšœ ˜ Kšžœ˜Kšœ˜K˜ Kšœ ˜ K˜—šΡblnœžœžœ˜ Kšžœ&žœg˜–Kšžœ!˜(Kšžœ ˜—Kšž˜K˜Kšœ žœ˜Kšœ žœ˜Kš œ žœžœ žœžœžœ˜?Kš œžœžœžœžœžœ˜1K˜Kš œžœžœžœžœ˜#Kšœžœžœžœ˜Kšœžœžœžœ˜K˜š Οnœžœžœžœ žœ žœ˜JKšžœžœžœ˜š žœžœžœžœžœžœž˜;Kšžœžœžœžœ˜$Kšžœ˜—Kšœžœ˜Kšžœžœ˜ Kšœ˜—K˜šΠbn œ˜(šœžœ žœžœž˜$Kšœ$˜$Kšžœ"˜)—Kšœ žœ˜šœ˜Kšœžœ-˜9Kšœžœ/˜;Kšœ ˜ Kšœ'˜'Kšœ˜—Kšœ˜K˜—š  œžœžœžœžœžœžœžœ žœžœžœžœ ˜™Kšœ4˜4Kšœžœ˜2šžœžœ˜$KšœI˜Išœ ˜ Kšœ(˜(Kšœ˜Kšœ˜—Kšœ˜K˜—Kšœ ˜ Kšœ˜—K˜š   œžœžœžœ žœ˜Dšžœ,žœž˜;Kšœžœ˜ Kšžœžœžœ˜—Kšœ˜—K˜š  œžœžœ žœžœ˜;Kšžœžœžœ˜šžœžœž˜(Kšœžœžœ˜!šžœ˜ Kšœ(žœ žœžœ˜AKšžœ ˜K˜——Kšœ˜—K˜š  œžœžœ žœ#žœžœ˜XKšžœžœžœžœ˜Kšžœžœžœ˜*Kšœ,˜,Kšžœ'žœ ˜Ašžœžœž˜Kšœžœ&˜+Kšžœžœ˜—Kšœ˜—K˜š‘œ Οb˜5š žœžœžœžœžœžœž˜>K˜Kšžœ˜—Kšœ˜—K˜š œžœžœžœžœžœ žœ˜`Kšœ;™;K˜š œžœžœžœ žœžœ žœ˜PKšœžœžœžœ˜šžœ,žœž˜;Kšœžœžœžœ ˜"Kšžœ˜—š žœžœžœžœžœžœž˜5Kšžœžœžœ˜%Kšœ ˜ Kšžœ˜—šžœžœžœ˜Kšœ˜Kšœ.˜.Kšœ˜—Kšœ˜—K˜š   œžœ žœžœžœ˜7Kšœžœ˜ Kšœžœ˜Kšžœžœžœ žœ˜5Kšžœžœžœ žœ˜7Kšžœ˜K˜—K˜š  œžœ žœžœ žœ žœ˜FKšžœžœžœ˜#Kšœ˜šžœžœ˜Kš œžœžœžœžœ˜Kšžœžœ žœ ˜;Kšœžœ˜%Kšœ˜—Kšžœ ž˜K˜—K˜Kšœ žœ˜)šœ^˜^Kšœ™šžœžœ ž˜+Kšœf˜f——Kšžœžœ)˜GKšžœ žœ˜!Kšœ˜—K˜š œžœžœ˜"Kšœ=™=K˜š  œžœžœ'žœ˜RKšœžœ žœ˜ Kšœ,˜,Kšžœžœžœ2žœžœžœžœ˜~Kšžœžœž˜2Kšžœ@˜DKšœ˜—K˜Kšœžœ˜Kšœžœ˜šžœžœž˜šžœžœž˜$Kšœ˜Kšžœ žœžœ˜&Kšžœ˜——šžœ žœžœ˜Kšœ9˜9—Kšœ˜—K˜š œžœžœžœžœžœ žœžœ˜bšžœžœžœ˜Kšœ˜Kšžœžœ&˜3Kšžœžœ>˜UK˜—Kšžœžœ˜)Kšœ˜—K˜š œžœ ˜7Kšœžœ˜ Kšœžœ(˜2Kšœžœ˜Kšœžœ,˜3Kš œžœžœžœžœ˜Kšœ&˜&šžœžœžœ ž˜Kš žœžœžœžœžœ˜BKšžœ˜—KšžœžœžœE˜Ušžœžœ˜ š žœžœž œžœ ž˜%šžœžœžœ˜Kšœžœžœžœ˜+K˜—Kšžœ˜——Kšžœ žœžœ$˜8šžœ˜Kšœ@žœ˜HKšœ6žœ˜SK˜—Kšœ˜—K˜š  œžœžœ žœžœžœžœžœ ˜\Jšœ žœ˜šžœ žœž˜Jšœžœžœ˜AJšžœžœ˜—Jšœ ˜ Jš žœ žœžœ žœžœ˜>J˜—Kš ˜Kš œžœžœžœžœ‘˜·Kšœ&žœ˜1Kšœ"žœ˜-Kšœ$žœ˜/Kšœžœ"˜3Kšœ6˜6KšœF˜FKšžœ˜K™—…—Z'z