mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 05:26:58 +00:00
[CMD]: Continue refactoring to lay out the way to using the CONUTILS library in CMD. Part 3/x
svn path=/trunk/; revision=76008
This commit is contained in:
parent
03f438982b
commit
d7bbf5ad8a
|
@ -1956,7 +1956,7 @@ Initialize(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wDefColor != 0)
|
if (wDefColor != 0)
|
||||||
ConSetScreenColor(wDefColor, TRUE);
|
ConSetScreenColor(GetStdHandle(STD_OUTPUT_HANDLE), wDefColor, TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!*ptr)
|
if (!*ptr)
|
||||||
|
|
|
@ -46,7 +46,7 @@ INT CommandColor(LPTSTR rest)
|
||||||
/* No parameter: Set the default colors */
|
/* No parameter: Set the default colors */
|
||||||
if (rest[0] == _T('\0'))
|
if (rest[0] == _T('\0'))
|
||||||
{
|
{
|
||||||
ConSetScreenColor(wDefColor, TRUE);
|
ConSetScreenColor(GetStdHandle(STD_OUTPUT_HANDLE), wDefColor, TRUE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,8 @@ INT CommandColor(LPTSTR rest)
|
||||||
* Set the chosen color. Use also the following advanced flag:
|
* Set the chosen color. Use also the following advanced flag:
|
||||||
* /-F to avoid changing already buffered foreground/background.
|
* /-F to avoid changing already buffered foreground/background.
|
||||||
*/
|
*/
|
||||||
if (ConSetScreenColor(wColor, !_tcsstr(rest, _T("/-F")) && !_tcsstr(rest, _T("/-f"))) == FALSE)
|
if (ConSetScreenColor(GetStdHandle(STD_OUTPUT_HANDLE), wColor,
|
||||||
|
!_tcsstr(rest, _T("/-F")) && !_tcsstr(rest, _T("/-f"))) == FALSE)
|
||||||
{
|
{
|
||||||
/* Failed because foreground and background colors were the same */
|
/* Failed because foreground and background colors were the same */
|
||||||
ConErrResPuts(STRING_COLOR_ERROR1);
|
ConErrResPuts(STRING_COLOR_ERROR1);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define OUTPUT_BUFFER_SIZE 4096
|
#define OUTPUT_BUFFER_SIZE 4096
|
||||||
|
|
||||||
|
/* Cache codepage for text streams */
|
||||||
UINT InputCodePage;
|
UINT InputCodePage;
|
||||||
UINT OutputCodePage;
|
UINT OutputCodePage;
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ VOID ConFormatMessage(DWORD nStdHandle, DWORD MessageId, ...)
|
||||||
|
|
||||||
/************************** Console PAGER functions ***************************/
|
/************************** Console PAGER functions ***************************/
|
||||||
|
|
||||||
INT ConPrintfVPaging(DWORD nStdHandle, BOOL NewPage, LPTSTR szFormat, va_list arg_ptr)
|
BOOL ConPrintfVPaging(DWORD nStdHandle, BOOL NewPage, LPTSTR szFormat, va_list arg_ptr)
|
||||||
{
|
{
|
||||||
INT len;
|
INT len;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
@ -366,14 +366,14 @@ INT ConPrintfVPaging(DWORD nStdHandle, BOOL NewPage, LPTSTR szFormat, va_list ar
|
||||||
|
|
||||||
/* Reset LineCount and return if no string has been given */
|
/* Reset LineCount and return if no string has been given */
|
||||||
if (szFormat == NULL)
|
if (szFormat == NULL)
|
||||||
return 0;
|
return TRUE;
|
||||||
|
|
||||||
/* Get the size of the visual screen that can be printed to */
|
/* Get the size of the visual screen that can be printed to */
|
||||||
if (!IsConsoleHandle(hOutput) || !GetConsoleScreenBufferInfo(hOutput, &csbi))
|
if (!IsConsoleHandle(hOutput) || !GetConsoleScreenBufferInfo(hOutput, &csbi))
|
||||||
{
|
{
|
||||||
/* We assume it's a file handle */
|
/* We assume it's a file handle */
|
||||||
ConPrintfV(nStdHandle, szFormat, arg_ptr);
|
ConPrintfV(nStdHandle, szFormat, arg_ptr);
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -387,7 +387,7 @@ INT ConPrintfVPaging(DWORD nStdHandle, BOOL NewPage, LPTSTR szFormat, va_list ar
|
||||||
if (ScreenLines < 4)
|
if (ScreenLines < 4)
|
||||||
{
|
{
|
||||||
ConPrintfV(nStdHandle, szFormat, arg_ptr);
|
ConPrintfV(nStdHandle, szFormat, arg_ptr);
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = _vstprintf(szOut, szFormat, arg_ptr);
|
len = _vstprintf(szOut, szFormat, arg_ptr);
|
||||||
|
@ -408,9 +408,7 @@ INT ConPrintfVPaging(DWORD nStdHandle, BOOL NewPage, LPTSTR szFormat, va_list ar
|
||||||
|
|
||||||
/* Prompt the user */
|
/* Prompt the user */
|
||||||
if (PagePrompt() != PROMPT_YES)
|
if (PagePrompt() != PROMPT_YES)
|
||||||
{
|
return FALSE;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Recalculate 'ScreenLines' in case the user redimensions
|
// TODO: Recalculate 'ScreenLines' in case the user redimensions
|
||||||
// the window during the prompt.
|
// the window during the prompt.
|
||||||
|
@ -422,18 +420,18 @@ INT ConPrintfVPaging(DWORD nStdHandle, BOOL NewPage, LPTSTR szFormat, va_list ar
|
||||||
|
|
||||||
WriteConsole(hOutput, &szOut[from], i-from, &dwWritten, NULL);
|
WriteConsole(hOutput, &szOut[from], i-from, &dwWritten, NULL);
|
||||||
|
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT ConOutPrintfPaging(BOOL NewPage, LPTSTR szFormat, ...)
|
BOOL ConOutPrintfPaging(BOOL NewPage, LPTSTR szFormat, ...)
|
||||||
{
|
{
|
||||||
INT iReturn;
|
BOOL bRet;
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
|
||||||
va_start(arg_ptr, szFormat);
|
va_start(arg_ptr, szFormat);
|
||||||
iReturn = ConPrintfVPaging(STD_OUTPUT_HANDLE, NewPage, szFormat, arg_ptr);
|
bRet = ConPrintfVPaging(STD_OUTPUT_HANDLE, NewPage, szFormat, arg_ptr);
|
||||||
va_end(arg_ptr);
|
va_end(arg_ptr);
|
||||||
return iReturn;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ConOutResPaging(BOOL NewPage, UINT resID)
|
VOID ConOutResPaging(BOOL NewPage, UINT resID)
|
||||||
|
@ -557,9 +555,8 @@ VOID ConClearScreen(HANDLE hOutput)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COLOR
|
#ifdef INCLUDE_CMD_COLOR
|
||||||
BOOL ConSetScreenColor(WORD wColor, BOOL bFill)
|
BOOL ConSetScreenColor(HANDLE hOutput, WORD wColor, BOOL bFill)
|
||||||
{
|
{
|
||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
COORD coPos;
|
COORD coPos;
|
||||||
|
@ -571,11 +568,11 @@ BOOL ConSetScreenColor(WORD wColor, BOOL bFill)
|
||||||
/* Fill the whole background if needed */
|
/* Fill the whole background if needed */
|
||||||
if (bFill)
|
if (bFill)
|
||||||
{
|
{
|
||||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
GetConsoleScreenBufferInfo(hOutput, &csbi);
|
||||||
|
|
||||||
coPos.X = 0;
|
coPos.X = 0;
|
||||||
coPos.Y = 0;
|
coPos.Y = 0;
|
||||||
FillConsoleOutputAttribute(hConsole,
|
FillConsoleOutputAttribute(hOutput,
|
||||||
wColor & 0x00FF,
|
wColor & 0x00FF,
|
||||||
csbi.dwSize.X * csbi.dwSize.Y,
|
csbi.dwSize.X * csbi.dwSize.Y,
|
||||||
coPos,
|
coPos,
|
||||||
|
@ -583,7 +580,7 @@ BOOL ConSetScreenColor(WORD wColor, BOOL bFill)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the text attribute */
|
/* Set the text attribute */
|
||||||
SetConsoleTextAttribute(hConsole, wColor & 0x00FF);
|
SetConsoleTextAttribute(hOutput, wColor & 0x00FF);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -59,8 +59,8 @@ VOID ConFormatMessage(DWORD nStdHandle, DWORD MessageId, ...);
|
||||||
ConFormatMessage(STD_ERROR_HANDLE, (MessageId), ##__VA_ARGS__)
|
ConFormatMessage(STD_ERROR_HANDLE, (MessageId), ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
INT ConPrintfVPaging(DWORD nStdHandle, BOOL, LPTSTR, va_list);
|
BOOL ConPrintfVPaging(DWORD nStdHandle, BOOL, LPTSTR, va_list);
|
||||||
INT ConOutPrintfPaging (BOOL NewPage, LPTSTR, ...);
|
BOOL ConOutPrintfPaging (BOOL NewPage, LPTSTR, ...);
|
||||||
VOID ConOutResPaging(BOOL NewPage, UINT resID);
|
VOID ConOutResPaging(BOOL NewPage, UINT resID);
|
||||||
|
|
||||||
SHORT GetCursorX (VOID);
|
SHORT GetCursorX (VOID);
|
||||||
|
@ -83,7 +83,7 @@ VOID ConClearScreen(HANDLE hOutput);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COLOR
|
#ifdef INCLUDE_CMD_COLOR
|
||||||
BOOL ConSetScreenColor(WORD wColor, BOOL bFill);
|
BOOL ConSetScreenColor(HANDLE hOutput, WORD wColor, BOOL bFill);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TCHAR cgetchar (VOID);
|
// TCHAR cgetchar (VOID);
|
||||||
|
|
|
@ -550,18 +550,18 @@ DirReadParam(LPTSTR Line, /* [IN] The line with the parameters & s
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print either with or without paging, depending on /P switch */
|
/* Print either with or without paging, depending on /P switch */
|
||||||
static INT
|
static BOOL
|
||||||
DirPrintf(LPDIRSWITCHFLAGS lpFlags, LPTSTR szFormat, ...)
|
DirPrintf(LPDIRSWITCHFLAGS lpFlags, LPTSTR szFormat, ...)
|
||||||
{
|
{
|
||||||
INT iReturn = 0;
|
BOOL Done = TRUE;
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
va_start(arg_ptr, szFormat);
|
va_start(arg_ptr, szFormat);
|
||||||
if (lpFlags->bPause)
|
if (lpFlags->bPause)
|
||||||
iReturn = ConPrintfVPaging(STD_OUTPUT_HANDLE, FALSE, szFormat, arg_ptr);
|
Done = ConPrintfVPaging(STD_OUTPUT_HANDLE, FALSE, szFormat, arg_ptr);
|
||||||
else
|
else
|
||||||
ConPrintfV(STD_OUTPUT_HANDLE, szFormat, arg_ptr);
|
ConPrintfV(STD_OUTPUT_HANDLE, szFormat, arg_ptr);
|
||||||
va_end(arg_ptr);
|
va_end(arg_ptr);
|
||||||
return iReturn;
|
return Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1139,7 +1139,7 @@ DirPrintFiles(PDIRFINDINFO ptrFiles[], /* [IN] Files' Info */
|
||||||
if (!lpFlags->bBareFormat && !(lpFlags->bRecursive && (dwCount <= 0)))
|
if (!lpFlags->bBareFormat && !(lpFlags->bRecursive && (dwCount <= 0)))
|
||||||
{
|
{
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP7, szMsg, ARRAYSIZE(szMsg));
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP7, szMsg, ARRAYSIZE(szMsg));
|
||||||
if (DirPrintf(lpFlags, szMsg, szTemp))
|
if (!DirPrintf(lpFlags, szMsg, szTemp))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ INT cmd_type(LPTSTR param)
|
||||||
{
|
{
|
||||||
while (FileGetString(hFile, buff, ARRAYSIZE(buff)))
|
while (FileGetString(hFile, buff, ARRAYSIZE(buff)))
|
||||||
{
|
{
|
||||||
if (ConOutPrintfPaging(bFirstTime, _T("%s"), buff) == 1)
|
if (!ConOutPrintfPaging(bFirstTime, _T("%s"), buff))
|
||||||
{
|
{
|
||||||
bCtrlBreak = FALSE;
|
bCtrlBreak = FALSE;
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
Loading…
Reference in a new issue