From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B12672195407C for ; Mon, 24 Apr 2017 01:12:19 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2017 01:12:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,243,1488873600"; d="scan'208";a="252681237" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 24 Apr 2017 01:12:18 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong Date: Mon, 24 Apr 2017 16:11:28 +0800 Message-Id: <1493021488-201704-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] MdemodulePkg/DisplayEngine: clean the line before showing message X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Apr 2017 08:12:19 -0000 Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../CustomizedDisplayLibInternal.c | 21 ++++++++------------- .../Universal/DisplayEngineDxe/FormDisplay.c | 15 +++++++-------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c index bc14a9d..3e24f35 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c @@ -857,12 +857,10 @@ PrintInternal ( CHAR16 *BackupBuffer; UINTN Index; UINTN PreviousIndex; UINTN Count; UINTN TotalCount; - UINTN PrintWidth; - UINTN CharWidth; // // For now, allocate an arbitrarily long buffer // Buffer = AllocateZeroPool (0x10000); @@ -882,12 +880,18 @@ PrintInternal ( Index = 0; PreviousIndex = 0; Count = 0; TotalCount = 0; - PrintWidth = 0; - CharWidth = 1; + + // + // Clean the line and then reset the position of the cursor. + // + Out->OutputString (Out, &mSpaceBuffer[SPACE_BUFFER_SIZE - Width]); + if (Column != (UINTN) -1) { + Out->SetCursorPosition (Out, Column, Row); + } do { for (; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) { BackupBuffer[Index] = Buffer[Index]; } @@ -899,11 +903,10 @@ PrintInternal ( // // Print this out, we are about to switch widths // Out->OutputString (Out, &BackupBuffer[PreviousIndex]); Count = StrLen (&BackupBuffer[PreviousIndex]); - PrintWidth += Count * CharWidth; TotalCount += Count; // // Preserve the current index + 1, since this is where we will start printing from next // @@ -916,18 +919,16 @@ PrintInternal ( // // Preserve bits 0 - 6 and zero out the rest // Out->Mode->Attribute = Out->Mode->Attribute & 0x7f; Out->SetAttribute (Out, Out->Mode->Attribute); - CharWidth = 1; } else { // // Must be wide, set bit 7 ON // Out->Mode->Attribute = Out->Mode->Attribute | EFI_WIDE_ATTRIBUTE; Out->SetAttribute (Out, Out->Mode->Attribute); - CharWidth = 2; } Index++; } while (Buffer[Index] != 0); @@ -935,17 +936,11 @@ PrintInternal ( // // We hit the end of the string - print it // Out->OutputString (Out, &BackupBuffer[PreviousIndex]); Count = StrLen (&BackupBuffer[PreviousIndex]); - PrintWidth += Count * CharWidth; TotalCount += Count; - if (PrintWidth < Width) { - Out->Mode->Attribute = Out->Mode->Attribute & 0x7f; - Out->SetAttribute (Out, Out->Mode->Attribute); - Out->OutputString (Out, &mSpaceBuffer[SPACE_BUFFER_SIZE - Width + PrintWidth]); - } FreePool (Buffer); FreePool (BackupBuffer); return TotalCount; } diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c index e1ac5a3..2938351 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c @@ -2056,32 +2056,31 @@ DisplayMenuString ( IN CHAR16 *String, IN UINTN Width, IN BOOLEAN Highlight ) { - UINTN Length; - // // Print string with normal color. // if (!Highlight) { PrintStringAtWithWidth (Col, Row, String, Width); return; } - // // Print the highlight menu string. - // First print the highlight string. + // First, clean the line. // + PrintStringAtWithWidth (Col, Row, L"", Width); + // + // Second, set the display attribute for highlight string and then print it. + // SetDisplayAttribute(MenuOption, TRUE); - Length = PrintStringAt (Col, Row, String); - + PrintStringAt (Col, Row, String); // - // Second, clean the empty after the string. + // Last, reset the display attribute. // SetDisplayAttribute(MenuOption, FALSE); - PrintStringAtWithWidth (Col + Length, Row, L"", Width - Length); } /** Check whether this menu can has option string. -- 1.9.5.msysgit.1