summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
index 82907df092..2a51af8e2f 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
@@ -978,6 +978,7 @@ ProcessOptions (
@param StringPtr The entire help string.
@param FormattedString The oupput formatted string.
+ @param EachLineWidth The max string length of each line in the formatted string.
@param RowCount TRUE: if Question is selected.
**/
@@ -985,6 +986,7 @@ UINTN
ProcessHelpString (
IN CHAR16 *StringPtr,
OUT CHAR16 **FormattedString,
+ OUT UINT16 *EachLineWidth,
IN UINTN RowCount
)
{
@@ -992,27 +994,49 @@ ProcessHelpString (
CHAR16 *OutputString;
UINTN TotalRowNum;
UINTN CheckedNum;
+ UINT16 GlyphWidth;
+ UINT16 LineWidth;
+ UINT16 MaxStringLen;
+ UINT16 StringLen;
+
+ TotalRowNum = 0;
+ CheckedNum = 0;
+ GlyphWidth = 1;
+ Index = 0;
+ MaxStringLen = 0;
+ StringLen = 0;
- TotalRowNum = 0;
- CheckedNum = 0;
+ //
+ // Set default help string width.
+ //
+ LineWidth = (UINT16) (gHelpBlockWidth - 1);
//
// Get row number of the String.
//
- for (Index = 0; GetLineByWidth (StringPtr, (UINT16) (gHelpBlockWidth - 1), &Index, &OutputString) != 0x0000; ) {
+ while ((StringLen = GetLineByWidth (StringPtr, LineWidth, &GlyphWidth, &Index, &OutputString)) != 0) {
+ if (StringLen > MaxStringLen) {
+ MaxStringLen = StringLen;
+ }
+
TotalRowNum ++;
FreePool (OutputString);
}
-
- *FormattedString = AllocateZeroPool (TotalRowNum * gHelpBlockWidth * sizeof (CHAR16) * 2);
+ *EachLineWidth = MaxStringLen;
+
+ *FormattedString = AllocateZeroPool (TotalRowNum * MaxStringLen * sizeof (CHAR16));
ASSERT (*FormattedString != NULL);
- for (Index = 0; GetLineByWidth (StringPtr, (UINT16) (gHelpBlockWidth - 1), &Index, &OutputString) != 0x0000; CheckedNum ++) {
- CopyMem (*FormattedString + CheckedNum * gHelpBlockWidth * sizeof (CHAR16), OutputString, gHelpBlockWidth * sizeof (CHAR16));
+ //
+ // Generate formatted help string array.
+ //
+ GlyphWidth = 1;
+ Index = 0;
+ while((StringLen = GetLineByWidth (StringPtr, LineWidth, &GlyphWidth, &Index, &OutputString)) != 0) {
+ CopyMem (*FormattedString + CheckedNum * MaxStringLen, OutputString, StringLen * sizeof (CHAR16));
+ CheckedNum ++;
FreePool (OutputString);
}
- ASSERT (CheckedNum == TotalRowNum);
-
return TotalRowNum;
}