- Move the code used to beep, clear screen, and color the screen into console.c ;
- Rename SetScreenColor into ConSetScreenColor, and invert its second parameter (bNoFill -> bFill); its default behaviour is to fill all the screen.
svn path=/trunk/; revision=76000
if (bc == NULL)
return 1;
#endif
- MessageBeep (-1);
+ ConRingBell(GetStdHandle(STD_OUTPUT_HANDLE));
return 0;
}
INT cmd_cls(LPTSTR param)
{
- HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- COORD coPos;
- DWORD dwWritten;
-
if (!_tcsncmp(param, _T("/?"), 2))
{
ConOutResPaging(TRUE, STRING_CLS_HELP);
return 0;
}
- if (GetConsoleScreenBufferInfo(hOutput, &csbi))
- {
- coPos.X = 0;
- coPos.Y = 0;
- FillConsoleOutputAttribute(hOutput, csbi.wAttributes,
- csbi.dwSize.X * csbi.dwSize.Y,
- coPos, &dwWritten);
- FillConsoleOutputCharacter(hOutput, _T(' '),
- csbi.dwSize.X * csbi.dwSize.Y,
- coPos, &dwWritten);
- SetConsoleCursorPosition(hOutput, coPos);
- }
- else
- {
- ConOutChar(_T('\f'));
- }
-
+ ConClearScreen(GetStdHandle(STD_OUTPUT_HANDLE));
return 0;
}
}
if (wDefColor != 0)
- SetScreenColor(wDefColor, FALSE);
+ ConSetScreenColor(wDefColor, TRUE);
#endif
if (!*ptr)
LPCTSTR GetParsedEnvVar ( LPCTSTR varName, UINT* varNameLen, BOOL ModeSetA );
/* Prototypes for COLOR.C */
-BOOL SetScreenColor(WORD wColor, BOOL bNoFill);
INT CommandColor(LPTSTR);
VOID ConInDummy (VOID);
VOID ConErrResPrintf (UINT resID, ...);
VOID ConOutResPaging(BOOL NewPage, UINT resID);
+#ifdef INCLUDE_CMD_BEEP
+VOID ConRingBell(HANDLE hOutput);
+#endif
+
+#ifdef INCLUDE_CMD_CLS
+VOID ConClearScreen(HANDLE hOutput);
+#endif
+
+#ifdef INCLUDE_CMD_COLOR
+BOOL ConSetScreenColor(WORD wColor, BOOL bFill);
+#endif
+
+
/* Prototypes for COPY.C */
INT cmd_copy (LPTSTR);
#ifdef INCLUDE_CMD_COLOR
-BOOL SetScreenColor(WORD wColor, BOOL bNoFill)
-{
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- DWORD dwWritten;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- COORD coPos;
-
- /* Foreground and Background colors can't be the same */
- if ((wColor & 0x0F) == (wColor & 0xF0) >> 4)
- return FALSE;
-
- /* Fill the whole background if needed */
- if (bNoFill != TRUE)
- {
- GetConsoleScreenBufferInfo(hConsole, &csbi);
-
- coPos.X = 0;
- coPos.Y = 0;
- FillConsoleOutputAttribute(hConsole,
- wColor & 0x00FF,
- csbi.dwSize.X * csbi.dwSize.Y,
- coPos,
- &dwWritten);
- }
-
- /* Set the text attribute */
- SetConsoleTextAttribute(hConsole, wColor & 0x00FF);
- return TRUE;
-}
-
/*
* color
*
/* No parameter: Set the default colors */
if (rest[0] == _T('\0'))
{
- SetScreenColor(wDefColor, FALSE);
+ ConSetScreenColor(wDefColor, TRUE);
return 0;
}
* Set the chosen color. Use also the following advanced flag:
* /-F to avoid changing already buffered foreground/background.
*/
- if (SetScreenColor(wColor, (_tcsstr(rest, _T("/-F")) || _tcsstr(rest, _T("/-f")))) == FALSE)
+ if (ConSetScreenColor(wColor, !_tcsstr(rest, _T("/-F")) && !_tcsstr(rest, _T("/-f"))) == FALSE)
{
/* Failed because foreground and background colors were the same */
ConErrResPuts(STRING_COLOR_ERROR1);
if (maxy) *maxy = csbi.dwSize.Y;
}
+
+
+#ifdef INCLUDE_CMD_BEEP
+VOID ConRingBell(HANDLE hOutput)
+{
+#if 0
+ /* Emit an error beep sound */
+ if (IsConsoleHandle(hOutput))
+ Beep(800, 200);
+ else if (IsTTYHandle(hOutput))
+ ConOutPuts(_T("\a")); // BEL character 0x07
+ else
+#endif
+ MessageBeep(-1);
+}
+#endif
+
+#ifdef INCLUDE_CMD_CLS
+VOID ConClearScreen(HANDLE hOutput)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD coPos;
+ DWORD dwWritten;
+
+ if (GetConsoleScreenBufferInfo(hOutput, &csbi))
+ {
+ coPos.X = 0;
+ coPos.Y = 0;
+ FillConsoleOutputAttribute(hOutput, csbi.wAttributes,
+ csbi.dwSize.X * csbi.dwSize.Y,
+ coPos, &dwWritten);
+ FillConsoleOutputCharacter(hOutput, _T(' '),
+ csbi.dwSize.X * csbi.dwSize.Y,
+ coPos, &dwWritten);
+ SetConsoleCursorPosition(hOutput, coPos);
+ }
+ else
+ {
+ ConOutChar(_T('\f'));
+ }
+}
+#endif
+
+#ifdef INCLUDE_CMD_COLOR
+BOOL ConSetScreenColor(WORD wColor, BOOL bFill)
+{
+ HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+ DWORD dwWritten;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD coPos;
+
+ /* Foreground and Background colors can't be the same */
+ if ((wColor & 0x0F) == (wColor & 0xF0) >> 4)
+ return FALSE;
+
+ /* Fill the whole background if needed */
+ if (bFill)
+ {
+ GetConsoleScreenBufferInfo(hConsole, &csbi);
+
+ coPos.X = 0;
+ coPos.Y = 0;
+ FillConsoleOutputAttribute(hConsole,
+ wColor & 0x00FF,
+ csbi.dwSize.X * csbi.dwSize.Y,
+ coPos,
+ &dwWritten);
+ }
+
+ /* Set the text attribute */
+ SetConsoleTextAttribute(hConsole, wColor & 0x00FF);
+ return TRUE;
+}
+#endif
+
/* EOF */