[CONSRV] Stub out support for terminal-level changing of output code page.

CORE-17601
This commit is contained in:
Hermès Bélusca-Maïto 2021-07-04 00:41:33 +02:00
parent b0e9212a05
commit ac2494994b
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
9 changed files with 64 additions and 8 deletions

View file

@ -424,20 +424,27 @@ ConDrvSetConsoleCP(IN PCONSOLE Console,
IN UINT CodePage,
IN BOOLEAN OutputCP)
{
BOOL Success = TRUE;
if (Console == NULL || !IsValidCodePage(CodePage))
return STATUS_INVALID_PARAMETER;
if (OutputCP)
{
Console->OutputCodePage = CodePage;
Console->IsCJK = IsCJKCodePage(CodePage);
/* Request the terminal to change its code page support */
Success = TermSetCodePage(Console, CodePage);
if (Success)
{
Console->OutputCodePage = CodePage;
Console->IsCJK = IsCJKCodePage(CodePage);
}
}
else
{
Console->InputCodePage = CodePage;
}
return STATUS_SUCCESS;
return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
}
/* EOF */

View file

@ -126,6 +126,13 @@ DummySetPalette(IN OUT PTERMINAL This,
return TRUE;
}
static BOOL NTAPI
DummySetCodePage(IN OUT PTERMINAL This,
UINT CodePage)
{
return TRUE;
}
static INT NTAPI
DummyShowMouseCursor(IN OUT PTERMINAL This,
BOOL Show)
@ -149,6 +156,7 @@ static TERMINAL_VTBL DummyVtbl =
DummyReleaseScreenBuffer,
DummyGetLargestConsoleWindowSize,
DummySetPalette,
DummySetCodePage,
DummyShowMouseCursor,
};

View file

@ -1034,6 +1034,17 @@ GuiSetPalette(IN OUT PFRONTEND This,
return TRUE;
}
static BOOL NTAPI
GuiSetCodePage(IN OUT PFRONTEND This,
UINT CodePage)
{
// TODO: Find a suitable console font for the given code page,
// and set it if found; otherwise fail the call, or fall back
// to some default font...
return TRUE;
}
static ULONG NTAPI
GuiGetDisplayMode(IN OUT PFRONTEND This)
{
@ -1164,6 +1175,7 @@ static FRONTEND_VTBL GuiVtbl =
GuiGetLargestConsoleWindowSize,
GuiGetSelectionInfo,
GuiSetPalette,
GuiSetCodePage,
GuiGetDisplayMode,
GuiSetDisplayMode,
GuiShowMouseCursor,

View file

@ -939,6 +939,14 @@ ConSrvTermSetPalette(IN OUT PTERMINAL This,
return FrontEnd->Vtbl->SetPalette(FrontEnd, PaletteHandle, PaletteUsage);
}
static BOOL NTAPI
ConSrvTermSetCodePage(IN OUT PTERMINAL This,
UINT CodePage)
{
PFRONTEND FrontEnd = This->Context;
return FrontEnd->Vtbl->SetCodePage(FrontEnd, CodePage);
}
static INT NTAPI
ConSrvTermShowMouseCursor(IN OUT PTERMINAL This,
BOOL Show)
@ -963,6 +971,7 @@ static TERMINAL_VTBL ConSrvTermVtbl =
ConSrvTermReleaseScreenBuffer,
ConSrvTermGetLargestConsoleWindowSize,
ConSrvTermSetPalette,
ConSrvTermSetCodePage,
ConSrvTermShowMouseCursor,
};

View file

@ -881,6 +881,17 @@ TuiSetPalette(IN OUT PFRONTEND This,
return TRUE;
}
static BOOL NTAPI
TuiSetCodePage(IN OUT PFRONTEND This,
UINT CodePage)
{
// TODO: Find a suitable console font for the given code page,
// and set it if found; otherwise fail the call, or fall back
// to some default font...
return TRUE;
}
static ULONG NTAPI
TuiGetDisplayMode(IN OUT PFRONTEND This)
{
@ -945,6 +956,7 @@ static FRONTEND_VTBL TuiVtbl =
TuiGetLargestConsoleWindowSize,
TuiGetSelectionInfo,
TuiSetPalette,
TuiSetCodePage,
TuiGetDisplayMode,
TuiSetDisplayMode,
TuiShowMouseCursor,

View file

@ -250,8 +250,10 @@ typedef struct _TERMINAL_VTBL
BOOL (NTAPI *SetPalette)(IN OUT PTERMINAL This,
HPALETTE PaletteHandle,
UINT PaletteUsage);
INT (NTAPI *ShowMouseCursor)(IN OUT PTERMINAL This,
BOOL Show);
BOOL (NTAPI *SetCodePage)(IN OUT PTERMINAL This,
UINT CodePage);
INT (NTAPI *ShowMouseCursor)(IN OUT PTERMINAL This,
BOOL Show);
#if 0 // Possible future terminal interface
BOOL (NTAPI *GetTerminalProperty)(IN OUT PTERMINAL This,

View file

@ -79,6 +79,8 @@ typedef struct _FRONTEND_VTBL
BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
HPALETTE PaletteHandle,
UINT PaletteUsage);
BOOL (NTAPI *SetCodePage)(IN OUT PFRONTEND This,
UINT CodePage);
ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This);
BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This,
ULONG NewMode);

View file

@ -35,6 +35,8 @@
(Console)->TermIFace.Vtbl->GetLargestConsoleWindowSize(&(Console)->TermIFace, (pSize))
#define TermSetPalette(Console, PaletteHandle, PaletteUsage) \
(Console)->TermIFace.Vtbl->SetPalette(&(Console)->TermIFace, (PaletteHandle), (PaletteUsage))
#define TermSetCodePage(Console, CodePage) \
(Console)->TermIFace.Vtbl->SetCodePage(&(Console)->TermIFace, (CodePage))
#define TermShowMouseCursor(Console, Show) \
(Console)->TermIFace.Vtbl->ShowMouseCursor(&(Console)->TermIFace, (Show))

View file

@ -64,11 +64,13 @@ ConSrvApplyUserSettings(
if ((Console->OutputCodePage != ConsoleInfo->CodePage) &&
IsValidCodePage(ConsoleInfo->CodePage))
{
Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
// ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, TRUE); // Output
// ConDrvSetConsoleCP(Console, ConsoleInfo->CodePage, FALSE); // Input
Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
if (TermSetCodePage(Console, ConsoleInfo->CodePage))
{
Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
}
}
// FIXME: Check ConsoleInfo->WindowSize with respect to