[CONSRV]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 4 Aug 2014 20:23:33 +0000 (20:23 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 4 Aug 2014 20:23:33 +0000 (20:23 +0000)
- Few code reshuffling before more restructuration.
- Some type fixes.

svn path=/branches/condrv_restructure/; revision=63806

win32ss/user/winsrv/consrv/condrv/coninput.c
win32ss/user/winsrv/consrv/condrv/console.c
win32ss/user/winsrv/consrv/condrv/text.c
win32ss/user/winsrv/consrv/coninput.c
win32ss/user/winsrv/consrv/frontends/input.c
win32ss/user/winsrv/consrv/include/conio.h
win32ss/user/winsrv/consrv/include/conio_winsrv.h

index c19b601..4c883ee 100644 (file)
@@ -66,90 +66,12 @@ ConioInputEventToUnicode(PCONSOLE Console, PINPUT_RECORD InputEvent)
 }
 
 
 }
 
 
-/*
- * This pre-processing code MUST be IN consrv ONLY
- */
-static ULONG
-PreprocessInput(PCONSOLE Console,
-                PINPUT_RECORD InputEvent,
-                ULONG NumEventsToWrite)
-{
-    ULONG NumEvents;
-
-    /*
-     * Loop each event, and for each, check for pause or unpause
-     * and perform adequate behaviour.
-     */
-    for (NumEvents = NumEventsToWrite; NumEvents > 0; --NumEvents)
-    {
-        /* Check for pause or unpause */
-        if (InputEvent->EventType == KEY_EVENT && InputEvent->Event.KeyEvent.bKeyDown)
-        {
-            WORD vk = InputEvent->Event.KeyEvent.wVirtualKeyCode;
-            if (!(Console->PauseFlags & PAUSED_FROM_KEYBOARD))
-            {
-                DWORD cks = InputEvent->Event.KeyEvent.dwControlKeyState;
-                if (Console->InputBuffer.Mode & ENABLE_LINE_INPUT &&
-                    (vk == VK_PAUSE ||
-                    (vk == 'S' && (cks & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) &&
-                                 !(cks & (LEFT_ALT_PRESSED  | RIGHT_ALT_PRESSED)))))
-                {
-                    ConioPause(Console, PAUSED_FROM_KEYBOARD);
-
-                    /* Skip the event */
-                    RtlMoveMemory(InputEvent,
-                                  InputEvent + 1,
-                                  (NumEvents - 1) * sizeof(INPUT_RECORD));
-                    --NumEventsToWrite;
-                    continue;
-                }
-            }
-            else
-            {
-                if ((vk < VK_SHIFT || vk > VK_CAPITAL) && vk != VK_LWIN &&
-                    vk != VK_RWIN && vk != VK_NUMLOCK && vk != VK_SCROLL)
-                {
-                    ConioUnpause(Console, PAUSED_FROM_KEYBOARD);
-
-                    /* Skip the event */
-                    RtlMoveMemory(InputEvent,
-                                  InputEvent + 1,
-                                  (NumEvents - 1) * sizeof(INPUT_RECORD));
-                    --NumEventsToWrite;
-                    continue;
-                }
-            }
-        }
-
-        /* Go to the next event */
-        ++InputEvent;
-    }
-
-    return NumEventsToWrite;
-}
-
-/*
- * This post-processing code MUST be IN consrv ONLY
- */
-static VOID
-PostprocessInput(PCONSOLE Console)
-{
-    CsrNotifyWait(&Console->ReadWaitQueue,
-                  FALSE,
-                  NULL,
-                  NULL);
-    if (!IsListEmpty(&Console->ReadWaitQueue))
-    {
-        CsrDereferenceWait(&Console->ReadWaitQueue);
-    }
-}
-
 NTSTATUS
 NTSTATUS
-ConioAddInputEvents(PCONSOLE Console,
-                    PINPUT_RECORD InputRecords, // InputEvent
-                    ULONG NumEventsToWrite,
-                    PULONG NumEventsWritten,
-                    BOOLEAN AppendToEnd)
+ConDrvAddInputEvents(PCONSOLE Console,
+                     PINPUT_RECORD InputRecords, // InputEvent
+                     ULONG NumEventsToWrite,
+                     PULONG NumEventsWritten,
+                     BOOLEAN AppendToEnd)
 {
     NTSTATUS Status = STATUS_SUCCESS;
     ULONG i = 0;
 {
     NTSTATUS Status = STATUS_SUCCESS;
     ULONG i = 0;
@@ -157,13 +79,6 @@ ConioAddInputEvents(PCONSOLE Console,
 
     if (NumEventsWritten) *NumEventsWritten = 0;
 
 
     if (NumEventsWritten) *NumEventsWritten = 0;
 
-    /*
-     * This pre-processing code MUST be IN consrv ONLY!!
-     */
-    NumEventsToWrite = PreprocessInput(Console, InputRecords, NumEventsToWrite);
-    if (NumEventsToWrite == 0) return STATUS_SUCCESS;
-
-
     /*
      * When adding many single events, in the case of repeated mouse move or
      * key down events, we try to coalesce them so that we do not saturate
     /*
      * When adding many single events, in the case of repeated mouse move or
      * key down events, we try to coalesce them so that we do not saturate
@@ -300,6 +215,39 @@ ConioAddInputEvents(PCONSOLE Console,
 Done:
     if (NumEventsWritten) *NumEventsWritten = i;
 
 Done:
     if (NumEventsWritten) *NumEventsWritten = i;
 
+    return Status;
+}
+
+
+ULONG
+PreprocessInput(PCONSOLE Console,
+                PINPUT_RECORD InputEvent,
+                ULONG NumEventsToWrite);
+VOID
+PostprocessInput(PCONSOLE Console);
+
+NTSTATUS
+ConioAddInputEvents(PCONSOLE Console,
+                    PINPUT_RECORD InputRecords, // InputEvent
+                    ULONG NumEventsToWrite,
+                    PULONG NumEventsWritten,
+                    BOOLEAN AppendToEnd)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+
+    if (NumEventsWritten) *NumEventsWritten = 0;
+
+    /*
+     * This pre-processing code MUST be IN consrv ONLY!!
+     */
+    NumEventsToWrite = PreprocessInput(Console, InputRecords, NumEventsToWrite);
+    if (NumEventsToWrite == 0) return STATUS_SUCCESS;
+
+    Status = ConDrvAddInputEvents(Console,
+                                  InputRecords,
+                                  NumEventsToWrite,
+                                  NumEventsWritten,
+                                  AppendToEnd);
 
     /*
      * This post-processing code MUST be IN consrv ONLY!!
 
     /*
      * This post-processing code MUST be IN consrv ONLY!!
@@ -307,9 +255,10 @@ Done:
     // if (NT_SUCCESS(Status))
     if (Status == STATUS_SUCCESS) PostprocessInput(Console);
 
     // if (NT_SUCCESS(Status))
     if (Status == STATUS_SUCCESS) PostprocessInput(Console);
 
-    return STATUS_SUCCESS;
+    return Status;
 }
 
 }
 
+/* Move elsewhere...*/
 NTSTATUS
 ConioProcessInputEvent(PCONSOLE Console,
                        PINPUT_RECORD InputEvent)
 NTSTATUS
 ConioProcessInputEvent(PCONSOLE Console,
                        PINPUT_RECORD InputEvent)
@@ -377,17 +326,15 @@ ConDrvReadConsole(IN PCONSOLE Console,
         if (Console->LineBuffer == NULL)
         {
             /* Starting a new line */
         if (Console->LineBuffer == NULL)
         {
             /* Starting a new line */
-            Console->LineMaxSize = (WORD)max(256, NumCharsToRead);
+            Console->LineMaxSize = max(256, NumCharsToRead);
 
             Console->LineBuffer = ConsoleAllocHeap(0, Console->LineMaxSize * sizeof(WCHAR));
             if (Console->LineBuffer == NULL) return STATUS_NO_MEMORY;
 
 
             Console->LineBuffer = ConsoleAllocHeap(0, Console->LineMaxSize * sizeof(WCHAR));
             if (Console->LineBuffer == NULL) return STATUS_NO_MEMORY;
 
-            Console->LineComplete = FALSE;
-            Console->LineUpPressed = FALSE;
+            Console->LinePos = Console->LineSize = ReadControl->nInitialChars;
+            Console->LineComplete = Console->LineUpPressed = FALSE;
             Console->LineInsertToggle = Console->InsertMode;
             Console->LineWakeupMask = ReadControl->dwCtrlWakeupMask;
             Console->LineInsertToggle = Console->InsertMode;
             Console->LineWakeupMask = ReadControl->dwCtrlWakeupMask;
-            Console->LineSize = ReadControl->nInitialChars;
-            Console->LinePos = Console->LineSize;
 
             /*
              * Pre-filling the buffer is only allowed in the Unicode API,
 
             /*
              * Pre-filling the buffer is only allowed in the Unicode API,
@@ -597,6 +544,7 @@ ConDrvWriteConsoleInput(IN PCONSOLE Console,
 
     /* Now, add the events */
     // if (NumEventsWritten) *NumEventsWritten = 0;
 
     /* Now, add the events */
     // if (NumEventsWritten) *NumEventsWritten = 0;
+    // ConDrvAddInputEvents
     Status = ConioAddInputEvents(Console,
                                  InputRecord,
                                  NumEventsToWrite,
     Status = ConioAddInputEvents(Console,
                                  InputRecord,
                                  NumEventsToWrite,
index a17c42b..b0f7099 100644 (file)
@@ -260,7 +260,7 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
 
     Console->InsertMode = ConsoleInfo->InsertMode;
     Console->LineBuffer = NULL;
 
     Console->InsertMode = ConsoleInfo->InsertMode;
     Console->LineBuffer = NULL;
-    Console->LineMaxSize = Console->LineSize = Console->LinePos = 0;
+    Console->LinePos = Console->LineMaxSize = Console->LineSize = 0;
     Console->LineComplete = Console->LineUpPressed = FALSE;
     Console->LineInsertToggle = Console->InsertMode;
     // LineWakeupMask
     Console->LineComplete = Console->LineUpPressed = FALSE;
     Console->LineInsertToggle = Console->InsertMode;
     // LineWakeupMask
index 3373687..98d5a85 100644 (file)
@@ -235,16 +235,6 @@ ConioMoveRegion(PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
     }
 }
 
     }
 }
 
-DWORD
-ConioEffectiveCursorSize(PCONSOLE Console, DWORD Scale)
-{
-    DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100;
-    /* If line input in progress, perhaps adjust for insert toggle */
-    if (Console->LineBuffer && !Console->LineComplete && (Console->InsertMode ? !Console->LineInsertToggle : Console->LineInsertToggle))
-        return (Size * 2 <= Scale) ? (Size * 2) : (Size / 2);
-    return Size;
-}
-
 NTSTATUS
 ConioResizeBuffer(PCONSOLE Console,
                   PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
 NTSTATUS
 ConioResizeBuffer(PCONSOLE Console,
                   PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
index ba76ea7..738e819 100644 (file)
@@ -36,6 +36,88 @@ typedef struct _GET_INPUT_INFO
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
+/*
+ * This pre-processing code MUST be IN consrv ONLY
+ */
+/* static */ ULONG
+PreprocessInput(PCONSOLE Console,
+                PINPUT_RECORD InputEvent,
+                ULONG NumEventsToWrite)
+{
+    ULONG NumEvents;
+
+    /*
+     * Loop each event, and for each, check for pause or unpause
+     * and perform adequate behaviour.
+     */
+    for (NumEvents = NumEventsToWrite; NumEvents > 0; --NumEvents)
+    {
+        /* Check for pause or unpause */
+        if (InputEvent->EventType == KEY_EVENT && InputEvent->Event.KeyEvent.bKeyDown)
+        {
+            WORD vk = InputEvent->Event.KeyEvent.wVirtualKeyCode;
+            if (!(Console->PauseFlags & PAUSED_FROM_KEYBOARD))
+            {
+                DWORD cks = InputEvent->Event.KeyEvent.dwControlKeyState;
+                if (Console->InputBuffer.Mode & ENABLE_LINE_INPUT &&
+                    (vk == VK_PAUSE ||
+                    (vk == 'S' && (cks & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) &&
+                                 !(cks & (LEFT_ALT_PRESSED  | RIGHT_ALT_PRESSED)))))
+                {
+                    ConioPause(Console, PAUSED_FROM_KEYBOARD);
+
+                    /* Skip the event */
+                    RtlMoveMemory(InputEvent,
+                                  InputEvent + 1,
+                                  (NumEvents - 1) * sizeof(INPUT_RECORD));
+                    --NumEventsToWrite;
+                    continue;
+                }
+            }
+            else
+            {
+                if ((vk < VK_SHIFT || vk > VK_CAPITAL) && vk != VK_LWIN &&
+                    vk != VK_RWIN && vk != VK_NUMLOCK && vk != VK_SCROLL)
+                {
+                    ConioUnpause(Console, PAUSED_FROM_KEYBOARD);
+
+                    /* Skip the event */
+                    RtlMoveMemory(InputEvent,
+                                  InputEvent + 1,
+                                  (NumEvents - 1) * sizeof(INPUT_RECORD));
+                    --NumEventsToWrite;
+                    continue;
+                }
+            }
+        }
+
+        /* Go to the next event */
+        ++InputEvent;
+    }
+
+    return NumEventsToWrite;
+}
+
+/*
+ * This post-processing code MUST be IN consrv ONLY
+ */
+/* static */ VOID
+PostprocessInput(PCONSOLE Console)
+{
+    CsrNotifyWait(&Console->ReadWaitQueue,
+                  FALSE,
+                  NULL,
+                  NULL);
+    if (!IsListEmpty(&Console->ReadWaitQueue))
+    {
+        CsrDereferenceWait(&Console->ReadWaitQueue);
+    }
+}
+
+
+
+
+
 static NTSTATUS
 WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
                   IN PCSR_API_MESSAGE ApiMessage,
 static NTSTATUS
 WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
                   IN PCSR_API_MESSAGE ApiMessage,
index 3509a14..2fb6f3b 100644 (file)
@@ -204,4 +204,14 @@ ConioProcessKey(PCONSOLE Console, MSG* msg)
                      KeyState[VK_CONTROL]);
 }
 
                      KeyState[VK_CONTROL]);
 }
 
+DWORD
+ConioEffectiveCursorSize(PCONSOLE Console, DWORD Scale)
+{
+    DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100;
+    /* If line input in progress, perhaps adjust for insert toggle */
+    if (Console->LineBuffer && !Console->LineComplete && (Console->InsertMode ? !Console->LineInsertToggle : Console->LineInsertToggle))
+        return (Size * 2 <= Scale) ? (Size * 2) : (Size / 2);
+    return Size;
+}
+
 /* EOF */
 /* EOF */
index c505c75..90defe0 100644 (file)
@@ -282,16 +282,16 @@ typedef struct _CONSOLE
     CONSOLE_INPUT_BUFFER InputBuffer;       /* Input buffer of the console */
     UINT InputCodePage;
 
     CONSOLE_INPUT_BUFFER InputBuffer;       /* Input buffer of the console */
     UINT InputCodePage;
 
-    /** Put those things in TEXTMODE_SCREEN_BUFFER ?? **/
-    PWCHAR LineBuffer;                      /* Current line being input, in line buffered mode */
-    ULONG  LineMaxSize;                     /* Maximum size of line in characters (including CR+LF) */
-    ULONG  LineSize;                        /* Current size of line */
-    ULONG  LinePos;                         /* Current position within line */
+    /** Put those things in CONSOLE_INPUT_BUFFER ?? **/
+    PWCHAR  LineBuffer;                     /* Current line being input, in line buffered mode */
+    ULONG   LineMaxSize;                    /* Maximum size of line in characters (including CR+LF) */
+    ULONG   LineSize;                       /* Current size of line */
+    ULONG   LinePos;                        /* Current position within line */
     BOOLEAN LineComplete;                   /* User pressed enter, ready to send back to client */
     BOOLEAN LineUpPressed;
     BOOLEAN LineInsertToggle;               /* Replace character over cursor instead of inserting */
     BOOLEAN LineComplete;                   /* User pressed enter, ready to send back to client */
     BOOLEAN LineUpPressed;
     BOOLEAN LineInsertToggle;               /* Replace character over cursor instead of inserting */
-    ULONG LineWakeupMask;                   /* Bitmap of which control characters will end line input */
-    /***************************************************/
+    ULONG   LineWakeupMask;                 /* Bitmap of which control characters will end line input */
+    /*************************************************/
 
     BOOLEAN InsertMode;
 
 
     BOOLEAN InsertMode;
 
index 18cefe2..aba4715 100644 (file)
@@ -142,6 +142,9 @@ ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
 
 /* coninput.c */
 VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
 
 /* coninput.c */
 VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
+DWORD ConioEffectiveCursorSize(PCONSOLE Console,
+                               DWORD Scale);
+
 NTSTATUS
 ConioAddInputEvents(PCONSOLE Console,
                     PINPUT_RECORD InputRecords,
 NTSTATUS
 ConioAddInputEvents(PCONSOLE Console,
                     PINPUT_RECORD InputRecords,
@@ -178,7 +181,5 @@ NTSTATUS ConioWriteConsole(PCONSOLE Console,
                            PWCHAR Buffer,
                            DWORD Length,
                            BOOL Attrib);
                            PWCHAR Buffer,
                            DWORD Length,
                            BOOL Attrib);
-DWORD ConioEffectiveCursorSize(PCONSOLE Console,
-                                        DWORD Scale);
 
 /* EOF */
 
 /* EOF */