diff --git a/reactos/base/shell/cmd/cmdinput.c b/reactos/base/shell/cmd/cmdinput.c index 0a9e297ca21..a93d3bdda8d 100644 --- a/reactos/base/shell/cmd/cmdinput.c +++ b/reactos/base/shell/cmd/cmdinput.c @@ -137,11 +137,11 @@ VOID ReadCommand (LPTSTR str, INT maxlen) WORD wLastKey = 0; TCHAR ch; BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/ - BOOL bReturn = FALSE; - BOOL bCharInput; - #ifdef FEATURE_4NT_FILENAME_COMPLETION - TCHAR szPath[MAX_PATH]; - #endif + BOOL bReturn = FALSE; + BOOL bCharInput; +#ifdef FEATURE_4NT_FILENAME_COMPLETION + TCHAR szPath[MAX_PATH]; +#endif /* get screen size */ GetScreenSize (&maxx, &maxy); @@ -159,9 +159,9 @@ VOID ReadCommand (LPTSTR str, INT maxlen) do { - - bReturn = FALSE; - + + bReturn = FALSE; + ConInKey (&ir); if (ir.Event.KeyEvent.dwControlKeyState & @@ -213,11 +213,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen) } - //if (bContinue) - // continue; - - - bCharInput = FALSE; + bCharInput = FALSE; switch (ir.Event.KeyEvent.wVirtualKeyCode) { @@ -367,12 +363,12 @@ VOID ReadCommand (LPTSTR str, INT maxlen) } #endif #ifdef FEATURE_4NT_FILENAME_COMPLETION - + /* used to later see if we went down to the next line */ tempscreen = charcount; szPath[0]=_T('\0'); - /* str is the whole things that is on the current line + /* str is the whole things that is on the current line that is and and out. arg 2 is weather it goes back one file or forward one file */ CompleteFilename(str, !(ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED), szPath, current); @@ -380,12 +376,11 @@ VOID ReadCommand (LPTSTR str, INT maxlen) ClearCommandLine (str, maxlen, orgx, orgy); curx = orgx; cury = orgy; - current = charcount = 0; - //str[0]=_T('\0'); - + current = charcount = 0; + /* Everything is deleted, lets add it back in */ _tcscpy(str,szPath); - + /* Figure out where cusor is going to be after we print it */ charcount = _tcslen (str); current = charcount; @@ -412,17 +407,17 @@ VOID ReadCommand (LPTSTR str, INT maxlen) #endif break; - - case _T('M'): - case _T('C'): - /* ^M does the same as return */ - bCharInput = TRUE; - if(!(ir.Event.KeyEvent.dwControlKeyState & - (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED))) - { - break; - } - + + case _T('M'): + case _T('C'): + /* ^M does the same as return */ + bCharInput = TRUE; + if(!(ir.Event.KeyEvent.dwControlKeyState & + (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED))) + { + break; + } + case VK_RETURN: /* end input, return to main */ #ifdef FEATURE_HISTORY @@ -432,7 +427,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen) #endif ConInDummy (); ConOutChar (_T('\n')); - bReturn = TRUE; + bReturn = TRUE; break; case VK_ESCAPE: @@ -515,58 +510,58 @@ VOID ReadCommand (LPTSTR str, INT maxlen) } break; - default: - /* This input is just a normal char */ - bCharInput = TRUE; + default: + /* This input is just a normal char */ + bCharInput = TRUE; } #ifdef _UNICODE - ch = ir.Event.KeyEvent.uChar.UnicodeChar; - if (ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) + ch = ir.Event.KeyEvent.uChar.UnicodeChar; + if (ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) #else - ch = ir.Event.KeyEvent.uChar.AsciiChar; - if ((UCHAR)ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) + ch = ir.Event.KeyEvent.uChar.AsciiChar; + if ((UCHAR)ch >= 32 && (charcount != (maxlen - 2)) && bCharInput) #endif /* _UNICODE */ - { - /* insert character into string... */ - if (bInsert && current != charcount) - { - /* If this character insertion will cause screen scrolling, - * adjust the saved origin of the command prompt. */ - tempscreen = _tcslen(str + current) + curx; - if ((tempscreen % maxx) == (maxx - 1) && - (tempscreen / maxx) + cury == (maxy - 1)) - { - orgy--; - cury--; - } + { + /* insert character into string... */ + if (bInsert && current != charcount) + { + /* If this character insertion will cause screen scrolling, + * adjust the saved origin of the command prompt. */ + tempscreen = _tcslen(str + current) + curx; + if ((tempscreen % maxx) == (maxx - 1) && + (tempscreen / maxx) + cury == (maxy - 1)) + { + orgy--; + cury--; + } + + for (count = charcount; count > current; count--) + str[count] = str[count - 1]; + str[current++] = ch; + if (curx == maxx - 1) + curx = 0, cury++; + else + curx++; + ConOutPrintf (_T("%s"), &str[current - 1]); + SetCursorXY (curx, cury); + charcount++; + } + else + { + if (current == charcount) + charcount++; + str[current++] = ch; + if (GetCursorX () == maxx - 1 && GetCursorY () == maxy - 1) + orgy--, cury--; + if (GetCursorX () == maxx - 1) + curx = 0, cury++; + else + curx++; + ConOutChar (ch); + } + } - for (count = charcount; count > current; count--) - str[count] = str[count - 1]; - str[current++] = ch; - if (curx == maxx - 1) - curx = 0, cury++; - else - curx++; - ConOutPrintf (_T("%s"), &str[current - 1]); - SetCursorXY (curx, cury); - charcount++; - } - else - { - if (current == charcount) - charcount++; - str[current++] = ch; - if (GetCursorX () == maxx - 1 && GetCursorY () == maxy - 1) - orgy--, cury--; - if (GetCursorX () == maxx - 1) - curx = 0, cury++; - else - curx++; - ConOutChar (ch); - } - } - wLastKey = ir.Event.KeyEvent.wVirtualKeyCode; } while (!bReturn);