CDColorCommands.mesa
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi October 28, 1983 4:21 pm
last edited by Christian Jacobi, March 13, 1986 5:57:02 pm PST
DIRECTORY
CDMenus,
CDSequencer,
Commander USING [CommandProc, Register],
ImagerTerminal,
IO,
Rope,
Terminal,
TerminalIO,
UserProfile,
ViewerPrivate,
WindowManager;
CDColorCommands: CEDAR PROGRAM
IMPORTS CDMenus, CDSequencer, Commander, IO, ImagerTerminal, Rope, Terminal, TerminalIO, UserProfile, ViewerPrivate, WindowManager =
BEGIN
SetColorBPP: PROC [bpp: INT, pos: WindowManager.ScreenPos, force: BOOLFALSE] =
--force position by putting off and on again
BEGIN
virtual: Terminal.Virtual = Terminal.Current[];
m: Terminal.ColorMode = Terminal.GetColorMode[virtual];
IF bpp=4 OR bpp=8 AND Terminal.LegalColorMode[virtual,
[full: FALSE, bitsPerPixelChannelA: bpp, bitsPerPixelChannelB: 0]]
THEN {
IF WindowManager.colorDisplayOn THEN {
IF NOT force AND NOT m.full AND m.bitsPerPixelChannelA=bpp THEN {
[] ← Terminal.SetColorCursorPresentation[virtual, onesAreWhite];
RETURN;
};
WindowManager.StopColorViewers[];
};
WindowManager.StartColorViewers[screenPos: pos, bitsPerPixel: bpp];
[] ← Terminal.SetColorCursorPresentation[virtual, onesAreWhite];
};
END;
ColorMenuComm: PROC[comm: CDSequencer.Command] =
BEGIN
n: CARDINAL;
virtual: Terminal.Virtual = Terminal.Current[];
IF ~ (Terminal.LegalColorMode[virtual, [FALSE, 8, 0]]
OR Terminal.LegalColorMode[virtual, [FALSE, 4, 0]])
THEN {
TerminalIO.WriteRope["no color display\n"];
RETURN
};
n ← TerminalIO.RequestSelection[
label: "color display",
choice:
IF Terminal.LegalColorMode[virtual, [FALSE, 8, 0]] THEN
LIST["reset cedar", "off", "cursor white", "cursor black", "4 bit left", "4 bit right", "8 bit left", "8 bit right"]
ELSE
LIST["reset cedar", "off", "cursor white", "cursor black", "4 bit left", "4 bit right"]
];
SELECT n FROM
1 => ResetCedarColorsComm[NIL];
2 => IF WindowManager.colorDisplayOn THEN WindowManager.StopColorViewers[];
3 => [] ← Terminal.SetColorCursorPresentation[Terminal.Current[], onesAreWhite];
4 => [] ← Terminal.SetColorCursorPresentation[Terminal.Current[], onesAreBlack];
5 => SetColorBPP[4, left, TRUE];
6 => SetColorBPP[4, right, TRUE];
7 => SetColorBPP[8, left, TRUE];
8 => SetColorBPP[8, right, TRUE];
ENDCASE => TerminalIO.WriteRope["skipped\n"];
IF comm#NIL THEN TerminalIO.WriteRope[" this command forced the display hardware; now set color map and pattern\n"];
END;
ResetCedarColorsComm: PROC[comm: CDSequencer.Command] =
BEGIN
virtual: Terminal.Virtual = Terminal.Current[];
TerminalIO.WriteRope["reset cedar colors\n"];
IF virtual.hasColorDisplay THEN {
ImagerTerminal.SetStandardColorMap[virtual];
WindowManager.RestoreCursor[];
[] ← Terminal.SetColorCursorPresentation[virtual, onesAreBlack];
[] ← ViewerPrivate.SetCreator[NIL];
};
END;
ColorCommand: Commander.CommandProc =
BEGIN
s: IO.STREAM = IO.RIS[cmd.commandLine];
bbp: INT ← 0;
side: INT ← 0;
DO
token: Rope.ROPEIO.GetTokenRope[s ! IO.EndOfStream => EXIT].token;
IF Rope.IsEmpty[token] THEN EXIT;
SELECT Rope.Fetch[token, 0] FROM
'4 => bbp ← 4;
'8 => bbp ← 8;
'r, 'R => side ← 1;
'l, 'L => side ← -1;
ENDCASE => EXIT;
ENDLOOP;
IF bbp>0 AND side#0 THEN SetColorBPP[bbp, IF side=1 THEN right ELSE left, TRUE]
ELSE ColorMenuComm[NIL]
END;
-- Module initialization
Init: PROC [] =
BEGIN
virtual: Terminal.Virtual = Terminal.Current[];
IF virtual.hasColorDisplay THEN {
bpp: INT ← UserProfile.Number[key: "ChipNDale.ColorStartBits", default: -1];
-- strategy is
-- -1 don't touch
-- 0 take bitmode as is and initialize, if possible
-- >0 do bitmode and initialize, if possible
pos: WindowManager.ScreenPos ← left;
IF Rope.Equal["right", UserProfile.Token[key: "ColorDisplay.Side"], FALSE] THEN pos ← right;
SetColorBPP[bpp: bpp, pos: pos];
CDSequencer.ImplementCommand[$ColorDisplayMenuC, ColorMenuComm,, doQueue];
CDSequencer.ImplementCommand[$CedarColorDisplay, ResetCedarColorsComm,, doQueue];
CDMenus.CreateEntry[$DisplayMenu, "reset cedar", $CedarColorDisplay];
CDMenus.CreateEntry[$DisplayMenu, "color-menu", $ColorDisplayMenuC];
Commander.Register[
 key: "///Commands/CDColor",
 proc: ColorCommand,
 doc: "ChipNDale color setup"
 ];
};
END;
Init[];
END.