DIRECTORY Ascii, CD, CDOps, CDPanel, CDPanelFonts, CDPrivate, CDSequencer, CDTexts, CDValue, Convert, FileNames, IO, PopUpSelection, Rope, TerminalIO, UserProfile; CDPanelFontsImpl: CEDAR MONITOR IMPORTS Ascii, CDOps, CDPanel, CDTexts, CDValue, Convert, FileNames, IO, PopUpSelection, Rope, TerminalIO, UserProfile EXPORTS CDPanelFonts 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] }; ImplementIt: PUBLIC PROC [tech: CD.Technology, 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.Redisplay[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[CDOps.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.PutRope["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 _ PopUpSelection.Request[header: "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.PutRope["discarded\n"] ELSE { SetCurrentFont[comm.design, selected, UseName[selected, lambda, FALSE]]; TerminalIO.PutRopes[" ", UseName[selected, lambda, TRUE], " for text inputs\n"]; }; }; LayerForText: PUBLIC PROC [layer: CD.Layer, technology: REF_NIL] RETURNS [lay: CD.Layer] = { layerProc: REF LProc _ NIL; 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]; 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, October 21, 1986 12:41:06 pm 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™B—K˜šΟk ˜ Kšœ˜Kšžœ˜Kšœ˜K˜Kšœ ˜ Kšœ ˜ Kšœ ˜ K˜K˜K˜Kšœ ˜ Kšžœ˜Kšœ˜Kšœ˜K˜ Kšœ ˜ K˜—šΟnœžœžœ˜ Kšžœ>žœ/˜vKšžœ ˜Kšžœ ˜—Kšž˜K˜Kšœ žœ˜Kšœ žœ˜Kš œ žœžœ žœžœžœ˜?Kš œžœžœžœžœžœ˜1K˜Kš œžœžœžœžœ˜#Kšœžœžœžœ˜Kšœžœžœžœ˜K˜š Ÿœžœžœžœ žœ žœ˜JKšžœžœžœ˜š žœžœžœžœžœžœž˜;Kšžœžœžœžœ˜$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˜šΠbnœ Ο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šžœžœ7˜NK˜—Kšžœžœ˜)Kšœ˜—K˜šŸœžœ ˜7Kšœžœ˜ Kšœžœ(˜2Kšœžœ˜Kšœžœ,˜3Kš œžœžœžœžœ˜Kšœ$˜$šžœžœžœ ž˜Kš žœžœžœžœžœ˜BKšžœ˜—KšžœžœžœA˜Qšžœžœ˜ š žœžœž œžœ ž˜%šžœžœžœ˜Kšœžœžœžœ˜+K˜—Kšžœ˜——Kšžœ žœžœ"˜6šžœ˜Kšœ@žœ˜HKšœ4žœ˜QK˜—Kšœ˜—K˜šŸ œžœžœ žœžœžœžœžœ ˜\Jšœ žœ žœ˜šžœ žœž˜Jšœžœžœ˜AJšžœžœ˜—Jšœ ˜ Jš žœ žœžœ žœžœ˜>J˜—KšŸ˜Kš œžœžœžœžœ‘˜·Kšœ&žœ˜1Kšœ"žœ˜-Kšœ$žœ˜/Kšœžœ"˜3Kšœ6˜6Kšžœ˜K™—…—$’