mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
[CONSRV]
- Move some functions where they belong. - Start to differentiate frontends for consrv terminal, and terminals. svn path=/branches/condrv_restructure/; revision=63117
This commit is contained in:
@@ -18,10 +18,11 @@ list(APPEND CONSRV_SOURCE
|
||||
consrv/condrv/coninput.c
|
||||
consrv/condrv/conoutput.c
|
||||
consrv/condrv/console.c
|
||||
consrv/condrv/dummyfrontend.c
|
||||
consrv/condrv/dummyterm.c
|
||||
consrv/condrv/graphics.c
|
||||
consrv/condrv/text.c
|
||||
consrv/frontends/input.c
|
||||
consrv/frontends/terminal.c
|
||||
consrv/frontends/gui/conwnd.c
|
||||
consrv/frontends/gui/fullscreen.c
|
||||
consrv/frontends/gui/guiterm.c
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \
|
||||
WideCharToMultiByte((Console)->CodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
|
||||
WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
|
||||
|
||||
#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \
|
||||
MultiByteToWideChar((Console)->CodePage, 0, (sChar), 1, (dWChar), 1)
|
||||
MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
|
||||
|
||||
typedef struct ConsoleInput_t
|
||||
{
|
||||
@@ -144,82 +144,6 @@ PurgeInputBuffer(PCONSOLE Console)
|
||||
CloseHandle(Console->InputBuffer.ActiveEvent);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function explicitely references Console->ActiveBuffer
|
||||
* (and also makes use of keyboard functions...).
|
||||
* It is possible that it will move into frontends...
|
||||
*/
|
||||
VOID NTAPI
|
||||
ConDrvProcessKey(IN PCONSOLE Console,
|
||||
IN BOOLEAN Down,
|
||||
IN UINT VirtualKeyCode,
|
||||
IN UINT VirtualScanCode,
|
||||
IN WCHAR UnicodeChar,
|
||||
IN ULONG ShiftState,
|
||||
IN BYTE KeyStateCtrl)
|
||||
{
|
||||
INPUT_RECORD er;
|
||||
|
||||
/* process Ctrl-C and Ctrl-Break */
|
||||
if ( Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
|
||||
Down && (VirtualKeyCode == VK_PAUSE || VirtualKeyCode == 'C') &&
|
||||
(ShiftState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) || KeyStateCtrl & 0x80) )
|
||||
{
|
||||
DPRINT1("Console_Api Ctrl-C\n");
|
||||
ConSrvConsoleProcessCtrlEvent(Console, 0, CTRL_C_EVENT);
|
||||
|
||||
if (Console->LineBuffer && !Console->LineComplete)
|
||||
{
|
||||
/* Line input is in progress; end it */
|
||||
Console->LinePos = Console->LineSize = 0;
|
||||
Console->LineComplete = TRUE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) != 0 &&
|
||||
(VK_UP == VirtualKeyCode || VK_DOWN == VirtualKeyCode) )
|
||||
{
|
||||
if (!Down) return;
|
||||
|
||||
/* scroll up or down */
|
||||
if (VK_UP == VirtualKeyCode)
|
||||
{
|
||||
/* only scroll up if there is room to scroll up into */
|
||||
if (Console->ActiveBuffer->CursorPosition.Y != Console->ActiveBuffer->ScreenBufferSize.Y - 1)
|
||||
{
|
||||
Console->ActiveBuffer->VirtualY = (Console->ActiveBuffer->VirtualY +
|
||||
Console->ActiveBuffer->ScreenBufferSize.Y - 1) %
|
||||
Console->ActiveBuffer->ScreenBufferSize.Y;
|
||||
Console->ActiveBuffer->CursorPosition.Y++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* only scroll down if there is room to scroll down into */
|
||||
if (Console->ActiveBuffer->CursorPosition.Y != 0)
|
||||
{
|
||||
Console->ActiveBuffer->VirtualY = (Console->ActiveBuffer->VirtualY + 1) %
|
||||
Console->ActiveBuffer->ScreenBufferSize.Y;
|
||||
Console->ActiveBuffer->CursorPosition.Y--;
|
||||
}
|
||||
}
|
||||
|
||||
ConioDrawConsole(Console);
|
||||
return;
|
||||
}
|
||||
|
||||
er.EventType = KEY_EVENT;
|
||||
er.Event.KeyEvent.bKeyDown = Down;
|
||||
er.Event.KeyEvent.wRepeatCount = 1;
|
||||
er.Event.KeyEvent.wVirtualKeyCode = VirtualKeyCode;
|
||||
er.Event.KeyEvent.wVirtualScanCode = VirtualScanCode;
|
||||
er.Event.KeyEvent.uChar.UnicodeChar = UnicodeChar;
|
||||
er.Event.KeyEvent.dwControlKeyState = ShiftState;
|
||||
|
||||
ConioProcessInputEvent(Console, &er);
|
||||
}
|
||||
|
||||
|
||||
/* PUBLIC DRIVER APIS *********************************************************/
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
// LineWakeupMask
|
||||
|
||||
/* Set-up the code page */
|
||||
Console->CodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
|
||||
Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
|
||||
|
||||
/* Initialize a new text-mode screen buffer with default settings */
|
||||
ScreenBufferInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize;
|
||||
@@ -862,7 +862,7 @@ ConDrvGetConsoleTitle(IN PCONSOLE Console,
|
||||
if (*BufLength >= sizeof(CHAR))
|
||||
{
|
||||
Length = min(*BufLength - sizeof(CHAR), Console->Title.Length / sizeof(WCHAR));
|
||||
Length = WideCharToMultiByte(Console->CodePage, 0,
|
||||
Length = WideCharToMultiByte(Console->InputCodePage, 0,
|
||||
Console->Title.Buffer, Length,
|
||||
TitleBuffer, Length,
|
||||
NULL, NULL);
|
||||
@@ -898,7 +898,7 @@ ConDrvSetConsoleTitle(IN PCONSOLE Console,
|
||||
else
|
||||
{
|
||||
/* Use the console input CP for the conversion */
|
||||
Length = MultiByteToWideChar(Console->CodePage, 0,
|
||||
Length = MultiByteToWideChar(Console->InputCodePage, 0,
|
||||
TitleBuffer, BufLength,
|
||||
NULL, 0);
|
||||
/* The returned Length was in number of wchars, convert it in bytes */
|
||||
@@ -923,7 +923,7 @@ ConDrvSetConsoleTitle(IN PCONSOLE Console,
|
||||
}
|
||||
else
|
||||
{
|
||||
MultiByteToWideChar(Console->CodePage, 0,
|
||||
MultiByteToWideChar(Console->InputCodePage, 0,
|
||||
TitleBuffer, BufLength,
|
||||
Console->Title.Buffer,
|
||||
Console->Title.Length / sizeof(WCHAR));
|
||||
@@ -944,7 +944,7 @@ ConDrvGetConsoleCP(IN PCONSOLE Console,
|
||||
if (Console == NULL || CodePage == NULL)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
*CodePage = (OutputCP ? Console->OutputCodePage : Console->CodePage);
|
||||
*CodePage = (OutputCP ? Console->OutputCodePage : Console->InputCodePage);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
@@ -960,7 +960,7 @@ ConDrvSetConsoleCP(IN PCONSOLE Console,
|
||||
if (OutputCP)
|
||||
Console->OutputCodePage = CodePage;
|
||||
else
|
||||
Console->CodePage = CodePage;
|
||||
Console->InputCodePage = CodePage;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Console Server DLL
|
||||
* FILE: win32ss/user/winsrv/consrv/condrv/dummyfrontend.c
|
||||
* PURPOSE: Dummy Terminal Front-End used when no frontend
|
||||
* FILE: condrv/dummyterm.c
|
||||
* PURPOSE: Dummy Terminal used when no terminal
|
||||
* is attached to the specified console.
|
||||
* PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
||||
*/
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <consrv.h>
|
||||
|
||||
/* DUMMY FRONTEND INTERFACE ***************************************************/
|
||||
/* DUMMY TERMINAL INTERFACE ***************************************************/
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
DummyInitFrontEnd(IN OUT PFRONTEND This,
|
||||
@@ -10,12 +10,3 @@
|
||||
#pragma once
|
||||
|
||||
VOID PurgeInputBuffer(PCONSOLE Console);
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvProcessKey(IN PCONSOLE Console,
|
||||
IN BOOLEAN Down,
|
||||
IN UINT VirtualKeyCode,
|
||||
IN UINT VirtualScanCode,
|
||||
IN WCHAR UnicodeChar,
|
||||
IN ULONG ShiftState,
|
||||
IN BYTE KeyStateCtrl);
|
||||
|
||||
@@ -13,13 +13,8 @@
|
||||
#include "consrv.h"
|
||||
|
||||
#include <ndk/psfuncs.h>
|
||||
|
||||
#include "procinit.h"
|
||||
|
||||
#ifdef TUITERM_COMPILE
|
||||
#include "frontends/tui/tuiterm.h"
|
||||
#endif
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
@@ -28,69 +23,6 @@ NTSTATUS NTAPI RtlGetLastNtStatus(VOID);
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
/***************/
|
||||
#ifdef TUITERM_COMPILE
|
||||
NTSTATUS NTAPI
|
||||
TuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
NTSTATUS NTAPI
|
||||
TuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd);
|
||||
#endif
|
||||
|
||||
NTSTATUS NTAPI
|
||||
GuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
NTSTATUS NTAPI
|
||||
GuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd);
|
||||
/***************/
|
||||
|
||||
typedef
|
||||
NTSTATUS (NTAPI *FRONTEND_LOAD)(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
|
||||
typedef
|
||||
NTSTATUS (NTAPI *FRONTEND_UNLOAD)(IN OUT PFRONTEND FrontEnd);
|
||||
|
||||
/*
|
||||
* If we are not in GUI-mode, start the text-mode terminal emulator.
|
||||
* If we fail, try to start the GUI-mode terminal emulator.
|
||||
*
|
||||
* Try to open the GUI-mode terminal emulator. Two cases are possible:
|
||||
* - We are in GUI-mode, therefore GuiMode == TRUE, the previous test-case
|
||||
* failed and we start GUI-mode terminal emulator.
|
||||
* - We are in text-mode, therefore GuiMode == FALSE, the previous test-case
|
||||
* succeeded BUT we failed at starting text-mode terminal emulator.
|
||||
* Then GuiMode was switched to TRUE in order to try to open the GUI-mode
|
||||
* terminal emulator (Win32k will automatically switch to graphical mode,
|
||||
* therefore no additional code is needed).
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: Each entry of the table should be retrieved when loading a front-end
|
||||
* (examples of the CSR servers which register some data for CSRSS).
|
||||
*/
|
||||
struct
|
||||
{
|
||||
CHAR FrontEndName[80];
|
||||
FRONTEND_LOAD FrontEndLoad;
|
||||
FRONTEND_UNLOAD FrontEndUnload;
|
||||
} FrontEndLoadingMethods[] =
|
||||
{
|
||||
#ifdef TUITERM_COMPILE
|
||||
{"TUI", TuiLoadFrontEnd, TuiUnloadFrontEnd},
|
||||
#endif
|
||||
{"GUI", GuiLoadFrontEnd, GuiUnloadFrontEnd},
|
||||
|
||||
// {"Not found", 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
VOID
|
||||
@@ -150,6 +82,14 @@ ConSrvReleaseConsole(PCONSOLE Console,
|
||||
}
|
||||
|
||||
|
||||
/* static */ NTSTATUS
|
||||
ConSrvLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
/* static */ NTSTATUS
|
||||
ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
OUT PCONSOLE* NewConsole,
|
||||
@@ -161,7 +101,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
PCONSOLE Console;
|
||||
CONSOLE_INFO ConsoleInfo;
|
||||
SIZE_T Length = 0;
|
||||
ULONG i = 0;
|
||||
|
||||
FRONTEND FrontEnd;
|
||||
|
||||
if (NewConsole == NULL || ConsoleStartInfo == NULL)
|
||||
@@ -182,39 +122,31 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
wcsncpy(ConsoleInfo.ConsoleTitle, ConsoleStartInfo->ConsoleTitle, Length);
|
||||
ConsoleInfo.ConsoleTitle[Length] = L'\0';
|
||||
|
||||
|
||||
/*
|
||||
* Choose an adequate terminal front-end to load, and load it
|
||||
*/
|
||||
Status = STATUS_SUCCESS;
|
||||
for (i = 0; i < sizeof(FrontEndLoadingMethods) / sizeof(FrontEndLoadingMethods[0]); ++i)
|
||||
#if 0
|
||||
/* 3. Initialize the ConSrv terminal */
|
||||
Status = ConSrvInitTerminal(&Terminal,
|
||||
&ConsoleInfo,
|
||||
ConsoleStartInfo,
|
||||
ConsoleLeaderProcessId);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("CONSRV: Trying to load %s terminal emulator...\n", FrontEndLoadingMethods[i].FrontEndName);
|
||||
Status = FrontEndLoadingMethods[i].FrontEndLoad(&FrontEnd,
|
||||
&ConsoleInfo,
|
||||
ConsoleStartInfo,
|
||||
ConsoleLeaderProcessId);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("CONSRV: %s terminal emulator loaded successfully\n", FrontEndLoadingMethods[i].FrontEndName);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("CONSRV: Loading %s terminal emulator failed, Status = 0x%08lx , continuing...\n", FrontEndLoadingMethods[i].FrontEndName, Status);
|
||||
}
|
||||
DPRINT1("CONSRV: Failed to initialize a terminal, Status = 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("CONSRV: Terminal initialized\n");
|
||||
#else
|
||||
Status = ConSrvLoadFrontEnd(&FrontEnd,
|
||||
&ConsoleInfo,
|
||||
ConsoleStartInfo,
|
||||
ConsoleLeaderProcessId);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CONSRV: Failed to initialize a frontend, Status = 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("CONSRV: Frontend initialized\n");
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* 4. Load the remaining console settings via the registry.
|
||||
*/
|
||||
@@ -249,8 +181,8 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
|
||||
/* Set-up the code page */
|
||||
ConsoleInfo.CodePage = GetOEMCP();
|
||||
/******************************************************************************/
|
||||
|
||||
/* Initialize a new console via the driver */
|
||||
Status = ConDrvInitConsole(&ConsoleHandle,
|
||||
&Console,
|
||||
&ConsoleInfo,
|
||||
@@ -258,7 +190,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Creating a new console failed, Status = 0x%08lx\n", Status);
|
||||
FrontEndLoadingMethods[i].FrontEndUnload(&FrontEnd);
|
||||
ConSrvUnloadFrontEnd(&FrontEnd);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -266,20 +198,26 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
||||
DPRINT("Console initialized\n");
|
||||
|
||||
/*** Register ConSrv features ***/
|
||||
|
||||
/* Initialize process support */
|
||||
InitializeListHead(&Console->ProcessList);
|
||||
Console->NotifiedLastCloseProcess = NULL;
|
||||
Console->NotifyLastClose = FALSE;
|
||||
|
||||
/* Initialize pausing support */
|
||||
Console->PauseFlags = 0;
|
||||
InitializeListHead(&Console->ReadWaitQueue);
|
||||
InitializeListHead(&Console->WriteWaitQueue);
|
||||
Console->PauseFlags = 0;
|
||||
Console->QuickEdit = ConsoleInfo.QuickEdit;
|
||||
|
||||
Console->QuickEdit = ConsoleInfo.QuickEdit;
|
||||
|
||||
/* Attach the ConSrv terminal to the console */
|
||||
Status = ConDrvRegisterFrontEnd(Console, &FrontEnd);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to register frontend to the given console, Status = 0x%08lx\n", Status);
|
||||
ConDrvDeleteConsole(Console);
|
||||
FrontEndLoadingMethods[i].FrontEndUnload(&FrontEnd);
|
||||
ConSrvUnloadFrontEnd(&FrontEnd);
|
||||
return Status;
|
||||
}
|
||||
DPRINT("FrontEnd registered\n");
|
||||
|
||||
@@ -20,6 +20,77 @@
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
static VOID
|
||||
ConDrvProcessKey(IN PCONSOLE Console,
|
||||
IN BOOLEAN Down,
|
||||
IN UINT VirtualKeyCode,
|
||||
IN UINT VirtualScanCode,
|
||||
IN WCHAR UnicodeChar,
|
||||
IN ULONG ShiftState,
|
||||
IN BYTE KeyStateCtrl)
|
||||
{
|
||||
INPUT_RECORD er;
|
||||
|
||||
/* process Ctrl-C and Ctrl-Break */
|
||||
if ( Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
|
||||
Down && (VirtualKeyCode == VK_PAUSE || VirtualKeyCode == 'C') &&
|
||||
(ShiftState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) || KeyStateCtrl & 0x80) )
|
||||
{
|
||||
DPRINT1("Console_Api Ctrl-C\n");
|
||||
ConSrvConsoleProcessCtrlEvent(Console, 0, CTRL_C_EVENT);
|
||||
|
||||
if (Console->LineBuffer && !Console->LineComplete)
|
||||
{
|
||||
/* Line input is in progress; end it */
|
||||
Console->LinePos = Console->LineSize = 0;
|
||||
Console->LineComplete = TRUE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED)) != 0 &&
|
||||
(VK_UP == VirtualKeyCode || VK_DOWN == VirtualKeyCode) )
|
||||
{
|
||||
if (!Down) return;
|
||||
|
||||
/* scroll up or down */
|
||||
if (VK_UP == VirtualKeyCode)
|
||||
{
|
||||
/* only scroll up if there is room to scroll up into */
|
||||
if (Console->ActiveBuffer->CursorPosition.Y != Console->ActiveBuffer->ScreenBufferSize.Y - 1)
|
||||
{
|
||||
Console->ActiveBuffer->VirtualY = (Console->ActiveBuffer->VirtualY +
|
||||
Console->ActiveBuffer->ScreenBufferSize.Y - 1) %
|
||||
Console->ActiveBuffer->ScreenBufferSize.Y;
|
||||
Console->ActiveBuffer->CursorPosition.Y++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* only scroll down if there is room to scroll down into */
|
||||
if (Console->ActiveBuffer->CursorPosition.Y != 0)
|
||||
{
|
||||
Console->ActiveBuffer->VirtualY = (Console->ActiveBuffer->VirtualY + 1) %
|
||||
Console->ActiveBuffer->ScreenBufferSize.Y;
|
||||
Console->ActiveBuffer->CursorPosition.Y--;
|
||||
}
|
||||
}
|
||||
|
||||
ConioDrawConsole(Console);
|
||||
return;
|
||||
}
|
||||
|
||||
er.EventType = KEY_EVENT;
|
||||
er.Event.KeyEvent.bKeyDown = Down;
|
||||
er.Event.KeyEvent.wRepeatCount = 1;
|
||||
er.Event.KeyEvent.wVirtualKeyCode = VirtualKeyCode;
|
||||
er.Event.KeyEvent.wVirtualScanCode = VirtualScanCode;
|
||||
er.Event.KeyEvent.uChar.UnicodeChar = UnicodeChar;
|
||||
er.Event.KeyEvent.dwControlKeyState = ShiftState;
|
||||
|
||||
ConioProcessInputEvent(Console, &er);
|
||||
}
|
||||
|
||||
static DWORD
|
||||
ConioGetShiftState(PBYTE KeyState, LPARAM lParam)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Console Server DLL
|
||||
* FILE: frontends/terminal.c
|
||||
* PURPOSE: ConSrv terminal.
|
||||
* PROGRAMMERS: Hermes Belusca-Maito ([email protected])
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include <consrv.h>
|
||||
|
||||
#ifdef TUITERM_COMPILE
|
||||
#include "frontends/tui/tuiterm.h"
|
||||
#endif
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* CONSRV TERMINAL FRONTENDS INTERFACE ****************************************/
|
||||
|
||||
/***************/
|
||||
#ifdef TUITERM_COMPILE
|
||||
NTSTATUS NTAPI
|
||||
TuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
NTSTATUS NTAPI
|
||||
TuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd);
|
||||
#endif
|
||||
|
||||
NTSTATUS NTAPI
|
||||
GuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
NTSTATUS NTAPI
|
||||
GuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd);
|
||||
/***************/
|
||||
|
||||
typedef
|
||||
NTSTATUS (NTAPI *FRONTEND_LOAD)(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId);
|
||||
|
||||
typedef
|
||||
NTSTATUS (NTAPI *FRONTEND_UNLOAD)(IN OUT PFRONTEND FrontEnd);
|
||||
|
||||
/*
|
||||
* If we are not in GUI-mode, start the text-mode terminal emulator.
|
||||
* If we fail, try to start the GUI-mode terminal emulator.
|
||||
*
|
||||
* Try to open the GUI-mode terminal emulator. Two cases are possible:
|
||||
* - We are in GUI-mode, therefore GuiMode == TRUE, the previous test-case
|
||||
* failed and we start GUI-mode terminal emulator.
|
||||
* - We are in text-mode, therefore GuiMode == FALSE, the previous test-case
|
||||
* succeeded BUT we failed at starting text-mode terminal emulator.
|
||||
* Then GuiMode was switched to TRUE in order to try to open the GUI-mode
|
||||
* terminal emulator (Win32k will automatically switch to graphical mode,
|
||||
* therefore no additional code is needed).
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: Each entry of the table should be retrieved when loading a front-end
|
||||
* (examples of the CSR servers which register some data for CSRSS).
|
||||
*/
|
||||
struct
|
||||
{
|
||||
CHAR FrontEndName[80];
|
||||
FRONTEND_LOAD FrontEndLoad;
|
||||
FRONTEND_UNLOAD FrontEndUnload;
|
||||
} FrontEndLoadingMethods[] =
|
||||
{
|
||||
#ifdef TUITERM_COMPILE
|
||||
{"TUI", TuiLoadFrontEnd, TuiUnloadFrontEnd},
|
||||
#endif
|
||||
{"GUI", GuiLoadFrontEnd, GuiUnloadFrontEnd},
|
||||
|
||||
// {"Not found", 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
/* static */ NTSTATUS
|
||||
ConSrvLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
|
||||
IN OUT PCONSOLE_INFO ConsoleInfo,
|
||||
IN OUT PVOID ExtraConsoleInfo,
|
||||
IN ULONG ProcessId)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
ULONG i;
|
||||
|
||||
/*
|
||||
* Choose an adequate terminal front-end to load, and load it
|
||||
*/
|
||||
for (i = 0; i < sizeof(FrontEndLoadingMethods) / sizeof(FrontEndLoadingMethods[0]); ++i)
|
||||
{
|
||||
DPRINT("CONSRV: Trying to load %s frontend...\n",
|
||||
FrontEndLoadingMethods[i].FrontEndName);
|
||||
Status = FrontEndLoadingMethods[i].FrontEndLoad(FrontEnd,
|
||||
ConsoleInfo,
|
||||
ExtraConsoleInfo,
|
||||
ProcessId);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Save the unload callback */
|
||||
FrontEnd->UnloadFrontEnd = FrontEndLoadingMethods[i].FrontEndUnload;
|
||||
|
||||
DPRINT("CONSRV: %s frontend loaded successfully\n",
|
||||
FrontEndLoadingMethods[i].FrontEndName);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("CONSRV: Loading %s frontend failed, Status = 0x%08lx , continuing...\n",
|
||||
FrontEndLoadingMethods[i].FrontEndName, Status);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* static */ NTSTATUS
|
||||
ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd)
|
||||
{
|
||||
if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
|
||||
// return FrontEnd->Vtbl->UnloadFrontEnd(FrontEnd);
|
||||
return FrontEnd->UnloadFrontEnd(FrontEnd);
|
||||
}
|
||||
|
||||
|
||||
/* DUMMY FRONTEND INTERFACE ***************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
DummyInitFrontEnd(IN OUT PFRONTEND This,
|
||||
IN PCONSOLE Console)
|
||||
{
|
||||
/* Load some settings ?? */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyDeinitFrontEnd(IN OUT PFRONTEND This)
|
||||
{
|
||||
/* Free some settings ?? */
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyDrawRegion(IN OUT PFRONTEND This,
|
||||
SMALL_RECT* Region)
|
||||
{
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyWriteStream(IN OUT PFRONTEND This,
|
||||
SMALL_RECT* Region,
|
||||
SHORT CursorStartX,
|
||||
SHORT CursorStartY,
|
||||
UINT ScrolledLines,
|
||||
PWCHAR Buffer,
|
||||
UINT Length)
|
||||
{
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummySetCursorInfo(IN OUT PFRONTEND This,
|
||||
PCONSOLE_SCREEN_BUFFER Buff)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummySetScreenInfo(IN OUT PFRONTEND This,
|
||||
PCONSOLE_SCREEN_BUFFER Buff,
|
||||
SHORT OldCursorX,
|
||||
SHORT OldCursorY)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyResizeTerminal(IN OUT PFRONTEND This)
|
||||
{
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummySetActiveScreenBuffer(IN OUT PFRONTEND This)
|
||||
{
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyReleaseScreenBuffer(IN OUT PFRONTEND This,
|
||||
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
|
||||
{
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummyProcessKeyCallback(IN OUT PFRONTEND This,
|
||||
MSG* msg,
|
||||
BYTE KeyStateMenu,
|
||||
DWORD ShiftState,
|
||||
UINT VirtualKeyCode,
|
||||
BOOL Down)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyRefreshInternalInfo(IN OUT PFRONTEND This)
|
||||
{
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyChangeTitle(IN OUT PFRONTEND This)
|
||||
{
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummyChangeIcon(IN OUT PFRONTEND This,
|
||||
HICON IconHandle)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HWND NTAPI
|
||||
DummyGetConsoleWindowHandle(IN OUT PFRONTEND This)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DummyGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
|
||||
PCOORD pSize)
|
||||
{
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummyGetSelectionInfo(IN OUT PFRONTEND This,
|
||||
PCONSOLE_SELECTION_INFO pSelectionInfo)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummySetPalette(IN OUT PFRONTEND This,
|
||||
HPALETTE PaletteHandle,
|
||||
UINT PaletteUsage)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static ULONG NTAPI
|
||||
DummyGetDisplayMode(IN OUT PFRONTEND This)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummySetDisplayMode(IN OUT PFRONTEND This,
|
||||
ULONG NewMode)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INT NTAPI
|
||||
DummyShowMouseCursor(IN OUT PFRONTEND This,
|
||||
BOOL Show)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummySetMouseCursor(IN OUT PFRONTEND This,
|
||||
HCURSOR CursorHandle)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HMENU NTAPI
|
||||
DummyMenuControl(IN OUT PFRONTEND This,
|
||||
UINT CmdIdLow,
|
||||
UINT CmdIdHigh)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BOOL NTAPI
|
||||
DummySetMenuClose(IN OUT PFRONTEND This,
|
||||
BOOL Enable)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static FRONTEND_VTBL DummyVtbl =
|
||||
{
|
||||
DummyInitFrontEnd,
|
||||
DummyDeinitFrontEnd,
|
||||
DummyDrawRegion,
|
||||
DummyWriteStream,
|
||||
DummySetCursorInfo,
|
||||
DummySetScreenInfo,
|
||||
DummyResizeTerminal,
|
||||
DummySetActiveScreenBuffer,
|
||||
DummyReleaseScreenBuffer,
|
||||
DummyProcessKeyCallback,
|
||||
DummyRefreshInternalInfo,
|
||||
DummyChangeTitle,
|
||||
DummyChangeIcon,
|
||||
DummyGetConsoleWindowHandle,
|
||||
DummyGetLargestConsoleWindowSize,
|
||||
DummyGetSelectionInfo,
|
||||
DummySetPalette,
|
||||
DummyGetDisplayMode,
|
||||
DummySetDisplayMode,
|
||||
DummyShowMouseCursor,
|
||||
DummySetMouseCursor,
|
||||
DummyMenuControl,
|
||||
DummySetMenuClose,
|
||||
};
|
||||
|
||||
VOID
|
||||
ResetFrontEnd(IN PCONSOLE Console)
|
||||
{
|
||||
if (!Console) return;
|
||||
|
||||
/* Reinitialize the frontend interface */
|
||||
RtlZeroMemory(&Console->FrontEndIFace, sizeof(Console->FrontEndIFace));
|
||||
Console->FrontEndIFace.Vtbl = &DummyVtbl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
@@ -297,7 +297,7 @@ typedef struct _CONSOLE
|
||||
|
||||
/**************************** Input buffer and data ***************************/
|
||||
CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
|
||||
UINT CodePage;
|
||||
UINT InputCodePage;
|
||||
|
||||
/** Put those things in TEXTMODE_SCREEN_BUFFER ?? **/
|
||||
PWCHAR LineBuffer; /* Current line being input, in line buffered mode */
|
||||
|
||||
@@ -85,6 +85,8 @@ typedef struct _FRONTEND_VTBL
|
||||
struct _FRONTEND
|
||||
{
|
||||
PFRONTEND_VTBL Vtbl; /* Virtual table */
|
||||
NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
|
||||
|
||||
struct _CONSOLE* Console; /* Console to which the frontend is attached to */
|
||||
PVOID Data; /* Private data */
|
||||
PVOID OldData; /* Reserved */
|
||||
|
||||
Reference in New Issue
Block a user