https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ac2494994bfe072e6b991…
commit ac2494994bfe072e6b991a8a18fc588c65774255
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 4 00:41:33 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat Jan 15 17:41:34 2022 +0100
[CONSRV] Stub out support for terminal-level changing of output code page.
CORE-17601
---
win32ss/user/winsrv/consrv/condrv/console.c | 13 ++++++++++---
win32ss/user/winsrv/consrv/condrv/dummyterm.c | 8 ++++++++
win32ss/user/winsrv/consrv/frontends/gui/guiterm.c | 12 ++++++++++++
win32ss/user/winsrv/consrv/frontends/terminal.c | 9 +++++++++
win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c | 12 ++++++++++++
win32ss/user/winsrv/consrv/include/conio.h | 6 ++++--
win32ss/user/winsrv/consrv/include/conio_winsrv.h | 2 ++
win32ss/user/winsrv/consrv/include/term.h | 2 ++
win32ss/user/winsrv/consrv/settings.c | 8 +++++---
9 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/win32ss/user/winsrv/consrv/condrv/console.c
b/win32ss/user/winsrv/consrv/condrv/console.c
index 1dd90fb7b2f..fae7beb7de3 100644
--- a/win32ss/user/winsrv/consrv/condrv/console.c
+++ b/win32ss/user/winsrv/consrv/condrv/console.c
@@ -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 */
diff --git a/win32ss/user/winsrv/consrv/condrv/dummyterm.c
b/win32ss/user/winsrv/consrv/condrv/dummyterm.c
index eaeb94561c7..5d9156a2a96 100644
--- a/win32ss/user/winsrv/consrv/condrv/dummyterm.c
+++ b/win32ss/user/winsrv/consrv/condrv/dummyterm.c
@@ -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,
};
diff --git a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
index 96dc93b52b5..778b11073c1 100644
--- a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
+++ b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
@@ -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,
diff --git a/win32ss/user/winsrv/consrv/frontends/terminal.c
b/win32ss/user/winsrv/consrv/frontends/terminal.c
index 24e43ccc0b5..ddf8f75af22 100644
--- a/win32ss/user/winsrv/consrv/frontends/terminal.c
+++ b/win32ss/user/winsrv/consrv/frontends/terminal.c
@@ -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,
};
diff --git a/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
b/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
index fd58595ff69..3bc48c85940 100644
--- a/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
+++ b/win32ss/user/winsrv/consrv/frontends/tui/tuiterm.c
@@ -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,
diff --git a/win32ss/user/winsrv/consrv/include/conio.h
b/win32ss/user/winsrv/consrv/include/conio.h
index 37360b17b11..ead041e51df 100644
--- a/win32ss/user/winsrv/consrv/include/conio.h
+++ b/win32ss/user/winsrv/consrv/include/conio.h
@@ -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,
diff --git a/win32ss/user/winsrv/consrv/include/conio_winsrv.h
b/win32ss/user/winsrv/consrv/include/conio_winsrv.h
index 2f682bd8b2f..0dff19813cb 100644
--- a/win32ss/user/winsrv/consrv/include/conio_winsrv.h
+++ b/win32ss/user/winsrv/consrv/include/conio_winsrv.h
@@ -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);
diff --git a/win32ss/user/winsrv/consrv/include/term.h
b/win32ss/user/winsrv/consrv/include/term.h
index 2766ec89068..6137d3742bb 100644
--- a/win32ss/user/winsrv/consrv/include/term.h
+++ b/win32ss/user/winsrv/consrv/include/term.h
@@ -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))
diff --git a/win32ss/user/winsrv/consrv/settings.c
b/win32ss/user/winsrv/consrv/settings.c
index b0cef35638c..22cccc2d81c 100644
--- a/win32ss/user/winsrv/consrv/settings.c
+++ b/win32ss/user/winsrv/consrv/settings.c
@@ -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