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>)
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.
26 #ifdef INCLUDE_CMD_COLOR
32 VOID
SetScreenColor (WORD wColor
, BOOL bNoFill
)
35 CONSOLE_SCREEN_BUFFER_INFO csbi
;
39 if ((wColor
& 0xF) == (wColor
&0xF0) >> 4)
41 ConErrResPuts(STRING_COLOR_ERROR1
);
47 GetConsoleScreenBufferInfo (hConsole
, &csbi
);
51 FillConsoleOutputAttribute (hConsole
,
52 (WORD
)(wColor
& 0x00FF),
53 (csbi
.dwSize
.X
)*(csbi
.dwSize
.Y
),
57 SetConsoleTextAttribute (hConsole
, (WORD
)(wColor
& 0x00FF));
65 * internal dir command
67 INT
CommandColor (LPTSTR first
, LPTSTR rest
)
69 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
71 if (_tcsncmp (rest
, _T("/?"), 2) == 0)
73 ConOutResPaging(TRUE
,STRING_COLOR_HELP1
);
79 if (rest
[0] == _T('\0'))
81 /* set default color */
83 SetScreenColor (wColor
, FALSE
);
88 if ( _tcslen(&rest
[0])==1)
90 if ( (_tcscmp(&rest
[0], _T("0")) >=0 ) && (_tcscmp(&rest
[0], _T("9")) <=0 ) )
92 SetConsoleTextAttribute (hConsole
, (WORD
)_ttoi(rest
));
95 else if ( (_tcscmp(&rest
[0], _T("a")) >=0 ) && (_tcscmp(&rest
[0], _T("f")) <=0 ) )
97 SetConsoleTextAttribute (hConsole
, (WORD
) (rest
[0] + 10 - _T('a')) );
100 else if ( (_tcscmp(&rest
[0], _T("A")) >=0 ) && (_tcscmp(&rest
[0], _T("F")) <=0 ) )
102 SetConsoleTextAttribute (hConsole
, (WORD
) (rest
[0] + 10 - _T('A')) );
105 ConErrResPuts(STRING_COLOR_ERROR2
);
110 if (StringToColor(&wColor
, &rest
) == FALSE
)
112 ConErrResPuts(STRING_COLOR_ERROR2
);
117 LoadString(CMD_ModuleHandle
, STRING_COLOR_ERROR3
, szMsg
, RC_STRING_MAX_SIZE
);
118 ConErrPrintf(szMsg
, wColor
);
120 if ((wColor
& 0xF) == (wColor
&0xF0) >> 4)
122 LoadString(CMD_ModuleHandle
, STRING_COLOR_ERROR4
, szMsg
, RC_STRING_MAX_SIZE
);
123 ConErrPrintf(szMsg
, wColor
);
129 SetScreenColor(wColor
,
130 (_tcsstr (rest
,_T("/-F")) || _tcsstr (rest
,_T("/-f"))));
135 #endif /* INCLUDE_CMD_COLOR */