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 to En.rc.
25 #ifdef INCLUDE_CMD_COLOR
31 VOID
SetScreenColor (WORD wColor
, BOOL bNoFill
)
34 CONSOLE_SCREEN_BUFFER_INFO csbi
;
38 if ((wColor
& 0xF) == (wColor
&0xF0) >> 4)
40 ConErrResPuts(STRING_COLOR_ERROR1
);
46 GetConsoleScreenBufferInfo (hConsole
, &csbi
);
50 FillConsoleOutputAttribute (hConsole
,
51 (WORD
)(wColor
& 0x00FF),
52 (csbi
.dwSize
.X
)*(csbi
.dwSize
.Y
),
56 SetConsoleTextAttribute (hConsole
, (WORD
)(wColor
& 0x00FF));
64 * internal dir command
66 INT
CommandColor (LPTSTR first
, LPTSTR rest
)
68 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
70 if (_tcsncmp (rest
, _T("/?"), 2) == 0)
72 ConOutResPaging(TRUE
,STRING_COLOR_HELP1
);
78 if (rest
[0] == _T('\0'))
80 /* set default color */
82 SetScreenColor (wColor
, FALSE
);
87 if ( _tcslen(&rest
[0])==1)
89 if ( (_tcscmp(&rest
[0], _T("0")) >=0 ) && (_tcscmp(&rest
[0], _T("9")) <=0 ) )
91 SetConsoleTextAttribute (hConsole
, (WORD
)_ttoi(rest
));
94 else if ( (_tcscmp(&rest
[0], _T("a")) >=0 ) && (_tcscmp(&rest
[0], _T("f")) <=0 ) )
96 SetConsoleTextAttribute (hConsole
, (WORD
) (rest
[0] + 10 - _T('a')) );
99 else if ( (_tcscmp(&rest
[0], _T("A")) >=0 ) && (_tcscmp(&rest
[0], _T("F")) <=0 ) )
101 SetConsoleTextAttribute (hConsole
, (WORD
) (rest
[0] + 10 - _T('A')) );
104 ConErrResPuts(STRING_COLOR_ERROR2
);
109 if (StringToColor(&wColor
, &rest
) == FALSE
)
111 ConErrResPuts(STRING_COLOR_ERROR2
);
116 LoadString(CMD_ModuleHandle
, STRING_COLOR_ERROR3
, szMsg
, RC_STRING_MAX_SIZE
);
117 ConErrPrintf(szMsg
, wColor
);
119 if ((wColor
& 0xF) == (wColor
&0xF0) >> 4)
121 LoadString(CMD_ModuleHandle
, STRING_COLOR_ERROR4
, szMsg
, RC_STRING_MAX_SIZE
);
122 ConErrPrintf(szMsg
, wColor
);
128 SetScreenColor(wColor
,
129 (_tcsstr (rest
,_T("/-F")) || _tcsstr (rest
,_T("/-f"))));
134 #endif /* INCLUDE_CMD_COLOR */