Author: hbelusca
Date: Fri Mar 8 23:37:11 2013
New Revision: 58447
URL:
http://svn.reactos.org/svn/reactos?rev=58447&view=rev
Log:
[CONSRV]
- Start to sort out things that depends only of the internals of a console, and things
which are only related to "terminal emulators". Do it especially for (what I
will call starting from now) the "GUI terminal emulator".
- Temporarily deactivate starting "TUI terminals".
- Temporarily break report that the terminal window is held by the current running console
application in it (see r58107). This will be fixed later on.
Modified:
branches/ros-csrss/win32ss/user/consrv/conio.h
branches/ros-csrss/win32ss/user/consrv/conoutput.c
branches/ros-csrss/win32ss/user/consrv/console.c
branches/ros-csrss/win32ss/user/consrv/guiconsole.c
branches/ros-csrss/win32ss/user/consrv/guiconsole.h
branches/ros-csrss/win32ss/user/consrv/handle.c
branches/ros-csrss/win32ss/user/consrv/settings.h
branches/ros-csrss/win32ss/user/consrv/tuiconsole.c
branches/ros-csrss/win32ss/user/consrv/tuiconsole.h
Modified: branches/ros-csrss/win32ss/user/consrv/conio.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] Fri Mar 8 23:37:11 2013
@@ -15,14 +15,6 @@
#define DEFAULT_SCREEN_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
#define DEFAULT_POPUP_ATTRIB (FOREGROUND_BLUE | FOREGROUND_RED | \
BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED |
BACKGROUND_INTENSITY)
-
-#ifndef WM_APP
-#define WM_APP 0x8000
-#endif
-#define PM_CREATE_CONSOLE (WM_APP + 1)
-#define PM_DESTROY_CONSOLE (WM_APP + 2)
-#define PM_CONSOLE_BEEP (WM_APP + 3)
-#define PM_CONSOLE_SET_TITLE (WM_APP + 4)
/************************************************************************
@@ -82,16 +74,81 @@
INPUT_RECORD InputEvent;
} ConsoleInput;
+typedef struct _TERMINAL_VTBL
+{
+ /*
+ * Internal interface (functions called by the console server only)
+ */
+ VOID (WINAPI *CleanupConsole)(struct _CONSOLE* Console);
+ VOID (WINAPI *WriteStream)(struct _CONSOLE* Console,
+ SMALL_RECT* Block,
+ LONG CursorStartX,
+ LONG CursorStartY,
+ UINT ScrolledLines,
+ CHAR *Buffer,
+ UINT Length);
+ VOID (WINAPI *DrawRegion)(struct _CONSOLE* Console,
+ SMALL_RECT* Region);
+ BOOL (WINAPI *SetCursorInfo)(struct _CONSOLE* Console,
+ PCONSOLE_SCREEN_BUFFER ScreenBuffer);
+ BOOL (WINAPI *SetScreenInfo)(struct _CONSOLE* Console,
+ PCONSOLE_SCREEN_BUFFER ScreenBuffer,
+ UINT OldCursorX,
+ UINT OldCursorY);
+ BOOL (WINAPI *UpdateScreenInfo)(struct _CONSOLE* Console,
+ PCONSOLE_SCREEN_BUFFER ScreenBuffer);
+ NTSTATUS (WINAPI *ResizeBuffer)(struct _CONSOLE* Console,
+ PCONSOLE_SCREEN_BUFFER ScreenBuffer,
+ COORD Size);
+ BOOL (WINAPI *ProcessKeyCallback)(struct _CONSOLE* Console,
+ MSG* msg,
+ BYTE KeyStateMenu,
+ DWORD ShiftState,
+ UINT VirtualKeyCode,
+ BOOL Down);
+
+ /*
+ * External interface (functions corresponding to the Console API)
+ */
+ VOID (WINAPI *ChangeTitle)(struct _CONSOLE* Console);
+ BOOL (WINAPI *ChangeIcon)(struct _CONSOLE* Console,
+ HICON hWindowIcon);
+ HWND (WINAPI *GetConsoleWindowHandle)(struct _CONSOLE* Console);
+
+} TERMINAL_VTBL, *PTERMINAL_VTBL;
+
+#define ConioDrawRegion(Console, Region)
(Console)->TermIFace.Vtbl->DrawRegion((Console), (Region))
+#define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer,
Length) \
+ (Console)->TermIFace.Vtbl->WriteStream((Console), (Block), (CurStartX),
(CurStartY), \
+ (ScrolledLines), (Buffer), (Length))
+#define ConioSetCursorInfo(Console, Buff)
(Console)->TermIFace.Vtbl->SetCursorInfo((Console), (Buff))
+#define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
+ (Console)->TermIFace.Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX),
(OldCursorY))
+#define ConioUpdateScreenInfo(Console, Buff) \
+ (Console)->TermIFace.Vtbl->UpdateScreenInfo((Console), (Buff))
+#define ConioChangeTitle(Console) (Console)->TermIFace.Vtbl->ChangeTitle(Console)
+#define ConioCleanupConsole(Console)
(Console)->TermIFace.Vtbl->CleanupConsole(Console)
+#define ConioChangeIcon(Console, hWindowIcon)
(Console)->TermIFace.Vtbl->ChangeIcon((Console), (hWindowIcon))
+#define ConioResizeBuffer(Console, Buff, Size)
(Console)->TermIFace.Vtbl->ResizeBuffer((Console), (Buff), (Size))
+#define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode,
Down) \
+ (Console)->TermIFace.Vtbl->ProcessKeyCallback((Console), (Msg),
(KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down))
+
+typedef struct _TERMINAL_IFACE
+{
+ PTERMINAL_VTBL Vtbl; /* Virtual table */
+ PVOID Data; /* Private data */
+ PVOID OldData; /* Reserved */
+} TERMINAL_IFACE, *PTERMINAL_IFACE;
+
typedef struct _CONSOLE
{
LONG ReferenceCount; /* Is incremented each time a handle to a
screen-buffer or the input buffer of this console gets referenced, or the console gets
locked */
CRITICAL_SECTION Lock;
struct _CONSOLE *Prev, *Next; /* Next and Prev consoles in console wheel
*/
- struct _CONSOLE_VTBL *Vtbl; /* Using CUI or GUI consoles */
-
- CLIENT_ID ConsoleLeaderCID; /* Contains the Console Leader Process CID
for this console. TODO: Is it possible to compute it via the contents of the ProcessList
list ?? */
- LIST_ENTRY ProcessList;
+ LIST_ENTRY ProcessList; /* List of processes owning the console. The
first one is the so-called "Console Leader Process" */
+
+ TERMINAL_IFACE TermIFace; /* Terminal-specific interface */
/**************************** Input buffer and data ***************************/
CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
@@ -129,18 +186,12 @@
ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed
*/
BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
-/******************************* Common UI data *******************************/
- UNICODE_STRING OriginalTitle; /* Original title of console, the one when
the console leader is launched. It is always NULL-terminated */
- UNICODE_STRING Title; /* Title of console. It is always
NULL-terminated */
+/****************************** Other properties ******************************/
+ UNICODE_STRING OriginalTitle; /* Original title of console, the one when
the console leader is launched. Always NULL-terminated */
+ UNICODE_STRING Title; /* Title of console. Always NULL-terminated
*/
COORD Size; /* Size of the console (different of the size
of the screen buffer */
COLORREF Colors[16]; /* Colour palette */
-
-/****************************** GUI-related data ******************************/
- HWND hWindow; /* Handle to the console's window */
- HICON hIcon; /* Handle to its icon (used when freeing) */
- HICON hIconSm;
- PVOID GuiData; /* PGUI_CONSOLE_DATA */
} CONSOLE, *PCONSOLE;
@@ -150,28 +201,18 @@
#define GWLP_CONSOLE_LEADER_PID 0
#define GWLP_CONSOLE_LEADER_TID 4
-#define SetConsoleWndConsoleLeaderCID(Console) \
-do { \
- SetWindowLongPtrW((Console)->hWindow, GWLP_CONSOLE_LEADER_PID,
(LONG_PTR)((Console)->ConsoleLeaderCID.UniqueProcess)); \
- SetWindowLongPtrW((Console)->hWindow, GWLP_CONSOLE_LEADER_TID,
(LONG_PTR)((Console)->ConsoleLeaderCID.UniqueThread )); \
+#define SetConsoleWndConsoleLeaderCID(GuiData) \
+do { \
+ PCONSOLE_PROCESS_DATA ProcessData; \
+ CLIENT_ID ConsoleLeaderCID; \
+ ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink, \
+ CONSOLE_PROCESS_DATA, \
+ ConsoleLink); \
+ ConsoleLeaderCID = ProcessData->Process->ClientId; \
+ SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID,
(LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); \
+ SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID,
(LONG_PTR)(ConsoleLeaderCID.UniqueThread )); \
} while(0)
/**************************************************************/
-
-typedef struct _CONSOLE_VTBL
-{
- VOID (WINAPI *WriteStream)(PCONSOLE Console, SMALL_RECT* Block, LONG CursorStartX,
LONG CursorStartY,
- UINT ScrolledLines, CHAR *Buffer, UINT Length);
- VOID (WINAPI *DrawRegion)(PCONSOLE Console, SMALL_RECT* Region);
- BOOL (WINAPI *SetCursorInfo)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer);
- BOOL (WINAPI *SetScreenInfo)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer,
- UINT OldCursorX, UINT OldCursorY);
- BOOL (WINAPI *UpdateScreenInfo)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER
ScreenBuffer);
- VOID (WINAPI *ChangeTitle)(PCONSOLE Console);
- VOID (WINAPI *CleanupConsole)(PCONSOLE Console);
- BOOL (WINAPI *ChangeIcon)(PCONSOLE Console, HICON hWindowIcon);
- NTSTATUS (WINAPI *ResizeBuffer)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER
ScreenBuffer, COORD Size);
- BOOL (WINAPI *ProcessKeyCallback)(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu,
DWORD ShiftState, UINT VirtualKeyCode, BOOL Down);
-} CONSOLE_VTBL, *PCONSOLE_VTBL;
/* CONSOLE_SELECTION_INFO dwFlags values */
#define CONSOLE_NO_SELECTION 0x0
@@ -179,6 +220,7 @@
#define CONSOLE_SELECTION_NOT_EMPTY 0x2
#define CONSOLE_MOUSE_SELECTION 0x4
#define CONSOLE_MOUSE_DOWN 0x8
+
/* HistoryFlags values */
#define HISTORY_NO_DUP_FLAG 0x1
@@ -186,21 +228,6 @@
#define PAUSED_FROM_KEYBOARD 0x1
#define PAUSED_FROM_SCROLLBAR 0x2
#define PAUSED_FROM_SELECTION 0x4
-
-#define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console),
(Region))
-#define ConioWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer,
Length) \
- (Console)->Vtbl->WriteStream((Console), (Block), (CurStartX),
(CurStartY), \
- (ScrolledLines), (Buffer), (Length))
-#define ConioSetCursorInfo(Console, Buff) (Console)->Vtbl->SetCursorInfo((Console),
(Buff))
-#define ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY) \
- (Console)->Vtbl->SetScreenInfo((Console), (Buff), (OldCursorX),
(OldCursorY))
-#define ConioUpdateScreenInfo(Console, Buff) \
- (Console)->Vtbl->UpdateScreenInfo((Console), (Buff))
-#define ConioChangeTitle(Console) (Console)->Vtbl->ChangeTitle(Console)
-#define ConioCleanupConsole(Console) (Console)->Vtbl->CleanupConsole(Console)
-#define ConioChangeIcon(Console, hWindowIcon)
(Console)->Vtbl->ChangeIcon((Console), (hWindowIcon))
-#define ConioResizeBuffer(Console, Buff, Size)
(Console)->Vtbl->ResizeBuffer((Console), (Buff), (Size))
-#define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode,
Down) (Console)->Vtbl->ProcessKeyCallback((Console), (Msg), (KeyStateMenu),
(ShiftState), (VirtualKeyCode), (Down))
/* console.c */
VOID WINAPI ConSrvDeleteConsole(PCONSOLE Console);
Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -231,8 +231,9 @@
/* --- BEL ---*/
else if (Buffer[i] == '\a')
{
+ // FIXME: This MUST BE moved to the terminal emulator!!
DPRINT1("Bell\n");
- SendNotifyMessage(Console->hWindow, PM_CONSOLE_BEEP, 0, 0);
+ // SendNotifyMessage(Console->hWindow, PM_CONSOLE_BEEP, 0, 0);
continue;
}
}
Modified: branches/ros-csrss/win32ss/user/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -14,7 +14,10 @@
#include "consrv.h"
#include "settings.h"
#include "guiconsole.h"
-#include "tuiconsole.h"
+
+#ifdef TUI_CONSOLE
+ #include "tuiconsole.h"
+#endif
#include <shlwapi.h>
#include <shlobj.h>
@@ -324,7 +327,6 @@
*/
InitializeCriticalSection(&Console->Lock);
Console->ReferenceCount = 0;
- Console->ConsoleLeaderCID = ConsoleLeaderProcess->ClientId;
InitializeListHead(&Console->ProcessList);
memcpy(Console->Colors, ConsoleInfo.Colors, sizeof(ConsoleInfo.Colors));
Console->Size = ConsoleInfo.ConsoleSize;
@@ -385,10 +387,6 @@
Console->NumberOfHistoryBuffers = ConsoleInfo.NumberOfHistoryBuffers;
Console->HistoryNoDup = ConsoleInfo.HistoryNoDup;
- /* Finish initialization */
- Console->GuiData = NULL;
- Console->hIcon = Console->hIconSm = NULL;
-
/* Initialize the console title */
RtlCreateUnicodeString(&Console->OriginalTitle,
ConsoleStartInfo->ConsoleTitle);
if (ConsoleStartInfo->ConsoleTitle[0] == L'\0')
@@ -408,35 +406,41 @@
}
/*
- * If we are not in GUI-mode, start the text-mode console.
- * If we fail, try to start the GUI-mode console.
+ * If we are not in GUI-mode, start the text-mode terminal emulator.
+ * If we fail, try to start the GUI-mode terminal emulator.
*/
+#ifdef TUI_CONSOLE
GuiMode = DtbgIsDesktopVisible();
-
+#else
+ GuiMode = TRUE;
+#endif
+
+#ifdef TUI_CONSOLE
if (!GuiMode)
{
- DPRINT1("CONSRV: Opening text-mode console\n");
+ DPRINT1("CONSRV: Opening text-mode terminal emulator\n");
Status = TuiInitConsole(Console, &ConsoleInfo);
if (!NT_SUCCESS(Status))
{
- DPRINT1("Failed to open text-mode console, switching to gui-mode, Status
= 0x%08lx\n", Status);
+ DPRINT1("Failed to open text-mode terminal emulator, switching to
gui-mode, Status = 0x%08lx\n", Status);
GuiMode = TRUE;
}
}
+#endif
/*
- * Try to open the GUI-mode console. Two cases are possible:
+ * 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 console.
+ * 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 console. Then GuiMode
- * was switched to TRUE in order to try to open the console in GUI-mode
- * (win32k will automatically switch to graphical mode, therefore
- * no additional code is needed).
+ * 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).
*/
if (GuiMode)
{
- DPRINT1("CONSRV: Opening GUI-mode console\n");
+ DPRINT1("CONSRV: Opening GUI-mode terminal emulator\n");
Status = GuiInitConsole(Console,
AppPath,
&ConsoleInfo,
@@ -1023,7 +1027,7 @@
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
- GetWindowRequest->WindowHandle = Console->hWindow;
+ GetWindowRequest->WindowHandle =
Console->TermIFace.Vtbl->GetConsoleWindowHandle(Console);
ConSrvReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/guiconsole.c
- * PURPOSE: Implementation of GUI-mode consoles
+ * PURPOSE: GUI terminal emulator
* PROGRAMMERS:
*/
@@ -23,6 +23,14 @@
/* GUI Console Window Class name */
#define GUI_CONSOLE_WINDOW_CLASS L"ConsoleWindowClass"
+
+#ifndef WM_APP
+ #define WM_APP 0x8000
+#endif
+#define PM_CREATE_CONSOLE (WM_APP + 1)
+#define PM_DESTROY_CONSOLE (WM_APP + 2)
+#define PM_CONSOLE_BEEP (WM_APP + 3)
+#define PM_CONSOLE_SET_TITLE (WM_APP + 4)
/* Not defined in any header file */
@@ -44,15 +52,17 @@
BOOL WindowSizeLock;
POINT OldCursor;
- // HWND hWindow;
- // HICON hIcon;
- // HICON hIconSm;
+ HWND hWindow; /* Handle to the console's window */
+ HICON hIcon; /* Handle to the console's icon (big) */
+ HICON hIconSm; /* Handle to the console's icon (small) */
+ // COLORREF Colors[16];
HFONT Font;
UINT CharWidth;
UINT CharHeight;
- GUI_CONSOLE_INFO GuiInfo;
+ PCONSOLE Console; /* Pointer to the owned console */
+ GUI_CONSOLE_INFO GuiInfo; /* GUI terminal settings */
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
static BOOL ConsInitialized = FALSE;
@@ -171,38 +181,38 @@
}
static VOID
-GuiConsoleCreateSysMenu(PCONSOLE Console)
+GuiConsoleCreateSysMenu(HWND hWnd)
{
HMENU hMenu;
- hMenu = GetSystemMenu(Console->hWindow,
- FALSE);
+ hMenu = GetSystemMenu(hWnd, FALSE);
if (hMenu != NULL)
{
- GuiConsoleAppendMenuItems(hMenu,
- GuiConsoleMainMenuItems);
- DrawMenuBar(Console->hWindow);
- }
-}
-
-
-static VOID
-GuiConsoleCopy(HWND hWnd, PCONSOLE Console);
-static VOID
-GuiConsolePaste(HWND hWnd, PCONSOLE Console);
+ GuiConsoleAppendMenuItems(hMenu, GuiConsoleMainMenuItems);
+ DrawMenuBar(hWnd);
+ }
+}
+
+
+static VOID
+GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData);
+static VOID
+GuiConsolePaste(PGUI_CONSOLE_DATA GuiData);
static VOID
GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord);
static VOID
-GuiConsoleShowConsoleProperties(PCONSOLE Console,
- HWND hWnd,
- BOOL Defaults);
+GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults);
+static VOID WINAPI
+GuiDrawRegion(PCONSOLE Console, SMALL_RECT* Region);
+static NTSTATUS WINAPI
+GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size);
+VOID FASTCALL
+GuiConsoleInitScrollbar(PGUI_CONSOLE_DATA GuiData);
+
static LRESULT
-GuiConsoleHandleSysMenuCommand(PCONSOLE Console,
- HWND hWnd,
- WPARAM wParam, LPARAM lParam)
+GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
LRESULT Ret = TRUE;
- COORD bottomRight = { 0, 0 };
switch (wParam)
{
@@ -211,18 +221,23 @@
break;
case ID_SYSTEM_EDIT_COPY:
- GuiConsoleCopy(hWnd, Console);
+ GuiConsoleCopy(GuiData);
break;
case ID_SYSTEM_EDIT_PASTE:
- GuiConsolePaste(hWnd, Console);
+ GuiConsolePaste(GuiData);
break;
case ID_SYSTEM_EDIT_SELECTALL:
+ {
+ PCONSOLE Console = GuiData->Console;
+ COORD bottomRight = { 0, 0 };
+
bottomRight.X = Console->Size.X - 1;
bottomRight.Y = Console->Size.Y - 1;
GuiConsoleUpdateSelection(Console, &bottomRight);
break;
+ }
case ID_SYSTEM_EDIT_SCROLL:
DPRINT1("Scrolling is not handled yet\n");
@@ -233,27 +248,25 @@
break;
case ID_SYSTEM_DEFAULTS:
- GuiConsoleShowConsoleProperties(Console, hWnd, TRUE);
+ GuiConsoleShowConsoleProperties(GuiData, TRUE);
break;
case ID_SYSTEM_PROPERTIES:
- GuiConsoleShowConsoleProperties(Console, hWnd, FALSE);
+ GuiConsoleShowConsoleProperties(GuiData, FALSE);
break;
default:
- Ret = DefWindowProcW(hWnd, WM_SYSCOMMAND, wParam, lParam);
+ Ret = DefWindowProcW(GuiData->hWindow, WM_SYSCOMMAND, wParam, lParam);
break;
}
return Ret;
}
static VOID
-GuiConsoleShowConsoleProperties(PCONSOLE Console,
- HWND hWnd,
- BOOL Defaults)
+GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
{
NTSTATUS Status;
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+ PCONSOLE Console = GuiData->Console;
PCONSOLE_PROCESS_DATA ProcessData;
HANDLE hSection = NULL, hClientSection = NULL;
LARGE_INTEGER SectionSize;
@@ -262,8 +275,6 @@
PCONSOLE_PROPS pSharedInfo = NULL;
DPRINT("GuiConsoleShowConsoleProperties entered\n");
-
- if (GuiData == NULL) return;
/* Create a memory section to share with the applet, and map it */
SectionSize.QuadPart = sizeof(CONSOLE_PROPS);
@@ -301,7 +312,7 @@
* Setup the shared console properties structure.
*/
/* Header */
- pSharedInfo->hConsoleWindow = hWnd; // Console->hWindow;
+ pSharedInfo->hConsoleWindow = GuiData->hWindow;
pSharedInfo->ShowDefaultParams = Defaults;
/* Console information */
pSharedInfo->ci.HistoryBufferSize = Console->HistoryBufferSize;
@@ -380,18 +391,13 @@
return;
}
-
-static NTSTATUS WINAPI
-GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size);
-VOID FASTCALL
-GuiConsoleInitScrollbar(PCONSOLE Console, HWND hwnd);
-
-static VOID
-GuiApplyUserSettings(PCONSOLE Console,
+static VOID
+GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection,
BOOL SaveSettings)
{
NTSTATUS Status;
+ PCONSOLE Console = GuiData->Console;
PCONSOLE_PROCESS_DATA ProcessData;
HANDLE hSection = NULL;
ULONG ViewSize = 0;
@@ -446,6 +452,8 @@
return;
}
+ // TODO: Check that GuiData->hWindow == pConInfo->hConsoleWindow
+
/*
* Apply foreground and background colors for both screen and popup.
* Copy the new palette.
@@ -475,13 +483,9 @@
if (SizeChanged)
{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
- if (GuiData)
- {
- GuiData->WindowSizeLock = TRUE;
- GuiConsoleInitScrollbar(Console, pConInfo->hConsoleWindow);
- GuiData->WindowSizeLock = FALSE;
- }
+ GuiData->WindowSizeLock = TRUE;
+ GuiConsoleInitScrollbar(GuiData);
+ GuiData->WindowSizeLock = FALSE;
}
/// LOCK /// LeaveCriticalSection(&Console->Lock);
@@ -500,18 +504,19 @@
NtClose(hSection);
}
-static PCONSOLE
-GuiGetWindowConsole(HWND hWnd)
-{
- return (PCONSOLE)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
+static PGUI_CONSOLE_DATA
+GuiGetGuiData(HWND hWnd)
+{
+ PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)GetWindowLongPtrW(hWnd,
GWLP_USERDATA);
+ return ( ((GuiData == NULL) || (GuiData->hWindow == hWnd &&
GuiData->Console != NULL)) ? GuiData : NULL );
}
VOID
FASTCALL
-GuiConsoleInitScrollbar(PCONSOLE Console, HWND hwnd)
-{
+GuiConsoleInitScrollbar(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
SCROLLINFO sInfo;
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
DWORD Width = Console->Size.X * GuiData->CharWidth + 2 *
(GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXEDGE));
DWORD Height = Console->Size.Y * GuiData->CharHeight + 2 *
(GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) +
GetSystemMetrics(SM_CYCAPTION);
@@ -525,13 +530,13 @@
sInfo.nMax = Console->ActiveBuffer->ScreenBufferSize.Y - 1;
sInfo.nPage = Console->Size.Y;
sInfo.nPos = Console->ActiveBuffer->ShowY;
- SetScrollInfo(hwnd, SB_VERT, &sInfo, TRUE);
+ SetScrollInfo(GuiData->hWindow, SB_VERT, &sInfo, TRUE);
Width += GetSystemMetrics(SM_CXVSCROLL);
- ShowScrollBar(hwnd, SB_VERT, TRUE);
+ ShowScrollBar(GuiData->hWindow, SB_VERT, TRUE);
}
else
{
- ShowScrollBar(hwnd, SB_VERT, FALSE);
+ ShowScrollBar(GuiData->hWindow, SB_VERT, FALSE);
}
if (Console->ActiveBuffer->ScreenBufferSize.X > Console->Size.X)
@@ -539,31 +544,31 @@
sInfo.nMax = Console->ActiveBuffer->ScreenBufferSize.X - 1;
sInfo.nPage = Console->Size.X;
sInfo.nPos = Console->ActiveBuffer->ShowX;
- SetScrollInfo(hwnd, SB_HORZ, &sInfo, TRUE);
+ SetScrollInfo(GuiData->hWindow, SB_HORZ, &sInfo, TRUE);
Height += GetSystemMetrics(SM_CYHSCROLL);
- ShowScrollBar(hwnd, SB_HORZ, TRUE);
+ ShowScrollBar(GuiData->hWindow, SB_HORZ, TRUE);
}
else
{
- ShowScrollBar(hwnd, SB_HORZ, FALSE);
- }
-
- SetWindowPos(hwnd, NULL, 0, 0, Width, Height,
+ ShowScrollBar(GuiData->hWindow, SB_HORZ, FALSE);
+ }
+
+ SetWindowPos(GuiData->hWindow, NULL, 0, 0, Width, Height,
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
static BOOL
GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
{
- PCONSOLE Console = (PCONSOLE)Create->lpCreateParams;
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+ PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
+ PCONSOLE Console = GuiData->Console;
HDC Dc;
HFONT OldFont;
TEXTMETRICW Metrics;
SIZE CharSize;
- Console->hWindow = hWnd;
+ GuiData->hWindow = hWnd;
if (NULL == GuiData)
{
@@ -594,7 +599,7 @@
RtlFreeHeap(ConSrvHeap, 0, GuiData);
return FALSE;
}
- Dc = GetDC(hWnd);
+ Dc = GetDC(GuiData->hWindow);
if (NULL == Dc)
{
DPRINT1("GuiConsoleNcCreate: GetDC failed\n");
@@ -607,7 +612,7 @@
if (NULL == OldFont)
{
DPRINT1("GuiConsoleNcCreate: SelectObject failed\n");
- ReleaseDC(hWnd, Dc);
+ ReleaseDC(GuiData->hWindow, Dc);
DeleteObject(GuiData->Font);
DeleteCriticalSection(&GuiData->Lock);
RtlFreeHeap(ConSrvHeap, 0, GuiData);
@@ -617,7 +622,7 @@
{
DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n");
SelectObject(Dc, OldFont);
- ReleaseDC(hWnd, Dc);
+ ReleaseDC(GuiData->hWindow, Dc);
DeleteObject(GuiData->Font);
DeleteCriticalSection(&GuiData->Lock);
RtlFreeHeap(ConSrvHeap, 0, GuiData);
@@ -632,7 +637,7 @@
SelectObject(Dc, OldFont);
- ReleaseDC(hWnd, Dc);
+ ReleaseDC(GuiData->hWindow, Dc);
// FIXME: Keep these instructions here ? ///////////////////////////////////
Console->ActiveBuffer->CursorBlinkOn = TRUE;
@@ -640,25 +645,26 @@
////////////////////////////////////////////////////////////////////////////
DPRINT("Console %p GuiData %p\n", Console, GuiData);
- SetWindowLongPtrW(hWnd, GWLP_USERDATA, (DWORD_PTR)Console);
-
- SetTimer(hWnd, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
- GuiConsoleCreateSysMenu(Console);
+ SetWindowLongPtrW(GuiData->hWindow, GWLP_USERDATA, (DWORD_PTR)GuiData);
+
+ SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
+ GuiConsoleCreateSysMenu(GuiData->hWindow);
GuiData->WindowSizeLock = TRUE;
- GuiConsoleInitScrollbar(Console, hWnd);
+ GuiConsoleInitScrollbar(GuiData);
GuiData->WindowSizeLock = FALSE;
SetEvent(GuiData->hGuiInitEvent);
- return (BOOL)DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM)Create);
-}
-
-static VOID
-SmallRectToRect(PCONSOLE Console, PRECT Rect, PSMALL_RECT SmallRect)
-{
+ return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
+}
+
+static VOID
+SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
+{
+ PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+
Rect->left = (SmallRect->Left - Buffer->ShowX) *
GuiData->CharWidth;
Rect->top = (SmallRect->Top - Buffer->ShowY) *
GuiData->CharHeight;
Rect->right = (SmallRect->Right + 1 - Buffer->ShowX) *
GuiData->CharWidth;
@@ -668,10 +674,10 @@
static VOID
GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord)
{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
RECT oldRect, newRect;
- HWND hWnd = Console->hWindow;
-
- SmallRectToRect(Console, &oldRect, &Console->Selection.srSelection);
+
+ SmallRectToRect(GuiData, &oldRect, &Console->Selection.srSelection);
if(coord != NULL)
{
@@ -682,7 +688,7 @@
rc.Right = max(Console->Selection.dwSelectionAnchor.X, coord->X);
rc.Bottom = max(Console->Selection.dwSelectionAnchor.Y, coord->Y);
- SmallRectToRect(Console, &newRect, &rc);
+ SmallRectToRect(GuiData, &newRect, &rc);
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{
@@ -697,7 +703,7 @@
{
if(CombineRgn(rgn1, rgn2, rgn1, RGN_XOR) != ERROR)
{
- InvalidateRgn(hWnd, rgn1, FALSE);
+ InvalidateRgn(GuiData->hWindow, rgn1, FALSE);
}
DeleteObject(rgn2);
@@ -708,7 +714,7 @@
}
else
{
- InvalidateRect(hWnd, &newRect, FALSE);
+ InvalidateRect(GuiData->hWindow, &newRect, FALSE);
}
Console->Selection.dwFlags |= CONSOLE_SELECTION_NOT_EMPTY;
Console->Selection.srSelection = rc;
@@ -719,7 +725,7 @@
/* clear the selection */
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{
- InvalidateRect(hWnd, &oldRect, FALSE);
+ InvalidateRect(GuiData->hWindow, &oldRect, FALSE);
}
Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
ConioUnpause(Console, PAUSED_FROM_SELECTION);
@@ -758,8 +764,7 @@
if (BottomLine >= Buff->ScreenBufferSize.Y) BottomLine =
Buff->ScreenBufferSize.Y - 1;
if (RightChar >= Buff->ScreenBufferSize.X) RightChar =
Buff->ScreenBufferSize.X - 1;
- OldFont = SelectObject(hDC,
- GuiData->Font);
+ OldFont = SelectObject(hDC, GuiData->Font);
for (Line = TopLine; Line <= BottomLine; Line++)
{
@@ -825,39 +830,33 @@
CursorBrush = CreateSolidBrush(RGBFromAttrib(Console,
Buff->ScreenDefaultAttrib));
}
- OldBrush = SelectObject(hDC,
- CursorBrush);
+ OldBrush = SelectObject(hDC, CursorBrush);
PatBlt(hDC,
(CursorX - Buff->ShowX) * GuiData->CharWidth,
(CursorY - Buff->ShowY) * GuiData->CharHeight +
(GuiData->CharHeight - CursorHeight),
GuiData->CharWidth,
CursorHeight,
PATCOPY);
- SelectObject(hDC,
- OldBrush);
+ SelectObject(hDC, OldBrush);
DeleteObject(CursorBrush);
}
}
/// LOCK /// LeaveCriticalSection(&Buff->Header.Console->Lock);
- SelectObject(hDC,
- OldFont);
-}
-
-static VOID
-GuiConsoleHandlePaint(PCONSOLE Console,
- HWND hWnd,
- HDC hDCPaint)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+ SelectObject(hDC, OldFont);
+}
+
+static VOID
+GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData, HDC hDCPaint)
+{
+ PCONSOLE Console = GuiData->Console;
HDC hDC;
PAINTSTRUCT ps;
- if (GuiData == NULL) return;
if (Console->ActiveBuffer == NULL) return;
- hDC = BeginPaint(hWnd, &ps);
+ hDC = BeginPaint(GuiData->hWindow, &ps);
if (hDC != NULL &&
ps.rcPaint.left < ps.rcPaint.right &&
ps.rcPaint.top < ps.rcPaint.bottom)
@@ -874,7 +873,7 @@
if (Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY)
{
RECT rc;
- SmallRectToRect(Console, &rc,
&Console->Selection.srSelection);
+ SmallRectToRect(GuiData, &rc,
&Console->Selection.srSelection);
/* invert the selection */
if (IntersectRect(&rc,
@@ -893,16 +892,16 @@
LeaveCriticalSection(&GuiData->Lock);
}
}
- EndPaint(hWnd, &ps);
-}
-
-static VOID
-GuiConsoleHandleKey(PCONSOLE Console, HWND hWnd,
- UINT msg, WPARAM wParam, LPARAM lParam)
-{
+ EndPaint(GuiData->hWindow, &ps);
+}
+
+static VOID
+GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ PCONSOLE Console = GuiData->Console;
MSG Message;
- Message.hwnd = hWnd;
+ Message.hwnd = GuiData->hWindow;
Message.message = msg;
Message.wParam = wParam;
Message.lParam = lParam;
@@ -916,27 +915,6 @@
ConioProcessKey(Console, &Message);
}
-static BOOL WINAPI
-GuiProcessKeyCallback(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu, DWORD ShiftState,
UINT VirtualKeyCode, BOOL Down)
-{
- if ((ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED) || KeyStateMenu &
0x80) &&
- (VirtualKeyCode == VK_ESCAPE || VirtualKeyCode == VK_TAB || VirtualKeyCode ==
VK_SPACE))
- {
- DefWindowProcW(msg->hwnd, msg->message, msg->wParam, msg->lParam);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static VOID WINAPI
-GuiDrawRegion(PCONSOLE Console, SMALL_RECT* Region)
-{
- RECT RegionRect;
- SmallRectToRect(Console, &RegionRect, Region);
- InvalidateRect(Console->hWindow, &RegionRect, FALSE);
-}
-
static VOID
GuiInvalidateCell(PCONSOLE Console, UINT x, UINT y)
{
@@ -944,100 +922,13 @@
GuiDrawRegion(Console, &CellRect);
}
-static VOID WINAPI
-GuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG
CursorStartY,
- UINT ScrolledLines, CHAR *Buffer, UINT Length)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
- PCONSOLE_SCREEN_BUFFER Buff = Console->ActiveBuffer;
- LONG CursorEndX, CursorEndY;
- RECT ScrollRect;
-
- if (NULL == Console->hWindow || NULL == GuiData)
- {
- return;
- }
-
- if (0 != ScrolledLines)
- {
- ScrollRect.left = 0;
- ScrollRect.top = 0;
- ScrollRect.right = Console->Size.X * GuiData->CharWidth;
- ScrollRect.bottom = Region->Top * GuiData->CharHeight;
-
- ScrollWindowEx(Console->hWindow,
- 0,
- -(ScrolledLines * GuiData->CharHeight),
- &ScrollRect,
- NULL,
- NULL,
- NULL,
- SW_INVALIDATE);
- }
-
- GuiDrawRegion(Console, Region);
-
- if (CursorStartX < Region->Left || Region->Right < CursorStartX
- || CursorStartY < Region->Top || Region->Bottom < CursorStartY)
- {
- GuiInvalidateCell(Console, CursorStartX, CursorStartY);
- }
-
- CursorEndX = Buff->CursorPosition.X;
- CursorEndY = Buff->CursorPosition.Y;
- if ((CursorEndX < Region->Left || Region->Right < CursorEndX
- || CursorEndY < Region->Top || Region->Bottom < CursorEndY)
- && (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
- {
- GuiInvalidateCell(Console, CursorEndX, CursorEndY);
- }
-
- // Set up the update timer (very short interval) - this is a "hack" for
getting the OS to
- // repaint the window without having it just freeze up and stay on the screen
permanently.
- Buff->CursorBlinkOn = TRUE;
- SetTimer(Console->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
-}
-
-static BOOL WINAPI
-GuiSetCursorInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff)
-{
- if (Console->ActiveBuffer == Buff)
- {
- GuiInvalidateCell(Console, Buff->CursorPosition.X,
Buff->CursorPosition.Y);
- }
-
- return TRUE;
-}
-
-static BOOL WINAPI
-GuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, UINT OldCursorX, UINT
OldCursorY)
-{
- if (Console->ActiveBuffer == Buff)
- {
- /* Redraw char at old position (removes cursor) */
- GuiInvalidateCell(Console, OldCursorX, OldCursorY);
- /* Redraw char at new position (shows cursor) */
- GuiInvalidateCell(Console, Buff->CursorPosition.X,
Buff->CursorPosition.Y);
- }
-
- return TRUE;
-}
-
-static BOOL WINAPI
-GuiUpdateScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff)
-{
- return TRUE;
-}
-
-static VOID
-GuiConsoleHandleTimer(PCONSOLE Console, HWND hWnd)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+static VOID
+GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
- if (GuiData == NULL) return;
-
- SetTimer(hWnd, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL);
+ SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL);
Buff = Console->ActiveBuffer;
GuiInvalidateCell(Console, Buff->CursorPosition.X, Buff->CursorPosition.Y);
@@ -1052,8 +943,8 @@
xScroll.cbSize = sizeof(SCROLLINFO);
xScroll.fMask = SIF_POS;
// Capture the original position of the scroll bars and save them.
- if(GetScrollInfo(hWnd, SB_HORZ, &xScroll))OldScrollX = xScroll.nPos;
- if(GetScrollInfo(hWnd, SB_VERT, &xScroll))OldScrollY = xScroll.nPos;
+ if(GetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll))OldScrollX =
xScroll.nPos;
+ if(GetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll))OldScrollY =
xScroll.nPos;
// If we successfully got the info for the horizontal scrollbar
if(OldScrollX >= 0)
@@ -1092,7 +983,7 @@
{
Buff->ShowX = NewScrollX;
Buff->ShowY = NewScrollY;
- ScrollWindowEx(hWnd,
+ ScrollWindowEx(GuiData->hWindow,
(OldScrollX - NewScrollX) * GuiData->CharWidth,
(OldScrollY - NewScrollY) * GuiData->CharHeight,
NULL,
@@ -1103,14 +994,14 @@
if(NewScrollX >= 0)
{
xScroll.nPos = NewScrollX;
- SetScrollInfo(hWnd, SB_HORZ, &xScroll, TRUE);
+ SetScrollInfo(GuiData->hWindow, SB_HORZ, &xScroll, TRUE);
}
if(NewScrollY >= 0)
{
xScroll.nPos = NewScrollY;
- SetScrollInfo(hWnd, SB_VERT, &xScroll, TRUE);
+ SetScrollInfo(GuiData->hWindow, SB_VERT, &xScroll, TRUE);
}
- UpdateWindow(hWnd);
+ UpdateWindow(GuiData->hWindow);
GuiData->OldCursor.x = Buff->CursorPosition.X;
GuiData->OldCursor.y = Buff->CursorPosition.Y;
}
@@ -1118,8 +1009,9 @@
}
static VOID
-GuiConsoleHandleClose(PCONSOLE Console, HWND hWnd)
-{
+GuiConsoleHandleClose(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
PLIST_ENTRY current_entry;
PCONSOLE_PROCESS_DATA current;
@@ -1148,12 +1040,12 @@
}
static VOID
-GuiConsoleHandleNcDestroy(PCONSOLE Console, HWND hWnd)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+GuiConsoleHandleNcDestroy(PGUI_CONSOLE_DATA GuiData, HWND hWnd)
+{
+ PCONSOLE Console = GuiData->Console;
KillTimer(hWnd, 1);
- Console->GuiData = NULL;
+ Console->TermIFace.Data = NULL;
DeleteCriticalSection(&GuiData->Lock);
GetSystemMenu(hWnd, TRUE);
@@ -1161,9 +1053,9 @@
}
static COORD
-PointToCoord(PCONSOLE Console, LPARAM lParam)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
+{
+ PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
COORD Coord;
@@ -1185,54 +1077,50 @@
}
static VOID
-GuiConsoleLeftMouseDown(PCONSOLE Console, HWND hWnd,
- LPARAM lParam)
-{
- Console->Selection.dwSelectionAnchor = PointToCoord(Console, lParam);
-
- SetCapture(hWnd);
-
+GuiConsoleLeftMouseDown(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
+{
+ PCONSOLE Console = GuiData->Console;
+
+ Console->Selection.dwSelectionAnchor = PointToCoord(GuiData, lParam);
+ SetCapture(GuiData->hWindow);
Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS |
CONSOLE_MOUSE_SELECTION | CONSOLE_MOUSE_DOWN;
-
GuiConsoleUpdateSelection(Console, &Console->Selection.dwSelectionAnchor);
}
static VOID
-GuiConsoleLeftMouseUp(PCONSOLE Console, HWND hWnd,
- LPARAM lParam)
-{
+GuiConsoleLeftMouseUp(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
+{
+ PCONSOLE Console = GuiData->Console;
COORD c;
if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) return;
- c = PointToCoord(Console, lParam);
-
+ c = PointToCoord(GuiData, lParam);
Console->Selection.dwFlags &= ~CONSOLE_MOUSE_DOWN;
-
GuiConsoleUpdateSelection(Console, &c);
-
ReleaseCapture();
}
static VOID
-GuiConsoleMouseMove(PCONSOLE Console, HWND hWnd,
- WPARAM wParam, LPARAM lParam)
-{
+GuiConsoleMouseMove(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
+{
+ PCONSOLE Console = GuiData->Console;
COORD c;
if (!(wParam & MK_LBUTTON)) return;
if (!(Console->Selection.dwFlags & CONSOLE_MOUSE_DOWN)) return;
- c = PointToCoord(Console, lParam); /* TODO: Scroll buffer to bring c into view */
-
+ c = PointToCoord(GuiData, lParam); /* TODO: Scroll buffer to bring c into view */
GuiConsoleUpdateSelection(Console, &c);
}
static VOID
-GuiConsoleCopy(HWND hWnd, PCONSOLE Console)
-{
- if (OpenClipboard(hWnd) == TRUE)
+GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+
+ if (OpenClipboard(GuiData->hWindow) == TRUE)
{
HANDLE hData;
PBYTE ptr;
@@ -1301,9 +1189,11 @@
}
static VOID
-GuiConsolePaste(HWND hWnd, PCONSOLE Console)
-{
- if (OpenClipboard(hWnd) == TRUE)
+GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+
+ if (OpenClipboard(GuiData->hWindow) == TRUE)
{
HANDLE hData;
LPSTR str;
@@ -1334,15 +1224,17 @@
}
static VOID
-GuiConsoleRightMouseDown(PCONSOLE Console, HWND hWnd)
-{
+GuiConsoleRightMouseDown(PGUI_CONSOLE_DATA GuiData)
+{
+ PCONSOLE Console = GuiData->Console;
+
if (!(Console->Selection.dwFlags & CONSOLE_SELECTION_NOT_EMPTY))
{
- GuiConsolePaste(hWnd, Console);
+ GuiConsolePaste(GuiData);
}
else
{
- GuiConsoleCopy(hWnd, Console);
+ GuiConsoleCopy(GuiData);
/* Clear the selection */
GuiConsoleUpdateSelection(Console, NULL);
@@ -1350,14 +1242,10 @@
}
static VOID
-GuiConsoleGetMinMaxInfo(PCONSOLE Console,
- HWND hWnd,
- PMINMAXINFO minMaxInfo)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
+{
+ PCONSOLE Console = GuiData->Console;
DWORD windx, windy;
-
- if (GuiData == NULL) return;
windx = CONGUI_MIN_WIDTH * GuiData->CharWidth + 2 * (GetSystemMetrics(SM_CXFRAME)
+ GetSystemMetrics(SM_CXEDGE));
windy = CONGUI_MIN_HEIGHT * GuiData->CharHeight + 2 *
(GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYEDGE)) +
GetSystemMetrics(SM_CYCAPTION);
@@ -1376,13 +1264,9 @@
}
static VOID
-GuiConsoleResize(PCONSOLE Console,
- HWND hWnd,
- WPARAM wParam, LPARAM lParam)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
-
- if (GuiData == NULL) return;
+GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
+{
+ PCONSOLE Console = GuiData->Console;
if ((GuiData->WindowSizeLock == FALSE) && (wParam == SIZE_RESTORED ||
wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED))
{
@@ -1423,16 +1307,19 @@
Console->Size.Y = (chary <= Buff->ScreenBufferSize.Y) ? chary :
Buff->ScreenBufferSize.Y;
}
- GuiConsoleInitScrollbar(Console, hWnd);
+ GuiConsoleInitScrollbar(GuiData);
// Adjust the start of the visible area if we are attempting to show nonexistent
areas
if((Buff->ScreenBufferSize.X - Buff->ShowX) < Console->Size.X)
Buff->ShowX = Buff->ScreenBufferSize.X - Console->Size.X;
if((Buff->ScreenBufferSize.Y - Buff->ShowY) < Console->Size.Y)
Buff->ShowY = Buff->ScreenBufferSize.Y - Console->Size.Y;
- InvalidateRect(hWnd, NULL, TRUE);
+ InvalidateRect(GuiData->hWindow, NULL, TRUE);
GuiData->WindowSizeLock = FALSE;
}
}
+
+/*
+// HACK: This functionality is standard for general scrollbars. Don't add it by
hand.
VOID
FASTCALL
@@ -1446,6 +1333,7 @@
DPRINT("CreatePopupMenu failed\n");
return;
}
+
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLHERE);
//InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLTOP);
@@ -1456,110 +1344,14 @@
//InsertItem(hMenu, MFT_SEPARATOR, MIIM_FTYPE, 0, NULL, -1);
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLUP);
//InsertItem(hMenu, MIIM_STRING, MIIM_ID | MIIM_FTYPE | MIIM_STRING, 0, NULL,
IDS_SCROLLDOWN);
-
-}
-
-static NTSTATUS WINAPI
-GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size)
-{
- BYTE * Buffer;
- DWORD Offset = 0;
- BYTE * OldPtr;
- USHORT CurrentY;
- BYTE * OldBuffer;
-#ifdef HAVE_WMEMSET
- USHORT value = MAKEWORD(' ', ScreenBuffer->ScreenDefaultAttrib);
-#else
- DWORD i;
-#endif
- DWORD diff;
-
- /* Buffer size is not allowed to be smaller than window size */
- if (Size.X < Console->Size.X || Size.Y < Console->Size.Y)
- return STATUS_INVALID_PARAMETER;
-
- if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y ==
ScreenBuffer->ScreenBufferSize.Y)
- return STATUS_SUCCESS;
-
- Buffer = RtlAllocateHeap(ConSrvHeap, 0, Size.X * Size.Y * 2);
- if (!Buffer)
- return STATUS_NO_MEMORY;
-
- DPRINT1("Resizing (%d,%d) to (%d,%d)\n",
ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X,
Size.Y);
- OldBuffer = ScreenBuffer->Buffer;
-
- for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y &&
CurrentY < Size.Y; CurrentY++)
- {
- OldPtr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
- if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
- {
- /* reduce size */
- RtlCopyMemory(&Buffer[Offset], OldPtr, Size.X * 2);
- Offset += (Size.X * 2);
- }
- else
- {
- /* enlarge size */
- RtlCopyMemory(&Buffer[Offset], OldPtr,
ScreenBuffer->ScreenBufferSize.X * 2);
- Offset += (ScreenBuffer->ScreenBufferSize.X * 2);
-
- diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
- /* zero new part of it */
-#ifdef HAVE_WMEMSET
- wmemset((PWCHAR)&Buffer[Offset], value, diff);
-#else
- for (i = 0; i < diff; i++)
- {
- Buffer[Offset++] = ' ';
- Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib;
- }
-#endif
- }
- }
-
- if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
- {
- diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
-#ifdef HAVE_WMEMSET
- wmemset((PWCHAR)&Buffer[Offset], value, diff);
-#else
- for (i = 0; i < diff; i++)
- {
- Buffer[Offset++] = ' ';
- Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib;
- }
-#endif
- }
-
- (void)InterlockedExchangePointer((PVOID volatile*)&ScreenBuffer->Buffer,
Buffer);
- RtlFreeHeap(ConSrvHeap, 0, OldBuffer);
- ScreenBuffer->ScreenBufferSize = Size;
- ScreenBuffer->VirtualY = 0;
-
- /* Ensure cursor and window are within buffer */
- if (ScreenBuffer->CursorPosition.X >= Size.X)
- ScreenBuffer->CursorPosition.X = Size.X - 1;
- if (ScreenBuffer->CursorPosition.Y >= Size.Y)
- ScreenBuffer->CursorPosition.Y = Size.Y - 1;
- if (ScreenBuffer->ShowX > Size.X - Console->Size.X)
- ScreenBuffer->ShowX = Size.X - Console->Size.X;
- if (ScreenBuffer->ShowY > Size.Y - Console->Size.Y)
- ScreenBuffer->ShowY = Size.Y - Console->Size.Y;
-
- /* TODO: Should update scrollbar, but can't use anything that
- * calls SendMessage or it could cause deadlock --> Use PostMessage */
-
- return STATUS_SUCCESS;
-}
+}
+*/
static
LRESULT
-GuiConsoleHandleScroll(PCONSOLE Console,
- HWND hWnd,
- UINT uMsg,
- WPARAM wParam)
-{
- PGUI_CONSOLE_DATA GuiData = Console->GuiData;
+GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
+{
+ PCONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
SCROLLINFO sInfo;
int fnBar;
@@ -1587,7 +1379,7 @@
sInfo.cbSize = sizeof(SCROLLINFO);
sInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE | SIF_TRACKPOS;
- if (!GetScrollInfo(hWnd, fnBar, &sInfo))
+ if (!GetScrollInfo(GuiData->hWindow, fnBar, &sInfo))
{
return FALSE;
}
@@ -1642,7 +1434,7 @@
USHORT OldY = Buff->ShowY;
*pShowXY = sInfo.nPos;
- ScrollWindowEx(hWnd,
+ ScrollWindowEx(GuiData->hWindow,
(OldX - Buff->ShowX) * GuiData->CharWidth,
(OldY - Buff->ShowY) * GuiData->CharHeight,
NULL,
@@ -1652,9 +1444,9 @@
SW_INVALIDATE);
sInfo.fMask = SIF_POS;
- SetScrollInfo(hWnd, fnBar, &sInfo, TRUE);
-
- UpdateWindow(hWnd);
+ SetScrollInfo(GuiData->hWindow, fnBar, &sInfo, TRUE);
+
+ UpdateWindow(GuiData->hWindow);
}
return 0;
@@ -1664,11 +1456,11 @@
GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT Result = 0;
- PCONSOLE Console = NULL;
+ PGUI_CONSOLE_DATA GuiData = NULL;
/*
* If it's the first time we create a window
- * for the console, just initialize it.
+ * for the terminal, just initialize it.
*/
if (msg == WM_NCCREATE)
{
@@ -1676,31 +1468,31 @@
}
/*
- * Now the console window is initialized.
- * Get the console owned by the window.
- * If there is no console, just go away.
+ * Now the terminal window is initialized.
+ * Get the terminal data via the window's data.
+ * If there is no data, just go away.
*/
- Console = GuiGetWindowConsole(hWnd);
- if (Console == NULL) return 0;
+ GuiData = GuiGetGuiData(hWnd);
+ if (GuiData == NULL) return 0;
// TODO: If the console is about to be destroyed, leave the loop.
/* Lock the console */
- EnterCriticalSection(&Console->Lock);
+ EnterCriticalSection(&GuiData->Console->Lock);
/* We have a console, start message dispatching. */
switch (msg)
{
case WM_CLOSE:
- GuiConsoleHandleClose(Console, hWnd);
+ GuiConsoleHandleClose(GuiData);
break;
case WM_NCDESTROY:
- GuiConsoleHandleNcDestroy(Console, hWnd);
+ GuiConsoleHandleNcDestroy(GuiData, hWnd);
break;
case WM_PAINT:
- GuiConsoleHandlePaint(Console, hWnd, (HDC)wParam);
+ GuiConsoleHandlePaint(GuiData, (HDC)wParam);
break;
case WM_KEYDOWN:
@@ -1708,48 +1500,48 @@
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_CHAR:
- GuiConsoleHandleKey(Console, hWnd, msg, wParam, lParam);
+ GuiConsoleHandleKey(GuiData, msg, wParam, lParam);
break;
case WM_TIMER:
- GuiConsoleHandleTimer(Console, hWnd);
+ GuiConsoleHandleTimer(GuiData);
break;
case WM_LBUTTONDOWN:
- GuiConsoleLeftMouseDown(Console, hWnd, lParam);
+ GuiConsoleLeftMouseDown(GuiData, lParam);
break;
case WM_LBUTTONUP:
- GuiConsoleLeftMouseUp(Console, hWnd, lParam);
+ GuiConsoleLeftMouseUp(GuiData, lParam);
break;
case WM_RBUTTONDOWN:
- GuiConsoleRightMouseDown(Console, hWnd);
+ GuiConsoleRightMouseDown(GuiData);
break;
case WM_MOUSEMOVE:
- GuiConsoleMouseMove(Console, hWnd, wParam, lParam);
+ GuiConsoleMouseMove(GuiData, wParam, lParam);
break;
case WM_SYSCOMMAND:
- Result = GuiConsoleHandleSysMenuCommand(Console, hWnd, wParam, lParam);
+ Result = GuiConsoleHandleSysMenuCommand(GuiData, wParam, lParam);
break;
case WM_HSCROLL:
case WM_VSCROLL:
- Result = GuiConsoleHandleScroll(Console, hWnd, msg, wParam);
+ Result = GuiConsoleHandleScroll(GuiData, msg, wParam);
break;
case WM_GETMINMAXINFO:
- GuiConsoleGetMinMaxInfo(Console, hWnd, (PMINMAXINFO)lParam);
+ GuiConsoleGetMinMaxInfo(GuiData, (PMINMAXINFO)lParam);
break;
case WM_SIZE:
- GuiConsoleResize(Console, hWnd, wParam, lParam);
+ GuiConsoleResize(GuiData, wParam, lParam);
break;
case PM_APPLY_CONSOLE_INFO:
- GuiApplyUserSettings(Console, (HANDLE)wParam, (BOOL)lParam);
+ GuiApplyUserSettings(GuiData, (HANDLE)wParam, (BOOL)lParam);
break;
case PM_CONSOLE_BEEP:
@@ -1758,19 +1550,25 @@
break;
case PM_CONSOLE_SET_TITLE:
- SetWindowText(hWnd, Console->Title.Buffer);
+ SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
break;
default:
- Result = DefWindowProcW(hWnd, msg, wParam, lParam);
+ Result = DefWindowProcW(GuiData->hWindow, msg, wParam, lParam);
break;
}
/* Unlock the console */
- LeaveCriticalSection(&Console->Lock);
+ LeaveCriticalSection(&GuiData->Console->Lock);
return Result;
}
+
+
+
+/******************************************************************************
+ * GUI Terminal Initialization *
+ ******************************************************************************/
static LRESULT CALLBACK
GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1778,14 +1576,19 @@
HWND NewWindow;
LONG WindowCount;
MSG Msg;
- PCONSOLE Console = (PCONSOLE)lParam;
+ PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)lParam;
+ PCONSOLE Console = GuiData->Console;
switch (msg)
{
case WM_CREATE:
+ {
SetWindowLongW(hWnd, GWL_USERDATA, 0);
return 0;
+ }
+
case PM_CREATE_CONSOLE:
+ {
NewWindow = CreateWindowExW(WS_EX_CLIENTEDGE,
GUI_CONSOLE_WINDOW_CLASS,
Console->Title.Buffer,
@@ -1797,40 +1600,50 @@
NULL,
NULL,
ConSrvDllInstance,
- (PVOID)Console);
+ (PVOID)GuiData);
if (NULL != NewWindow)
{
- SetConsoleWndConsoleLeaderCID(Console);
- SetWindowLongW(hWnd, GWL_USERDATA, GetWindowLongW(hWnd, GWL_USERDATA) +
1);
+ WindowCount = GetWindowLongW(hWnd, GWL_USERDATA);
+ WindowCount++;
+ SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
+
+ // SetConsoleWndConsoleLeaderCID(Console);
DPRINT1("Set icons via PM_CREATE_CONSOLE\n");
- if (Console->hIcon == NULL)
+ if (GuiData->hIcon == NULL)
{
- DPRINT1("Not really...\n");
- Console->hIcon = ghDefaultIcon;
- Console->hIconSm = ghDefaultIconSm;
+ DPRINT1("Not really /o\\...\n");
+ GuiData->hIcon = ghDefaultIcon;
+ GuiData->hIconSm = ghDefaultIconSm;
}
- else if (Console->hIcon != ghDefaultIcon)
+ else if (GuiData->hIcon != ghDefaultIcon)
{
- DPRINT1("Yes !\n");
- SendMessageW(Console->hWindow, WM_SETICON, ICON_BIG,
(LPARAM)Console->hIcon);
- SendMessageW(Console->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)Console->hIconSm);
+ DPRINT1("Yes \\o/\n");
+ SendMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG,
(LPARAM)GuiData->hIcon);
+ SendMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)GuiData->hIconSm);
}
ShowWindow(NewWindow, (int)wParam);
}
+
return (LRESULT)NewWindow;
+ }
+
case PM_DESTROY_CONSOLE:
- /* Window creation is done using a PostMessage(), so it's possible that
the
- * window that we want to destroy doesn't exist yet. So first empty the
message
- * queue */
+ {
+ /*
+ * Window creation is done using a PostMessage(), so it's possible
+ * that the window that we want to destroy doesn't exist yet.
+ * So first empty the message queue.
+ */
while(PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessageW(&Msg);
}
- DestroyWindow(Console->hWindow);
- Console->hWindow = NULL;
+ DestroyWindow(GuiData->hWindow);
+ GuiData->hWindow = NULL;
+
WindowCount = GetWindowLongW(hWnd, GWL_USERDATA);
WindowCount--;
SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
@@ -1838,10 +1651,13 @@
{
NotifyWnd = NULL;
DestroyWindow(hWnd);
- PrivateCsrssManualGuiCheck(-1);
+ DPRINT1("CONSRV: Going to quit the Gui Thread!!\n");
PostQuitMessage(0);
}
+
return 0;
+ }
+
default:
return DefWindowProcW(hWnd, msg, wParam, lParam);
}
@@ -1851,7 +1667,14 @@
GuiConsoleGuiThread(PVOID Data)
{
MSG msg;
- PHANDLE GraphicsStartupEvent = (PHANDLE) Data;
+ PHANDLE GraphicsStartupEvent = (PHANDLE)Data;
+
+ /*
+ * This thread dispatches all the console notifications to the notify window.
+ * It is common for all the console windows.
+ */
+
+ PrivateCsrssManualGuiCheck(+1);
NotifyWnd = CreateWindowW(L"ConSrvCreateNotify",
L"",
@@ -1879,6 +1702,9 @@
DispatchMessageW(&msg);
}
+ DPRINT1("CONSRV: Quit the Gui Thread!!\n");
+ PrivateCsrssManualGuiCheck(-1);
+
return 1;
}
@@ -1888,180 +1714,78 @@
WNDCLASSEXW wc;
ATOM ConsoleClassAtom;
+ /* Exit if we were already initialized */
+ // if (ConsInitialized) return TRUE;
+
+ /*
+ * Initialize and register the different window classes, if needed.
+ */
+ if (!ConsInitialized)
+ {
+ /* Initialize the notification window class */
+ wc.cbSize = sizeof(WNDCLASSEXW);
+ wc.lpszClassName = L"ConSrvCreateNotify";
+ wc.lpfnWndProc = GuiConsoleNotifyWndProc;
+ wc.style = 0;
+ wc.hInstance = ConSrvDllInstance;
+ wc.hIcon = NULL;
+ wc.hIconSm = NULL;
+ wc.hCursor = NULL;
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ if (RegisterClassExW(&wc) == 0)
+ {
+ DPRINT1("Failed to register GUI notify wndproc\n");
+ return FALSE;
+ }
+
+ /* Initialize the console window class */
+ ghDefaultIcon = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE),
IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON),
+ LR_SHARED);
+ ghDefaultIconSm = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE),
IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
+ LR_SHARED);
+ ghDefaultCursor = LoadCursorW(NULL, IDC_ARROW);
+ wc.cbSize = sizeof(WNDCLASSEXW);
+ wc.lpszClassName = GUI_CONSOLE_WINDOW_CLASS;
+ wc.lpfnWndProc = GuiConsoleWndProc;
+ wc.style = 0;
+ wc.hInstance = ConSrvDllInstance;
+ wc.hIcon = ghDefaultIcon;
+ wc.hIconSm = ghDefaultIconSm;
+ wc.hCursor = ghDefaultCursor;
+ wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); // FIXME: Use defaults from
registry.
+ wc.lpszMenuName = NULL;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = GWLP_CONSOLEWND_ALLOC;
+
+ ConsoleClassAtom = RegisterClassExW(&wc);
+ if (ConsoleClassAtom == 0)
+ {
+ DPRINT1("Failed to register GUI console wndproc\n");
+ return FALSE;
+ }
+ else
+ {
+ NtUserConsoleControl(GuiConsoleWndClassAtom, &ConsoleClassAtom,
sizeof(ATOM));
+ }
+
+ ConsInitialized = TRUE;
+ }
+
+ /*
+ * Set-up the notification window
+ */
if (NULL == NotifyWnd)
{
- PrivateCsrssManualGuiCheck(+1);
- }
-
- /* Initialize the notification window class */
- wc.cbSize = sizeof(WNDCLASSEXW);
- wc.lpszClassName = L"ConSrvCreateNotify";
- wc.lpfnWndProc = GuiConsoleNotifyWndProc;
- wc.style = 0;
- wc.hInstance = ConSrvDllInstance;
- wc.hIcon = NULL;
- wc.hIconSm = NULL;
- wc.hCursor = NULL;
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- if (RegisterClassExW(&wc) == 0)
- {
- DPRINT1("Failed to register GUI notify wndproc\n");
- return FALSE;
- }
-
- /* Initialize the console window class */
- ghDefaultIcon = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE),
IMAGE_ICON,
- GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON),
- LR_SHARED);
- ghDefaultIconSm = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(IDI_CONSOLE),
IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
- LR_SHARED);
- ghDefaultCursor = LoadCursorW(NULL, IDC_ARROW);
- wc.cbSize = sizeof(WNDCLASSEXW);
- wc.lpszClassName = GUI_CONSOLE_WINDOW_CLASS;
- wc.lpfnWndProc = GuiConsoleWndProc;
- wc.style = 0;
- wc.hInstance = ConSrvDllInstance;
- wc.hIcon = ghDefaultIcon;
- wc.hIconSm = ghDefaultIconSm;
- wc.hCursor = ghDefaultCursor;
- wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); // FIXME: Use defaults from
registry.
- wc.lpszMenuName = NULL;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = GWLP_CONSOLEWND_ALLOC;
-
- ConsoleClassAtom = RegisterClassExW(&wc);
- if (ConsoleClassAtom == 0)
- {
- DPRINT1("Failed to register GUI console wndproc\n");
- return FALSE;
- }
- else
- {
- NtUserConsoleControl(GuiConsoleWndClassAtom, &ConsoleClassAtom,
sizeof(ATOM));
- }
-
- return TRUE;
-}
-
-static VOID WINAPI
-GuiChangeTitle(PCONSOLE Console)
-{
- PostMessageW(Console->hWindow, PM_CONSOLE_SET_TITLE, 0, 0);
-}
-
-static BOOL WINAPI
-GuiChangeIcon(PCONSOLE Console, HICON hWindowIcon)
-{
- HICON hIcon, hIconSm;
-
- if (hWindowIcon == NULL)
- {
- hIcon = ghDefaultIcon;
- hIconSm = ghDefaultIconSm;
- }
- else
- {
- hIcon = CopyIcon(hWindowIcon);
- hIconSm = CopyIcon(hWindowIcon);
- }
-
- if (hIcon == NULL)
- {
- return FALSE;
- }
-
- if (hIcon != Console->hIcon)
- {
- if (Console->hIcon != NULL && Console->hIcon != ghDefaultIcon)
- {
- DestroyIcon(Console->hIcon);
- }
- if (Console->hIconSm != NULL && Console->hIconSm !=
ghDefaultIconSm)
- {
- DestroyIcon(Console->hIconSm);
- }
-
- Console->hIcon = hIcon;
- Console->hIconSm = hIconSm;
-
- DPRINT1("Set icons in GuiChangeIcon\n");
- PostMessageW(Console->hWindow, WM_SETICON, ICON_BIG,
(LPARAM)Console->hIcon);
- PostMessageW(Console->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)Console->hIconSm);
- }
-
- return TRUE;
-}
-
-static VOID WINAPI
-GuiCleanupConsole(PCONSOLE Console)
-{
- SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM)Console);
-
- DPRINT1("Destroying icons !! - Console->hIcon = 0x%p ; ghDefaultIcon = 0x%p ;
Console->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
- Console->hIcon, ghDefaultIcon, Console->hIconSm, ghDefaultIconSm);
- if (Console->hIcon != NULL && Console->hIcon != ghDefaultIcon)
- {
- DPRINT1("Destroy hIcon\n");
- DestroyIcon(Console->hIcon);
- }
- if (Console->hIconSm != NULL && Console->hIconSm != ghDefaultIconSm)
- {
- DPRINT1("Destroy hIconSm\n");
- DestroyIcon(Console->hIconSm);
- }
-}
-
-static CONSOLE_VTBL GuiVtbl =
-{
- GuiWriteStream,
- GuiDrawRegion,
- GuiSetCursorInfo,
- GuiSetScreenInfo,
- GuiUpdateScreenInfo,
- GuiChangeTitle,
- GuiCleanupConsole,
- GuiChangeIcon,
- GuiResizeBuffer,
- GuiProcessKeyCallback
-};
-
-NTSTATUS FASTCALL
-GuiInitConsole(PCONSOLE Console,
- LPCWSTR AppPath,
- PCONSOLE_INFO ConsoleInfo,
- LPCWSTR IconPath,
- INT IconIndex)
-{
- HANDLE GraphicsStartupEvent;
- HANDLE ThreadHandle;
- PGUI_CONSOLE_DATA GuiData;
-
- /* Initialize the GUI */
- if (!ConsInitialized)
- {
- ConsInitialized = TRUE;
- if (!GuiInit())
- {
- ConsInitialized = FALSE;
- return STATUS_UNSUCCESSFUL;
- }
- }
-
- /* Finish to initialize the console */
- Console->Vtbl = &GuiVtbl;
- Console->hWindow = NULL;
-
- if (NULL == NotifyWnd)
- {
+ HANDLE ThreadHandle;
+ HANDLE GraphicsStartupEvent;
+
GraphicsStartupEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- if (NULL == GraphicsStartupEvent)
- {
- return STATUS_UNSUCCESSFUL;
- }
+ if (NULL == GraphicsStartupEvent) return FALSE;
ThreadHandle = CreateThread(NULL,
0,
@@ -2073,7 +1797,7 @@
{
CloseHandle(GraphicsStartupEvent);
DPRINT1("CONSRV: Failed to create graphics console thread. Expect
problems\n");
- return STATUS_UNSUCCESSFUL;
+ return FALSE;
}
SetThreadPriority(ThreadHandle, THREAD_PRIORITY_HIGHEST);
CloseHandle(ThreadHandle);
@@ -2084,9 +1808,334 @@
if (NULL == NotifyWnd)
{
DPRINT1("CONSRV: Failed to create notification window.\n");
- return STATUS_UNSUCCESSFUL;
- }
- }
+ return FALSE;
+ }
+ }
+
+ // ConsInitialized = TRUE;
+
+ return TRUE;
+}
+
+
+
+/******************************************************************************
+ * GUI Console Driver *
+ ******************************************************************************/
+
+static VOID WINAPI
+GuiCleanupConsole(PCONSOLE Console)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+
+ SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM)GuiData);
+
+ DPRINT1("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ;
GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
+ GuiData->hIcon, ghDefaultIcon, GuiData->hIconSm, ghDefaultIconSm);
+ if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
+ {
+ DPRINT1("Destroy hIcon\n");
+ DestroyIcon(GuiData->hIcon);
+ }
+ if (GuiData->hIconSm != NULL && GuiData->hIconSm != ghDefaultIconSm)
+ {
+ DPRINT1("Destroy hIconSm\n");
+ DestroyIcon(GuiData->hIconSm);
+ }
+}
+
+static VOID WINAPI
+GuiWriteStream(PCONSOLE Console, SMALL_RECT* Region, LONG CursorStartX, LONG
CursorStartY,
+ UINT ScrolledLines, CHAR *Buffer, UINT Length)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ PCONSOLE_SCREEN_BUFFER Buff = Console->ActiveBuffer;
+ LONG CursorEndX, CursorEndY;
+ RECT ScrollRect;
+
+ if (NULL == GuiData || NULL == GuiData->hWindow)
+ {
+ return;
+ }
+
+ if (0 != ScrolledLines)
+ {
+ ScrollRect.left = 0;
+ ScrollRect.top = 0;
+ ScrollRect.right = Console->Size.X * GuiData->CharWidth;
+ ScrollRect.bottom = Region->Top * GuiData->CharHeight;
+
+ ScrollWindowEx(GuiData->hWindow,
+ 0,
+ -(ScrolledLines * GuiData->CharHeight),
+ &ScrollRect,
+ NULL,
+ NULL,
+ NULL,
+ SW_INVALIDATE);
+ }
+
+ GuiDrawRegion(Console, Region);
+
+ if (CursorStartX < Region->Left || Region->Right < CursorStartX
+ || CursorStartY < Region->Top || Region->Bottom < CursorStartY)
+ {
+ GuiInvalidateCell(Console, CursorStartX, CursorStartY);
+ }
+
+ CursorEndX = Buff->CursorPosition.X;
+ CursorEndY = Buff->CursorPosition.Y;
+ if ((CursorEndX < Region->Left || Region->Right < CursorEndX
+ || CursorEndY < Region->Top || Region->Bottom < CursorEndY)
+ && (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
+ {
+ GuiInvalidateCell(Console, CursorEndX, CursorEndY);
+ }
+
+ // Set up the update timer (very short interval) - this is a "hack" for
getting the OS to
+ // repaint the window without having it just freeze up and stay on the screen
permanently.
+ Buff->CursorBlinkOn = TRUE;
+ SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
+}
+
+static VOID WINAPI
+GuiDrawRegion(PCONSOLE Console, SMALL_RECT* Region)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ RECT RegionRect;
+
+ SmallRectToRect(GuiData, &RegionRect, Region);
+ InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
+}
+
+static BOOL WINAPI
+GuiSetCursorInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff)
+{
+ if (Console->ActiveBuffer == Buff)
+ {
+ GuiInvalidateCell(Console, Buff->CursorPosition.X,
Buff->CursorPosition.Y);
+ }
+
+ return TRUE;
+}
+
+static BOOL WINAPI
+GuiSetScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff, UINT OldCursorX, UINT
OldCursorY)
+{
+ if (Console->ActiveBuffer == Buff)
+ {
+ /* Redraw char at old position (removes cursor) */
+ GuiInvalidateCell(Console, OldCursorX, OldCursorY);
+ /* Redraw char at new position (shows cursor) */
+ GuiInvalidateCell(Console, Buff->CursorPosition.X,
Buff->CursorPosition.Y);
+ }
+
+ return TRUE;
+}
+
+static BOOL WINAPI
+GuiUpdateScreenInfo(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff)
+{
+ return TRUE;
+}
+
+static NTSTATUS WINAPI
+GuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size)
+{
+ BYTE * Buffer;
+ DWORD Offset = 0;
+ BYTE * OldPtr;
+ USHORT CurrentY;
+ BYTE * OldBuffer;
+#ifdef HAVE_WMEMSET
+ USHORT value = MAKEWORD(' ', ScreenBuffer->ScreenDefaultAttrib);
+#else
+ DWORD i;
+#endif
+ DWORD diff;
+
+ /* Buffer size is not allowed to be smaller than window size */
+ if (Size.X < Console->Size.X || Size.Y < Console->Size.Y)
+ return STATUS_INVALID_PARAMETER;
+
+ if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y ==
ScreenBuffer->ScreenBufferSize.Y)
+ return STATUS_SUCCESS;
+
+ Buffer = RtlAllocateHeap(ConSrvHeap, 0, Size.X * Size.Y * 2);
+ if (!Buffer)
+ return STATUS_NO_MEMORY;
+
+ DPRINT1("Resizing (%d,%d) to (%d,%d)\n",
ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X,
Size.Y);
+ OldBuffer = ScreenBuffer->Buffer;
+
+ for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y &&
CurrentY < Size.Y; CurrentY++)
+ {
+ OldPtr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
+ if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
+ {
+ /* reduce size */
+ RtlCopyMemory(&Buffer[Offset], OldPtr, Size.X * 2);
+ Offset += (Size.X * 2);
+ }
+ else
+ {
+ /* enlarge size */
+ RtlCopyMemory(&Buffer[Offset], OldPtr,
ScreenBuffer->ScreenBufferSize.X * 2);
+ Offset += (ScreenBuffer->ScreenBufferSize.X * 2);
+
+ diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
+ /* zero new part of it */
+#ifdef HAVE_WMEMSET
+ wmemset((PWCHAR)&Buffer[Offset], value, diff);
+#else
+ for (i = 0; i < diff; i++)
+ {
+ Buffer[Offset++] = ' ';
+ Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib;
+ }
+#endif
+ }
+ }
+
+ if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
+ {
+ diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
+#ifdef HAVE_WMEMSET
+ wmemset((PWCHAR)&Buffer[Offset], value, diff);
+#else
+ for (i = 0; i < diff; i++)
+ {
+ Buffer[Offset++] = ' ';
+ Buffer[Offset++] = ScreenBuffer->ScreenDefaultAttrib;
+ }
+#endif
+ }
+
+ (void)InterlockedExchangePointer((PVOID volatile*)&ScreenBuffer->Buffer,
Buffer);
+ RtlFreeHeap(ConSrvHeap, 0, OldBuffer);
+ ScreenBuffer->ScreenBufferSize = Size;
+ ScreenBuffer->VirtualY = 0;
+
+ /* Ensure cursor and window are within buffer */
+ if (ScreenBuffer->CursorPosition.X >= Size.X)
+ ScreenBuffer->CursorPosition.X = Size.X - 1;
+ if (ScreenBuffer->CursorPosition.Y >= Size.Y)
+ ScreenBuffer->CursorPosition.Y = Size.Y - 1;
+ if (ScreenBuffer->ShowX > Size.X - Console->Size.X)
+ ScreenBuffer->ShowX = Size.X - Console->Size.X;
+ if (ScreenBuffer->ShowY > Size.Y - Console->Size.Y)
+ ScreenBuffer->ShowY = Size.Y - Console->Size.Y;
+
+ /* TODO: Should update scrollbar, but can't use anything that
+ * calls SendMessage or it could cause deadlock --> Use PostMessage */
+ // TODO: Tell the terminal to resize its scrollbars.
+
+ return STATUS_SUCCESS;
+}
+
+static BOOL WINAPI
+GuiProcessKeyCallback(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu, DWORD ShiftState,
UINT VirtualKeyCode, BOOL Down)
+{
+ if ((ShiftState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED) || KeyStateMenu &
0x80) &&
+ (VirtualKeyCode == VK_ESCAPE || VirtualKeyCode == VK_TAB || VirtualKeyCode ==
VK_SPACE))
+ {
+ DefWindowProcW(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static VOID WINAPI
+GuiChangeTitle(PCONSOLE Console)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ PostMessageW(GuiData->hWindow, PM_CONSOLE_SET_TITLE, 0, 0);
+}
+
+static BOOL WINAPI
+GuiChangeIcon(PCONSOLE Console, HICON hWindowIcon)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ HICON hIcon, hIconSm;
+
+ if (hWindowIcon == NULL)
+ {
+ hIcon = ghDefaultIcon;
+ hIconSm = ghDefaultIconSm;
+ }
+ else
+ {
+ hIcon = CopyIcon(hWindowIcon);
+ hIconSm = CopyIcon(hWindowIcon);
+ }
+
+ if (hIcon == NULL)
+ {
+ return FALSE;
+ }
+
+ if (hIcon != GuiData->hIcon)
+ {
+ if (GuiData->hIcon != NULL && GuiData->hIcon != ghDefaultIcon)
+ {
+ DestroyIcon(GuiData->hIcon);
+ }
+ if (GuiData->hIconSm != NULL && GuiData->hIconSm !=
ghDefaultIconSm)
+ {
+ DestroyIcon(GuiData->hIconSm);
+ }
+
+ GuiData->hIcon = hIcon;
+ GuiData->hIconSm = hIconSm;
+
+ DPRINT1("Set icons in GuiChangeIcon\n");
+ PostMessageW(GuiData->hWindow, WM_SETICON, ICON_BIG,
(LPARAM)GuiData->hIcon);
+ PostMessageW(GuiData->hWindow, WM_SETICON, ICON_SMALL,
(LPARAM)GuiData->hIconSm);
+ }
+
+ return TRUE;
+}
+
+static HWND WINAPI
+GuiGetConsoleWindowHandle(PCONSOLE Console)
+{
+ PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
+ return GuiData->hWindow;
+}
+
+static TERMINAL_VTBL GuiVtbl =
+{
+ GuiCleanupConsole,
+ GuiWriteStream,
+ GuiDrawRegion,
+ GuiSetCursorInfo,
+ GuiSetScreenInfo,
+ GuiUpdateScreenInfo,
+ GuiResizeBuffer,
+ GuiProcessKeyCallback,
+ GuiChangeTitle,
+ GuiChangeIcon,
+ GuiGetConsoleWindowHandle
+};
+
+NTSTATUS FASTCALL
+GuiInitConsole(PCONSOLE Console,
+ LPCWSTR AppPath,
+ PCONSOLE_INFO ConsoleInfo,
+ LPCWSTR IconPath,
+ INT IconIndex)
+{
+ PGUI_CONSOLE_DATA GuiData;
+
+ if (Console == NULL || ConsoleInfo == NULL)
+ return STATUS_INVALID_PARAMETER;
+
+ /* Initialize the GUI terminal emulator */
+ if (!GuiInit()) return STATUS_UNSUCCESSFUL;
+
+ /* Initialize the console */
+ Console->TermIFace.Vtbl = &GuiVtbl;
GuiData = RtlAllocateHeap(ConSrvHeap, HEAP_ZERO_MEMORY,
sizeof(GUI_CONSOLE_DATA));
@@ -2095,30 +2144,23 @@
DPRINT1("CONSRV: Failed to create GUI_CONSOLE_DATA\n");
return STATUS_UNSUCCESSFUL;
}
- Console->GuiData = (PVOID)GuiData;
-
- if (ConsoleInfo)
- {
- wcsncpy(GuiData->GuiInfo.FaceName, ConsoleInfo->u.GuiInfo.FaceName,
LF_FACESIZE);
- GuiData->GuiInfo.FontFamily = ConsoleInfo->u.GuiInfo.FontFamily;
- GuiData->GuiInfo.FontSize = ConsoleInfo->u.GuiInfo.FontSize;
- GuiData->GuiInfo.FontWeight = ConsoleInfo->u.GuiInfo.FontWeight;
- GuiData->GuiInfo.UseRasterFonts = ConsoleInfo->u.GuiInfo.UseRasterFonts;
-
- GuiData->GuiInfo.ShowWindow = ConsoleInfo->u.GuiInfo.ShowWindow;
- GuiData->GuiInfo.AutoPosition = ConsoleInfo->u.GuiInfo.AutoPosition;
- GuiData->GuiInfo.WindowOrigin = ConsoleInfo->u.GuiInfo.WindowOrigin;
- }
- /*
- else
- {
- // TODO: What could be the defaults ?
- }
- */
+ Console->TermIFace.Data = (PVOID)GuiData;
+ GuiData->Console = Console;
+ GuiData->hWindow = NULL;
+
+ /* Set up the GUI data */
+ wcsncpy(GuiData->GuiInfo.FaceName, ConsoleInfo->u.GuiInfo.FaceName,
LF_FACESIZE);
+ GuiData->GuiInfo.FontFamily = ConsoleInfo->u.GuiInfo.FontFamily;
+ GuiData->GuiInfo.FontSize = ConsoleInfo->u.GuiInfo.FontSize;
+ GuiData->GuiInfo.FontWeight = ConsoleInfo->u.GuiInfo.FontWeight;
+ GuiData->GuiInfo.UseRasterFonts = ConsoleInfo->u.GuiInfo.UseRasterFonts;
+ GuiData->GuiInfo.ShowWindow = ConsoleInfo->u.GuiInfo.ShowWindow;
+ GuiData->GuiInfo.AutoPosition = ConsoleInfo->u.GuiInfo.AutoPosition;
+ GuiData->GuiInfo.WindowOrigin = ConsoleInfo->u.GuiInfo.WindowOrigin;
/* Initialize the icon handles to their default values */
- Console->hIcon = ghDefaultIcon;
- Console->hIconSm = ghDefaultIconSm;
+ GuiData->hIcon = ghDefaultIcon;
+ GuiData->hIconSm = ghDefaultIconSm;
/* Get the associated icon, if any */
if (IconPath == NULL || *IconPath == L'\0')
@@ -2139,8 +2181,8 @@
if (hIcon != NULL)
{
DPRINT1("Effectively set the icons\n");
- Console->hIcon = hIcon;
- Console->hIconSm = hIconSm;
+ GuiData->hIcon = hIcon;
+ GuiData->hIconSm = hIconSm;
}
}
@@ -2153,11 +2195,11 @@
GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
/* Create the GUI console */
- PostMessageW(NotifyWnd, PM_CREATE_CONSOLE, GuiData->GuiInfo.ShowWindow,
(LPARAM)Console);
+ PostMessageW(NotifyWnd, PM_CREATE_CONSOLE, GuiData->GuiInfo.ShowWindow,
(LPARAM)GuiData);
/* Wait until initialization has finished */
WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE);
- DPRINT("Received event Console %p GuiData %p X %d Y %d\n", Console,
Console->GuiData, Console->Size.X, Console->Size.Y);
+ DPRINT1("Received event Console %p GuiData %p X %d Y %d\n", Console,
GuiData, Console->Size.X, Console->Size.Y);
CloseHandle(GuiData->hGuiInitEvent);
GuiData->hGuiInitEvent = NULL;
Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/guiconsole.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/guiconsole.h [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/guiconsole.h
- * PURPOSE: Interface to GUI-mode consoles
+ * PURPOSE: GUI terminal emulator
* PROGRAMMERS:
*/
Modified: branches/ros-csrss/win32ss/user/consrv/handle.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/h…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] Fri Mar 8 23:37:11 2013
@@ -373,7 +373,7 @@
(HandleEntry->Access & Access) == 0 ||
(Type != 0 && ObjectEntry->Type != Type) )
{
- DPRINT1("CsrGetObject returning invalid handle (%x) of type %lu with access
%lu\n", Handle, Type, Access);
+ DPRINT1("ConSrvGetObject returning invalid handle (%x) of type %lu with
access %lu\n", Handle, Type, Access);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
return STATUS_INVALID_HANDLE;
}
@@ -511,7 +511,6 @@
ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
{
PCONSOLE Console;
- PCONSOLE_PROCESS_DATA NewProcessData;
DPRINT1("ConSrvRemoveConsole\n");
@@ -532,11 +531,7 @@
RemoveEntryList(&ProcessData->ConsoleLink);
/* Update the console leader process */
- NewProcessData = CONTAINING_RECORD(Console->ProcessList.Blink,
- CONSOLE_PROCESS_DATA,
- ConsoleLink);
- Console->ConsoleLeaderCID = NewProcessData->Process->ClientId;
- SetConsoleWndConsoleLeaderCID(Console);
+ // SetConsoleWndConsoleLeaderCID(Console);
/* Release the console */
ConSrvReleaseConsole(Console, TRUE);
@@ -799,7 +794,7 @@
Index >= ProcessData->HandleTableSize ||
ProcessData->HandleTable[Index].Object == NULL)
{
- DPRINT("CsrVerifyObject failed\n");
+ DPRINT("SrvVerifyConsoleIoHandle failed\n");
Status = STATUS_INVALID_HANDLE;
}
Modified: branches/ros-csrss/win32ss/user/consrv/settings.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/s…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/settings.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/settings.h [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -8,6 +8,9 @@
* NOTE: Adapted from existing code.
*/
+#ifndef WM_APP
+ #define WM_APP 0x8000
+#endif
#define PM_APPLY_CONSOLE_INFO (WM_APP + 100)
/* STRUCTURES *****************************************************************/
@@ -54,6 +57,7 @@
WCHAR ConsoleTitle[MAX_PATH + 1];
+ // PVOID TerminalInfo; /* Terminal-specific parameters */
union
{
GUI_CONSOLE_INFO GuiInfo;
Modified: branches/ros-csrss/win32ss/user/consrv/tuiconsole.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/t…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/tuiconsole.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/tuiconsole.c [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -2,9 +2,11 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/tuiconsole.c
- * PURPOSE: Interface to text-mode consoles
+ * PURPOSE: TUI terminal emulator
* PROGRAMMERS:
*/
+
+#ifdef TUI_CONSOLE
#include "consrv.h"
#include "settings.h"
@@ -15,9 +17,21 @@
#include <debug.h>
+/* GLOBALS ********************************************************************/
+
/* TUI Console Window Class name */
#define TUI_CONSOLE_WINDOW_CLASS L"TuiConsoleWindowClass"
+typedef struct _TUI_CONSOLE_DATA
+{
+ CRITICAL_SECTION Lock;
+ // HANDLE hTuiInitEvent;
+
+ HWND hWindow;
+
+ PCONSOLE Console;
+ // TUI_CONSOLE_INFO TuiInfo;
+} TUI_CONSOLE_DATA, *PTUI_CONSOLE_DATA;
CRITICAL_SECTION ActiveConsoleLock;
static COORD PhysicalConsoleSize;
@@ -164,7 +178,7 @@
/* alt-tab, swap consoles */
/* move SwapConsole to next console, and print its title */
EnterCriticalSection(&ActiveConsoleLock);
- if (! SwapConsole)
+ if (!SwapConsole)
{
SwapConsole = ActiveConsole;
}
@@ -480,6 +494,12 @@
return TRUE;
}
+static HWND WINAPI
+TuiGetConsoleWindowHandle(PCONSOLE Console)
+{
+ return Console->hWindow;
+}
+
static NTSTATUS WINAPI
TuiResizeBuffer(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size)
{
@@ -507,7 +527,6 @@
return 1;
}
Console->hWindow = NewWindow;
- SetConsoleWndConsoleLeaderCID(Console);
SetForegroundWindow(Console->hWindow);
@@ -528,16 +547,17 @@
return 0;
}
-static CONSOLE_VTBL TuiVtbl =
-{
+static TERMINAL_VTBL TuiVtbl =
+{
+ TuiCleanupConsole,
TuiWriteStream,
TuiDrawRegion,
TuiSetCursorInfo,
TuiSetScreenInfo,
TuiUpdateScreenInfo,
TuiChangeTitle,
- TuiCleanupConsole,
TuiChangeIcon,
+ TuiGetConsoleWindowHandle,
TuiResizeBuffer,
TuiProcessKeyCallback
};
@@ -558,7 +578,7 @@
}
}
- Console->Vtbl = &TuiVtbl;
+ Console->TermIFace.Vtbl = &TuiVtbl;
Console->hWindow = NULL;
Console->Size = PhysicalConsoleSize;
Console->ActiveBuffer->ScreenBufferSize = PhysicalConsoleSize;
@@ -601,4 +621,6 @@
return ActiveConsole;
}
+#endif
+
/* EOF */
Modified: branches/ros-csrss/win32ss/user/consrv/tuiconsole.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/t…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/tuiconsole.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/tuiconsole.h [iso-8859-1] Fri Mar 8 23:37:11
2013
@@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/tuiconsole.h
- * PURPOSE: Interface to text-mode consoles
+ * PURPOSE: TUI terminal emulator
* PROGRAMMERS:
*/