Author: hbelusca
Date: Sun Sep 7 20:05:39 2014
New Revision: 64075
URL:
http://svn.reactos.org/svn/reactos?rev=64075&view=rev
Log:
[CONSRV]
- Start to implement a popup list of entered commands (history), WIP.
- Fix Get/SetConsoleHistoryInfo.
- Implement SetConsoleCommandHistoryMode.
Modified:
branches/condrv_restructure/include/psdk/wincon.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/history.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h
Modified: branches/condrv_restructure/include/psdk/wincon.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/include/psdk…
==============================================================================
--- branches/condrv_restructure/include/psdk/wincon.h [iso-8859-1] (original)
+++ branches/condrv_restructure/include/psdk/wincon.h [iso-8859-1] Sun Sep 7 20:05:39
2014
@@ -27,9 +27,6 @@
// These codes are answered by GetConsoleDisplayMode
#define CONSOLE_WINDOWED 0
#define CONSOLE_FULLSCREEN 1
-#if (_WIN32_WINNT >= 0x0600)
-#define CONSOLE_OVERSTRIKE 1
-#endif
#define CONSOLE_FULLSCREEN_HARDWARE 2
// These codes should be given to SetConsoleDisplayMode
@@ -103,11 +100,15 @@
#define CONSOLE_MOUSE_DOWN 0x0008
/*
- * History duplicate flags
+ * History information and mode flags
*/
#if (_WIN32_WINNT >= 0x0600)
+// For Get/SetConsoleHistoryInfo
#define HISTORY_NO_DUP_FLAG 0x0001
-#endif
+// For SetConsoleCommandHistoryMode
+#define CONSOLE_OVERSTRIKE 0x0001
+#endif
+
/*
* Read input flags
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/history.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/history.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/history.c [iso-8859-1] Sun Sep
7 20:05:39 2014
@@ -9,6 +9,7 @@
/* INCLUDES *******************************************************************/
#include "consrv.h"
+#include "popup.h"
#define NDEBUG
#include <debug.h>
@@ -25,14 +26,14 @@
BOOLEAN
-ConvertInputAnsiToUnicode(PCONSOLE Console,
+ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console,
PVOID Source,
USHORT SourceLength,
// BOOLEAN IsUnicode,
PWCHAR* Target,
PUSHORT TargetLength);
BOOLEAN
-ConvertInputUnicodeToAnsi(PCONSOLE Console,
+ConvertInputUnicodeToAnsi(PCONSRV_CONSOLE Console,
PVOID Source,
USHORT SourceLength,
// BOOLEAN IsAnsi,
@@ -266,9 +267,44 @@
return FALSE;
}
+PPOPUP_WINDOW
+HistoryDisplayCurrentHistory(PCONSRV_CONSOLE Console,
+ PUNICODE_STRING ExeName)
+{
+ PTEXTMODE_SCREEN_BUFFER ActiveBuffer;
+ PPOPUP_WINDOW Popup;
+
+ SHORT xLeft, yTop;
+ SHORT Width, Height;
+
+ PHISTORY_BUFFER Hist = HistoryCurrentBuffer(Console, ExeName);
+
+ if (!Hist) return NULL;
+ if (Hist->NumEntries == 0) return NULL;
+
+ if (GetType(Console->ActiveBuffer) != TEXTMODE_BUFFER) return NULL;
+ ActiveBuffer = (PTEXTMODE_SCREEN_BUFFER)Console->ActiveBuffer;
+
+ Width = 40;
+ Height = 10;
+
+ /* Center the popup window on the screen */
+ xLeft = ActiveBuffer->ViewOrigin.X + (ActiveBuffer->ViewSize.X - Width ) / 2;
+ yTop = ActiveBuffer->ViewOrigin.Y + (ActiveBuffer->ViewSize.Y - Height) / 2;
+
+ /* Create the popup */
+ Popup = CreatePopupWindow(Console, ActiveBuffer,
+ xLeft, yTop, Width, Height);
+ if (Popup == NULL) return NULL;
+
+ Popup->PopupInputRoutine = NULL;
+
+ return Popup;
+}
+
VOID
HistoryDeleteCurrentBuffer(PCONSRV_CONSOLE Console,
- PVOID ExeName)
+ PUNICODE_STRING ExeName)
{
HistoryDeleteBuffer(HistoryCurrentBuffer(Console, ExeName));
}
@@ -312,7 +348,8 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Hist = HistoryFindBuffer(Console,
@@ -394,7 +431,8 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Hist = HistoryFindBuffer(Console,
@@ -435,7 +473,8 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Hist = HistoryFindBuffer(Console,
@@ -463,7 +502,8 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Hist = HistoryFindBuffer(Console,
@@ -504,12 +544,13 @@
#if 0 // Vista+
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSRV_CONSOLE Console;
- NTSTATUS Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
+ NTSTATUS Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (NT_SUCCESS(Status))
{
HistoryInfoRequest->HistoryBufferSize = Console->HistoryBufferSize;
HistoryInfoRequest->NumberOfHistoryBuffers =
Console->NumberOfHistoryBuffers;
- HistoryInfoRequest->dwFlags = Console->HistoryNoDup;
+ HistoryInfoRequest->dwFlags = (Console->HistoryNoDup ?
HISTORY_NO_DUP_FLAG : 0);
ConSrvReleaseConsole(Console, TRUE);
}
return Status;
@@ -524,12 +565,13 @@
#if 0 // Vista+
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSRV_CONSOLE Console;
- NTSTATUS Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
+ NTSTATUS Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (NT_SUCCESS(Status))
{
Console->HistoryBufferSize = HistoryInfoRequest->HistoryBufferSize;
Console->NumberOfHistoryBuffers =
HistoryInfoRequest->NumberOfHistoryBuffers;
- Console->HistoryNoDup = HistoryInfoRequest->dwFlags &
HISTORY_NO_DUP_FLAG;
+ Console->HistoryNoDup = !!(HistoryInfoRequest->dwFlags &
HISTORY_NO_DUP_FLAG);
ConSrvReleaseConsole(Console, TRUE);
}
return Status;
@@ -548,14 +590,14 @@
DPRINT1("SrvSetConsoleCommandHistoryMode(Mode = %d) is not yet
implemented\n",
SetHistoryModeRequest->Mode);
- Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
- /* This API is not yet implemented */
- Status = STATUS_NOT_IMPLEMENTED;
+ Console->InsertMode = !!(SetHistoryModeRequest->Mode &
CONSOLE_OVERSTRIKE);
ConSrvReleaseConsole(Console, TRUE);
- return Status;
+ return STATUS_SUCCESS;
}
/* EOF */
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c [iso-8859-1] Sun
Sep 7 20:05:39 2014
@@ -9,20 +9,21 @@
/* INCLUDES *******************************************************************/
#include "consrv.h"
+#include "popup.h"
#define NDEBUG
#include <debug.h>
BOOLEAN
-ConvertInputAnsiToUnicode(PCONSOLE Console,
+ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console,
PVOID Source,
USHORT SourceLength,
// BOOLEAN IsUnicode,
PWCHAR* Target,
PUSHORT TargetLength);
BOOLEAN
-ConvertInputUnicodeToAnsi(PCONSOLE Console,
+ConvertInputUnicodeToAnsi(PCONSRV_CONSOLE Console,
PVOID Source,
USHORT SourceLength,
// BOOLEAN IsAnsi,
@@ -45,7 +46,7 @@
PUNICODE_STRING Entry);
VOID
HistoryDeleteCurrentBuffer(PCONSRV_CONSOLE Console,
- PVOID ExeName);
+ PUNICODE_STRING ExeName);
BOOL
HistoryFindEntryByPrefix(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName,
@@ -53,14 +54,13 @@
PUNICODE_STRING Entry);
-
/* PRIVATE FUNCTIONS **********************************************************/
static VOID
LineInputSetPos(PCONSRV_CONSOLE Console,
UINT Pos)
{
- if (Pos != Console->LinePos && Console->InputBuffer.Mode &
ENABLE_ECHO_INPUT)
+ if (Pos != Console->LinePos && GetConsoleInputBufferMode(Console) &
ENABLE_ECHO_INPUT)
{
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
SHORT OldCursorX = Buffer->CursorPosition.X;
@@ -104,7 +104,7 @@
(Console->LineSize - (Pos + NumToDelete)) * sizeof(WCHAR));
memcpy(&Console->LineBuffer[Pos], Insertion, NumToInsert * sizeof(WCHAR));
- if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
+ if (GetConsoleInputBufferMode(Console) & ENABLE_ECHO_INPUT)
{
for (i = Pos; i < NewSize; i++)
{
@@ -158,6 +158,14 @@
}
#endif
+
+// TESTS!!
+PPOPUP_WINDOW Popup = NULL;
+
+PPOPUP_WINDOW
+HistoryDisplayCurrentHistory(PCONSRV_CONSOLE Console,
+ PUNICODE_STRING ExeName);
+
VOID
LineInputKeyDown(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName,
@@ -177,6 +185,13 @@
/* Clear entire line */
LineInputSetPos(Console, 0);
LineInputEdit(Console, Console->LineSize, 0, NULL);
+
+ // TESTS!!
+ if (Popup)
+ {
+ DestroyPopupWindow(Popup);
+ Popup = NULL;
+ }
return;
}
@@ -310,6 +325,11 @@
{
if (KeyEvent->dwControlKeyState & (LEFT_ALT_PRESSED |
RIGHT_ALT_PRESSED))
HistoryDeleteCurrentBuffer(Console, ExeName);
+ else
+ {
+ if (Popup) DestroyPopupWindow(Popup);
+ Popup = HistoryDisplayCurrentHistory(Console, ExeName);
+ }
return;
}
@@ -383,7 +403,7 @@
* 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' &&
GetConsoleInputBufferMode(Console) & ENABLE_PROCESSED_INPUT)
{
/* backspace handling - if processed input enabled then we handle it here
* otherwise we treat it like a normal char. */
@@ -404,7 +424,7 @@
LineInputSetPos(Console, Console->LineSize);
Console->LineBuffer[Console->LineSize++] = L'\r';
- if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
+ if (GetConsoleInputBufferMode(Console) & ENABLE_ECHO_INPUT)
{
if (GetType(Console->ActiveBuffer) == TEXTMODE_BUFFER)
{
@@ -417,11 +437,11 @@
* but an exception to the rule exists: the buffer could have been
* pre-filled with LineMaxSize - 1 characters.
*/
- if (Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
+ if (GetConsoleInputBufferMode(Console) & ENABLE_PROCESSED_INPUT &&
Console->LineSize < Console->LineMaxSize)
{
Console->LineBuffer[Console->LineSize++] = L'\n';
- if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
+ if (GetConsoleInputBufferMode(Console) & ENABLE_ECHO_INPUT)
{
if (GetType(Console->ActiveBuffer) == TEXTMODE_BUFFER)
{
@@ -447,6 +467,7 @@
{
/* Normal character */
BOOL Overstrike = !Console->LineInsertToggle &&
(Console->LinePos != Console->LineSize);
+ DPRINT("Overstrike = %s\n", Overstrike ? "true" :
"false");
LineInputEdit(Console, (Overstrike ? 1 : 0), 1,
&KeyEvent->uChar.UnicodeChar);
}
}
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.c [iso-8859-1] Sun Sep 7
20:05:39 2014
@@ -170,7 +170,8 @@
/* PUBLIC FUNCTIONS ***********************************************************/
PPOPUP_WINDOW
-CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer,
+CreatePopupWindow(PCONSRV_CONSOLE Console,
+ PTEXTMODE_SCREEN_BUFFER Buffer,
SHORT xLeft,
SHORT yTop,
SHORT Width,
@@ -178,6 +179,8 @@
{
PPOPUP_WINDOW Popup;
SMALL_RECT Region;
+
+ ASSERT((PCONSOLE)Console == Buffer->Header.Console);
/* Create the popup window */
Popup = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*Popup));
@@ -214,7 +217,7 @@
Width, Height);
/* Add it into the list of popups */
- InsertTailList(&Buffer->Header.Console->PopupWindows,
&Popup->ListEntry);
+ InsertTailList(&Console->PopupWindows, &Popup->ListEntry);
return Popup;
}
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/popup.h [iso-8859-1] Sun Sep 7
20:05:39 2014
@@ -27,7 +27,8 @@
PPOPUP_WINDOW
-CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer,
+CreatePopupWindow(PCONSRV_CONSOLE Console,
+ PTEXTMODE_SCREEN_BUFFER Buffer,
SHORT xLeft,
SHORT yTop,
SHORT Width,