2 * COLOR.C - color internal command.
7 * 13-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
10 * 19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
13 * 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 #define WIN32_LEAN_AND_MEAN
21 #ifdef INCLUDE_CMD_COLOR
30 VOID
SetScreenColor (WORD wColor
)
33 CONSOLE_SCREEN_BUFFER_INFO csbi
;
36 GetConsoleScreenBufferInfo (hOut
, &csbi
);
40 FillConsoleOutputAttribute (hOut
, wColor
,
41 (csbi
.dwSize
.X
)*(csbi
.dwSize
.Y
),
43 SetConsoleTextAttribute (hOut
, wColor
);
50 * internal dir command
52 INT
cmd_color (LPTSTR first
, LPTSTR rest
)
54 if (_tcsncmp (rest
, _T("/?"), 2) == 0)
56 ConOutPuts (_T("Sets the default foreground and background colors.\n\n"
58 " attr Specifies color attribute of console output\n\n"
59 "Color attributes are specified by TWO hex digits -- the first\n"
60 "corresponds to the background; the second to the foreground. Each digit\n"
61 "can be one of the following:\n"));
63 ConOutPuts (_T(" 0 = Black 8 = Gray\n"
64 " 1 = Blue 9 = Light Blue\n"
65 " 2 = Green A = Light Green\n"
66 " 3 = Aqua B = Light Aqua\n"
67 " 4 = Red C = Light Red\n"
68 " 5 = Purple D = Light Purple\n"
69 " 6 = Yellow E = Light Yellow\n"
70 " 7 = White F = Bright White\n"));
74 if (rest
[0] == _T('\0'))
76 /* set default color */
78 SetScreenColor (wColor
);
82 if (_tcslen (rest
) != 2)
84 ConErrPuts (_T("parameter error!"));
88 wColor
= (WORD
)_tcstoul (rest
, NULL
, 16);
90 if ((wColor
& 0xF) == (wColor
&0xF0) >> 4)
92 ConErrPuts (_T("same colors error!"));
97 SetScreenColor (wColor
);