Fourth partial merge of the condrv_restructure branch, with fonts improvements.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 14 Aug 2014 20:23:03 +0000 (20:23 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 14 Aug 2014 20:23:03 +0000 (20:23 +0000)
CORE-8439 #resolve #comment r63885 merged to trunk in r63886.

svn path=/trunk/; revision=63886

29 files changed:
reactos/dll/cpl/console/console.c
reactos/dll/cpl/console/layout.c
reactos/dll/win32/kernel32/client/console/console.c
reactos/win32ss/user/winsrv/consrv/alias.c
reactos/win32ss/user/winsrv/consrv/alias.h
reactos/win32ss/user/winsrv/consrv/condrv/console.c
reactos/win32ss/user/winsrv/consrv/coninput.c
reactos/win32ss/user/winsrv/consrv/conoutput.c
reactos/win32ss/user/winsrv/consrv/console.c
reactos/win32ss/user/winsrv/consrv/consrv.h
reactos/win32ss/user/winsrv/consrv/frontendctl.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
reactos/win32ss/user/winsrv/consrv/frontends/gui/fullscreen.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/graphics.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h
reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c
reactos/win32ss/user/winsrv/consrv/frontends/input.c
reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
reactos/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.h
reactos/win32ss/user/winsrv/consrv/handle.c
reactos/win32ss/user/winsrv/consrv/include/conio.h
reactos/win32ss/user/winsrv/consrv/include/conio_winsrv.h
reactos/win32ss/user/winsrv/consrv/lineinput.c
reactos/win32ss/user/winsrv/consrv/lineinput.h
reactos/win32ss/user/winsrv/consrv/subsysreg.c

index 436626b..8fdda90 100644 (file)
@@ -117,7 +117,8 @@ InitConsoleDefaults(PCONSOLE_PROPS pConInfo)
     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;
index fac40bb..90926c8 100644 (file)
@@ -121,7 +121,7 @@ PaintText(LPDRAWITEMSTRUCT drawItem,
     if (!hBrush) return FALSE;
 
     Font = CreateFontW(GuiInfo->FontSize.Y,
-                       0, // GuiInfo->FontSize.X,
+                       GuiInfo->FontSize.X,
                        0,
                        TA_BASELINE,
                        GuiInfo->FontWeight,
@@ -131,8 +131,8 @@ PaintText(LPDRAWITEMSTRUCT drawItem,
                        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)
     {
index fe4a084..0a4059a 100644 (file)
@@ -561,7 +561,7 @@ InvalidateConsoleDIBits(IN HANDLE hConsoleOutput,
 
 
 /*
- * @unimplemented (Undocumented)
+ * @implemented (Undocumented)
  */
 HANDLE
 WINAPI
index 3d7a533..a288f97 100644 (file)
@@ -102,7 +102,7 @@ ConvertInputUnicodeToAnsi(PCONSOLE Console,
 /* PRIVATE FUNCTIONS **********************************************************/
 
 static PALIAS_HEADER
-IntFindAliasHeader(PCONSOLE Console,
+IntFindAliasHeader(PCONSRV_CONSOLE Console,
                    PVOID    ExeName,
                    USHORT   ExeLength,
                    BOOLEAN  UnicodeExe)
@@ -149,7 +149,7 @@ IntFindAliasHeader(PCONSOLE Console,
 }
 
 static PALIAS_HEADER
-IntCreateAliasHeader(PCONSOLE Console,
+IntCreateAliasHeader(PCONSRV_CONSOLE Console,
                      PVOID    ExeName,
                      USHORT   ExeLength,
                      BOOLEAN  UnicodeExe)
@@ -217,7 +217,7 @@ IntInsertAliasHeader(PALIAS_HEADER* RootHeader,
 }
 
 static PALIAS_ENTRY
-IntGetAliasEntry(PCONSOLE Console,
+IntGetAliasEntry(PCONSRV_CONSOLE Console,
                  PALIAS_HEADER Header,
                  PVOID    Source,
                  USHORT   SourceLength,
@@ -266,7 +266,7 @@ IntGetAliasEntry(PCONSOLE Console,
 }
 
 static PALIAS_ENTRY
-IntCreateAliasEntry(PCONSOLE Console,
+IntCreateAliasEntry(PCONSRV_CONSOLE Console,
                     PVOID    Source,
                     USHORT   SourceLength,
                     PVOID    Target,
@@ -425,7 +425,7 @@ IntGetAllConsoleAliasesLength(PALIAS_HEADER Header,
 }
 
 VOID
-IntDeleteAllAliases(PCONSOLE Console)
+IntDeleteAllAliases(PCONSRV_CONSOLE Console)
 {
     PALIAS_HEADER Header, NextHeader;
     PALIAS_ENTRY Entry, NextEntry;
@@ -449,7 +449,7 @@ CSR_API(SrvAddConsoleAlias)
 {
     NTSTATUS Status;
     PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     PALIAS_HEADER Header;
     PALIAS_ENTRY Entry;
     PVOID lpTarget;
@@ -538,7 +538,7 @@ CSR_API(SrvGetConsoleAlias)
 {
     NTSTATUS Status;
     PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     PALIAS_HEADER Header;
     PALIAS_ENTRY Entry;
     UINT Length;
@@ -629,7 +629,7 @@ CSR_API(SrvGetConsoleAliases)
 {
     NTSTATUS Status;
     PCONSOLE_GETALLALIASES GetAllAliasesRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     ULONG BytesWritten = 0;
     PALIAS_HEADER Header;
 
@@ -734,7 +734,7 @@ CSR_API(SrvGetConsoleAliasesLength)
 {
     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);
@@ -774,7 +774,7 @@ CSR_API(SrvGetConsoleAliasExes)
 {
     NTSTATUS Status;
     PCONSOLE_GETALIASESEXES GetAliasesExesRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     UINT BytesWritten = 0;
 
     DPRINT1("SrvGetConsoleAliasExes entered\n");
@@ -860,7 +860,7 @@ CSR_API(SrvGetConsoleAliasExesLength)
 {
     NTSTATUS Status;
     PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     DPRINT1("SrvGetConsoleAliasExesLength entered ApiMessage %p\n", ApiMessage);
 
index d3653e5..38505d1 100644 (file)
@@ -9,4 +9,4 @@
 
 #pragma once
 
-VOID IntDeleteAllAliases(PCONSOLE Console);
+VOID IntDeleteAllAliases(PCONSRV_CONSOLE Console);
index b0f7099..4f60730 100644 (file)
@@ -233,7 +233,6 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
     /* 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.
 
index 738e819..953451e 100644 (file)
@@ -40,7 +40,7 @@ typedef struct _GET_INPUT_INFO
  * This pre-processing code MUST be IN consrv ONLY
  */
 /* static */ ULONG
-PreprocessInput(PCONSOLE Console,
+PreprocessInput(PCONSRV_CONSOLE Console,
                 PINPUT_RECORD InputEvent,
                 ULONG NumEventsToWrite)
 {
@@ -102,7 +102,7 @@ PreprocessInput(PCONSOLE Console,
  * This post-processing code MUST be IN consrv ONLY
  */
 /* static */ VOID
-PostprocessInput(PCONSOLE Console)
+PostprocessInput(PCONSRV_CONSOLE Console)
 {
     CsrNotifyWait(&Console->ReadWaitQueue,
                   FALSE,
index 12a4d4d..ab911f7 100644 (file)
@@ -170,7 +170,7 @@ CSR_API(SrvCreateConsoleScreenBuffer)
     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;
index fb0ddf7..a5d7c65 100644 (file)
@@ -26,7 +26,7 @@ NTSTATUS NTAPI RtlGetLastNtStatus(VOID);
 /* 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()    \
@@ -41,13 +41,13 @@ static RTL_RESOURCE ListLock;
 
 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) );
@@ -70,7 +70,7 @@ InsertConsole(OUT PHANDLE Handle,
         /* 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;
@@ -83,7 +83,7 @@ InsertConsole(OUT PHANDLE Handle,
             /* 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;
@@ -105,7 +105,7 @@ static NTSTATUS
 RemoveConsoleByHandle(IN HANDLE Handle)
 {
     NTSTATUS Status = STATUS_SUCCESS;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     BOOLEAN ValidHandle = ((HandleToULong(Handle) & 0x3) == 0x3);
     ULONG Index = HandleToULong(Handle) >> 2;
@@ -135,7 +135,7 @@ Quit:
 #endif
 
 static NTSTATUS
-RemoveConsoleByPointer(IN PCONSOLE Console)
+RemoveConsoleByPointer(IN PCONSRV_CONSOLE Console)
 {
     ULONG i = 0;
 
@@ -162,13 +162,13 @@ RemoveConsoleByPointer(IN PCONSOLE Console)
 }
 
 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;
@@ -210,14 +210,14 @@ ConSrvValidateConsole(OUT PCONSOLE* Console,
 /* 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;
 
@@ -239,11 +239,11 @@ ConioUnpause(PCONSOLE Console, UINT 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);
@@ -266,7 +266,7 @@ ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData,
 }
 
 VOID
-ConSrvReleaseConsole(IN PCONSOLE Console,
+ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console,
                      IN BOOLEAN WasConsoleLocked)
 {
     LONG RefCount = 0;
@@ -319,13 +319,13 @@ ConSrvDeinitTerminal(IN OUT PTERMINAL Terminal);
 
 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;
 
@@ -429,6 +429,9 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
 
     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))
@@ -450,7 +453,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
 }
 
 VOID NTAPI
-ConSrvDeleteConsole(PCONSOLE Console)
+ConSrvDeleteConsole(PCONSRV_CONSOLE Console)
 {
     DPRINT("ConSrvDeleteConsole\n");
 
@@ -528,7 +531,7 @@ ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
 }
 
 PCONSOLE_PROCESS_DATA NTAPI
-ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console)
+ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
 {
     if (Console == NULL) return NULL;
 
@@ -538,7 +541,7 @@ ConSrvGetConsoleLeaderProcess(IN PCONSOLE Console)
 }
 
 NTSTATUS NTAPI
-ConSrvGetConsoleProcessList(IN PCONSOLE Console,
+ConSrvGetConsoleProcessList(IN PCONSRV_CONSOLE Console,
                             IN OUT PULONG ProcessIdsList,
                             IN ULONG MaxIdListItems,
                             OUT PULONG ProcessIdsTotal)
@@ -567,7 +570,7 @@ ConSrvGetConsoleProcessList(IN PCONSOLE Console,
 
 // ConSrvGenerateConsoleCtrlEvent
 NTSTATUS NTAPI
-ConSrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
+ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console,
                               IN ULONG ProcessGroupId,
                               IN ULONG CtrlEvent)
 {
@@ -795,7 +798,7 @@ CSR_API(SrvGetConsoleTitle)
 {
     NTSTATUS Status;
     PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     if (!CsrValidateMessageBuffer(ApiMessage,
                                   (PVOID)&TitleRequest->Title,
@@ -830,7 +833,7 @@ CSR_API(SrvSetConsoleTitle)
 {
     NTSTATUS Status;
     PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     if (!CsrValidateMessageBuffer(ApiMessage,
                                   (PVOID)&TitleRequest->Title,
@@ -865,7 +868,7 @@ CSR_API(SrvGetConsoleCP)
 {
     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");
@@ -889,7 +892,7 @@ CSR_API(SrvSetConsoleCP)
 {
     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");
@@ -909,7 +912,7 @@ CSR_API(SrvGetConsoleProcessList)
 {
     NTSTATUS Status;
     PCONSOLE_GETPROCESSLIST GetProcessListRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetProcessListRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     if (!CsrValidateMessageBuffer(ApiMessage,
                                   (PVOID)&GetProcessListRequest->ProcessIdsList,
@@ -935,7 +938,7 @@ CSR_API(SrvGenerateConsoleCtrlEvent)
 {
     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;
@@ -952,7 +955,7 @@ CSR_API(SrvConsoleNotifyLastClose)
 {
     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;
@@ -979,7 +982,7 @@ CSR_API(SrvGetConsoleMouseInfo)
 {
     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;
@@ -1001,7 +1004,7 @@ CSR_API(SrvGetConsoleKeyboardLayoutName)
 {
     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;
index 57a0acf..2c9c1e7 100644 (file)
@@ -67,6 +67,7 @@ typedef struct _CONSOLE_PROCESS_DATA
 } 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"
index e8545ec..24bef40 100644 (file)
@@ -31,7 +31,7 @@
  */
 #if 0
 static NTSTATUS
-SetConsoleHardwareState(PCONSOLE Console, ULONG ConsoleHwState)
+SetConsoleHardwareState(PCONSRV_CONSOLE Console, ULONG ConsoleHwState)
 {
     DPRINT1("Console Hardware State: %d\n", ConsoleHwState);
 
@@ -58,7 +58,7 @@ CSR_API(SrvGetConsoleHardwareState)
     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,
@@ -88,7 +88,7 @@ CSR_API(SrvSetConsoleHardwareState)
     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,
@@ -117,7 +117,7 @@ CSR_API(SrvGetConsoleDisplayMode)
 {
     NTSTATUS Status;
     PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetDisplayModeRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
                               &Console, TRUE);
@@ -133,7 +133,7 @@ CSR_API(SrvSetConsoleDisplayMode)
 {
     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),
@@ -164,7 +164,7 @@ CSR_API(SrvGetLargestConsoleWindowSize)
     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,
@@ -184,7 +184,7 @@ CSR_API(SrvShowConsoleCursor)
 {
     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),
@@ -207,7 +207,7 @@ CSR_API(SrvSetConsoleCursor)
     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
@@ -232,7 +232,7 @@ CSR_API(SrvConsoleMenuControl)
 {
     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),
@@ -257,7 +257,7 @@ CSR_API(SrvSetConsoleMenuClose)
     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);
@@ -273,7 +273,7 @@ CSR_API(SrvGetConsoleWindow)
 {
     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;
@@ -288,7 +288,7 @@ CSR_API(SrvSetConsoleIcon)
 {
     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;
@@ -305,7 +305,7 @@ CSR_API(SrvGetConsoleSelectionInfo)
 {
     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;
index 2a7ff36..84de187 100644 (file)
@@ -282,7 +282,7 @@ CreateSysMenu(HWND hWnd)
 }
 
 static VOID
-SendMenuEvent(PCONSOLE Console, UINT CmdId)
+SendMenuEvent(PCONSRV_CONSOLE Console, UINT CmdId)
 {
     INPUT_RECORD er;
 
@@ -366,7 +366,7 @@ static LRESULT
 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,
@@ -486,75 +486,106 @@ ResizeConWnd(PGUI_CONSOLE_DATA GuiData, DWORD WidthUnit, DWORD HeightUnit)
     // 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;
@@ -565,9 +596,80 @@ OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
         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;
@@ -647,7 +749,7 @@ OnActivate(PGUI_CONSOLE_DATA GuiData, WPARAM wParam)
 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;
@@ -814,7 +916,7 @@ UpdateSelection(PGUI_CONSOLE_DATA GuiData,
                 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);
@@ -1039,7 +1141,7 @@ IsSystemKey(WORD VirtualKeyCode)
 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;
@@ -1204,7 +1306,7 @@ InvalidateCell(PGUI_CONSOLE_DATA GuiData,
 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);
@@ -1309,7 +1411,7 @@ OnTimer(PGUI_CONSOLE_DATA GuiData)
 static BOOL
 OnClose(PGUI_CONSOLE_DATA GuiData)
 {
-    PCONSOLE Console = GuiData->Console;
+    PCONSRV_CONSOLE Console = GuiData->Console;
 
     if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
         return TRUE;
@@ -1341,7 +1443,7 @@ OnNcDestroy(HWND hWnd)
         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 */
@@ -1380,7 +1482,7 @@ static LRESULT
 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
@@ -1735,7 +1837,7 @@ Paste(PGUI_CONSOLE_DATA GuiData)
 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;
@@ -1767,7 +1869,7 @@ OnGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
 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;
 
@@ -1872,7 +1974,7 @@ GuiConsoleHandleScrollbarMenu(VOID)
 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;
@@ -1983,7 +2085,7 @@ ConWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     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,
index f6caa6d..dee5c32 100644 (file)
 #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
 {
@@ -56,12 +67,12 @@ 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 */
index caf9330..1bb4283 100644 (file)
@@ -48,7 +48,7 @@ LeaveFullScreen(PGUI_CONSOLE_DATA GuiData)
 VOID
 SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
 {
-    PCONSOLE Console = GuiData->Console;
+    PCONSRV_CONSOLE Console = GuiData->Console;
 
     /*
      * See:
@@ -174,7 +174,7 @@ SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
 VOID
 GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
 {
-    PCONSOLE Console = GuiData->Console;
+    PCONSRV_CONSOLE Console = GuiData->Console;
     BOOL FullScreen;
 
     if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
index 37111b3..ba1d6ff 100644 (file)
@@ -115,7 +115,7 @@ GuiPasteToGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
      * This function supposes that the system clipboard was opened.
      */
 
-    // PCONSOLE Console = Buffer->Header.Console;
+    // PCONSRV_CONSOLE Console = Buffer->Header.Console;
 
     UNIMPLEMENTED;
 }
@@ -126,7 +126,7 @@ GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
                        PRECT rcView,
                        PRECT rcFramebuffer)
 {
-    PCONSOLE Console = Buffer->Header.Console;
+    PCONSRV_CONSOLE Console = Buffer->Header.Console;
     // ASSERT(Console == GuiData->Console);
 
     if (Buffer->BitMap == NULL) return;
index a3969fe..12dce74 100644 (file)
@@ -17,9 +17,6 @@
 #include "guiterm.h"
 #include "guisettings.h"
 
-VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
-VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
-
 /* FUNCTIONS ******************************************************************/
 
 BOOL
@@ -199,14 +196,14 @@ GuiConsoleGetDefaultSettings(IN OUT PGUI_CONSOLE_INFO TermInfo,
     // 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;
@@ -230,7 +227,7 @@ GuiConsoleShowConsoleProperties(PGUI_CONSOLE_DATA GuiData,
                                 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;
@@ -418,99 +415,13 @@ Quit:
     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;
@@ -586,11 +497,11 @@ GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
             // 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);/**/
 
@@ -654,7 +565,7 @@ GuiApplyWindowsConsoleSettings(PGUI_CONSOLE_DATA GuiData,
                                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;
@@ -768,11 +679,11 @@ GuiApplyWindowsConsoleSettings(PGUI_CONSOLE_DATA GuiData,
             // 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);/**/
 
index df95bdc..593c14e 100644 (file)
@@ -29,7 +29,6 @@
 
 typedef struct _GUI_CONSOLE_INFO
 {
-    // FONTSIGNATURE FontSignature;
     WCHAR FaceName[LF_FACESIZE];
     ULONG FontFamily;
     COORD FontSize;
index 8b6bc26..730d9a3 100644 (file)
@@ -160,7 +160,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
         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");
@@ -394,9 +394,9 @@ GuiInit(VOID)
 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;
index b70efa9..8755cdd 100644 (file)
 #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);
index 50ebbb6..ba38aaa 100644 (file)
@@ -25,7 +25,7 @@
 /* FUNCTIONS ******************************************************************/
 
 static COLORREF
-PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute)
+PaletteRGBFromAttrib(PCONSRV_CONSOLE Console, WORD Attribute)
 {
     HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle;
     PALETTEENTRY pe;
@@ -36,44 +36,6 @@ PaletteRGBFromAttrib(PCONSOLE Console, WORD Attribute)
     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)
@@ -309,7 +271,7 @@ GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
      * This function supposes that the system clipboard was opened.
      */
 
-    PCONSOLE Console = Buffer->Header.Console;
+    PCONSRV_CONSOLE Console = Buffer->Header.Console;
 
     HANDLE hData;
     LPWSTR str;
@@ -377,7 +339,7 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
                        PRECT rcView,
                        PRECT rcFramebuffer)
 {
-    PCONSOLE Console = Buffer->Header.Console;
+    PCONSRV_CONSOLE Console = Buffer->Header.Console;
     // ASSERT(Console == GuiData->Console);
 
     ULONG TopLine, BottomLine, LeftChar, RightChar;
@@ -388,7 +350,7 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
     ULONG CursorX, CursorY, CursorHeight;
     HBRUSH CursorBrush, OldBrush;
     HFONT OldFont, NewFont;
-    BOOLEAN IsUnderscore;
+    BOOLEAN IsUnderline;
 
     if (Buffer->Buffer == NULL) return;
 
@@ -412,17 +374,10 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
     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++)
@@ -454,25 +409,12 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
                     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);
                     }
                 }
@@ -488,6 +430,9 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
                  RightChar - Start + 1);
     }
 
+    /* Restore the old font */
+    SelectObject(GuiData->hMemDC, OldFont);
+
     /*
      * Draw the caret
      */
@@ -520,10 +465,6 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
         }
     }
 
-    /* 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);
 }
 
index 2fb6f3b..b2c1704 100644 (file)
@@ -126,7 +126,7 @@ ConioGetShiftState(PBYTE KeyState, LPARAM lParam)
 }
 
 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
@@ -205,7 +205,7 @@ ConioProcessKey(PCONSOLE Console, MSG* msg)
 }
 
 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 */
index 1231148..3e2bed7 100644 (file)
@@ -35,7 +35,7 @@ typedef struct _TUI_CONSOLE_DATA
 
     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;
 
@@ -261,7 +261,7 @@ TuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 /*
     PTUI_CONSOLE_DATA TuiData = NULL;
-    PCONSOLE Console = NULL;
+    PCONSRV_CONSOLE Console = NULL;
 
     TuiData = TuiGetGuiData(hWnd);
     if (TuiData == NULL) return 0;
@@ -330,7 +330,7 @@ static DWORD NTAPI
 TuiConsoleThread(PVOID Data)
 {
     PTUI_CONSOLE_DATA TuiData = (PTUI_CONSOLE_DATA)Data;
-    PCONSOLE Console = TuiData->Console;
+    PCONSRV_CONSOLE Console = TuiData->Console;
     HWND NewWindow;
     MSG msg;
 
@@ -458,11 +458,11 @@ Quit:
 
 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;
@@ -539,7 +539,7 @@ TuiInitFrontEnd(IN OUT PFRONTEND This,
 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 */
index 2a176dc..84be2f7 100644 (file)
@@ -12,8 +12,8 @@
 #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 */
index a114411..4c74ab1 100644 (file)
@@ -482,7 +482,7 @@ ConSrvAllocateConsole(PCONSOLE_PROCESS_DATA ProcessData,
 {
     NTSTATUS Status = STATUS_SUCCESS;
     HANDLE ConsoleHandle;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     /*
      * We are about to create a new console. However when ConSrvNewProcess
index 8d3dc9f..fc9d4eb 100644 (file)
 
 #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
@@ -272,7 +262,6 @@ typedef enum _CONSOLE_STATE
 
 // HACK!!
 struct _CONSOLE;
-struct _WINSRV_CONSOLE;
 /* HACK: */ typedef struct _CONSOLE *PCONSOLE;
 #include "conio_winsrv.h"
 
@@ -294,7 +283,7 @@ typedef struct _CONSOLE
     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 */
@@ -303,26 +292,16 @@ typedef struct _CONSOLE
     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 */
@@ -332,30 +311,19 @@ typedef struct _CONSOLE
     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,
@@ -392,7 +360,5 @@ NTSTATUS ConioWriteConsole(PCONSOLE Console,
                            PWCHAR Buffer,
                            DWORD Length,
                            BOOL Attrib);
-DWORD ConioEffectiveCursorSize(PCONSOLE Console,
-                                        DWORD Scale);
 
 /* EOF */
index 4669dae..d7be50e 100644 (file)
 
 #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
@@ -24,7 +44,7 @@ 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 */
@@ -83,8 +103,7 @@ struct _FRONTEND
     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      */
 };
@@ -99,6 +118,7 @@ typedef struct _WINSRV_CONSOLE
 /******************************* 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;
@@ -125,35 +145,49 @@ typedef struct _WINSRV_CONSOLE
     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 */
@@ -173,11 +207,11 @@ ConioProcessInputEvent(PCONSOLE Console,
     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,
index c3ae65e..e60ff4c 100644 (file)
@@ -43,7 +43,7 @@ ConvertInputUnicodeToAnsi(PCONSOLE Console,
 /* PRIVATE FUNCTIONS **********************************************************/
 
 static PHISTORY_BUFFER
-HistoryCurrentBuffer(PCONSOLE Console,
+HistoryCurrentBuffer(PCONSRV_CONSOLE Console,
                      PUNICODE_STRING ExeName)
 {
     PLIST_ENTRY Entry = Console->HistoryBuffers.Flink;
@@ -75,7 +75,7 @@ HistoryCurrentBuffer(PCONSOLE Console,
 }
 
 static VOID
-HistoryAddEntry(PCONSOLE Console,
+HistoryAddEntry(PCONSRV_CONSOLE Console,
                 PUNICODE_STRING ExeName)
 {
     UNICODE_STRING NewEntry;
@@ -127,7 +127,7 @@ HistoryAddEntry(PCONSOLE Console,
 }
 
 static VOID
-HistoryGetCurrentEntry(PCONSOLE Console,
+HistoryGetCurrentEntry(PCONSRV_CONSOLE Console,
                        PUNICODE_STRING ExeName,
                        PUNICODE_STRING Entry)
 {
@@ -140,7 +140,7 @@ HistoryGetCurrentEntry(PCONSOLE Console,
 }
 
 static PHISTORY_BUFFER
-HistoryFindBuffer(PCONSOLE Console,
+HistoryFindBuffer(PCONSRV_CONSOLE Console,
                   PVOID    ExeName,
                   USHORT   ExeLength,
                   BOOLEAN  UnicodeExe)
@@ -202,7 +202,7 @@ HistoryDeleteBuffer(PHISTORY_BUFFER Hist)
 }
 
 VOID
-HistoryDeleteBuffers(PCONSOLE Console)
+HistoryDeleteBuffers(PCONSRV_CONSOLE Console)
 {
     PLIST_ENTRY CurrentEntry;
     PHISTORY_BUFFER HistoryBuffer;
@@ -216,7 +216,7 @@ HistoryDeleteBuffers(PCONSOLE Console)
 }
 
 static VOID
-LineInputSetPos(PCONSOLE Console, UINT Pos)
+LineInputSetPos(PCONSRV_CONSOLE Console, UINT Pos)
 {
     if (Pos != Console->LinePos && Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
     {
@@ -240,7 +240,7 @@ LineInputSetPos(PCONSOLE Console, UINT Pos)
 }
 
 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;
@@ -277,7 +277,7 @@ LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, PWCHAR Inser
 }
 
 static VOID
-LineInputRecallHistory(PCONSOLE Console,
+LineInputRecallHistory(PCONSRV_CONSOLE Console,
                        PUNICODE_STRING ExeName,
                        INT Offset)
 {
@@ -297,7 +297,7 @@ LineInputRecallHistory(PCONSOLE Console,
 }
 
 VOID
-LineInputKeyDown(PCONSOLE Console,
+LineInputKeyDown(PCONSRV_CONSOLE Console,
                  PUNICODE_STRING ExeName,
                  KEY_EVENT_RECORD *KeyEvent)
 {
@@ -511,7 +511,7 @@ CSR_API(SrvGetConsoleCommandHistory)
 {
     NTSTATUS Status;
     PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     ULONG BytesWritten = 0;
     PHISTORY_BUFFER Hist;
 
@@ -599,7 +599,7 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
 {
     NTSTATUS Status;
     PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     PHISTORY_BUFFER Hist;
     ULONG Length = 0;
     UINT  i;
@@ -641,7 +641,7 @@ CSR_API(SrvExpungeConsoleCommandHistory)
 {
     NTSTATUS Status;
     PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     PHISTORY_BUFFER Hist;
 
     if (!CsrValidateMessageBuffer(ApiMessage,
@@ -669,7 +669,7 @@ CSR_API(SrvSetConsoleNumberOfCommands)
 {
     NTSTATUS Status;
     PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
     PHISTORY_BUFFER Hist;
 
     if (!CsrValidateMessageBuffer(ApiMessage,
@@ -720,7 +720,7 @@ CSR_API(SrvGetConsoleHistory)
 {
 #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))
     {
@@ -740,7 +740,7 @@ CSR_API(SrvSetConsoleHistory)
 {
 #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))
     {
@@ -760,7 +760,7 @@ CSR_API(SrvSetConsoleCommandHistoryMode)
 {
     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);
index afb6d25..55511a0 100644 (file)
@@ -8,9 +8,9 @@
 
 #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);
index 40f9740..e49f06e 100644 (file)
@@ -23,7 +23,7 @@ CSR_API(SrvRegisterConsoleVDM)
 {
     NTSTATUS Status;
     PCONSOLE_REGISTERVDM RegisterVDMRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.RegisterVDMRequest;
-    PCONSOLE Console;
+    PCONSRV_CONSOLE Console;
 
     DPRINT1("SrvRegisterConsoleVDM(%d)\n", RegisterVDMRequest->RegisterFlags);