CORE-8439 #resolve #comment r63885 merged to trunk in r63886.
svn path=/trunk/; revision=63886
GuiInfo->FontFamily = FF_DONTCARE;
GuiInfo->FontSize.X = 0;
GuiInfo->FontSize.Y = 0;
- GuiInfo->FontWeight = FW_DONTCARE;
+ GuiInfo->FontWeight = FW_NORMAL; // HACK: !!
+ // GuiInfo->FontWeight = FW_DONTCARE;
GuiInfo->FullScreen = FALSE;
GuiInfo->ShowWindow = SW_SHOWNORMAL;
if (!hBrush) return FALSE;
Font = CreateFontW(GuiInfo->FontSize.Y,
- 0, // GuiInfo->FontSize.X,
+ GuiInfo->FontSize.X,
0,
TA_BASELINE,
GuiInfo->FontWeight,
OEM_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
- NONANTIALIASED_QUALITY,
- FIXED_PITCH | GuiInfo->FontFamily /* FF_DONTCARE */,
+ DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY
+ FIXED_PITCH | GuiInfo->FontFamily,
GuiInfo->FaceName);
if (Font == NULL)
{
/*
- * @unimplemented (Undocumented)
+ * @implemented (Undocumented)
*/
HANDLE
WINAPI
/* PRIVATE FUNCTIONS **********************************************************/
static PALIAS_HEADER
-IntFindAliasHeader(PCONSOLE Console,
+IntFindAliasHeader(PCONSRV_CONSOLE Console,
PVOID ExeName,
USHORT ExeLength,
BOOLEAN UnicodeExe)
}
static PALIAS_HEADER
-IntCreateAliasHeader(PCONSOLE Console,
+IntCreateAliasHeader(PCONSRV_CONSOLE Console,
PVOID ExeName,
USHORT ExeLength,
BOOLEAN UnicodeExe)
}
static PALIAS_ENTRY
-IntGetAliasEntry(PCONSOLE Console,
+IntGetAliasEntry(PCONSRV_CONSOLE Console,
PALIAS_HEADER Header,
PVOID Source,
USHORT SourceLength,
}
static PALIAS_ENTRY
-IntCreateAliasEntry(PCONSOLE Console,
+IntCreateAliasEntry(PCONSRV_CONSOLE Console,
PVOID Source,
USHORT SourceLength,
PVOID Target,
}
VOID
-IntDeleteAllAliases(PCONSOLE Console)
+IntDeleteAllAliases(PCONSRV_CONSOLE Console)
{
PALIAS_HEADER Header, NextHeader;
PALIAS_ENTRY Entry, NextEntry;
{
NTSTATUS Status;
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
PVOID lpTarget;
{
NTSTATUS Status;
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
UINT Length;
{
NTSTATUS Status;
PCONSOLE_GETALLALIASES GetAllAliasesRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
ULONG BytesWritten = 0;
PALIAS_HEADER Header;
{
NTSTATUS Status;
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesLengthRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PALIAS_HEADER Header;
DPRINT1("SrvGetConsoleAliasesLength entered ApiMessage %p\n", ApiMessage);
{
NTSTATUS Status;
PCONSOLE_GETALIASESEXES GetAliasesExesRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
UINT BytesWritten = 0;
DPRINT1("SrvGetConsoleAliasExes entered\n");
{
NTSTATUS Status;
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
DPRINT1("SrvGetConsoleAliasExesLength entered ApiMessage %p\n", ApiMessage);
#pragma once
-VOID IntDeleteAllAliases(PCONSOLE Console);
+VOID IntDeleteAllAliases(PCONSRV_CONSOLE Console);
/* Initialize the terminal interface */
ResetTerminal(Console);
- memcpy(Console->Colors, ConsoleInfo->Colors, sizeof(ConsoleInfo->Colors));
Console->ConsoleSize = ConsoleInfo->ConsoleSize;
Console->FixedSize = FALSE; // Value by default; is reseted by the terminals if needed.
* This pre-processing code MUST be IN consrv ONLY
*/
/* static */ ULONG
-PreprocessInput(PCONSOLE Console,
+PreprocessInput(PCONSRV_CONSOLE Console,
PINPUT_RECORD InputEvent,
ULONG NumEventsToWrite)
{
* This post-processing code MUST be IN consrv ONLY
*/
/* static */ VOID
-PostprocessInput(PCONSOLE Console)
+PostprocessInput(PCONSRV_CONSOLE Console)
{
CsrNotifyWait(&Console->ReadWaitQueue,
FALSE,
NTSTATUS Status = STATUS_INVALID_PARAMETER;
PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CreateScreenBufferRequest;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
PVOID ScreenBufferInfo = NULL;
/* GLOBALS ********************************************************************/
static ULONG ConsoleListSize;
-static PCONSOLE* ConsoleList; /* The list of the ConSrv consoles */
+static PCONSRV_CONSOLE* ConsoleList; /* The list of the ConSrv consoles */
static RTL_RESOURCE ListLock;
#define ConSrvLockConsoleListExclusive() \
static NTSTATUS
InsertConsole(OUT PHANDLE Handle,
- IN PCONSOLE Console)
+ IN PCONSRV_CONSOLE Console)
{
#define CONSOLE_HANDLES_INCREMENT 2 * 3
NTSTATUS Status = STATUS_SUCCESS;
ULONG i = 0;
- PCONSOLE* Block;
+ PCONSRV_CONSOLE* Block;
ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
(ConsoleList != NULL && ConsoleListSize != 0) );
/* Allocate a new handles table */
Block = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
(ConsoleListSize +
- CONSOLE_HANDLES_INCREMENT) * sizeof(PCONSOLE));
+ CONSOLE_HANDLES_INCREMENT) * sizeof(PCONSRV_CONSOLE));
if (Block == NULL)
{
Status = STATUS_UNSUCCESSFUL;
/* Copy the handles from the old table to the new one */
RtlCopyMemory(Block,
ConsoleList,
- ConsoleListSize * sizeof(PCONSOLE));
+ ConsoleListSize * sizeof(PCONSRV_CONSOLE));
ConsoleFreeHeap(ConsoleList);
}
ConsoleList = Block;
RemoveConsoleByHandle(IN HANDLE Handle)
{
NTSTATUS Status = STATUS_SUCCESS;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
BOOLEAN ValidHandle = ((HandleToULong(Handle) & 0x3) == 0x3);
ULONG Index = HandleToULong(Handle) >> 2;
#endif
static NTSTATUS
-RemoveConsoleByPointer(IN PCONSOLE Console)
+RemoveConsoleByPointer(IN PCONSRV_CONSOLE Console)
{
ULONG i = 0;
}
BOOLEAN NTAPI
-ConSrvValidateConsole(OUT PCONSOLE* Console,
+ConSrvValidateConsole(OUT PCONSRV_CONSOLE* Console,
IN HANDLE ConsoleHandle,
IN CONSOLE_STATE ExpectedState,
IN BOOLEAN LockConsole)
{
BOOLEAN RetVal = FALSE;
- PCONSOLE ValidatedConsole;
+ PCONSRV_CONSOLE ValidatedConsole;
BOOLEAN ValidHandle = ((HandleToULong(ConsoleHandle) & 0x3) == 0x3);
ULONG Index = HandleToULong(ConsoleHandle) >> 2;
/* PRIVATE FUNCTIONS **********************************************************/
VOID
-ConioPause(PCONSOLE Console, UINT Flags)
+ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
{
Console->PauseFlags |= Flags;
ConDrvPause(Console);
}
VOID
-ConioUnpause(PCONSOLE Console, UINT Flags)
+ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
{
Console->PauseFlags &= ~Flags;
NTSTATUS
ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData,
- OUT PCONSOLE* Console,
+ OUT PCONSRV_CONSOLE* Console,
IN BOOLEAN LockConsole)
{
NTSTATUS Status = STATUS_INVALID_HANDLE;
- PCONSOLE GrabConsole;
+ PCONSRV_CONSOLE GrabConsole;
// if (Console == NULL) return STATUS_INVALID_PARAMETER;
ASSERT(Console);
}
VOID
-ConSrvReleaseConsole(IN PCONSOLE Console,
+ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console,
IN BOOLEAN WasConsoleLocked)
{
LONG RefCount = 0;
NTSTATUS NTAPI
ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
- OUT PCONSOLE* NewConsole,
+ OUT PCONSRV_CONSOLE* NewConsole,
IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
IN ULONG ConsoleLeaderProcessId)
{
NTSTATUS Status;
HANDLE ConsoleHandle;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
CONSOLE_INFO ConsoleInfo;
SIZE_T Length = 0;
Console->QuickEdit = ConsoleInfo.QuickEdit;
+ /* Colour table */
+ memcpy(Console->Colors, ConsoleInfo.Colors, sizeof(ConsoleInfo.Colors));
+
/* Attach the ConSrv terminal to the console */
Status = ConDrvRegisterTerminal(Console, &Terminal);
if (!NT_SUCCESS(Status))
}
VOID NTAPI
-ConSrvDeleteConsole(PCONSOLE Console)
+ConSrvDeleteConsole(PCONSRV_CONSOLE Console)
{
DPRINT("ConSrvDeleteConsole\n");
}
PCONSOLE_PROCESS_DATA NTAPI
-ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console)
+ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
{
if (Console == NULL) return NULL;
}
NTSTATUS NTAPI
-ConSrvGetConsoleProcessList(IN PCONSOLE Console,
+ConSrvGetConsoleProcessList(IN PCONSRV_CONSOLE Console,
IN OUT PULONG ProcessIdsList,
IN ULONG MaxIdListItems,
OUT PULONG ProcessIdsTotal)
// ConSrvGenerateConsoleCtrlEvent
NTSTATUS NTAPI
-ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
+ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console,
IN ULONG ProcessGroupId,
IN ULONG CtrlEvent)
{
{
NTSTATUS Status;
PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&TitleRequest->Title,
{
NTSTATUS Status;
PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&TitleRequest->Title,
{
NTSTATUS Status;
PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleCPRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
GetConsoleCPRequest->OutputCP ? "Output" : "Input");
{
NTSTATUS Status = STATUS_INVALID_PARAMETER;
PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetConsoleCPRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
SetConsoleCPRequest->OutputCP ? "Output" : "Input");
{
NTSTATUS Status;
PCONSOLE_GETPROCESSLIST GetProcessListRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetProcessListRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetProcessListRequest->ProcessIdsList,
{
NTSTATUS Status;
PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GenerateCtrlEventRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
{
NTSTATUS Status;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
{
NTSTATUS Status;
PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetMouseInfoRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
{
NTSTATUS Status;
PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetKbdLayoutNameRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
} CONSOLE_PROCESS_DATA, *PCONSOLE_PROCESS_DATA;
#include "include/conio.h"
+// #include "include/conio_winsrv.h"
#include "include/console.h"
#include "include/settings.h"
#include "include/term.h"
*/
#if 0
static NTSTATUS
-SetConsoleHardwareState(PCONSOLE Console, ULONG ConsoleHwState)
+SetConsoleHardwareState(PCONSRV_CONSOLE Console, ULONG ConsoleHwState)
{
DPRINT1("Console Hardware State: %d\n", ConsoleHwState);
NTSTATUS Status;
PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
PCONSOLE_SCREEN_BUFFER Buff;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
HardwareStateRequest->OutputHandle,
NTSTATUS Status;
PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
PCONSOLE_SCREEN_BUFFER Buff;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
HardwareStateRequest->OutputHandle,
{
NTSTATUS Status;
PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetDisplayModeRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
{
NTSTATUS Status;
PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetDisplayModeRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
NTSTATUS Status;
PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetLargestWindowSizeRequest;
PCONSOLE_SCREEN_BUFFER Buff;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
GetLargestWindowSizeRequest->OutputHandle,
{
NTSTATUS Status;
PCONSOLE_SHOWCURSOR ShowCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ShowCursorRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
NTSTATUS Status;
BOOL Success;
PCONSOLE_SETCURSOR SetCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
// FIXME: Tests show that this function is used only for graphics screen buffers
{
NTSTATUS Status;
PCONSOLE_MENUCONTROL MenuControlRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.MenuControlRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PCONSOLE_SCREEN_BUFFER Buff;
Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
NTSTATUS Status;
BOOL Success;
PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetMenuCloseRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
{
NTSTATUS Status;
PCONSOLE_GETWINDOW GetWindowRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetWindowRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
{
NTSTATUS Status;
PCONSOLE_SETICON SetIconRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetIconRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
{
NTSTATUS Status;
PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetSelectionInfoRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
}
static VOID
-SendMenuEvent(PCONSOLE Console, UINT CmdId)
+SendMenuEvent(PCONSRV_CONSOLE Console, UINT CmdId)
{
INPUT_RECORD er;
OnCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
LRESULT Ret = TRUE;
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
/*
* In case the selected menu item belongs to the user-reserved menu id range,
// to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
}
-static BOOL
-OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
-{
- PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
- PCONSOLE Console;
- HDC hDC;
- HFONT OldFont;
- TEXTMETRICW Metrics;
- SIZE CharSize;
- if (NULL == GuiData)
+VOID
+DeleteFonts(PGUI_CONSOLE_DATA GuiData)
+{
+ ULONG i;
+ for (i = 0; i < sizeof(GuiData->Font) / sizeof(GuiData->Font[0]); ++i)
{
- DPRINT1("GuiConsoleNcCreate: No GUI data\n");
- return FALSE;
+ if (GuiData->Font[i] != NULL) DeleteObject(GuiData->Font[i]);
+ GuiData->Font[i] = NULL;
}
+}
- Console = GuiData->Console;
+static HFONT
+CreateDerivedFont(HFONT OrgFont,
+ // COORD FontSize,
+ ULONG FontWeight,
+ // BOOLEAN bItalic,
+ BOOLEAN bUnderline,
+ BOOLEAN bStrikeOut)
+{
+ LOGFONT lf;
- GuiData->hWindow = hWnd;
+ /* Initialize the LOGFONT structure */
+ RtlZeroMemory(&lf, sizeof(lf));
+
+ /* Retrieve the details of the current font */
+ if (GetObject(OrgFont, sizeof(lf), &lf) == 0)
+ return NULL;
+
+ /* Change the font attributes */
+ // lf.lfHeight = FontSize.Y;
+ // lf.lfWidth = FontSize.X;
+ lf.lfWeight = FontWeight;
+ // lf.lfItalic = bItalic;
+ lf.lfUnderline = bUnderline;
+ lf.lfStrikeOut = bStrikeOut;
+
+ /* Build a new font */
+ return CreateFontIndirect(&lf);
+}
+
+BOOL
+InitFonts(PGUI_CONSOLE_DATA GuiData,
+ LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
+ ULONG FontFamily,
+ COORD FontSize,
+ ULONG FontWeight)
+{
+ HDC hDC;
+ HFONT OldFont, NewFont;
+ TEXTMETRICW Metrics;
+ SIZE CharSize;
+
+ /*
+ * Initialize a new NORMAL font and get its metrics.
+ */
- GuiData->Font = CreateFontW(GuiData->GuiInfo.FontSize.Y,
- 0, // GuiData->GuiInfo.FontSize.X,
- 0,
- TA_BASELINE,
- GuiData->GuiInfo.FontWeight,
- FALSE,
- FALSE,
- FALSE,
- OEM_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- NONANTIALIASED_QUALITY,
- FIXED_PITCH | GuiData->GuiInfo.FontFamily /* FF_DONTCARE */,
- GuiData->GuiInfo.FaceName);
-
- if (NULL == GuiData->Font)
+ NewFont = CreateFontW(FontSize.Y,
+ FontSize.X,
+ 0,
+ TA_BASELINE,
+ FontWeight,
+ FALSE,
+ FALSE,
+ FALSE,
+ OEM_CHARSET,
+ OUT_DEFAULT_PRECIS,
+ CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY
+ FIXED_PITCH | FontFamily,
+ FaceName);
+ if (NewFont == NULL)
{
- DPRINT1("GuiConsoleNcCreate: CreateFont failed\n");
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
+ DPRINT1("InitFonts: CreateFontW failed\n");
return FALSE;
}
+
hDC = GetDC(GuiData->hWindow);
- if (NULL == hDC)
+ if (hDC == NULL)
{
- DPRINT1("GuiConsoleNcCreate: GetDC failed\n");
- DeleteObject(GuiData->Font);
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
+ DPRINT1("InitFonts: GetDC failed\n");
+ DeleteObject(NewFont);
return FALSE;
}
- OldFont = SelectObject(hDC, GuiData->Font);
- if (NULL == OldFont)
+
+ OldFont = SelectObject(hDC, NewFont);
+ if (OldFont == NULL)
{
- DPRINT1("GuiConsoleNcCreate: SelectObject failed\n");
+ DPRINT1("InitFonts: SelectObject failed\n");
ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(GuiData->Font);
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
+ DeleteObject(NewFont);
return FALSE;
}
+
if (!GetTextMetricsW(hDC, &Metrics))
{
- DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n");
+ DPRINT1("InitFonts: GetTextMetrics failed\n");
SelectObject(hDC, OldFont);
ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(GuiData->Font);
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
+ DeleteObject(NewFont);
return FALSE;
}
GuiData->CharWidth = Metrics.tmMaxCharWidth;
GuiData->CharWidth = CharSize.cx;
SelectObject(hDC, OldFont);
-
ReleaseDC(GuiData->hWindow, hDC);
+ /*
+ * Initialization succeeded.
+ */
+ // Delete all the old fonts first.
+ DeleteFonts(GuiData);
+ GuiData->Font[FONT_NORMAL] = NewFont;
+
+ /*
+ * Now build the other fonts (bold, underlined, mixed).
+ */
+ GuiData->Font[FONT_BOLD] =
+ CreateDerivedFont(GuiData->Font[FONT_NORMAL],
+ FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
+ FALSE,
+ FALSE);
+ GuiData->Font[FONT_UNDERLINE] =
+ CreateDerivedFont(GuiData->Font[FONT_NORMAL],
+ FontWeight,
+ TRUE,
+ FALSE);
+ GuiData->Font[FONT_BOLD | FONT_UNDERLINE] =
+ CreateDerivedFont(GuiData->Font[FONT_NORMAL],
+ FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
+ TRUE,
+ FALSE);
+
+ /*
+ * Save the settings.
+ */
+ if (FaceName != GuiData->GuiInfo.FaceName)
+ {
+ SIZE_T Length = min(wcslen(FaceName) + 1, LF_FACESIZE); // wcsnlen
+ wcsncpy(GuiData->GuiInfo.FaceName, FaceName, LF_FACESIZE);
+ GuiData->GuiInfo.FaceName[Length] = L'\0'; // NULL-terminate
+ }
+ GuiData->GuiInfo.FontFamily = FontFamily;
+ GuiData->GuiInfo.FontSize = FontSize;
+ GuiData->GuiInfo.FontWeight = FontWeight;
+
+ return TRUE;
+}
+
+
+static BOOL
+OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
+{
+ PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
+ PCONSRV_CONSOLE Console;
+
+ if (NULL == GuiData)
+ {
+ DPRINT1("GuiConsoleNcCreate: No GUI data\n");
+ return FALSE;
+ }
+
+ Console = GuiData->Console;
+
+ GuiData->hWindow = hWnd;
+
+ /* Initialize the fonts */
+ if (!InitFonts(GuiData,
+ GuiData->GuiInfo.FaceName,
+ GuiData->GuiInfo.FontFamily,
+ GuiData->GuiInfo.FontSize,
+ GuiData->GuiInfo.FontWeight))
+ {
+ DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
+ GuiData->hWindow = NULL;
+ SetEvent(GuiData->hGuiInitEvent);
+ return FALSE;
+ }
+
/* Initialize the terminal framebuffer */
GuiData->hMemDC = CreateCompatibleDC(NULL);
GuiData->hBitmap = NULL;
static VOID
OnFocus(PGUI_CONSOLE_DATA GuiData, BOOL SetFocus)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
INPUT_RECORD er;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
PCOORD SelectionAnchor OPTIONAL,
PCOORD coord)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
HRGN oldRgn = CreateSelectionRgn(GuiData, GuiData->LineSelection,
&GuiData->Selection.dwSelectionAnchor,
&GuiData->Selection.srSelection);
static VOID
OnKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
static VOID
OnTimer(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CURSOR_BLINK_TIME, NULL);
static BOOL
OnClose(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
return TRUE;
if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
// if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
- if (GuiData->Font) DeleteObject(GuiData->Font);
+ DeleteFonts(GuiData);
}
/* Free the GuiData registration */
OnMouse(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL Err = FALSE;
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
// FIXME: It's here that we need to check whether we has focus or not
// and whether we are in edit mode or not, to know if we need to deal
static VOID
OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer;
DWORD windx, windy;
UINT WidthUnit, HeightUnit;
static VOID
OnSize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
static LRESULT
OnScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER Buff;
SCROLLINFO sInfo;
int fnBar;
{
LRESULT Result = 0;
PGUI_CONSOLE_DATA GuiData = NULL;
- PCONSOLE Console = NULL;
+ PCONSRV_CONSOLE Console = NULL;
/*
* - If it's the first time we create a window for the terminal,
#define PM_CONSOLE_BEEP (WM_APP + 4)
#define PM_CONSOLE_SET_TITLE (WM_APP + 5)
+/*
+typedef struct _CONSOLE_FONT
+{
+ HFONT Font;
+ ULONG Flag;
+} CONSOLE_FONT, *PCONSOLE_FONT;
+*/
+#define FONT_NORMAL 0x00
+#define FONT_BOLD 0x01
+#define FONT_UNDERLINE 0x02
+#define FONT_MAXNO 0x04
typedef struct _GUI_CONSOLE_DATA
{
// PVOID ScreenBuffer; /* Hardware screen buffer */
- HFONT Font;
- UINT CharWidth;
- UINT CharHeight;
+ HFONT Font[FONT_MAXNO];
+ UINT CharWidth; /* The character width and height should be the same for */
+ UINT CharHeight; /* both normal and bold/underlined fonts... */
/*****************************************************/
- PCONSOLE Console; /* Pointer to the owned console */
+ PCONSRV_CONSOLE Console; /* Pointer to the owned console */
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to the active screen buffer (then maybe the previous Console member is redundant?? Or not...) */
CONSOLE_SELECTION_INFO Selection; /* Contains information about the selection */
COORD dwSelectionCursor; /* Selection cursor position, most of the time different from Selection.dwSelectionAnchor */
VOID
SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
/*
* See:
VOID
GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
{
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
BOOL FullScreen;
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
* This function supposes that the system clipboard was opened.
*/
- // PCONSOLE Console = Buffer->Header.Console;
+ // PCONSRV_CONSOLE Console = Buffer->Header.Console;
UNIMPLEMENTED;
}
PRECT rcView,
PRECT rcFramebuffer)
{
- PCONSOLE Console = Buffer->Header.Console;
+ PCONSRV_CONSOLE Console = Buffer->Header.Console;
// ASSERT(Console == GuiData->Console);
if (Buffer->BitMap == NULL) return;
#include "guiterm.h"
#include "guisettings.h"
-VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
-VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
-
/* FUNCTIONS ******************************************************************/
BOOL
// wcsncpy(TermInfo->FaceName, L"DejaVu Sans Mono", LF_FACESIZE);
// TermInfo->FontSize = MAKELONG(8, 12); // 0x000C0008; // font is 8x12
// TermInfo->FontSize = MAKELONG(16, 16); // font is 16x16
- // TermInfo->FontWeight = FW_NORMAL;
wcsncpy(TermInfo->FaceName, L"VGA", LF_FACESIZE); // HACK: !!
// TermInfo->FaceName[0] = L'\0';
TermInfo->FontFamily = FF_DONTCARE;
TermInfo->FontSize.X = 0;
TermInfo->FontSize.Y = 0;
- TermInfo->FontWeight = FW_DONTCARE;
+ TermInfo->FontWeight = FW_NORMAL; // HACK: !!
+ // TermInfo->FontWeight = FW_DONTCARE;
TermInfo->FullScreen = FALSE;
TermInfo->ShowWindow = SW_SHOWNORMAL;
BOOL Defaults)
{
NTSTATUS Status;
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
PCONSOLE_PROCESS_DATA ProcessData;
HANDLE hSection = NULL, hClientSection = NULL;
return;
}
-
-
-
-BOOL
-ChangeFont(PGUI_CONSOLE_DATA GuiData,
- LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
- ULONG FontFamily,
- COORD FontSize,
- ULONG FontWeight)
-{
- HDC hDC;
- HFONT OldFont, NewFont;
- TEXTMETRICW Metrics;
- SIZE CharSize;
- SIZE_T Length;
-
- NewFont = CreateFontW(FontSize.Y,
- 0, // FontSize.X,
- 0,
- TA_BASELINE,
- FontWeight,
- FALSE,
- FALSE,
- FALSE,
- OEM_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- NONANTIALIASED_QUALITY,
- FIXED_PITCH | FontFamily /* FF_DONTCARE */,
- FaceName);
- if (NewFont == NULL)
- {
- DPRINT1("ChangeFont: CreateFont failed\n");
- return FALSE;
- }
-
- hDC = GetDC(GuiData->hWindow);
- if (hDC == NULL)
- {
- DPRINT1("ChangeFont: GetDC failed\n");
- DeleteObject(NewFont);
- return FALSE;
- }
-
- OldFont = SelectObject(hDC, NewFont);
- if (OldFont == NULL)
- {
- DPRINT1("ChangeFont: SelectObject failed\n");
- ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(NewFont);
- return FALSE;
- }
-
- if (!GetTextMetricsW(hDC, &Metrics))
- {
- DPRINT1("ChangeFont: GetTextMetrics failed\n");
- SelectObject(hDC, OldFont);
- ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(NewFont);
- return FALSE;
- }
- GuiData->CharWidth = Metrics.tmMaxCharWidth;
- GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
-
- /* Measure real char width more precisely if possible. */
- if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize))
- GuiData->CharWidth = CharSize.cx;
-
- SelectObject(hDC, OldFont);
- ReleaseDC(GuiData->hWindow, hDC);
-
- if (GuiData->Font != NULL) DeleteObject(GuiData->Font);
- GuiData->Font = NewFont;
-
- Length = min(wcslen(FaceName) + 1, LF_FACESIZE); // wcsnlen
- wcsncpy(GuiData->GuiInfo.FaceName, FaceName, LF_FACESIZE);
- GuiData->GuiInfo.FaceName[Length] = L'\0'; // NULL-terminate
- GuiData->GuiInfo.FontFamily = FontFamily;
- GuiData->GuiInfo.FontSize = FontSize;
- GuiData->GuiInfo.FontWeight = FontWeight;
-
- return TRUE;
-}
-
-
-
VOID
GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection,
BOOL SaveSettings)
{
NTSTATUS Status = STATUS_SUCCESS;
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_PROCESS_DATA ProcessData;
HANDLE hSection = NULL;
ULONG ViewSize = 0;
// memcpy(&GuiData->GuiInfo, GuiInfo, sizeof(GUI_CONSOLE_INFO));
/* Change the font */
- ChangeFont(GuiData,
- GuiInfo->FaceName,
- GuiInfo->FontFamily,
- GuiInfo->FontSize,
- GuiInfo->FontWeight);
+ InitFonts(GuiData,
+ GuiInfo->FaceName,
+ GuiInfo->FontFamily,
+ GuiInfo->FontSize,
+ GuiInfo->FontWeight);
// HACK, needed because changing font may change the size of the window
/**/TermResizeTerminal(Console);/**/
HANDLE hClientSection)
{
NTSTATUS Status = STATUS_SUCCESS;
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
PCONSOLE_PROCESS_DATA ProcessData;
HANDLE hSection = NULL;
ULONG ViewSize = 0;
// memcpy(&GuiData->GuiInfo, &GuiInfo, sizeof(GUI_CONSOLE_INFO));
/* Change the font */
- ChangeFont(GuiData,
- GuiInfo.FaceName,
- GuiInfo.FontFamily,
- GuiInfo.FontSize,
- GuiInfo.FontWeight);
+ InitFonts(GuiData,
+ GuiInfo.FaceName,
+ GuiInfo.FontFamily,
+ GuiInfo.FontSize,
+ GuiInfo.FontWeight);
// HACK, needed because changing font may change the size of the window
/**/TermResizeTerminal(Console);/**/
typedef struct _GUI_CONSOLE_INFO
{
- // FONTSIGNATURE FontSignature;
WCHAR FaceName[LF_FACESIZE];
ULONG FontFamily;
COORD FontSize;
case PM_CREATE_CONSOLE:
{
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)lParam;
- PCONSOLE Console = GuiData->Console;
+ PCONSRV_CONSOLE Console = GuiData->Console;
RECT rcWnd;
DPRINT("PM_CREATE_CONSOLE -- creating window\n");
static VOID NTAPI
GuiDeinitFrontEnd(IN OUT PFRONTEND This);
-NTSTATUS NTAPI
+static NTSTATUS NTAPI
GuiInitFrontEnd(IN OUT PFRONTEND This,
- IN PCONSOLE Console)
+ IN PCONSRV_CONSOLE Console)
{
PGUI_INIT_INFO GuiInitInfo;
PCONSOLE_INFO ConsoleInfo;
#include "conwnd.h"
NTSTATUS GuiInitConsole(PCONSOLE Console,
- /*IN*/ PCONSOLE_START_INFO ConsoleStartInfo,
- PCONSOLE_INFO ConsoleInfo,
- DWORD ProcessId,
- LPCWSTR IconPath,
- INT IconIndex);
+ /*IN*/ PCONSOLE_START_INFO ConsoleStartInfo,
+ PCONSOLE_INFO ConsoleInfo,
+ DWORD ProcessId,
+ LPCWSTR IconPath,
+ INT IconIndex);
+
+VOID
+GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
+
+VOID
+SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
+
+BOOL
+InitFonts(PGUI_CONSOLE_DATA GuiData,
+ LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
+ ULONG FontFamily,
+ COORD FontSize,
+ ULONG FontWeight);
+VOID
+DeleteFonts(PGUI_CONSOLE_DATA GuiData);
/* FUNCTIONS ******************************************************************/
static COLORREF
-PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute)
+PaletteRGBFromAttrib(PCONSRV_CONSOLE Console, WORD Attribute)
{
HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle;
PALETTEENTRY pe;
return PALETTERGB(pe.peRed, pe.peGreen, pe.peBlue);
}
-static HFONT
-ChangeFontAttributes(PGUI_CONSOLE_DATA GuiData,
- // COORD FontSize,
- ULONG FontWeight,
- BOOLEAN bItalic,
- BOOLEAN bUnderline,
- BOOLEAN bStrikeOut)
-{
- HFONT NewFont;
- LOGFONT lf;
-
- /* Initialize the LOGFONT structure */
- RtlZeroMemory(&lf, sizeof(lf));
-
- /* Retrieve the details of the current font */
- if (GetObject(GuiData->Font, sizeof(lf), &lf) == 0)
- return NULL; // GuiData->Font;
-
- /* Change the font attributes */
- // lf.lfHeight = FontSize.Y;
- // lf.lfWidth = FontSize.X;
- lf.lfWeight = FontWeight;
- lf.lfItalic = bItalic;
- lf.lfUnderline = bUnderline;
- lf.lfStrikeOut = bStrikeOut;
-
- /* Build a new font */
- NewFont = CreateFontIndirect(&lf);
- if (NewFont == NULL)
- return NULL; // GuiData->Font;
-
- // FIXME: Do we need to update GuiData->CharWidth and GuiData->CharHeight ??
-
- /* Select it (return the old font) */
- // return SelectObject(GuiData->hMemDC, NewFont);
- return NewFont;
-}
-
static VOID
CopyBlock(PTEXTMODE_SCREEN_BUFFER Buffer,
PSMALL_RECT Selection)
* This function supposes that the system clipboard was opened.
*/
- PCONSOLE Console = Buffer->Header.Console;
+ PCONSRV_CONSOLE Console = Buffer->Header.Console;
HANDLE hData;
LPWSTR str;
PRECT rcView,
PRECT rcFramebuffer)
{
- PCONSOLE Console = Buffer->Header.Console;
+ PCONSRV_CONSOLE Console = Buffer->Header.Console;
// ASSERT(Console == GuiData->Console);
ULONG TopLine, BottomLine, LeftChar, RightChar;
ULONG CursorX, CursorY, CursorHeight;
HBRUSH CursorBrush, OldBrush;
HFONT OldFont, NewFont;
- BOOLEAN IsUnderscore;
+ BOOLEAN IsUnderline;
if (Buffer->Buffer == NULL) return;
SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
- // OldFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight, FALSE, FALSE, FALSE);
- IsUnderscore = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
- NewFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight,
- FALSE,
- IsUnderscore,
- FALSE);
- if (NewFont == NULL)
- {
- DPRINT1("ChangeFontAttributes failed, use the original font\n");
- NewFont = GuiData->Font;
- }
+ /* We use the underscore flag as a underline flag */
+ IsUnderline = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
+ /* Select the new font */
+ NewFont = GuiData->Font[IsUnderline ? FONT_BOLD : FONT_NORMAL];
OldFont = SelectObject(GuiData->hMemDC, NewFont);
for (Line = TopLine; Line <= BottomLine; Line++)
SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
- /* Change underscore state if needed */
- if (!!(LastAttribute & COMMON_LVB_UNDERSCORE) != IsUnderscore)
+ /* Change underline state if needed */
+ if (!!(LastAttribute & COMMON_LVB_UNDERSCORE) != IsUnderline)
{
- IsUnderscore = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
-
- /* Delete the font we used up to now */
- // SelectObject(GuiData->hMemDC, OldFont);
- if (NewFont != GuiData->Font) DeleteObject(NewFont);
- /* Recreate it */
- NewFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight,
- FALSE,
- IsUnderscore,
- FALSE);
- if (NewFont == NULL)
- {
- DPRINT1("ChangeFontAttributes failed, use the original font\n");
- NewFont = GuiData->Font;
- }
- /* Select it */
+ IsUnderline = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
+ /* Select the new font */
+ NewFont = GuiData->Font[IsUnderline ? FONT_BOLD : FONT_NORMAL];
/* OldFont = */ SelectObject(GuiData->hMemDC, NewFont);
}
}
RightChar - Start + 1);
}
+ /* Restore the old font */
+ SelectObject(GuiData->hMemDC, OldFont);
+
/*
* Draw the caret
*/
}
}
- /* Restore the old font and delete the font we used up to now */
- SelectObject(GuiData->hMemDC, OldFont);
- if (NewFont != GuiData->Font) DeleteObject(NewFont);
-
LeaveCriticalSection(&Console->Lock);
}
}
VOID NTAPI
-ConioProcessKey(PCONSOLE Console, MSG* msg)
+ConioProcessKey(PCONSRV_CONSOLE Console, MSG* msg)
{
static BYTE KeyState[256] = { 0 };
/* MSDN mentions that you should use the last virtual key code received
}
DWORD
-ConioEffectiveCursorSize(PCONSOLE Console, DWORD Scale)
+ConioEffectiveCursorSize(PCONSRV_CONSOLE Console, DWORD Scale)
{
DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100;
/* If line input in progress, perhaps adjust for insert toggle */
HWND hWindow; /* Handle to the console's window (used for the window's procedure */
- PCONSOLE Console; /* Pointer to the owned console */
+ PCONSRV_CONSOLE Console; /* Pointer to the owned console */
// TUI_CONSOLE_INFO TuiInfo; /* TUI terminal settings */
} TUI_CONSOLE_DATA, *PTUI_CONSOLE_DATA;
{
/*
PTUI_CONSOLE_DATA TuiData = NULL;
- PCONSOLE Console = NULL;
+ PCONSRV_CONSOLE Console = NULL;
TuiData = TuiGetGuiData(hWnd);
if (TuiData == NULL) return 0;
TuiConsoleThread(PVOID Data)
{
PTUI_CONSOLE_DATA TuiData = (PTUI_CONSOLE_DATA)Data;
- PCONSOLE Console = TuiData->Console;
+ PCONSRV_CONSOLE Console = TuiData->Console;
HWND NewWindow;
MSG msg;
static VOID NTAPI
TuiDeinitFrontEnd(IN OUT PFRONTEND This /*,
- IN PCONSOLE Console */);
+ IN PCONSRV_CONSOLE Console */);
-NTSTATUS NTAPI
+static NTSTATUS NTAPI
TuiInitFrontEnd(IN OUT PFRONTEND This,
- IN PCONSOLE Console)
+ IN PCONSRV_CONSOLE Console)
{
PTUI_CONSOLE_DATA TuiData;
HANDLE ThreadHandle;
static VOID NTAPI
TuiDeinitFrontEnd(IN OUT PFRONTEND This)
{
- // PCONSOLE Console = This->Console;
+ // PCONSRV_CONSOLE Console = This->Console;
PTUI_CONSOLE_DATA TuiData = This->Data; // Console->FrontEndIFace.Data;
/* Close the notification window */
#pragma once
NTSTATUS TuiInitConsole(PCONSOLE Console,
- /*IN*/ PCONSOLE_START_INFO ConsoleStartInfo,
- PCONSOLE_INFO ConsoleInfo,
- DWORD ProcessId);
+ /*IN*/ PCONSOLE_START_INFO ConsoleStartInfo,
+ PCONSOLE_INFO ConsoleInfo,
+ DWORD ProcessId);
/* EOF */
{
NTSTATUS Status = STATUS_SUCCESS;
HANDLE ConsoleHandle;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
/*
* We are about to create a new console. However when ConSrvNewProcess
#include "rect.h"
-#define CSR_DEFAULT_CURSOR_SIZE 25
-
/* Default attributes */
#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)
-/* VGA character cell */
-typedef struct _CHAR_CELL
-{
- CHAR Char;
- BYTE Attributes;
-} CHAR_CELL, *PCHAR_CELL;
-C_ASSERT(sizeof(CHAR_CELL) == 2);
-
/* Object type magic numbers */
typedef enum _CONSOLE_IO_OBJECT_TYPE
// HACK!!
struct _CONSOLE;
-struct _WINSRV_CONSOLE;
/* HACK: */ typedef struct _CONSOLE *PCONSOLE;
#include "conio_winsrv.h"
CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
UINT InputCodePage;
- /** Put those things in CONSOLE_INPUT_BUFFER ?? **/
+ /** Put those things in CONSOLE_INPUT_BUFFER in PWINSRV_CONSOLE ?? **/
PWCHAR LineBuffer; /* Current line being input, in line buffered mode */
ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */
ULONG LineSize; /* Current size of line */
BOOLEAN LineUpPressed;
BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */
ULONG LineWakeupMask; /* Bitmap of which control characters will end line input */
- /*************************************************/
+ /** In PWINSRV_CONSOLE ?? **/
BOOLEAN InsertMode;
+ /*************************************************/
/******************************* Screen buffers *******************************/
LIST_ENTRY BufferList; /* List of all screen buffers for this console */
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
UINT OutputCodePage;
- /**** Per-console Virtual DOS Machine Text-mode Buffer ****/
- COORD VDMBufferSize; /* Real size of the VDM buffer, in units of ??? */
- HANDLE VDMBufferSection; /* Handle to the memory shared section for the VDM buffer */
- PVOID VDMBuffer; /* Our VDM buffer */
- PVOID ClientVDMBuffer; /* A copy of the client view of our VDM buffer */
- HANDLE VDMClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */
-
- HANDLE StartHardwareEvent;
- HANDLE EndHardwareEvent;
- HANDLE ErrorHardwareEvent;
-
/****************************** Other properties ******************************/
UNICODE_STRING OriginalTitle; /* Original title of console, the one defined when the console leader is launched; it never changes. Always NULL-terminated */
UNICODE_STRING Title; /* Title of console. Always NULL-terminated */
COORD ConsoleSize; /* The current size of the console, for text-mode only */
BOOLEAN FixedSize; /* TRUE if the console is of fixed size */
- COLORREF Colors[16]; /* Colour palette */
-
} CONSOLE; // , *PCONSOLE;
-// #include "conio_winsrv.h"
-
/* console.c */
VOID NTAPI
ConDrvPause(PCONSOLE Console);
VOID NTAPI
ConDrvUnpause(PCONSOLE Console);
-PCONSOLE_PROCESS_DATA NTAPI
-ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console);
NTSTATUS
ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
IN PCONSOLE_PROCESS_DATA ProcessData);
-NTSTATUS NTAPI
-ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
- IN ULONG ProcessGroupId,
- IN ULONG CtrlEvent);
/* coninput.c */
-VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
NTSTATUS
ConioAddInputEvents(PCONSOLE Console,
PINPUT_RECORD InputRecords,
PWCHAR Buffer,
DWORD Length,
BOOL Attrib);
-DWORD ConioEffectiveCursorSize(PCONSOLE Console,
- DWORD Scale);
/* EOF */
#include "rect.h"
+// This is ALMOST a HACK!!!!!!!
+// Helpers for code refactoring
+#define _CONSRV_CONSOLE _CONSOLE
+#define CONSRV_CONSOLE CONSOLE
+#define PCONSRV_CONSOLE PCONSOLE
+
+// #define _CONSRV_CONSOLE _WINSRV_CONSOLE
+// #define CONSRV_CONSOLE WINSRV_CONSOLE
+// #define PCONSRV_CONSOLE PWINSRV_CONSOLE
+
+
#define CSR_DEFAULT_CURSOR_SIZE 25
+/* VGA character cell */
+typedef struct _CHAR_CELL
+{
+ CHAR Char;
+ BYTE Attributes;
+} CHAR_CELL, *PCHAR_CELL;
+C_ASSERT(sizeof(CHAR_CELL) == 2);
+
+
typedef struct _FRONTEND FRONTEND, *PFRONTEND;
/* HACK: */ typedef struct _CONSOLE_INFO *PCONSOLE_INFO;
typedef struct _FRONTEND_VTBL
* Internal interface (functions called by the console server only)
*/
NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PFRONTEND This,
- IN struct _CONSOLE* Console);
+ IN struct _CONSRV_CONSOLE* Console);
VOID (NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This);
/* Interface used for both text-mode and graphics screen buffers */
PFRONTEND_VTBL Vtbl; /* Virtual table */
NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
- // struct _WINSRV_CONSOLE*
- struct _CONSOLE* Console; /* Console to which the frontend is attached to */
+ struct _CONSRV_CONSOLE* Console; /* Console to which the frontend is attached to */
PVOID Data; /* Private data */
PVOID OldData; /* Reserved */
};
/******************************* Console Set-up *******************************/
/* This **MUST** be FIRST!! */
// CONSOLE;
+ // PCONSOLE Console;
// LONG ReferenceCount; /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
// CRITICAL_SECTION Lock;
ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */
BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
+/************************ Virtual DOS Machine support *************************/
+ COORD VDMBufferSize; /* Real size of the VDM buffer, in units of ??? */
+ HANDLE VDMBufferSection; /* Handle to the memory shared section for the VDM buffer */
+ PVOID VDMBuffer; /* Our VDM buffer */
+ PVOID ClientVDMBuffer; /* A copy of the client view of our VDM buffer */
+ HANDLE VDMClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */
+
+ HANDLE StartHardwareEvent;
+ HANDLE EndHardwareEvent;
+ HANDLE ErrorHardwareEvent;
+
+/****************************** Other properties ******************************/
+ COLORREF Colors[16]; /* Colour palette */
+
} WINSRV_CONSOLE, *PWINSRV_CONSOLE;
/* console.c */
-VOID ConioPause(PCONSOLE Console, UINT Flags);
-VOID ConioUnpause(PCONSOLE Console, UINT Flags);
+VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags);
+VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags);
PCONSOLE_PROCESS_DATA NTAPI
-ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console);
+ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console);
NTSTATUS
ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
IN PCONSOLE_PROCESS_DATA ProcessData);
NTSTATUS NTAPI
-ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
+ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console,
IN ULONG ProcessGroupId,
IN ULONG CtrlEvent);
/* coninput.c */
-VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);
-DWORD ConioEffectiveCursorSize(PCONSOLE Console,
+VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG* msg);
+DWORD ConioEffectiveCursorSize(PCONSRV_CONSOLE Console,
DWORD Scale);
NTSTATUS
-ConioAddInputEvents(PCONSOLE Console,
+ConioAddInputEvents(PCONSRV_CONSOLE Console,
PINPUT_RECORD InputRecords,
ULONG NumEventsToWrite,
PULONG NumEventsWritten,
BOOLEAN AppendToEnd);
NTSTATUS
-ConioProcessInputEvent(PCONSOLE Console,
+ConioProcessInputEvent(PCONSRV_CONSOLE Console,
PINPUT_RECORD InputEvent);
/* conoutput.c */
MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
-VOID ConioDrawConsole(PCONSOLE Console);
-NTSTATUS ConioResizeBuffer(PCONSOLE Console,
+VOID ConioDrawConsole(PCONSRV_CONSOLE Console);
+NTSTATUS ConioResizeBuffer(PCONSRV_CONSOLE Console,
PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
COORD Size);
-NTSTATUS ConioWriteConsole(PCONSOLE Console,
+NTSTATUS ConioWriteConsole(PCONSRV_CONSOLE Console,
PTEXTMODE_SCREEN_BUFFER Buff,
PWCHAR Buffer,
DWORD Length,
/* PRIVATE FUNCTIONS **********************************************************/
static PHISTORY_BUFFER
-HistoryCurrentBuffer(PCONSOLE Console,
+HistoryCurrentBuffer(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName)
{
PLIST_ENTRY Entry = Console->HistoryBuffers.Flink;
}
static VOID
-HistoryAddEntry(PCONSOLE Console,
+HistoryAddEntry(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName)
{
UNICODE_STRING NewEntry;
}
static VOID
-HistoryGetCurrentEntry(PCONSOLE Console,
+HistoryGetCurrentEntry(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName,
PUNICODE_STRING Entry)
{
}
static PHISTORY_BUFFER
-HistoryFindBuffer(PCONSOLE Console,
+HistoryFindBuffer(PCONSRV_CONSOLE Console,
PVOID ExeName,
USHORT ExeLength,
BOOLEAN UnicodeExe)
}
VOID
-HistoryDeleteBuffers(PCONSOLE Console)
+HistoryDeleteBuffers(PCONSRV_CONSOLE Console)
{
PLIST_ENTRY CurrentEntry;
PHISTORY_BUFFER HistoryBuffer;
}
static VOID
-LineInputSetPos(PCONSOLE Console, UINT Pos)
+LineInputSetPos(PCONSRV_CONSOLE Console, UINT Pos)
{
if (Pos != Console->LinePos && Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
{
}
static VOID
-LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, PWCHAR Insertion)
+LineInputEdit(PCONSRV_CONSOLE Console, UINT NumToDelete, UINT NumToInsert, PWCHAR Insertion)
{
PTEXTMODE_SCREEN_BUFFER ActiveBuffer;
UINT Pos = Console->LinePos;
}
static VOID
-LineInputRecallHistory(PCONSOLE Console,
+LineInputRecallHistory(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName,
INT Offset)
{
}
VOID
-LineInputKeyDown(PCONSOLE Console,
+LineInputKeyDown(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName,
KEY_EVENT_RECORD *KeyEvent)
{
{
NTSTATUS Status;
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
ULONG BytesWritten = 0;
PHISTORY_BUFFER Hist;
{
NTSTATUS Status;
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PHISTORY_BUFFER Hist;
ULONG Length = 0;
UINT i;
{
NTSTATUS Status;
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PHISTORY_BUFFER Hist;
if (!CsrValidateMessageBuffer(ApiMessage,
{
NTSTATUS Status;
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
PHISTORY_BUFFER Hist;
if (!CsrValidateMessageBuffer(ApiMessage,
{
#if 0 // Vista+
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (NT_SUCCESS(Status))
{
{
#if 0 // Vista+
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (NT_SUCCESS(Status))
{
{
NTSTATUS Status;
PCONSOLE_SETHISTORYMODE SetHistoryModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryModeRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
DPRINT1("SrvSetConsoleCommandHistoryMode(Mode = %d) is not yet implemented\n",
SetHistoryModeRequest->Mode);
#pragma once
-VOID HistoryDeleteBuffers(PCONSOLE Console);
+VOID HistoryDeleteBuffers(PCONSRV_CONSOLE Console);
VOID
-LineInputKeyDown(PCONSOLE Console,
+LineInputKeyDown(PCONSRV_CONSOLE Console,
PUNICODE_STRING ExeName,
KEY_EVENT_RECORD *KeyEvent);
{
NTSTATUS Status;
PCONSOLE_REGISTERVDM RegisterVDMRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.RegisterVDMRequest;
- PCONSOLE Console;
+ PCONSRV_CONSOLE Console;
DPRINT1("SrvRegisterConsoleVDM(%d)\n", RegisterVDMRequest->RegisterFlags);