From nobody Thu May 16 01:29:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+81153+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81153+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1632726617; cv=none; d=zohomail.com; s=zohoarc; b=kSHtoY6eKrsk3H9IdEkrqK0M4Kh6rInyyWUK8NPJ7C251/kIsYintNlxRulXLlKghI+noFr54jkoHTKVfT//pDR03iqEgoLPt3KMWV/27tp2ghVtgYMSDOo27SLTJ3vUQo1+i/50c1x1ay0va+Rm2MWjNIfKpQlASStd3M9TlZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632726617; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=HY+Fs32Eq92tjsNCCBcdSwWTXRunJVu5RyHgh54/bnk=; b=NAqv9SjAllQTd9JtMmIk8fITRPDU90ozTf9nOuXws1zD3xWbRHLfQJeq5AIsaR/BfW8Ma9Q6VG4il00sJN+OH0+jhMcwFj2/8TpFZ0B9uyCyrxO/PzKqTBrBUyU98xPHYZtJ/En3MANFd8ovf76qV8FuVmG58JSbgpfbmLzLYMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81153+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1632726617193332.4981084929826; Mon, 27 Sep 2021 00:10:17 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dxsuYY1788612xqw5eI6Z8mN; Mon, 27 Sep 2021 00:10:16 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.27825.1632726615025878932 for ; Mon, 27 Sep 2021 00:10:15 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10119"; a="222531250" X-IronPort-AV: E=Sophos;i="5.85,325,1624345200"; d="scan'208";a="222531250" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 00:10:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,325,1624345200"; d="scan'208";a="553053602" X-Received: from gaozhic-desk.ccr.corp.intel.com ([10.239.137.133]) by FMSMGA003.fm.intel.com with ESMTP; 27 Sep 2021 00:10:10 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH V3] MdeModulePkg/BootManagerMenuApp: Limit string drawing within one line Date: Mon, 27 Sep 2021 15:10:08 +0800 Message-Id: <20210927071008.3297-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com X-Gm-Message-State: t6RDsBQFcN3sGy32ytLqcajUx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632726616; bh=6sT/zdCmc5SZPIYc598BjfLRhU0IIaPb9u7zMkgGcUg=; h=Cc:Date:From:Reply-To:Subject:To; b=Swpks3n3irv2zoWsTqyUhPZJudNMGTcVdk47Lxt2j6RmhkRQJiKtaeaih2KAG2mWtxU PStjiPBJ29rqQePtmFPlYih7Cp+eHed1cuwUaS+8YfuBinFV7Wdt0mlLQBl9URwsm1TD0 PhsGT7FHYiCPHO3Y9ng/kd29NGOJkLo0uwI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632726618574100001 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3590 Limit the draw box always within the screen's column and row. Limit the string drawing within one line. For the incompleted string the last 3 characters in one line would be replaced with "...". Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Signed-off-by: Zhichao Gao Reviewed-by: Ray Ni --- V2: Drop the change in UefiBootManagerLib in V1. Add the limitation in BootManagerMenuApp instead. V3: Update the commit message only. .../BootManagerMenuApp/BootManagerMenu.c | 72 ++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c = b/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c index 9e729074ec..d4bdeba073 100644 --- a/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c +++ b/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c @@ -1,7 +1,7 @@ /** @file The application to show the Boot Manager Menu. =20 -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -45,9 +45,56 @@ PrintStringAt ( IN CHAR16 *String ) { + UINTN ScreenWidth; + UINTN ScreenRows; + CHAR16 *TurncateString; + EFI_STATUS Status; + UINTN ShowingLength; =20 gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row); - return Print (L"%s", String); + + gST->ConOut->QueryMode ( + gST->ConOut, + gST->ConOut->Mode->Mode, + &ScreenWidth, + &ScreenRows + ); + + if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) { + return 0; + } + + if ((StrLen (String) + Column) > (ScreenWidth - 1)) { + // + // | - ScreenWidth - | + // ...Column..................... + // TurncateString length should leave one character for draw box and + // require one character for string end. + // + ShowingLength =3D ScreenWidth - Column - 1; + TurncateString =3D AllocatePool ((ShowingLength + 1) * sizeof (CHAR16)= ); + + if (TurncateString =3D=3D NULL) { + return 0; + } + + Status =3D StrnCpyS (TurncateString, ShowingLength + 1, String, Showin= gLength - 3); + + if (EFI_ERROR (Status)) { + FreePool (TurncateString); + return 0; + } + + *(TurncateString + ShowingLength - 3) =3D L'.'; + *(TurncateString + ShowingLength - 2) =3D L'.'; + *(TurncateString + ShowingLength - 1) =3D L'.'; + *(TurncateString + ShowingLength) =3D L'\0'; + ShowingLength =3D Print (L"%s", TurncateString); + FreePool (TurncateString); + return ShowingLength; + } else { + return Print (L"%s", String); + } } =20 /** @@ -68,7 +115,22 @@ PrintCharAt ( CHAR16 Character ) { + UINTN ScreenWidth; + UINTN ScreenRows; + gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row); + + gST->ConOut->QueryMode ( + gST->ConOut, + gST->ConOut->Mode->Mode, + &ScreenWidth, + &ScreenRows + ); + + if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) { + return 0; + } + return Print (L"%c", Character); } =20 @@ -193,7 +255,11 @@ InitializeBootMenuScreen ( =20 MaxPrintRows =3D Row - 6; UnSelectableItmes =3D TITLE_TOKEN_COUNT + 2 + HELP_TOKEN_COUNT + 2; - BootMenuData->MenuScreen.Width =3D MaxStrWidth + 8; + if (MaxStrWidth + 8 > Column) { + BootMenuData->MenuScreen.Width =3D Column; + } else { + BootMenuData->MenuScreen.Width =3D MaxStrWidth + 8; + } if (BootMenuData->ItemCount + UnSelectableItmes > MaxPrintRows) { BootMenuData->MenuScreen.Height =3D MaxPrintRows; BootMenuData->ScrollBarControl.HasScrollBar =3D TRUE; --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#81153): https://edk2.groups.io/g/devel/message/81153 Mute This Topic: https://groups.io/mt/85895022/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-