From 2909e025db6878723b49644a8a0cf160d07e6444 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 25 Feb 2014 22:40:01 +0100 Subject: MdeModulePkg: TerminalDxe: set xterm resolution on mode change (RH only) The CSI Ps ; Ps ; Ps t escape sequence serves for window manipulation. We can use the CSI 8 ; ; t sequence to adapt eg. the xterm window size to the selected console mode. Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - refresh commit 519b9751573e against various context changes Reference: Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- MdeModulePkg/MdeModulePkg.dec | 4 +++ .../Universal/Console/TerminalDxe/TerminalConOut.c | 30 ++++++++++++++++++++++ .../Universal/Console/TerminalDxe/TerminalDxe.inf | 2 ++ 3 files changed, 36 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 426634f..b4a7c3a 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1702,6 +1702,10 @@ # @Prompt A list of system FMP ImageTypeId GUIDs gEfiMdeModulePkgTokenSpaceGuid.PcdSystemFmpCapsuleImageTypeIdGuid|{0x0}|VOID*|0x30001046 + ## 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/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index e677a76..e2bdc31 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ +#include + #include "Terminal.h" // @@ -87,6 +89,16 @@ 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 // @@ -508,6 +520,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); diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf index 0780296..bd2ba82 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf @@ -60,6 +60,7 @@ DebugLib PcdLib BaseLib + PrintLib [Guids] ## SOMETIMES_PRODUCES ## Variable:L"ConInDev" @@ -88,6 +89,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. -- 1.8.3.1