public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>
Subject: [patch] MdemodulePkg/DisplayEngine: clean the line before showing message
Date: Mon, 24 Apr 2017 16:11:28 +0800	[thread overview]
Message-ID: <1493021488-201704-1-git-send-email-dandan.bi@intel.com> (raw)

Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../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



                 reply	other threads:[~2017-04-24  8:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1493021488-201704-1-git-send-email-dandan.bi@intel.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