DIRECTORY Ascii USING [Lower], Buttons USING [Button, ButtonProc, Create, SetDisplayStyle], ColorDisplay, --USING almost everything... Commander USING [CommandProc, Register], Containers USING [Container, Create], IO USING [card, EndOfStream, GetTokenRope, IDProc, PutF, RIS, rope, STREAM], MessageWindow USING [Append], Rope USING [Equal, Fetch, Length, ROPE, Translate, TranslatorType], ViewerOps USING [OpenIcon, SetOpenHeight]; ColorDisplayCommand: CEDAR MONITOR IMPORTS Ascii, Buttons, ColorDisplay, Commander, Containers, IO, MessageWindow, Rope, ViewerOps ~ { ROPE: TYPE ~ Rope.ROPE; FiddleWithDisplay: Commander.CommandProc ~ { MyLower:Rope.TranslatorType = BEGIN RETURN[Ascii.Lower[old]]; END; myOn: BOOLEAN; myBpp: CARDINAL; myOnLeft: BOOLEAN; myMonType: Rope.ROPE; noParams: BOOLEAN _ TRUE; s: IO.STREAM _ IO.RIS[Rope.Translate[base:cmd.commandLine, translator:MyLower]]; [myOn, myOnLeft, myBpp, myMonType] _ ColorDisplay.GetColorDisplayStatus[]; DO f:Rope.ROPE _ IO.GetTokenRope[s, IO.IDProc ! IO.EndOfStream => EXIT].token; noParams _ FALSE; SELECT Rope.Fetch[f, 0] FROM '0 => myOn _ FALSE; '1 => IF Rope.Equal[f, "1024x768"] THEN { myMonType _ "1024x768"; myOn _ TRUE } ELSE IF Rope.Length[f]=1 THEN {myBpp _ 1; myOn _ TRUE; } ELSE { IO.PutF[cmd.err, "Option %g that begins with a 1 has to be 1024x768 or 1 exactly.\n", IO.rope[f]]; RETURN; }; '2 => IF Rope.Equal[f, "24"] THEN { myOn _ TRUE; myBpp _ 24 } ELSE IF Rope.Length[f]=1 THEN { myBpp _ 2; myOn _ TRUE } ELSE { IO.PutF[cmd.err, "Can't do %g bpp\n", IO.rope[f]]; RETURN; }; '4 => { myBpp _ 4; myOn _ TRUE }; '6 => { IF Rope.Equal[f, "640x480"] THEN { myMonType _ "640x480"; myOn _ TRUE } ELSE { IO.PutF[cmd.err, "%g is an invalid key\n", IO.rope[f]]; RETURN; }; }; '8 => { myBpp _ 8; myOn _ TRUE }; 'l => { myOnLeft _ TRUE; myOn _ TRUE }; 'r => { myOnLeft _ FALSE; myOn _ TRUE }; 'd => { [myOn, myOnLeft, myBpp, myMonType] _ ColorDisplay.GetColorDisplayProfile[]; }; 'o => IF Rope.Equal[f, "on"] THEN myOn _ TRUE ELSE IF Rope.Equal[f, "off"] THEN myOn _ FALSE ELSE { IO.PutF[cmd.err, "%g is an invalid key\n", IO.rope[f]]; RETURN; }; '? => IO.PutF[cmd.err, "%g, %g bpp, %g, %g\n", IO.rope[IF myOn THEN "on" ELSE "off"], IO.card[myBpp], IO.rope[IF myOnLeft THEN "left" ELSE "right"], IO.rope[myMonType]]; ENDCASE => { IO.PutF[cmd.err, "%g is an invalid key\n", IO.rope[f]]; RETURN[]; }; ENDLOOP; IF noParams THEN myOn _ ~myOn; ColorDisplay.SetColorDisplayStatus[myOn, myOnLeft, myBpp, myMonType]; }; colorDisplayTool: Containers.Container _ NIL; prev, on, off, left, right, lowres, highres, c1, c2, c4, c8, c24: Buttons.Button; CreateColorDisplayTool: INTERNAL PROC RETURNS [ROPE] ~ { hMargin: INT ~ -1; hSeparator: INT ~ 20; vMargin: INT ~ 5; vHeight: INT ~ 10; thisX, thisY: INT; IF colorDisplayTool#NIL AND ~colorDisplayTool.destroyed THEN { ViewerOps.OpenIcon[icon: colorDisplayTool, bottom: FALSE]; RETURN ["Opened existing Color Display Tool."] }; colorDisplayTool _ Containers.Create[ info: [ name: "ColorDisplayTool", column: right, scrollable: FALSE ] ]; thisX _ hMargin+hSeparator; thisY _ vMargin; prev _ on _ Buttons.Create[ info: [ name: "On", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDTOn, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ off _ Buttons.Create[ info: [ name: "Off", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDTOff, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin + hSeparator; prev _ c1 _ Buttons.Create[ info: [ name: "1 ", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDT1, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ c2 _ Buttons.Create[ info: [ name: "2 ", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDT2, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ c4 _ Buttons.Create[ info: [ name: "4 ", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDT4, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ c8 _ Buttons.Create[ info: [ name: "8 ", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDT8, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ c24 _ Buttons.Create[ info: [ name: "24 ", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDT24, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin + hSeparator; prev _ left _ Buttons.Create[ info: [ name: "Left", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDTLeft, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ right _ Buttons.Create[ info: [ name: "Right", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDTRight, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin + hSeparator; prev _ lowres _ Buttons.Create[ info: [ name: "640x480", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDTLowRes, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin; prev _ highres _ Buttons.Create[ info: [ name: "1024x768", wx: thisX, wy: thisY, parent: colorDisplayTool, border: TRUE ], proc: CDTHighRes, fork: FALSE ]; thisX _ thisX + prev.ww + hMargin + hSeparator; { cdState: ColorDisplay.CDState; [cdState.on, cdState.onLeft, cdState.bpp, cdState.monitorType] _ ColorDisplay.GetColorDisplayStatus[]; MonitorButtons[cdState, cdState]; --Get the first button set-up right; }; ViewerOps.SetOpenHeight[colorDisplayTool, thisY + vHeight + 2*vMargin]; ViewerOps.OpenIcon[icon: colorDisplayTool, bottom: FALSE]; RETURN ["Created new Color Display Tool."] }; shouldBeLit: ARRAY BOOLEAN OF ATOM ~ [$BlackOnWhite, $WhiteOnBlack]; MonitorButtons: ColorDisplay.CDNotifyProc ~ { Repaint: PROC [button: Buttons.Button, condition: BOOLEAN] ~ INLINE { OPEN Buttons; Buttons.SetDisplayStyle[button, shouldBeLit[condition]]; }; IF colorDisplayTool=NIL OR colorDisplayTool.destroyed THEN RETURN; --No point blowing ourselves to smithereens. Repaint[on, new.on]; Repaint[off, ~new.on]; Repaint[c1, new.bpp=1]; Repaint[c2, new.bpp=2]; Repaint[c4, new.bpp=4]; Repaint[c8, new.bpp=8]; Repaint[c24, new.bpp=24]; Repaint[left, new.onLeft]; Repaint[right, ~new.onLeft]; Repaint[lowres, new.monitorType.Equal["640x480"]]; Repaint[highres, ~new.monitorType.Equal["640x480"]]; }; CDTOn: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: TRUE]}; CDTOff: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: FALSE]}; CDTLeft: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[onLeft: TRUE]}; CDTRight: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[onLeft: FALSE]}; CDTLowRes: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[monitorType: "640x480"]}; CDTHighRes: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[monitorType: "1024x768"]}; CDT1: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: TRUE, bpp: 1]}; CDT2: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: TRUE, bpp: 2]}; CDT4: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: TRUE, bpp: 4]}; CDT8: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: TRUE, bpp: 8]}; CDT24: Buttons.ButtonProc ~ {ColorDisplay.SetColorDisplayStatus[on: TRUE, bpp: 24]}; BugColor: ENTRY Buttons.ButtonProc ~ { SELECT mouseButton FROM red => ColorDisplay.SetColorDisplayStatus[on: ~ColorDisplay.GetColorDisplayStatus[].on]; yellow => ColorDisplay.SleepColorDisplay[300]; blue => MessageWindow.Append[CreateColorDisplayTool[], TRUE]; ENDCASE; }; Init: PROC = BEGIN Commander.Register[key:"ColorDisplay", proc:FiddleWithDisplay, doc:"Configure color monitor"]; ColorDisplay.RegisterCDNotifyProc[MonitorButtons]; [] _ Buttons.Create[ info: [name: "Color"], proc: BugColor, fork: FALSE ]; END; Init[]; }. hColorDisplayCommand.mesa Created from old ColorDisplay by Mik Lamming and Ken Pier Last Edited by: Nickell, April 1, 1985 5:50:40 am PST Last Edited by: Beach, August 17, 1984 5:41:30 pm PDT On Button Off Button 1 Button 2 Button 4 Button 8 Button 24 Button Left Button Right Button 640x480 Button 1024x768 Button Paint the buttons manually the first time for the new color display tool Set the height of the viewer as a whole This proc toggles the color of the buttons to show currect state of display Register the program with the commander and read user profile Establish the 'color' button up at the top Κš˜šœ™J™9J™5J™5—šΟk ˜ Jšœœ ˜Jšœœ/˜Kšœ3œ˜:Kšœ(˜.Kšœ˜—˜%˜J˜J˜Jšœ ˜J˜—J˜—J˜J˜,™ ˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜"—™ ˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜/—™˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜"—™˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜"—™˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜"—™˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜"—™ ˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜ Jšœ˜ J˜—J˜/—™ ˜˜J˜ J˜ J˜ J˜Jšœ ˜ J˜—J˜Jšœ˜ J˜—J˜"—™ ˜˜J˜J˜ J˜ J˜Jšœ ˜ J˜—J˜Jšœ˜ J˜—J˜/—™˜˜J˜J˜ J˜ J˜Jšœ ˜ J˜—J˜Jšœ˜ J˜—J˜"—™˜ ˜J˜J˜ J˜ J˜Jšœ ˜ J˜—J˜Jšœ˜ J˜—J˜/—J™J™Hšœ˜K˜K˜fKšœ"ž$˜FKšœ˜—J™'JšœG˜GJšœ3œ˜:Kšœ$˜*J˜J˜—Jš œ œœœœ"˜Dš’œ˜-š’œœ%œœ˜EKšœ ˜ K˜8K˜—J™KKš œœœœœž,˜oKšœ˜K˜K˜K˜K˜K˜K˜K˜K˜Kšœ2˜2Kšœ4˜4J˜—J˜JšœDœ˜KJšœEœ˜MJšœJœ˜QJšœKœ˜SJšœ]˜]Jšœ_˜_JšœCœ ˜RJšœCœ ˜RJšœCœ ˜RJšœCœ ˜RJšœDœ ˜TJ˜šœ œ˜&šœ ˜J˜XJ˜.Jšœ7œ˜=Jšœ˜—J˜J˜—J˜š’œœ˜J™=Jšœ_˜_J˜2J™*˜J˜J˜Jšœ˜ J˜—Jšœ˜J˜—˜J˜—Jšœ˜——…— )"