* PROGRAMMERS: Gé van Geldorp
* Jeffrey Morlan
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
+ * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
/* INCLUDES *******************************************************************/
#include <consrv.h>
-
#include <coninput.h>
+#include "../../concfg/font.h"
#define NDEBUG
#include <debug.h>
-
/* GLOBALS ********************************************************************/
static ULONG CurrentConsoleID = 0;
/* Linked list of consoles */
-static LIST_ENTRY ConsoleList;
+static LIST_ENTRY ConDrvConsoleList;
static RTL_RESOURCE ListLock;
#define ConDrvLockConsoleListExclusive() \
static NTSTATUS
-InsertConsole(IN PCONSOLE Console)
+ConDrvInsertConsole(IN PCONSOLE Console)
{
ASSERT(Console);
/* All went right, so add the console to the list */
ConDrvLockConsoleListExclusive();
- DPRINT1("Insert in the list\n");
- InsertTailList(&ConsoleList, &Console->ListEntry);
+ DPRINT("Insert in the list\n");
+ InsertTailList(&ConDrvConsoleList, &Console->ListEntry);
// FIXME: Move this code to the caller function!!
/* Get a new console ID */
VOID NTAPI
ConDrvPause(PCONSOLE Console)
{
- if (!Console->UnpauseEvent)
- Console->UnpauseEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ /* In case we already have a pause event, just exit... */
+ if (Console->UnpauseEvent) return;
+
+ /* ... otherwise create it */
+ NtCreateEvent(&Console->UnpauseEvent, EVENT_ALL_ACCESS,
+ NULL, NotificationEvent, FALSE);
}
VOID NTAPI
ConDrvUnpause(PCONSOLE Console)
{
- if (Console->UnpauseEvent)
- {
- SetEvent(Console->UnpauseEvent);
- CloseHandle(Console->UnpauseEvent);
- Console->UnpauseEvent = NULL;
- }
+ /* In case we already freed the event, just exit... */
+ if (!Console->UnpauseEvent) return;
+
+ /* ... otherwise set and free it */
+ NtSetEvent(Console->UnpauseEvent, NULL);
+ NtClose(Console->UnpauseEvent);
+ Console->UnpauseEvent = NULL;
}
DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
/* Initialize the console list and its lock */
- InitializeListHead(&ConsoleList);
+ InitializeListHead(&ConDrvConsoleList);
RtlInitializeResource(&ListLock);
-
- /* Should call LoadKeyboardLayout */
}
/* For resetting the terminal - defined in dummyterm.c */
}
/*
- * Fix the screen buffer size if needed. The rule is:
- * ScreenBufferSize >= ConsoleSize
+ * Set and fix the screen buffer size if needed.
+ * The rule is: ScreenBufferSize >= ConsoleSize
*/
+ if (ConsoleInfo->ScreenBufferSize.X == 0) ConsoleInfo->ScreenBufferSize.X = 1;
+ if (ConsoleInfo->ScreenBufferSize.Y == 0) ConsoleInfo->ScreenBufferSize.Y = 1;
if (ConsoleInfo->ScreenBufferSize.X < ConsoleInfo->ConsoleSize.X)
ConsoleInfo->ScreenBufferSize.X = ConsoleInfo->ConsoleSize.X;
if (ConsoleInfo->ScreenBufferSize.Y < ConsoleInfo->ConsoleSize.Y)
}
/* Set-up the code page */
- Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
+ if (IsValidCodePage(ConsoleInfo->CodePage))
+ Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
+
+ Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
/* Initialize a new text-mode screen buffer with default settings */
ScreenBufferInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize;
+ ScreenBufferInfo.ViewSize = ConsoleInfo->ConsoleSize;
ScreenBufferInfo.ScreenAttrib = ConsoleInfo->ScreenAttrib;
ScreenBufferInfo.PopupAttrib = ConsoleInfo->PopupAttrib;
- ScreenBufferInfo.IsCursorVisible = TRUE;
ScreenBufferInfo.CursorSize = ConsoleInfo->CursorSize;
+ ScreenBufferInfo.IsCursorVisible = TRUE;
InitializeListHead(&Console->BufferList);
Status = ConDrvCreateScreenBuffer(&NewBuffer,
Console,
+ NULL,
CONSOLE_TEXTMODE_BUFFER,
&ScreenBufferInfo);
if (!NT_SUCCESS(Status))
DPRINT("Console initialized\n");
/* All went right, so add the console to the list */
- Status = InsertConsole(Console);
+ Status = ConDrvInsertConsole(Console);
if (!NT_SUCCESS(Status))
{
/* Fail */
}
NTSTATUS NTAPI
-ConDrvRegisterTerminal(IN PCONSOLE Console,
- IN PTERMINAL Terminal)
+ConDrvAttachTerminal(IN PCONSOLE Console,
+ IN PTERMINAL Terminal)
{
NTSTATUS Status;
/* We failed, detach the terminal from the console */
Terminal->Console = NULL; // For the caller
ResetTerminal(Console);
-
return Status;
}
/* Copy buffer contents to screen */
// Terminal.Draw();
- // ConioDrawConsole(Console);
- DPRINT("Console drawn\n");
DPRINT("Terminal initialization done\n");
return STATUS_SUCCESS;
}
NTSTATUS NTAPI
-ConDrvDeregisterTerminal(IN PCONSOLE Console)
+ConDrvDetachTerminal(IN PCONSOLE Console)
{
if (Console == NULL) return STATUS_INVALID_PARAMETER;
LeaveCriticalSection(&Console->Lock);
ConDrvUnlockConsoleList();
- /* FIXME: Send a terminate message to all the processes owning this console */
-
/* Deregister the terminal */
DPRINT("Deregister terminal\n");
- ConDrvDeregisterTerminal(Console);
+ ConDrvDetachTerminal(Console);
DPRINT("Terminal deregistered\n");
/***
/* Deinitialize the input buffer */
ConDrvDeinitInputBuffer(Console);
- if (Console->UnpauseEvent) CloseHandle(Console->UnpauseEvent);
+ if (Console->UnpauseEvent) NtClose(Console->UnpauseEvent);
DPRINT("ConDrvDeleteConsole - Unlocking\n");
LeaveCriticalSection(&Console->Lock);
return STATUS_INVALID_PARAMETER;
if (OutputCP)
+ {
Console->OutputCodePage = CodePage;
+ Console->IsCJK = IsCJKCodePage(CodePage);
+ }
else
+ {
Console->InputCodePage = CodePage;
+ }
return STATUS_SUCCESS;
}