[CONSRV]: Code formatting only.

svn path=/branches/condrv_restructure/; revision=63990
This commit is contained in:
Hermès Bélusca-Maïto 2014-08-30 15:59:35 +00:00
parent e3e54a09b3
commit ccaa07fecf

View file

@ -165,7 +165,6 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
{ {
UINT Pos = Console->LinePos; UINT Pos = Console->LinePos;
UNICODE_STRING Entry; UNICODE_STRING Entry;
// INT HistPos;
/* /*
* First, deal with control keys... * First, deal with control keys...
@ -173,159 +172,207 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
switch (KeyEvent->wVirtualKeyCode) switch (KeyEvent->wVirtualKeyCode)
{ {
case VK_ESCAPE: case VK_ESCAPE:
/* Clear entire line */
LineInputSetPos(Console, 0);
LineInputEdit(Console, Console->LineSize, 0, NULL);
return;
case VK_HOME:
/* Move to start of line. With CTRL, erase everything left of cursor */
LineInputSetPos(Console, 0);
if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
LineInputEdit(Console, Pos, 0, NULL);
return;
case VK_END:
/* Move to end of line. With CTRL, erase everything right of cursor */
if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
LineInputEdit(Console, Console->LineSize - Pos, 0, NULL);
else
LineInputSetPos(Console, Console->LineSize);
return;
case VK_LEFT:
/* Move left. With CTRL, move to beginning of previous word */
if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
{ {
while (Pos > 0 && Console->LineBuffer[Pos - 1] == L' ') Pos--; /* Clear entire line */
while (Pos > 0 && Console->LineBuffer[Pos - 1] != L' ') Pos--; LineInputSetPos(Console, 0);
LineInputEdit(Console, Console->LineSize, 0, NULL);
return;
} }
else
case VK_HOME:
{ {
Pos -= (Pos > 0); /* Move to start of line. With CTRL, erase everything left of cursor */
LineInputSetPos(Console, 0);
if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
LineInputEdit(Console, Pos, 0, NULL);
return;
} }
LineInputSetPos(Console, Pos);
return; case VK_END:
case VK_RIGHT:
case VK_F1:
/* Move right. With CTRL, move to beginning of next word */
if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
{ {
while (Pos < Console->LineSize && Console->LineBuffer[Pos] != L' ') Pos++; /* Move to end of line. With CTRL, erase everything right of cursor */
while (Pos < Console->LineSize && Console->LineBuffer[Pos] == L' ') Pos++; if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
LineInputSetPos(Console, Pos); LineInputEdit(Console, Console->LineSize - Pos, 0, NULL);
else
LineInputSetPos(Console, Console->LineSize);
return;
} }
else
case VK_LEFT:
{ {
/* Recall one character (but don't overwrite current line) */ /* Move left. With CTRL, move to beginning of previous word */
HistoryGetCurrentEntry(Console, ExeName, &Entry); if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
if (Pos < Console->LineSize) {
LineInputSetPos(Console, Pos + 1); while (Pos > 0 && Console->LineBuffer[Pos - 1] == L' ') Pos--;
else if (Pos * sizeof(WCHAR) < Entry.Length) while (Pos > 0 && Console->LineBuffer[Pos - 1] != L' ') Pos--;
LineInputEdit(Console, 0, 1, &Entry.Buffer[Pos]); }
} else
return; {
case VK_INSERT: Pos -= (Pos > 0);
/* Toggle between insert and overstrike */ }
Console->LineInsertToggle = !Console->LineInsertToggle; LineInputSetPos(Console, Pos);
TermSetCursorInfo(Console, Console->ActiveBuffer); return;
return; }
case VK_DELETE:
/* Remove character to right of cursor */ case VK_RIGHT:
if (Pos != Console->LineSize) case VK_F1:
LineInputEdit(Console, 1, 0, NULL); {
return; /* Move right. With CTRL, move to beginning of next word */
case VK_PRIOR: if (KeyEvent->dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
/* Recall first history entry */ {
LineInputRecallHistory(Console, ExeName, -((WORD)-1)); while (Pos < Console->LineSize && Console->LineBuffer[Pos] != L' ') Pos++;
return; while (Pos < Console->LineSize && Console->LineBuffer[Pos] == L' ') Pos++;
case VK_NEXT: LineInputSetPos(Console, Pos);
/* Recall last history entry */ }
LineInputRecallHistory(Console, ExeName, +((WORD)-1)); else
return; {
case VK_UP: /* Recall one character (but don't overwrite current line) */
case VK_F5: HistoryGetCurrentEntry(Console, ExeName, &Entry);
/* if (Pos < Console->LineSize)
* Recall previous history entry. On first time, actually recall the LineInputSetPos(Console, Pos + 1);
* current (usually last) entry; on subsequent times go back. else if (Pos * sizeof(WCHAR) < Entry.Length)
*/ LineInputEdit(Console, 0, 1, &Entry.Buffer[Pos]);
LineInputRecallHistory(Console, ExeName, Console->LineUpPressed ? -1 : 0); }
Console->LineUpPressed = TRUE; return;
return; }
case VK_DOWN:
/* Recall next history entry */ case VK_INSERT:
LineInputRecallHistory(Console, ExeName, +1); {
return; /* Toggle between insert and overstrike */
case VK_F3: Console->LineInsertToggle = !Console->LineInsertToggle;
/* Recall remainder of current history entry */ TermSetCursorInfo(Console, Console->ActiveBuffer);
HistoryGetCurrentEntry(Console, ExeName, &Entry); return;
if (Pos * sizeof(WCHAR) < Entry.Length) }
{
UINT InsertSize = (Entry.Length / sizeof(WCHAR) - Pos); case VK_DELETE:
UINT DeleteSize = min(Console->LineSize - Pos, InsertSize); {
LineInputEdit(Console, DeleteSize, InsertSize, &Entry.Buffer[Pos]); /* Remove character to right of cursor */
} if (Pos != Console->LineSize)
return; LineInputEdit(Console, 1, 0, NULL);
case VK_F6: return;
/* Insert a ^Z character */ }
KeyEvent->uChar.UnicodeChar = 26;
break; case VK_PRIOR:
case VK_F7: {
if (KeyEvent->dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)) /* Recall first history entry */
HistoryDeleteCurrentBuffer(Console, ExeName); LineInputRecallHistory(Console, ExeName, -((WORD)-1));
return; return;
case VK_F8: }
{ case VK_NEXT:
UNICODE_STRING EntryFound; {
/* Recall last history entry */
Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR) LineInputRecallHistory(Console, ExeName, +((WORD)-1));
Entry.Buffer = Console->LineBuffer; return;
}
if (HistoryFindEntryByPrefix(Console, ExeName, &Entry, &EntryFound))
{ case VK_UP:
LineInputEdit(Console, Console->LineSize - Pos, case VK_F5:
EntryFound.Length / sizeof(WCHAR) - Pos, {
&EntryFound.Buffer[Pos]); /*
/* Cursor stays where it was */ * Recall previous history entry. On first time, actually recall the
LineInputSetPos(Console, Pos); * current (usually last) entry; on subsequent times go back.
} */
} LineInputRecallHistory(Console, ExeName, Console->LineUpPressed ? -1 : 0);
#if 0 Console->LineUpPressed = TRUE;
PHISTORY_BUFFER Hist; return;
}
/* Search for history entries starting with input. */
Hist = HistoryCurrentBuffer(Console, ExeName); case VK_DOWN:
if (!Hist || Hist->NumEntries == 0) return; {
/* Recall next history entry */
/* LineInputRecallHistory(Console, ExeName, +1);
* Like Up/F5, on first time start from current (usually last) entry, return;
* but on subsequent times start at previous entry. }
*/
if (Console->LineUpPressed) case VK_F3:
Hist->Position = (Hist->Position ? Hist->Position : Hist->NumEntries) - 1; {
Console->LineUpPressed = TRUE; /* Recall remainder of current history entry */
HistoryGetCurrentEntry(Console, ExeName, &Entry);
Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR) if (Pos * sizeof(WCHAR) < Entry.Length)
Entry.Buffer = Console->LineBuffer; {
UINT InsertSize = (Entry.Length / sizeof(WCHAR) - Pos);
/* UINT DeleteSize = min(Console->LineSize - Pos, InsertSize);
* Keep going backwards, even wrapping around to the end, LineInputEdit(Console, DeleteSize, InsertSize, &Entry.Buffer[Pos]);
* until we get back to starting point. }
*/ return;
HistPos = Hist->Position; }
do
{ case VK_F6:
if (RtlPrefixUnicodeString(&Entry, &Hist->Entries[HistPos], FALSE)) {
/* Insert a ^Z character */
KeyEvent->uChar.UnicodeChar = 26;
break;
}
case VK_F7:
{
if (KeyEvent->dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
HistoryDeleteCurrentBuffer(Console, ExeName);
return;
}
case VK_F8:
{
UNICODE_STRING EntryFound;
Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR)
Entry.Buffer = Console->LineBuffer;
if (HistoryFindEntryByPrefix(Console, ExeName, &Entry, &EntryFound))
{ {
Hist->Position = HistPos;
LineInputEdit(Console, Console->LineSize - Pos, LineInputEdit(Console, Console->LineSize - Pos,
Hist->Entries[HistPos].Length / sizeof(WCHAR) - Pos, EntryFound.Length / sizeof(WCHAR) - Pos,
&Hist->Entries[HistPos].Buffer[Pos]); &EntryFound.Buffer[Pos]);
/* Cursor stays where it was */ /* Cursor stays where it was */
LineInputSetPos(Console, Pos); LineInputSetPos(Console, Pos);
return;
} }
if (--HistPos < 0) HistPos += Hist->NumEntries;
} while (HistPos != Hist->Position); return;
}
#if 0
{
PHISTORY_BUFFER Hist;
INT HistPos;
/* Search for history entries starting with input. */
Hist = HistoryCurrentBuffer(Console, ExeName);
if (!Hist || Hist->NumEntries == 0) return;
/*
* Like Up/F5, on first time start from current (usually last) entry,
* but on subsequent times start at previous entry.
*/
if (Console->LineUpPressed)
Hist->Position = (Hist->Position ? Hist->Position : Hist->NumEntries) - 1;
Console->LineUpPressed = TRUE;
Entry.Length = Console->LinePos * sizeof(WCHAR); // == Pos * sizeof(WCHAR)
Entry.Buffer = Console->LineBuffer;
/*
* Keep going backwards, even wrapping around to the end,
* until we get back to starting point.
*/
HistPos = Hist->Position;
do
{
if (RtlPrefixUnicodeString(&Entry, &Hist->Entries[HistPos], FALSE))
{
Hist->Position = HistPos;
LineInputEdit(Console, Console->LineSize - Pos,
Hist->Entries[HistPos].Length / sizeof(WCHAR) - Pos,
&Hist->Entries[HistPos].Buffer[Pos]);
/* Cursor stays where it was */
LineInputSetPos(Console, Pos);
return;
}
if (--HistPos < 0) HistPos += Hist->NumEntries;
} while (HistPos != Hist->Position);
return;
}
#endif #endif
return; return;
@ -333,7 +380,7 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
/* /*
* OK, we can continue... * OK, we deal with normal keys, we can continue...
*/ */
if (KeyEvent->uChar.UnicodeChar == L'\b' && Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT) if (KeyEvent->uChar.UnicodeChar == L'\b' && Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT)