1 /* $Id: color.c,v 1.4 1999/12/04 14:54:50 ekohl Exp $
3 * COLOR.C - color internal command.
8 * 13-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
11 * 19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
14 * 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 * 14-Oct-1999 (Paolo Pantaleo <paolopan@freemail.it>)
18 * 4nt's syntax implemented
23 #ifdef INCLUDE_CMD_COLOR
31 static VOID
ColorHelp (VOID
)
34 "Sets the default foreground and background colors.\n"
36 "COLOR [attr [/F]] \n\n"
37 " attr Specifies color attribute of console output\n"
38 " /F fill the console with color attribute\n"
40 "There are three ways to specify the colors:"
45 "1) [bright] name on [bright] name (only the first three letters are required)\n"
46 "2) decimal on decimal\n"
53 "dec hex name dec hex name\n"
54 "0 0 Black 8 8 Gray(Bright black)\n"
55 "1 1 Blue 9 9 Bright Blue\n"
56 "2 2 Green 10 A Bright Green\n"
57 "3 3 Cyan 11 B Bright Cyan\n"
58 "4 4 Red 12 C Bright Red\n"
59 "5 5 Magenta 13 D Bright Magenta\n"
60 "6 6 Yellow 14 E Bright Yellow\n"
61 "7 7 White 15 F Bright White"));
65 VOID
SetScreenColor (WORD wColor
, BOOL bFill
)
68 CONSOLE_SCREEN_BUFFER_INFO csbi
;
73 GetConsoleScreenBufferInfo (hOut
, &csbi
);
77 FillConsoleOutputAttribute (hOut
,
78 (WORD
)(wColor
& 0x00FF),
79 (csbi
.dwSize
.X
)*(csbi
.dwSize
.Y
),
83 SetConsoleTextAttribute (hOut
, (WORD
)(wColor
& 0x00FF));
90 * internal dir command
92 INT
CommandColor (LPTSTR first
, LPTSTR rest
)
94 if (_tcsncmp (rest
, _T("/?"), 2) == 0)
100 if (rest
[0] == _T('\0'))
102 /* set default color */
104 SetScreenColor (wColor
, TRUE
);
108 if (StringToColor (&wColor
, &rest
) == FALSE
)
110 ConErrPuts("error in color specification");
114 ConErrPrintf ("Color %x\n", wColor
);
116 if ((wColor
& 0xF) == (wColor
&0xF0) >> 4)
118 ConErrPuts (_T("same colors error!"));
123 SetScreenColor (wColor
,
124 (_tcsstr (rest
,"/F") || _tcsstr (rest
,"/f")));
129 #endif /* INCLUDE_CMD_COLOR */