Author: jmorlan
Date: Fri Jun 4 18:31:56 2010
New Revision: 47568
URL:
http://svn.reactos.org/svn/reactos?rev=47568&view=rev
Log:
[WIN32CSR] Consistently store console input events internally as unicode.
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/coninput.c [iso-8859-1] Fri Jun 4
18:31:56 2010
@@ -26,7 +26,7 @@
{
PLIST_ENTRY CurrentEntry;
ConsoleInput *Input;
- PUCHAR Buffer;
+ PCHAR Buffer;
PWCHAR UnicodeBuffer;
ULONG i;
ULONG nNumberOfCharsToRead, CharSize;
@@ -42,7 +42,7 @@
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) -
sizeof(PORT_MESSAGE);
- Buffer = Request->Data.ReadConsoleRequest.Buffer;
+ Buffer = (PCHAR)Request->Data.ReadConsoleRequest.Buffer;
UnicodeBuffer = (PWCHAR)Buffer;
Status = ConioLockConsole(ProcessData,
Request->Data.ReadConsoleRequest.ConsoleHandle,
&Console, GENERIC_READ);
@@ -64,21 +64,20 @@
/* only pay attention to valid ascii chars, on key down */
if (KEY_EVENT == Input->InputEvent.EventType
&& Input->InputEvent.Event.KeyEvent.bKeyDown
- && Input->InputEvent.Event.KeyEvent.uChar.AsciiChar !=
'\0')
+ && Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar !=
L'\0')
{
/*
* backspace handling - if we are in charge of echoing it then we handle it
here
* otherwise we treat it like a normal char.
*/
- if ('\b' == Input->InputEvent.Event.KeyEvent.uChar.AsciiChar
&& 0
+ if (L'\b' == Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar
&& 0
!= (Console->Mode & ENABLE_ECHO_INPUT))
{
/* echo if it has not already been done, and either we or the client has
chars to be deleted */
if (! Input->Echoed
&& (0 != i ||
Request->Data.ReadConsoleRequest.nCharsCanBeDeleted))
{
- ConioWriteConsole(Console, Console->ActiveBuffer,
-
&Input->InputEvent.Event.KeyEvent.uChar.AsciiChar, 1, TRUE);
+ ConioWriteConsole(Console, Console->ActiveBuffer, "\b",
1, TRUE);
}
if (0 != i)
{
@@ -101,17 +100,20 @@
else
{
if(Request->Data.ReadConsoleRequest.Unicode)
- ConsoleInputAnsiCharToUnicodeChar(Console, &UnicodeBuffer[i],
&Input->InputEvent.Event.KeyEvent.uChar.AsciiChar);
+ UnicodeBuffer[i] =
Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar;
else
- Buffer[i] = Input->InputEvent.Event.KeyEvent.uChar.AsciiChar;
+ ConsoleInputUnicodeCharToAnsiChar(Console, &Buffer[i],
&Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar);
}
/* echo to screen if enabled and we did not already echo the char */
if (0 != (Console->Mode & ENABLE_ECHO_INPUT)
&& ! Input->Echoed
- && '\r' !=
Input->InputEvent.Event.KeyEvent.uChar.AsciiChar)
- {
- ConioWriteConsole(Console, Console->ActiveBuffer,
-
&Input->InputEvent.Event.KeyEvent.uChar.AsciiChar, 1, TRUE);
+ && L'\r' !=
Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar)
+ {
+ CHAR AsciiChar;
+ WideCharToMultiByte(Console->OutputCodePage, 0,
+
&Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar, 1,
+ &AsciiChar, 1, NULL, NULL);
+ ConioWriteConsole(Console, Console->ActiveBuffer, &AsciiChar, 1,
TRUE);
}
}
else
@@ -215,15 +217,15 @@
if (0 != (Console->Mode & (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT)))
{
- switch(KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar)
- {
- case '\r':
+ switch(KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar)
+ {
+ case L'\r':
/* first add the \r */
KeyEventRecord->InputEvent.EventType = KEY_EVENT;
updown = KeyEventRecord->InputEvent.Event.KeyEvent.bKeyDown;
KeyEventRecord->Echoed = FALSE;
KeyEventRecord->InputEvent.Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
- KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar = '\r';
+ KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar =
L'\r';
InsertTailList(&Console->InputEvents,
&KeyEventRecord->ListEntry);
Console->WaitingChars++;
KeyEventRecord = HeapAlloc(Win32CsrApiHeap, 0, sizeof(ConsoleInput));
@@ -236,7 +238,7 @@
KeyEventRecord->InputEvent.Event.KeyEvent.bKeyDown = updown;
KeyEventRecord->InputEvent.Event.KeyEvent.wVirtualKeyCode = 0;
KeyEventRecord->InputEvent.Event.KeyEvent.wVirtualScanCode = 0;
- KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar = '\n';
+ KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar =
L'\n';
KeyEventRecord->Fake = TRUE;
break;
}
@@ -247,17 +249,17 @@
/* if line input mode is enabled, only wake the client on enter key down */
if (0 == (Console->Mode & ENABLE_LINE_INPUT)
|| Console->EarlyReturn
- || ('\n' ==
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar
+ || (L'\n' ==
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar
&& KeyEventRecord->InputEvent.Event.KeyEvent.bKeyDown))
{
- if ('\n' ==
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar)
+ if (L'\n' ==
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar)
{
Console->WaitingLines++;
}
}
KeyEventRecord->Echoed = FALSE;
if (0 != (Console->Mode & (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT))
- && '\b' ==
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar
+ && L'\b' ==
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar
&& KeyEventRecord->InputEvent.Event.KeyEvent.bKeyDown)
{
/* walk the input queue looking for a char to backspace */
@@ -265,7 +267,7 @@
TempInput != (ConsoleInput *) &Console->InputEvents
&& (KEY_EVENT == TempInput->InputEvent.EventType
|| ! TempInput->InputEvent.Event.KeyEvent.bKeyDown
- || '\b' ==
TempInput->InputEvent.Event.KeyEvent.uChar.AsciiChar);
+ || L'\b' ==
TempInput->InputEvent.Event.KeyEvent.uChar.UnicodeChar);
TempInput = (ConsoleInput *) TempInput->ListEntry.Blink)
{
/* NOP */;
@@ -277,9 +279,11 @@
RemoveEntryList(&TempInput->ListEntry);
if (TempInput->Echoed)
{
- ConioWriteConsole(Console, Console->ActiveBuffer,
-
&KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar,
- 1, TRUE);
+ CHAR AsciiChar;
+ WideCharToMultiByte(Console->OutputCodePage, 0,
+
&KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar, 1,
+ &AsciiChar, 1, NULL, NULL);
+ ConioWriteConsole(Console, Console->ActiveBuffer, &AsciiChar, 1,
TRUE);
}
HeapFree(Win32CsrApiHeap, 0, TempInput);
RemoveEntryList(&KeyEventRecord->ListEntry);
@@ -292,14 +296,16 @@
{
/* echo chars if we are supposed to and client is waiting for some */
if (0 != (Console->Mode & ENABLE_ECHO_INPUT) &&
Console->EchoCount
- && KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar
+ &&
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar
&& KeyEventRecord->InputEvent.Event.KeyEvent.bKeyDown
- && '\r' !=
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar)
+ && L'\r' !=
KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar)
{
/* mark the char as already echoed */
- ConioWriteConsole(Console, Console->ActiveBuffer,
-
&KeyEventRecord->InputEvent.Event.KeyEvent.uChar.AsciiChar,
- 1, TRUE);
+ CHAR AsciiChar;
+ WideCharToMultiByte(Console->OutputCodePage, 0,
+
&KeyEventRecord->InputEvent.Event.KeyEvent.uChar.UnicodeChar, 1,
+ &AsciiChar, 1, NULL, NULL);
+ ConioWriteConsole(Console, Console->ActiveBuffer, &AsciiChar, 1,
TRUE);
Console->EchoCount--;
KeyEventRecord->Echoed = TRUE;
}
@@ -515,7 +521,6 @@
HeapFree(Win32CsrApiHeap, 0, ConInRec);
return;
}
- /* FIXME - convert to ascii */
ConioProcessChar(Console, ConInRec);
}
@@ -568,7 +573,7 @@
{
if (0 != (Console->Mode & ENABLE_LINE_INPUT)
&& Input->InputEvent.Event.KeyEvent.bKeyDown
- && '\r' ==
Input->InputEvent.Event.KeyEvent.uChar.AsciiChar)
+ && L'\r' ==
Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar)
{
Console->WaitingLines--;
}
@@ -782,11 +787,15 @@
Record->Fake = FALSE;
//Record->InputEvent = *InputRecord++;
memcpy(&Record->InputEvent, &InputRecord[i], sizeof(INPUT_RECORD));
- if (KEY_EVENT == Record->InputEvent.EventType)
- {
- /* FIXME - convert from unicode to ascii!! */
- ConioProcessChar(Console, Record);
- }
+ if (!Request->Data.WriteConsoleInputRequest.Unicode &&
+ Record->InputEvent.EventType == KEY_EVENT)
+ {
+ CHAR AsciiChar = Record->InputEvent.Event.KeyEvent.uChar.AsciiChar;
+ ConsoleInputAnsiCharToUnicodeChar(Console,
+
&Record->InputEvent.Event.KeyEvent.uChar.UnicodeChar,
+ &AsciiChar);
+ }
+ ConioProcessChar(Console, Record);
}
ConioUnlockConsole(Console);