From: Laszlo Ersek <ler...@redhat.com> Reference: <http://rtfm.etla.org/xterm/ctlseq.html> Signed-off-by: Laszlo Ersek <ler...@redhat.com>
Pawel: Updated commit message for re-submission Cc: Jian J Wang <jian.j.w...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Signed-off-by: Paweł Poławski <ppola...@redhat.com> --- MdeModulePkg/MdeModulePkg.dec | 4 +++ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf | 2 ++ MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 30 ++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 7d989108324a..45d793f3fddc 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -2098,6 +2098,10 @@ # @Prompt The shared bit mask when Intel Tdx is enabled. gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0|UINT64|0x10000025 + ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal + # mode change. + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080 + [PcdsPatchableInModule] ## Specify memory size with page number for PEI code when # Loading Module at Fixed Address feature is enabled. diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf index b2a8aeba8510..eff625346539 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf @@ -55,6 +55,7 @@ DebugLib PcdLib BaseLib + PrintLib [Guids] ## SOMETIMES_PRODUCES ## Variable:L"ConInDev" @@ -87,6 +88,7 @@ [Pcd] gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## CONSUMES # [Event] # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout. diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index 7809869e7d49..0ce931d6442b 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include <Library/PrintLib.h> + #include "Terminal.h" // @@ -80,6 +82,16 @@ CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 }; CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 }; +// +// Note that this is an ASCII format string, taking two INT32 arguments: +// rows, columns. +// +// A %d (INT32) format specification can expand to at most 11 characters. +// +CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt"; +#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2)) + + // // Body of the ConOut functions // @@ -498,6 +510,24 @@ TerminalConOutSetMode ( return EFI_DEVICE_ERROR; } + if (PcdGetBool (PcdResizeXterm)) { + CHAR16 ResizeSequence[RESIZE_SEQ_SIZE]; + + UnicodeSPrintAsciiFormat ( + ResizeSequence, + sizeof ResizeSequence, + mResizeTextAreaFormatString, + (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows, + (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns + ); + TerminalDevice->OutputEscChar = TRUE; + Status = This->OutputString (This, ResizeSequence); + TerminalDevice->OutputEscChar = FALSE; + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; + } + } + This->Mode->Mode = (INT32)ModeNumber; Status = This->ClearScreen (This); -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92629): https://edk2.groups.io/g/devel/message/92629 Mute This Topic: https://groups.io/mt/93195499/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-