[PATCH 1/1] MdeModulePkg/Console: Improve encoding of box drawing characters


Caden Kline
 

Improved encoding of box drawing characters for different terminal types.
This includes Dec special graphics mode and more utf8.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Caden Kline <cadenkline9@gmail.com>
---
.../Universal/Console/TerminalDxe/Terminal.h | 24 +-
.../Universal/Console/TerminalDxe/Ansi.c | 2 +-
.../Console/TerminalDxe/TerminalConOut.c | 322 ++++++++++++++----
3 files changed, 269 insertions(+), 79 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeMod=
ulePkg/Universal/Console/TerminalDxe/Terminal.h
index 360e58e84743..83c3ea94a042 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -122,7 +122,10 @@ typedef struct {
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleInputEx;=0D
LIST_ENTRY NotifyList;=0D
EFI_EVENT KeyNotifyProcessEvent;=0D
+ BOOLEAN DecSpecialGraphicsMode;=0D
} TERMINAL_DEV;=0D
+// This the lenth the escape squences for entering and exiting Dec Special=
Graphics Mode=0D
+#define LENGTH_DEC_ESCAPE 0x03=0D
=0D
#define INPUT_STATE_DEFAULT 0x00=0D
#define INPUT_STATE_ESC 0x01=0D
@@ -169,6 +172,7 @@ typedef struct {
UINT16 Unicode;=0D
CHAR8 PcAnsi;=0D
CHAR8 Ascii;=0D
+ CHAR8 DecSpecialGraphics;=0D
} UNICODE_TO_CHAR;=0D
=0D
//=0D
@@ -1367,20 +1371,22 @@ Utf8ToUnicode (
/**=0D
Detects if a Unicode char is for Box Drawing text graphics.=0D
=0D
- @param Graphic Unicode char to test.=0D
- @param PcAnsi Optional pointer to return PCANSI equivalent of=0D
- Graphic.=0D
- @param Ascii Optional pointer to return ASCII equivalent of=0D
- Graphic.=0D
-=0D
- @retval TRUE If Graphic is a supported Unicode Box Drawing chara=
cter.=0D
+ @param Graphic Unicode char to test.=0D
+ @param PcAnsi Optional pointer to return PCANSI equivalent=
of=0D
+ Graphic.=0D
+ @param Ascii Optional pointer to return ASCII equivalent =
of=0D
+ Graphic.=0D
+ @param DecSpecialGraphics Optional pointer to return Dec Special Graph=
ics equivalent of=0D
+ Graphic.=0D
+ @retval TRUE If Graphic is a supported Unicode Box Drawin=
g character.=0D
=0D
**/=0D
BOOLEAN=0D
TerminalIsValidTextGraphics (=0D
IN CHAR16 Graphic,=0D
- OUT CHAR8 *PcAnsi, OPTIONAL=0D
- OUT CHAR8 *Ascii OPTIONAL=0D
+ OUT CHAR8 *PcAnsi, OPTIONAL=0D
+ OUT CHAR8 *Ascii, OPTIONAL=0D
+ OUT CHAR8 *DecSpecialGraphics OPTIONAL=0D
);=0D
=0D
/**=0D
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c b/MdeModuleP=
kg/Universal/Console/TerminalDxe/Ansi.c
index f117d90b9de3..5ae5a4f0212e 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Ansi.c
@@ -63,7 +63,7 @@ AnsiTestString (
=0D
if ( !(TerminalIsValidAscii (*WString) ||=0D
TerminalIsValidEfiCntlChar (*WString) ||=0D
- TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL) )) {=0D
+ TerminalIsValidTextGraphics (*WString, &GraphicChar, NULL, NULL) )=
) {=0D
=0D
return EFI_UNSUPPORTED;=0D
}=0D
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/=
MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
index aae470e9562c..1c22ed426715 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c
@@ -16,61 +16,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//=0D
//=0D
UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] =3D {=0D
- { BOXDRAW_HORIZONTAL, 0xc4, L'-' },=0D
- { BOXDRAW_VERTICAL, 0xb3, L'|' },=0D
- { BOXDRAW_DOWN_RIGHT, 0xda, L'/' },=0D
- { BOXDRAW_DOWN_LEFT, 0xbf, L'\\' },=0D
- { BOXDRAW_UP_RIGHT, 0xc0, L'\\' },=0D
- { BOXDRAW_UP_LEFT, 0xd9, L'/' },=0D
- { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|' },=0D
- { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|' },=0D
- { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+' },=0D
- { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+' },=0D
- { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+' },=0D
- { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-' },=0D
- { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|' },=0D
- { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/' },=0D
- { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/' },=0D
- { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/' },=0D
- { BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\' },=0D
- { BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\' },=0D
- { BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\' },=0D
- { BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\' },=0D
- { BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\' },=0D
- { BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\' },=0D
- { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/' },=0D
- { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/' },=0D
- { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/' },=0D
- { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|' },=0D
- { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|' },=0D
- { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|' },=0D
- { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|' },=0D
- { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|' },=0D
- { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|' },=0D
- { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+' },=0D
- { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+' },=0D
- { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+' },=0D
- { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+' },=0D
- { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+' },=0D
- { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+' },=0D
- { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+' },=0D
- { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+' },=0D
- { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+' },=0D
+ { BOXDRAW_HORIZONTAL, 0xc4, L'-', 0x71 },=0D
+ { BOXDRAW_VERTICAL, 0xb3, L'|', 0x78 },=0D
+ { BOXDRAW_DOWN_RIGHT, 0xda, L'/', 0x6c },=0D
+ { BOXDRAW_DOWN_LEFT, 0xbf, L'\\', 0x6b },=0D
+ { BOXDRAW_UP_RIGHT, 0xc0, L'\\', 0x6d },=0D
+ { BOXDRAW_UP_LEFT, 0xd9, L'/', 0x6a },=0D
+ { BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|', 0x74 },=0D
+ { BOXDRAW_VERTICAL_LEFT, 0xb4, L'|', 0x75 },=0D
+ { BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+', 0x77 },=0D
+ { BOXDRAW_UP_HORIZONTAL, 0xc1, L'+', 0x76 },=0D
+ { BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+', 0x6e },=0D
+ { BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-', 0x71 },=0D
+ { BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|', 0x78 },=0D
+ { BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/', 0x6c },=0D
+ { BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/', 0x6c },=0D
+ { BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/', 0x6c },=0D
+ { BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\', 0x6b },=0D
+ { BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\', 0x6b },=0D
+ { BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\', 0x6b },=0D
+ { BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\', 0x6d },=0D
+ { BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\', 0x6d },=0D
+ { BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\', 0x6d },=0D
+ { BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/', 0x6a },=0D
+ { BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/', 0x6a },=0D
+ { BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/', 0x6a },=0D
+ { BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|', 0x74 },=0D
+ { BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|', 0x74 },=0D
+ { BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|', 0x74 },=0D
+ { BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|', 0x75 },=0D
+ { BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|', 0x75 },=0D
+ { BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|', 0x75 },=0D
+ { BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+', 0x77 },=0D
+ { BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+', 0x77 },=0D
+ { BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+', 0x77 },=0D
+ { BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+', 0x76 },=0D
+ { BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+', 0x76 },=0D
+ { BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+', 0x76 },=0D
+ { BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+', 0x6e },=0D
+ { BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+', 0x6e },=0D
+ { BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+', 0x6e },=0D
=0D
- { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*' },=0D
- { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+' },=0D
+ { BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*', 0x61 },=0D
+ { BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+', 0x61 },=0D
=0D
- { GEOMETRICSHAPE_UP_TRIANGLE, '^', L'^' },=0D
- { GEOMETRICSHAPE_RIGHT_TRIANGLE, '>', L'>' },=0D
- { GEOMETRICSHAPE_DOWN_TRIANGLE, 'v', L'v' },=0D
- { GEOMETRICSHAPE_LEFT_TRIANGLE, '<', L'<' },=0D
+ { GEOMETRICSHAPE_UP_TRIANGLE, '^', L'^', L'^' },=0D
+ { GEOMETRICSHAPE_RIGHT_TRIANGLE, '>', L'>', L'>' },=0D
+ { GEOMETRICSHAPE_DOWN_TRIANGLE, 'v', L'v', L'v' },=0D
+ { GEOMETRICSHAPE_LEFT_TRIANGLE, '<', L'<', L'<' },=0D
=0D
- { ARROW_LEFT, '<', L'<' },=0D
- { ARROW_UP, '^', L'^' },=0D
- { ARROW_RIGHT, '>', L'>' },=0D
- { ARROW_DOWN, 'v', L'v' },=0D
-=0D
- { 0x0000, 0x00, L'\0' }=0D
+ { ARROW_LEFT, '<', L'<', L'<' },=0D
+ { ARROW_UP, '^', L'^', L'^' },=0D
+ { ARROW_RIGHT, '>', L'>', L'>' },=0D
+ { ARROW_DOWN, 'v', L'v', L'v' },=0D
};=0D
=0D
CHAR16 mSetModeString[] =3D { ESC, '[', '=3D', '3', 'h', 0 };=0D
@@ -80,6 +78,8 @@ CHAR16 mSetCursorPositionString[] =3D { ESC, '[', '0', '=
0', ';', '0', '0', 'H', 0
CHAR16 mCursorForwardString[] =3D { ESC, '[', '0', '0', 'C', 0 };=0D
CHAR16 mCursorBackwardString[] =3D { ESC, '[', '0', '0', 'D', 0 };=0D
=0D
+CHAR8 SetDecModeString[] =3D {ESC, 0x28, 0x30};=0D
+CHAR8 ExitDecModeString[] =3D {ESC, 0x28, 0x42};=0D
//=0D
// Body of the ConOut functions=0D
//=0D
@@ -183,16 +183,19 @@ TerminalConOutOutputString (
EFI_STATUS Status;=0D
UINT8 ValidBytes;=0D
CHAR8 CrLfStr[2];=0D
+ CHAR8 DecChar;=0D
+ UINTN ModeSwitchLength;=0D
//=0D
// flag used to indicate whether condition happens which will cause=0D
// return EFI_WARN_UNKNOWN_GLYPH=0D
//=0D
BOOLEAN Warning;=0D
=0D
- ValidBytes =3D 0;=0D
- Warning =3D FALSE;=0D
- AsciiChar =3D 0;=0D
-=0D
+ ValidBytes =3D 0;=0D
+ Warning =3D FALSE;=0D
+ AsciiChar =3D 0;=0D
+ DecChar =3D 0;=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
//=0D
// get Terminal device data structure pointer.=0D
//=0D
@@ -217,17 +220,136 @@ TerminalConOutOutputString (
for (; *WString !=3D CHAR_NULL; WString++) {=0D
=0D
switch (TerminalDevice->TerminalType) {=0D
-=0D
case TerminalTypePcAnsi:=0D
- case TerminalTypeVt100:=0D
- case TerminalTypeVt100Plus:=0D
- case TerminalTypeTtyTerm:=0D
- case TerminalTypeLinux:=0D
+ if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar=
, NULL)) {=0D
+ //=0D
+ // If it's not a graphic character convert Unicode to ASCII.=0D
+ //=0D
+ GraphicChar =3D (CHAR8)*WString;=0D
+=0D
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntl=
Char (GraphicChar))) {=0D
+ //=0D
+ // when this driver use the OutputString to output control strin=
g,=0D
+ // TerminalDevice->OutputEscChar is set to let the Esc char=0D
+ // to be output to the terminal emulation software.=0D
+ //=0D
+ if ((GraphicChar =3D=3D 27) && TerminalDevice->OutputEscChar) {=
=0D
+ GraphicChar =3D 27;=0D
+ } else {=0D
+ GraphicChar =3D '?';=0D
+ Warning =3D TRUE;=0D
+ }=0D
+ }=0D
+=0D
+ AsciiChar =3D GraphicChar;=0D
+ }=0D
+ Length =3D 1;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ &GraphicChar=0D
+ );=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ break;=0D
case TerminalTypeXtermR6:=0D
- case TerminalTypeVt400:=0D
case TerminalTypeSCO:=0D
+ if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar) &=
& !TerminalIsValidAscii (*WString)) {=0D
+ //Box graphics are split into 2 types simple and advanced=0D
+ //simple are drawn with dec special graphics=0D
+ //advanced are drawn with utf8=0D
+ //This checks for simple because they have a lower value than th=
e advanced=0D
+ if(*WString < BOXDRAW_DOUBLE_HORIZONTAL) {=0D
+ if (!TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ValidBytes =3D 0;=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialI=
o,=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)SetDecModeStri=
ng=0D
+ );=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D TRUE;=0D
+ }=0D
=0D
- if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar=
)) {=0D
+ GraphicChar =3D DecChar;=0D
+ Length =3D 1;=0D
+ } else {=0D
+ if (TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialI=
o,=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)ExitDecModeStr=
ing=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D FALSE;=0D
+ }=0D
+=0D
+ UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);=0D
+ Length =3D ValidBytes;=0D
+ }=0D
+ } else {=0D
+ if (TerminalDevice->DecSpecialGraphicsMode) {=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)ExitDecModeString=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D FALSE;=0D
+ }=0D
+=0D
+ GraphicChar =3D (CHAR8)*WString;=0D
+=0D
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntl=
Char (GraphicChar))) {=0D
+ //=0D
+ // when this driver use the OutputString to output control strin=
g,=0D
+ // TerminalDevice->OutputEscChar is set to let the Esc char=0D
+ // to be output to the terminal emulation software.=0D
+ //=0D
+ if ((GraphicChar =3D=3D 27) && TerminalDevice->OutputEscChar) =
{=0D
+ GraphicChar =3D 27;=0D
+ Length =3D 1;=0D
+ } else {=0D
+ UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);=0D
+ Length =3D ValidBytes;=0D
+ }=0D
+ } else {=0D
+ Length =3D 1;=0D
+ }=0D
+ }=0D
+=0D
+ if (ValidBytes) {=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ (UINT8 *)&Utf8Char=0D
+ );=0D
+ ValidBytes =3D 0;=0D
+ } else {=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ &GraphicChar=0D
+ );=0D
+ }=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ break;=0D
+ case TerminalTypeVt100:=0D
+ case TerminalTypeTtyTerm:=0D
+ if (!TerminalIsValidTextGraphics (*WString, &GraphicChar, &AsciiChar=
, NULL)) {=0D
//=0D
// If it's not a graphic character convert Unicode to ASCII.=0D
//=0D
@@ -248,12 +370,9 @@ TerminalConOutOutputString (
}=0D
=0D
AsciiChar =3D GraphicChar;=0D
-=0D
}=0D
=0D
- if (TerminalDevice->TerminalType !=3D TerminalTypePcAnsi) {=0D
- GraphicChar =3D AsciiChar;=0D
- }=0D
+ GraphicChar =3D AsciiChar;=0D
=0D
Length =3D 1;=0D
=0D
@@ -267,8 +386,67 @@ TerminalConOutOutputString (
goto OutputError;=0D
}=0D
=0D
- break;=0D
+ break;=0D
+ case TerminalTypeVt100Plus:=0D
+ case TerminalTypeVt400:=0D
+ Length =3D 1;=0D
+ if (TerminalIsValidTextGraphics (*WString, NULL, NULL, &DecChar)) =
{=0D
+ if (!TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=
=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)SetDecModeString=
=0D
+ );=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D TRUE;=0D
+ }=0D
=0D
+ GraphicChar =3D DecChar;=0D
+ } else {=0D
+ if (TerminalDevice->DecSpecialGraphicsMode) {=0D
+ ModeSwitchLength =3D LENGTH_DEC_ESCAPE;=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=
=0D
+ &ModeSwitchLength,=0D
+ (UINT8 *)ExitDecModeStrin=
g=0D
+ );=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ TerminalDevice->DecSpecialGraphicsMode =3D FALSE;=0D
+ }=0D
+=0D
+ GraphicChar =3D (CHAR8)*WString;=0D
+=0D
+ if (!(TerminalIsValidAscii (GraphicChar) || TerminalIsValidEfiCntl=
Char (GraphicChar))) {=0D
+ //=0D
+ // when this driver use the OutputString to output control strin=
g,=0D
+ // TerminalDevice->OutputEscChar is set to let the Esc char=0D
+ // to be output to the terminal emulation software.=0D
+ //=0D
+ if ((GraphicChar =3D=3D 27) && TerminalDevice->OutputEscChar) {=
=0D
+ GraphicChar =3D 27;=0D
+ } else {=0D
+ GraphicChar =3D '?';=0D
+ Warning =3D TRUE;=0D
+ }=0D
+ }=0D
+ }=0D
+=0D
+ Status =3D TerminalDevice->SerialIo->Write (=0D
+ TerminalDevice->SerialIo,=0D
+ &Length,=0D
+ &GraphicChar=0D
+ );=0D
+=0D
+ if (EFI_ERROR (Status)) {=0D
+ goto OutputError;=0D
+ }=0D
+=0D
+ break;=0D
+ case TerminalTypeLinux:=0D
case TerminalTypeVtUtf8:=0D
UnicodeToUtf8 (*WString, &Utf8Char, &ValidBytes);=0D
Length =3D ValidBytes;=0D
@@ -280,8 +458,10 @@ TerminalConOutOutputString (
if (EFI_ERROR (Status)) {=0D
goto OutputError;=0D
}=0D
+=0D
break;=0D
}=0D
+=0D
//=0D
// Update cursor position.=0D
//=0D
@@ -875,7 +1055,8 @@ BOOLEAN
TerminalIsValidTextGraphics (=0D
IN CHAR16 Graphic,=0D
OUT CHAR8 *PcAnsi, OPTIONAL=0D
- OUT CHAR8 *Ascii OPTIONAL=0D
+ OUT CHAR8 *Ascii, OPTIONAL=0D
+ OUT CHAR8 *DecSpecialGraphics OPTIONAL=0D
)=0D
{=0D
UNICODE_TO_CHAR *Table;=0D
@@ -897,6 +1078,9 @@ TerminalIsValidTextGraphics (
if (Ascii !=3D NULL) {=0D
*Ascii =3D Table->Ascii;=0D
}=0D
+ if (DecSpecialGraphics !=3D NULL){=0D
+ *DecSpecialGraphics =3D Table->DecSpecialGraphics;=0D
+ }=0D
=0D
return TRUE;=0D
}=0D
--=20
2.32.0

Join devel@edk2.groups.io to automatically receive all group messages.