From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: zhichao.gao@intel.com) 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" 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" 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: [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> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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.=0D For the incompleted string the last 3 characters in one line would=0D be replaced with "...". Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Signed-off-by: Zhichao Gao =0D Reviewed-by: Ray Ni ---=0D V2:=0D Drop the change in UefiBootManagerLib in V1.=0D Add the limitation in BootManagerMenuApp instead.=0D =0D V3:=0D Update the commit message only.=0D .../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=0D The application to show the Boot Manager Menu.=0D =0D -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -45,9 +45,56 @@ PrintStringAt ( IN CHAR16 *String=0D )=0D {=0D + UINTN ScreenWidth;=0D + UINTN ScreenRows;=0D + CHAR16 *TurncateString;=0D + EFI_STATUS Status;=0D + UINTN ShowingLength;=0D =0D gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);=0D - return Print (L"%s", String);=0D +=0D + gST->ConOut->QueryMode (=0D + gST->ConOut,=0D + gST->ConOut->Mode->Mode,=0D + &ScreenWidth,=0D + &ScreenRows=0D + );=0D +=0D + if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) {=0D + return 0;=0D + }=0D +=0D + if ((StrLen (String) + Column) > (ScreenWidth - 1)) {=0D + //=0D + // | - ScreenWidth - |=0D + // ...Column.....................=0D + // TurncateString length should leave one character for draw box and=0D + // require one character for string end.=0D + //=0D + ShowingLength =3D ScreenWidth - Column - 1;=0D + TurncateString =3D AllocatePool ((ShowingLength + 1) * sizeof (CHAR16)= );=0D +=0D + if (TurncateString =3D=3D NULL) {=0D + return 0;=0D + }=0D +=0D + Status =3D StrnCpyS (TurncateString, ShowingLength + 1, String, Showin= gLength - 3);=0D +=0D + if (EFI_ERROR (Status)) {=0D + FreePool (TurncateString);=0D + return 0;=0D + }=0D +=0D + *(TurncateString + ShowingLength - 3) =3D L'.';=0D + *(TurncateString + ShowingLength - 2) =3D L'.';=0D + *(TurncateString + ShowingLength - 1) =3D L'.';=0D + *(TurncateString + ShowingLength) =3D L'\0';=0D + ShowingLength =3D Print (L"%s", TurncateString);=0D + FreePool (TurncateString);=0D + return ShowingLength;=0D + } else {=0D + return Print (L"%s", String);=0D + }=0D }=0D =0D /**=0D @@ -68,7 +115,22 @@ PrintCharAt ( CHAR16 Character=0D )=0D {=0D + UINTN ScreenWidth;=0D + UINTN ScreenRows;=0D +=0D gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);=0D +=0D + gST->ConOut->QueryMode (=0D + gST->ConOut,=0D + gST->ConOut->Mode->Mode,=0D + &ScreenWidth,=0D + &ScreenRows=0D + );=0D +=0D + if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) {=0D + return 0;=0D + }=0D +=0D return Print (L"%c", Character);=0D }=0D =0D @@ -193,7 +255,11 @@ InitializeBootMenuScreen ( =0D MaxPrintRows =3D Row - 6;=0D UnSelectableItmes =3D TITLE_TOKEN_COUNT + 2 + HELP_TOKEN_COUNT + 2;=0D - BootMenuData->MenuScreen.Width =3D MaxStrWidth + 8;=0D + if (MaxStrWidth + 8 > Column) {=0D + BootMenuData->MenuScreen.Width =3D Column;=0D + } else {=0D + BootMenuData->MenuScreen.Width =3D MaxStrWidth + 8;=0D + }=0D if (BootMenuData->ItemCount + UnSelectableItmes > MaxPrintRows) {=0D BootMenuData->MenuScreen.Height =3D MaxPrintRows;=0D BootMenuData->ScrollBarControl.HasScrollBar =3D TRUE;=0D --=20 2.31.1.windows.1