From nobody Thu Mar 28 22:10:46 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+80406+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+80406+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1631172349; cv=none; d=zohomail.com; s=zohoarc; b=KR2wUo8WYaosG/xmyIx5Qy0Mw7EWhmXqiWeL8jIPl8J+2JWXVilNijwHztr0zhxPFwKHSoHcqwwslORxnjGX+5yg5WVVe2QVH/ivPcBzYViZ5sadSsmyA6mDbOA7/ja6Cxmm2Ph6sYfa15rZvsoCwcgX6m+yuqbozC6CBfVvQyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631172349; 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=wZWlY6JpAwnHE0IEW2Fwo35Uec/k5GNvNexIM+l9ltA=; b=HlUvR5klI8k5cslsAIZ7GbJfkSG1ktWiL+3yNNxWWocnDH4S6dt7U9vK3NZucoocRbf2s6s7g4AflE5ZEJLjAGSLKDe0CxNQu0ljbMz/cO8rqCn6DvFiiULPWSlt9oEvXsKugeVt8tIyKCtZYdb/wA9CPFmFDZ2xUafBwA8bMH0= 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+80406+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 1631172349763367.2209554222709; Thu, 9 Sep 2021 00:25:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IKRWYY1788612xtUVpcJmD5X; Thu, 09 Sep 2021 00:25:49 -0700 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.4292.1631172347486629469 for ; Thu, 09 Sep 2021 00:25:48 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="217549672" X-IronPort-AV: E=Sophos;i="5.85,279,1624345200"; d="scan'208";a="217549672" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 00:25:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,279,1624345200"; d="scan'208";a="539453545" X-Received: from gaozhic-desk.ccr.corp.intel.com ([10.239.137.133]) by FMSMGA003.fm.intel.com with ESMTP; 09 Sep 2021 00:25:45 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH V2] MdeModulePkg/BootManagerMenuApp: Limit string drawing within one line Date: Thu, 9 Sep 2021 15:25:41 +0800 Message-Id: <20210909072541.3069-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: 2N0Axq1eSHKfzF4N7VetvTomx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631172349; bh=9fmmy48DPz5d/MUwEGfiwC+pinfqj5o3yQZYG1N/LHA=; h=Cc:Date:From:Reply-To:Subject:To; b=hmuBM+Qm5ZJh4Ylgl+73szktzulPk+Vlb8JQVrlRAgj8lsECZmsPxTY5Rb2cIGUtF27 y8tCtjXqZdrfcBfU5+RUAqzuGV42g8f8dKpiA3H2E1dHjtz+mb74FrZkExm5eqD7REpaC 4GHN3IB0/voeiiazpwSQBO5J8R1cmIuZNP0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631172351755100002 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. Change-Id: Ib7bd63cb07b23875a1e4f37ae80a422e1d5ed54f 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. .../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 (#80406): https://edk2.groups.io/g/devel/message/80406 Mute This Topic: https://groups.io/mt/85479254/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-