diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index bc608f8cce4..0ca949451be 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -311,10 +311,11 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd) { TCHAR szFullName[MAX_PATH]; TCHAR *first, *rest, *dot; - TCHAR szWindowTitle[MAX_PATH], szNewTitle[MAX_PATH*2]; + TCHAR szWindowTitle[MAX_PATH]; + TCHAR szNewTitle[MAX_PATH*2]; DWORD dwExitCode = 0; TCHAR *FirstEnd; - TCHAR szFullCmdLine [CMDLINE_LENGTH]; + TCHAR szFullCmdLine[CMDLINE_LENGTH]; TRACE ("Execute: \'%s\' \'%s\'\n", debugstr_aw(First), debugstr_aw(Rest)); @@ -1762,33 +1763,6 @@ GetCmdLineCommand(TCHAR *commandline, TCHAR *ptr, BOOL AlwaysStrip) } -#ifdef INCLUDE_CMD_COLOR - -BOOL ConGetDefaultAttributes(PWORD pwDefAttr) -{ - BOOL Success; - HANDLE hConsole; - CONSOLE_SCREEN_BUFFER_INFO csbi; - - /* Do not modify *pwDefAttr if we fail, in which case use default attributes */ - - hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, 0, NULL); - if (hConsole == INVALID_HANDLE_VALUE) - return FALSE; // No default console - - Success = GetConsoleScreenBufferInfo(hConsole, &csbi); - if (Success) - *pwDefAttr = csbi.wAttributes; - - CloseHandle(hConsole); - return Success; -} - -#endif - - /* * Set up global initializations and process parameters */ @@ -1997,7 +1971,6 @@ static VOID Cleanup(VOID) if (IsExistingFile(_T("cmdexit.bat"))) { ConErrResPuts(STRING_CMD_ERROR5); - ParseCommandLine(_T("cmdexit.bat")); } else if (IsExistingFile(_T("\\cmdexit.bat"))) diff --git a/reactos/base/shell/cmd/cmd.h b/reactos/base/shell/cmd/cmd.h index a0c7b56d525..8dab4a70a1c 100644 --- a/reactos/base/shell/cmd/cmd.h +++ b/reactos/base/shell/cmd/cmd.h @@ -25,12 +25,6 @@ #include -#include -#include -#include -#include -#include - #include "cmdver.h" #include "cmddbg.h" @@ -43,7 +37,6 @@ #define D_ON _T("on") #define D_OFF _T("off") - /* command line buffer length */ #define CMDLINE_LENGTH 8192 @@ -51,7 +44,6 @@ #define BUFF_SIZE 16384 /* Global variables */ -extern HANDLE hIn; extern LPTSTR lpOriginalEnvironment; extern WORD wColor; extern WORD wDefColor; @@ -62,8 +54,6 @@ extern BOOL bDisableBatchEcho; extern BOOL bEnableExtensions; extern BOOL bDelayedExpansion; extern INT nErrorLevel; -extern SHORT maxx; -extern SHORT maxy; extern BOOL bUnicodeOutput; diff --git a/reactos/base/shell/cmd/console.c b/reactos/base/shell/cmd/console.c index b83686f8342..346d49749f1 100644 --- a/reactos/base/shell/cmd/console.c +++ b/reactos/base/shell/cmd/console.c @@ -507,6 +507,33 @@ VOID GetScreenSize(PSHORT maxx, PSHORT maxy) +#ifdef INCLUDE_CMD_COLOR + +BOOL ConGetDefaultAttributes(PWORD pwDefAttr) +{ + BOOL Success; + HANDLE hConsole; + CONSOLE_SCREEN_BUFFER_INFO csbi; + + /* Do not modify *pwDefAttr if we fail, in which case use default attributes */ + + hConsole = CreateFile(_T("CONOUT$"), GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, NULL); + if (hConsole == INVALID_HANDLE_VALUE) + return FALSE; // No default console + + Success = GetConsoleScreenBufferInfo(hConsole, &csbi); + if (Success) + *pwDefAttr = csbi.wAttributes; + + CloseHandle(hConsole); + return Success; +} + +#endif + + BOOL ConSetTitle(IN LPCTSTR lpConsoleTitle) { /* Now really set the console title */ diff --git a/reactos/base/shell/cmd/console.h b/reactos/base/shell/cmd/console.h index 69ef9d32d0d..74a8e963b2c 100644 --- a/reactos/base/shell/cmd/console.h +++ b/reactos/base/shell/cmd/console.h @@ -72,6 +72,11 @@ VOID GetScreenSize (PSHORT, PSHORT); VOID SetCursorType (BOOL, BOOL); +#ifdef INCLUDE_CMD_COLOR +BOOL ConGetDefaultAttributes(PWORD pwDefAttr); +#endif + + BOOL ConSetTitle(IN LPCTSTR lpConsoleTitle); #ifdef INCLUDE_CMD_BEEP diff --git a/reactos/base/shell/cmd/dir.c b/reactos/base/shell/cmd/dir.c index 093ae8b97d1..ffd03a944d6 100644 --- a/reactos/base/shell/cmd/dir.c +++ b/reactos/base/shell/cmd/dir.c @@ -1052,7 +1052,7 @@ DirPrintOldList(PDIRFINDINFO ptrFiles[], /* [IN] Files' Info */ /* Calculate size */ if (ptrFiles[i]->stFindInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - /* Directory, no size it's a directory*/ + /* Directory, no size it's a directory */ iSizeFormat = -17; _tcscpy(szSize, _T("")); } diff --git a/reactos/base/shell/cmd/precomp.h b/reactos/base/shell/cmd/precomp.h index d55dff9a08d..8f2af74d61e 100644 --- a/reactos/base/shell/cmd/precomp.h +++ b/reactos/base/shell/cmd/precomp.h @@ -7,15 +7,20 @@ #define _CRT_SECURE_NO_DEPRECATE #endif /*_MSC_VER */ +#include +#include #include #include +#include #define WIN32_NO_STATUS -#include #include #include +#include +#include +#include +#include #include -#include #define NTOS_MODE_USER #include diff --git a/reactos/base/shell/cmd/screen.c b/reactos/base/shell/cmd/screen.c index b45d9da974b..0304b52672e 100644 --- a/reactos/base/shell/cmd/screen.c +++ b/reactos/base/shell/cmd/screen.c @@ -15,13 +15,13 @@ #ifdef INCLUDE_CMD_SCREEN - -INT CommandScreen (LPTSTR param) +INT CommandScreen(LPTSTR param) { - SHORT x,y; + SHORT x, y; + SHORT maxx, maxy; BOOL bSkipText = FALSE; - if (_tcsncmp (param, _T("/?"), 2) == 0) + if (_tcsncmp(param, _T("/?"), 2) == 0) { ConOutResPaging(TRUE,STRING_SCREEN_HELP); return 0; @@ -29,72 +29,71 @@ INT CommandScreen (LPTSTR param) nErrorLevel = 0; - //get row - while(_istspace(*param)) + /* Retrieve the screen dimensions */ + GetScreenSize(&maxx, &maxy); + + /* Get row */ + while (_istspace(*param)) param++; - if (!(*param)) + if (!*param) { - error_req_param_missing (); + error_req_param_missing(); return 1; } y = _ttoi(param); - if (y<0 || y>(maxy-1)) + if (y < 0 || y > (maxy-1)) { ConOutResPuts(STRING_SCREEN_ROW); - return 1; } - //get col - if (!(param = _tcschr(param,_T(' ')))) + /* Get column */ + if (!(param = _tcschr(param, _T(' ')))) { - error_req_param_missing (); + error_req_param_missing(); return 1; } - while(_istspace(*param)) + while (_istspace(*param)) param++; - if (!(*param)) + if (!*param) { - error_req_param_missing (); + error_req_param_missing(); return 1; } x = _ttoi(param); - if (x<0 || x>(maxx-1)) + if (x < 0 || x > (maxx-1)) { ConErrResPuts(STRING_SCREEN_COL); return 1; } - //get text - if (!(param = _tcschr(param,_T(' ')))) + /* Get text */ + if (!(param = _tcschr(param, _T(' ')))) { bSkipText = TRUE; } else { - while(_istspace(*param)) + while (_istspace(*param)) param++; - if (!(*param)) - { + if (!*param) bSkipText = TRUE; - } } bIgnoreEcho = TRUE; if (bSkipText) - x=0; + x = 0; + SetCursorXY(x, y); - SetCursorXY(x,y); - - if (!(bSkipText)) + if (!bSkipText) ConOutPuts(param); return 0; diff --git a/reactos/base/shell/cmd/start.c b/reactos/base/shell/cmd/start.c index de1b78f2fdf..f13bd8e43cd 100644 --- a/reactos/base/shell/cmd/start.c +++ b/reactos/base/shell/cmd/start.c @@ -45,7 +45,7 @@ INT cmd_start (LPTSTR Rest) BOOL bWait = FALSE; BOOL bBat = FALSE; BOOL bCreate = FALSE; - TCHAR szFullCmdLine [CMDLINE_LENGTH]; + TCHAR szFullCmdLine[CMDLINE_LENGTH]; PROCESS_INFORMATION prci; STARTUPINFO stui; #ifdef UNICODE @@ -303,6 +303,7 @@ INT cmd_start (LPTSTR Rest) nErrorLevel = (INT)dwExitCode; } CloseHandle (prci.hProcess); + /* Get New code page if it has change */ InputCodePage= GetConsoleCP(); OutputCodePage = GetConsoleOutputCP();