public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: devel@edk2.groups.io, ppolawsk@redhat.com
Cc: Jian J Wang <jian.j.wang@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>
Subject: Re: [edk2-devel] PATCH v3 1/3 MdeModulePkg: TerminalDxe: set xterm resolution on mode change
Date: Tue, 4 Apr 2023 17:12:11 +0200	[thread overview]
Message-ID: <CAMj1kXFxMj5LmcvKajngSY15KDaNyL14PoarLF7pAto7iGqELQ@mail.gmail.com> (raw)
In-Reply-To: <a131bbc9ce39f299e264d2b697003cc91a8e7aa4.1675733286.git.ppolawsk@redhat.com>

On Fri, 17 Feb 2023 at 14:02, Paweł Poławski <ppolawsk@redhat.com> wrote:
>
> From: Laszlo Ersek <lersek@redhat.com>
>
> TerminalDxe driver can send xterm control sequences.
> Reference: <http://rtfm.etla.org/xterm/ctlseq.html>
>
> This way it can trigger client window resize (xterm,
> gnome-terminal etc.) accordingly, to a specified number
> of rows and columns. It improves user experience
> when handling text mode based operations.
>
> New PcdResizeXterm config switch has been added to enable
> or disable this behaviour.
>
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>
> Pawel Polawski: Updated commit message for re-submission
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>
> Signed-off-by: Paweł Poławski <ppolawsk@redhat.com>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  MdeModulePkg/MdeModulePkg.dec                               |  4 +++
>  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf  |  2 ++
>  MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c | 29 ++++++++++++++++++++
>  3 files changed, 35 insertions(+)
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index 9605c617b7a8..76007e0af42a 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -2107,6 +2107,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>    # @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 @@ [LibraryClasses]
>    DebugLib
>    PcdLib
>    BaseLib
> +  PrintLib
>
>  [Guids]
>    ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
> @@ -87,6 +88,7 @@ [Protocols]
>  [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..496849458db4 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,15 @@ 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 +509,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.39.1
>
>
>
> 
>
>

  reply	other threads:[~2023-04-04 15:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 13:01 [edk2-devel] PATCH v3 0/3 Add xterm resize support to OVMF Paweł Poławski
2023-02-17 13:01 ` [edk2-devel] PATCH v3 1/3 MdeModulePkg: TerminalDxe: set xterm resolution on mode change Paweł Poławski
2023-04-04 15:12   ` Ard Biesheuvel [this message]
2023-02-17 13:01 ` [edk2-devel] PATCH v3 2/3 ArmVirtPkg: take PcdResizeXterm from the QEMU command line Paweł Poławski
2023-02-17 13:01 ` [edk2-devel] PATCH v3 3/3 OvmfPkg: " Paweł Poławski
     [not found] ` <17449E3B102C52E2.23192@groups.io>
2023-03-07 12:47   ` [edk2-devel] PATCH v3 1/3 MdeModulePkg: TerminalDxe: set xterm resolution on mode change Paweł Poławski
2023-03-10  2:31 ` 回复: [edk2-devel] PATCH v3 0/3 Add xterm resize support to OVMF gaoliming
2023-03-24 13:57   ` Paweł Poławski
     [not found] ` <17449E3BBCD94462.23192@groups.io>
2023-03-24 13:59   ` [edk2-devel] PATCH v3 3/3 OvmfPkg: take PcdResizeXterm from the QEMU command line Paweł Poławski
     [not found] ` <17449E3B887C4E80.23192@groups.io>
2023-03-24 14:00   ` [edk2-devel] PATCH v3 2/3 ArmVirtPkg: " Paweł Poławski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMj1kXFxMj5LmcvKajngSY15KDaNyL14PoarLF7pAto7iGqELQ@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox