mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[CMD]
Implement CTRL+Left (jump to previous word) and CRTL+Right (jump to next word) edit keys. CORE-5626 #resolve svn path=/trunk/; revision=65782
This commit is contained in:
parent
7528b04c30
commit
baf567d896
1 changed files with 118 additions and 37 deletions
|
@ -137,6 +137,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
|
||||||
INT current = 0; /*the position of the cursor in the string (str)*/
|
INT current = 0; /*the position of the cursor in the string (str)*/
|
||||||
INT charcount = 0;/*chars in the string (str)*/
|
INT charcount = 0;/*chars in the string (str)*/
|
||||||
INPUT_RECORD ir;
|
INPUT_RECORD ir;
|
||||||
|
DWORD dwControlKeyState;
|
||||||
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
|
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
|
||||||
WORD wLastKey = 0;
|
WORD wLastKey = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,7 +186,9 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
|
||||||
bReturn = FALSE;
|
bReturn = FALSE;
|
||||||
ConInKey (&ir);
|
ConInKey (&ir);
|
||||||
|
|
||||||
if (ir.Event.KeyEvent.dwControlKeyState &
|
dwControlKeyState = ir.Event.KeyEvent.dwControlKeyState;
|
||||||
|
|
||||||
|
if (dwControlKeyState &
|
||||||
(RIGHT_ALT_PRESSED |LEFT_ALT_PRESSED|
|
(RIGHT_ALT_PRESSED |LEFT_ALT_PRESSED|
|
||||||
RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED) )
|
RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED) )
|
||||||
{
|
{
|
||||||
|
@ -194,7 +197,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
case 'K':
|
case 'K':
|
||||||
/*add the current command line to the history*/
|
/*add the current command line to the history*/
|
||||||
if (ir.Event.KeyEvent.dwControlKeyState &
|
if (dwControlKeyState &
|
||||||
(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
|
(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
|
||||||
{
|
{
|
||||||
if (str[0])
|
if (str[0])
|
||||||
|
@ -210,7 +213,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
/*delete current history entry*/
|
/*delete current history entry*/
|
||||||
if (ir.Event.KeyEvent.dwControlKeyState &
|
if (dwControlKeyState &
|
||||||
(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
|
(LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
|
||||||
{
|
{
|
||||||
ClearCommandLine (str, maxlen, orgx, orgy);
|
ClearCommandLine (str, maxlen, orgx, orgy);
|
||||||
|
@ -481,59 +484,137 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_LEFT:
|
case VK_LEFT:
|
||||||
/* move cursor left */
|
if (dwControlKeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
|
||||||
if (current > 0)
|
|
||||||
{
|
{
|
||||||
current--;
|
/* move cursor to the previous word */
|
||||||
if (GetCursorX () == 0)
|
if (current > 0)
|
||||||
{
|
{
|
||||||
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
while (current > 0 && str[current - 1] == _T(' '))
|
||||||
curx = maxx - 1;
|
{
|
||||||
cury--;
|
current--;
|
||||||
}
|
if (curx == 0)
|
||||||
else
|
{
|
||||||
{
|
cury--;
|
||||||
SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ());
|
curx = maxx -1;
|
||||||
curx--;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curx--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (current > 0 && str[current -1] != _T(' '))
|
||||||
|
{
|
||||||
|
current--;
|
||||||
|
if (curx == 0)
|
||||||
|
{
|
||||||
|
cury--;
|
||||||
|
curx = maxx -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curx--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCursorXY(curx, cury);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBeep (-1);
|
/* move cursor left */
|
||||||
|
if (current > 0)
|
||||||
|
{
|
||||||
|
current--;
|
||||||
|
if (GetCursorX () == 0)
|
||||||
|
{
|
||||||
|
SetCursorXY ((SHORT)(maxx - 1), (SHORT)(GetCursorY () - 1));
|
||||||
|
curx = maxx - 1;
|
||||||
|
cury--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetCursorXY ((SHORT)(GetCursorX () - 1), GetCursorY ());
|
||||||
|
curx--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBeep (-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_RIGHT:
|
case VK_RIGHT:
|
||||||
/* move cursor right */
|
if (dwControlKeyState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
|
||||||
if (current != charcount)
|
|
||||||
{
|
{
|
||||||
current++;
|
/* move cursor to the next word */
|
||||||
if (GetCursorX () == maxx - 1)
|
if (current != charcount)
|
||||||
{
|
{
|
||||||
SetCursorXY (0, (SHORT)(GetCursorY () + 1));
|
while (current != charcount && str[current] != _T(' '))
|
||||||
curx = 0;
|
{
|
||||||
cury++;
|
current++;
|
||||||
}
|
if (curx == maxx - 1)
|
||||||
else
|
{
|
||||||
{
|
cury++;
|
||||||
SetCursorXY ((SHORT)(GetCursorX () + 1), GetCursorY ());
|
curx = 0;
|
||||||
curx++;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (current != charcount && str[current] == _T(' '))
|
||||||
|
{
|
||||||
|
current++;
|
||||||
|
if (curx == maxx - 1)
|
||||||
|
{
|
||||||
|
cury++;
|
||||||
|
curx = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCursorXY(curx, cury);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef FEATURE_HISTORY
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LPCTSTR last = PeekHistory(-1);
|
/* move cursor right */
|
||||||
if (last && charcount < (INT)_tcslen (last))
|
if (current != charcount)
|
||||||
{
|
{
|
||||||
PreviousChar = last[current];
|
current++;
|
||||||
ConOutChar(PreviousChar);
|
if (GetCursorX () == maxx - 1)
|
||||||
GetCursorXY(&curx, &cury);
|
{
|
||||||
str[current++] = PreviousChar;
|
SetCursorXY (0, (SHORT)(GetCursorY () + 1));
|
||||||
charcount++;
|
curx = 0;
|
||||||
|
cury++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetCursorXY ((SHORT)(GetCursorX () + 1), GetCursorY ());
|
||||||
|
curx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef FEATURE_HISTORY
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LPCTSTR last = PeekHistory(-1);
|
||||||
|
if (last && charcount < (INT)_tcslen (last))
|
||||||
|
{
|
||||||
|
PreviousChar = last[current];
|
||||||
|
ConOutChar(PreviousChar);
|
||||||
|
GetCursorXY(&curx, &cury);
|
||||||
|
str[current++] = PreviousChar;
|
||||||
|
charcount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue