2 * COLOR.C - color internal command.
7 * 13-Dec-1998 (Eric Kohl)
10 * 19-Jan-1999 (Eric Kohl)
13 * 20-Jan-1999 (Eric Kohl)
16 * 14-Oct-1999 (Paolo Pantaleo <paolopan@freemail.it>)
17 * 4nt's syntax implemented.
19 * 03-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
20 * Move all hardcoded strings in En.rc.
25 #ifdef INCLUDE_CMD_COLOR
30 * internal dir command
32 INT
CommandColor(LPTSTR rest
)
36 /* The user asked for help */
37 if (_tcsncmp(rest
, _T("/?"), 2) == 0)
39 ConOutResPaging(TRUE
, STRING_COLOR_HELP1
);
43 /* Let's prepare %ERRORLEVEL% */
46 /* No parameter: Set the default colors */
47 if (rest
[0] == _T('\0'))
49 ConSetScreenColor(wDefColor
, TRUE
);
53 /* The parameter is just one character: Set color text */
54 if (_tcslen(rest
) == 1)
56 if ((rest
[0] >= _T('0')) && (rest
[0] <= _T('9')))
58 wColor
= (WORD
)_ttoi(rest
);
60 else if ((rest
[0] >= _T('a')) && (rest
[0] <= _T('f')))
62 wColor
= (WORD
)(rest
[0] + 10 - _T('a'));
64 else if ((rest
[0] >= _T('A')) && (rest
[0] <= _T('F')))
66 wColor
= (WORD
)(rest
[0] + 10 - _T('A'));
68 else /* Invalid character */
70 ConOutResPaging(TRUE
, STRING_COLOR_HELP1
);
75 /* Color string: advanced choice: two-digits, "Color ON Color", "Foreground ON Background" */
76 else if (StringToColor(&wColor
, &rest
) == FALSE
)
78 /* Invalid color string */
79 ConOutResPaging(TRUE
, STRING_COLOR_HELP1
);
84 TRACE("Color %02x\n", wColor
);
87 * Set the chosen color. Use also the following advanced flag:
88 * /-F to avoid changing already buffered foreground/background.
90 if (ConSetScreenColor(wColor
, !_tcsstr(rest
, _T("/-F")) && !_tcsstr(rest
, _T("/-f"))) == FALSE
)
92 /* Failed because foreground and background colors were the same */
93 ConErrResPuts(STRING_COLOR_ERROR1
);
102 #endif /* INCLUDE_CMD_COLOR */