mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[CONSRV]
- Start to implement a popup list of entered commands (history), WIP. - Fix Get/SetConsoleHistoryInfo. - Implement SetConsoleCommandHistoryMode. svn path=/branches/condrv_restructure/; revision=64075
This commit is contained in:
parent
0f46d2a9bd
commit
4c18b81f0f
5 changed files with 100 additions and 32 deletions
|
@ -27,9 +27,6 @@ extern "C" {
|
|||
// 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,12 +100,16 @@ extern "C" {
|
|||
#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
|
||||
// For SetConsoleCommandHistoryMode
|
||||
#define CONSOLE_OVERSTRIKE 0x0001
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Read input flags
|
||||
*/
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include "consrv.h"
|
||||
#include "popup.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -25,14 +26,14 @@ typedef struct _HISTORY_BUFFER
|
|||
|
||||
|
||||
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 @@ HistoryFindEntryByPrefix(PCONSRV_CONSOLE Console,
|
|||
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 @@ CSR_API(SrvGetConsoleCommandHistory)
|
|||
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 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
|
|||
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 @@ CSR_API(SrvExpungeConsoleCommandHistory)
|
|||
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 @@ CSR_API(SrvSetConsoleNumberOfCommands)
|
|||
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 @@ CSR_API(SrvGetConsoleHistory)
|
|||
#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 @@ CSR_API(SrvSetConsoleHistory)
|
|||
#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 @@ CSR_API(SrvSetConsoleCommandHistoryMode)
|
|||
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 */
|
||||
|
|
|
@ -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 @@ HistoryGetCurrentEntry(PCONSRV_CONSOLE Console,
|
|||
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 @@ HistoryFindEntryByPrefix(PCONSRV_CONSOLE Console,
|
|||
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 @@ LineInputEdit(PCONSRV_CONSOLE Console,
|
|||
(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 @@ LineInputRecallHistory(PCONSRV_CONSOLE Console,
|
|||
}
|
||||
#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 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
|
|||
/* Clear entire line */
|
||||
LineInputSetPos(Console, 0);
|
||||
LineInputEdit(Console, Console->LineSize, 0, NULL);
|
||||
|
||||
// TESTS!!
|
||||
if (Popup)
|
||||
{
|
||||
DestroyPopupWindow(Popup);
|
||||
Popup = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -310,6 +325,11 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
|
|||
{
|
||||
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 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
|
|||
* 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 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
|
|||
|
||||
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 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
|
|||
* 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 @@ LineInputKeyDown(PCONSRV_CONSOLE Console,
|
|||
{
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,8 @@ DrawBox(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||
|
||||
PPOPUP_WINDOW
|
||||
CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer,
|
||||
CreatePopupWindow(PCONSRV_CONSOLE Console,
|
||||
PTEXTMODE_SCREEN_BUFFER Buffer,
|
||||
SHORT xLeft,
|
||||
SHORT yTop,
|
||||
SHORT Width,
|
||||
|
@ -179,6 +180,8 @@ CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
PPOPUP_WINDOW Popup;
|
||||
SMALL_RECT Region;
|
||||
|
||||
ASSERT((PCONSOLE)Console == Buffer->Header.Console);
|
||||
|
||||
/* Create the popup window */
|
||||
Popup = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*Popup));
|
||||
if (Popup == NULL) return NULL;
|
||||
|
@ -214,7 +217,7 @@ CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
Width, Height);
|
||||
|
||||
/* Add it into the list of popups */
|
||||
InsertTailList(&Buffer->Header.Console->PopupWindows, &Popup->ListEntry);
|
||||
InsertTailList(&Console->PopupWindows, &Popup->ListEntry);
|
||||
|
||||
return Popup;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ typedef struct _POPUP_WINDOW
|
|||
|
||||
|
||||
PPOPUP_WINDOW
|
||||
CreatePopupWindow(PTEXTMODE_SCREEN_BUFFER Buffer,
|
||||
CreatePopupWindow(PCONSRV_CONSOLE Console,
|
||||
PTEXTMODE_SCREEN_BUFFER Buffer,
|
||||
SHORT xLeft,
|
||||
SHORT yTop,
|
||||
SHORT Width,
|
||||
|
|
Loading…
Reference in a new issue