3 This library class defines a set of interfaces to customize Display module
5 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "CustomizedDisplayLibInternal.h"
17 EFI_SCREEN_DESCRIPTOR gScreenDimensions
;
18 CHAR16
*mLibUnknownString
;
19 extern EFI_HII_HANDLE mCDLStringPackHandle
;
21 #define SPACE_BUFFER_SIZE 1000
24 // Browser Global Strings
27 CHAR16
*gEnterCommitString
;
28 CHAR16
*gEnterEscapeString
;
29 CHAR16
*gEscapeString
;
30 CHAR16
*gMoveHighlight
;
31 CHAR16
*gDecNumericInput
;
32 CHAR16
*gHexNumericInput
;
33 CHAR16
*gToggleCheckBox
;
34 CHAR16
*gLibEmptyString
;
40 CHAR16
*gAdjustNumber
;
42 CHAR16
*gNvUpdateMessage
;
43 CHAR16
*gInputErrorMessage
;
47 Print banner info for front page.
49 @param[in] FormData Form Data to be shown in Page
54 IN FORM_DISPLAY_ENGINE_FORM
*FormData
59 CHAR16
*StrFrontPageBanner
;
64 // ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
67 gScreenDimensions
.LeftColumn
,
68 gScreenDimensions
.RightColumn
,
69 gScreenDimensions
.TopRow
,
70 FRONT_PAGE_HEADER_HEIGHT
- 1 + gScreenDimensions
.TopRow
,
71 BANNER_TEXT
| BANNER_BACKGROUND
75 // for (Line = 0; Line < BANNER_HEIGHT; Line++) {
77 for (Line
= (UINT8
) gScreenDimensions
.TopRow
; Line
< BANNER_HEIGHT
+ (UINT8
) gScreenDimensions
.TopRow
; Line
++) {
79 // for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
81 for (Alignment
= (UINT8
) gScreenDimensions
.LeftColumn
;
82 Alignment
< BANNER_COLUMNS
+ (UINT8
) gScreenDimensions
.LeftColumn
;
85 RowIdx
= (UINT8
) (Line
- (UINT8
) gScreenDimensions
.TopRow
);
86 ColumnIdx
= (UINT8
) (Alignment
- (UINT8
) gScreenDimensions
.LeftColumn
);
88 ASSERT (RowIdx
< BANNER_HEIGHT
&& ColumnIdx
< BANNER_COLUMNS
);
90 if (gBannerData
!= NULL
&& gBannerData
->Banner
[RowIdx
][ColumnIdx
] != 0x0000) {
91 StrFrontPageBanner
= LibGetToken (gBannerData
->Banner
[RowIdx
][ColumnIdx
], FormData
->HiiHandle
);
96 switch (Alignment
- gScreenDimensions
.LeftColumn
) {
101 PrintStringAt (gScreenDimensions
.LeftColumn
+ BANNER_LEFT_COLUMN_INDENT
, Line
, StrFrontPageBanner
);
106 // Handle center column
109 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) / 3,
117 // Handle right column
120 gScreenDimensions
.LeftColumn
+ (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
) * 2 / 3,
127 FreePool (StrFrontPageBanner
);
133 Print framework and form title for a page.
135 @param[in] FormData Form Data to be shown in Page
139 IN FORM_DISPLAY_ENGINE_FORM
*FormData
148 if (gClassOfVfr
!= FORMSET_CLASS_PLATFORM_SETUP
) {
150 // Only Setup page needs Framework
153 gScreenDimensions
.LeftColumn
,
154 gScreenDimensions
.RightColumn
,
155 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
,
156 gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1,
157 KEYHELP_TEXT
| KEYHELP_BACKGROUND
162 Buffer
= AllocateZeroPool (0x10000);
163 ASSERT (Buffer
!= NULL
);
164 Character
= BOXDRAW_HORIZONTAL
;
165 for (Index
= 0; Index
+ 2 < (gScreenDimensions
.RightColumn
- gScreenDimensions
.LeftColumn
); Index
++) {
166 Buffer
[Index
] = Character
;
170 // Print Top border line
171 // +------------------------------------------------------------------------------+
173 // +------------------------------------------------------------------------------+
175 gST
->ConOut
->SetAttribute (gST
->ConOut
, TITLE_TEXT
| TITLE_BACKGROUND
);
176 Character
= BOXDRAW_DOWN_RIGHT
;
178 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
, Character
);
179 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
181 Character
= BOXDRAW_DOWN_LEFT
;
182 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
184 Character
= BOXDRAW_VERTICAL
;
185 for (Row
= gScreenDimensions
.TopRow
+ 1; Row
<= gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 2; Row
++) {
186 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
187 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
194 gScreenDimensions
.LeftColumn
+ 1,
195 gScreenDimensions
.RightColumn
- 1,
196 gScreenDimensions
.TopRow
+ 1,
197 gScreenDimensions
.TopRow
+ 1,
198 TITLE_TEXT
| TITLE_BACKGROUND
201 TitleStr
= LibGetToken (FormData
->FormTitle
, FormData
->HiiHandle
);
202 ASSERT (TitleStr
!= NULL
);
204 (gScreenDimensions
.RightColumn
+ gScreenDimensions
.LeftColumn
- LibGetStringWidth (TitleStr
) / 2) / 2,
205 gScreenDimensions
.TopRow
+ 1,
210 Character
= BOXDRAW_UP_RIGHT
;
211 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.TopRow
+ NONE_FRONT_PAGE_HEADER_HEIGHT
- 1, Character
);
212 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
214 Character
= BOXDRAW_UP_LEFT
;
215 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
218 // Print Bottom border line
219 // +------------------------------------------------------------------------------+
221 // +------------------------------------------------------------------------------+
223 Character
= BOXDRAW_DOWN_RIGHT
;
224 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
, Character
);
226 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
228 Character
= BOXDRAW_DOWN_LEFT
;
229 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
230 Character
= BOXDRAW_VERTICAL
;
231 for (Row
= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- gFooterHeight
+ 1;
232 Row
<= gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 2;
235 PrintCharAt (gScreenDimensions
.LeftColumn
, Row
, Character
);
236 PrintCharAt (gScreenDimensions
.RightColumn
- 1, Row
, Character
);
239 Character
= BOXDRAW_UP_RIGHT
;
240 PrintCharAt (gScreenDimensions
.LeftColumn
, gScreenDimensions
.BottomRow
- STATUS_BAR_HEIGHT
- 1, Character
);
242 PrintStringAt ((UINTN
) -1, (UINTN
) -1, Buffer
);
244 Character
= BOXDRAW_UP_LEFT
;
245 PrintCharAt ((UINTN
) -1, (UINTN
) -1, Character
);
251 Process some op code which is not recognized by browser core.
253 @param OpCodeData The pointer to the op code buffer.
255 @return EFI_SUCCESS Pass the statement success.
260 IN EFI_IFR_OP_HEADER
*OpCodeData
263 switch (OpCodeData
->OpCode
) {
264 case EFI_IFR_GUID_OP
:
265 if (CompareGuid (&gEfiIfrTianoGuid
, (EFI_GUID
*)((CHAR8
*) OpCodeData
+ sizeof (EFI_IFR_OP_HEADER
)))) {
267 // Tiano specific GUIDed opcodes
269 switch (((EFI_IFR_GUID_LABEL
*) OpCodeData
)->ExtendOpCode
) {
270 case EFI_IFR_EXTEND_OP_LABEL
:
276 case EFI_IFR_EXTEND_OP_BANNER
:
278 // Only in front page form set, we care about the banner data.
280 if (gClassOfVfr
== FORMSET_CLASS_FRONT_PAGE
) {
282 // Initialize Driver private data
284 if (gBannerData
== NULL
) {
285 gBannerData
= AllocateZeroPool (sizeof (BANNER_DATA
));
286 ASSERT (gBannerData
!= NULL
);
290 &gBannerData
->Banner
[((EFI_IFR_GUID_BANNER
*) OpCodeData
)->LineNumber
][
291 ((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Alignment
],
292 &((EFI_IFR_GUID_BANNER
*) OpCodeData
)->Title
,
293 sizeof (EFI_STRING_ID
)
298 case EFI_IFR_EXTEND_OP_SUBCLASS
:
299 if (((EFI_IFR_GUID_SUBCLASS
*) OpCodeData
)->SubClass
== EFI_FRONT_PAGE_SUBCLASS
) {
300 gClassOfVfr
= FORMSET_CLASS_FRONT_PAGE
;
316 Process some op codes which is out side of current form.
318 @param FormData Pointer to the form data.
320 @return EFI_SUCCESS Pass the statement success.
324 ProcessExternedOpcode (
325 IN FORM_DISPLAY_ENGINE_FORM
*FormData
329 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
331 Link
= GetFirstNode (&FormData
->StatementListOSF
);
332 while (!IsNull (&FormData
->StatementListOSF
, Link
)) {
333 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
334 Link
= GetNextNode (&FormData
->StatementListOSF
, Link
);
336 ProcessUserOpcode(Statement
->OpCode
);
339 Link
= GetFirstNode (&FormData
->StatementListHead
);
340 while (!IsNull (&FormData
->StatementListHead
, Link
)) {
341 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
342 Link
= GetNextNode (&FormData
->StatementListHead
, Link
);
344 ProcessUserOpcode(Statement
->OpCode
);
349 Validate the input screen diemenstion info.
351 @param FormData The input form data info.
353 @return EFI_SUCCESS The input screen info is acceptable.
354 @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
358 ScreenDiemensionInfoValidate (
359 IN FORM_DISPLAY_ENGINE_FORM
*FormData
366 // Calculate total number of Register HotKeys.
369 if (!IsListEmpty (&FormData
->HotKeyListHead
)){
370 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
371 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
372 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
378 // Show three HotKeys help information on one row.
380 gFooterHeight
= FOOTER_HEIGHT
+ (Index
/ 3);
383 ZeroMem (&gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
384 gST
->ConOut
->QueryMode (
386 gST
->ConOut
->Mode
->Mode
,
387 &gScreenDimensions
.RightColumn
,
388 &gScreenDimensions
.BottomRow
392 // Check local dimension vs. global dimension.
394 if (FormData
->ScreenDimensions
!= NULL
) {
395 if ((gScreenDimensions
.RightColumn
< FormData
->ScreenDimensions
->RightColumn
) ||
396 (gScreenDimensions
.BottomRow
< FormData
->ScreenDimensions
->BottomRow
)
398 return EFI_INVALID_PARAMETER
;
401 // Local dimension validation.
403 if ((FormData
->ScreenDimensions
->RightColumn
> FormData
->ScreenDimensions
->LeftColumn
) &&
404 (FormData
->ScreenDimensions
->BottomRow
> FormData
->ScreenDimensions
->TopRow
) &&
405 ((FormData
->ScreenDimensions
->RightColumn
- FormData
->ScreenDimensions
->LeftColumn
) > 2) &&
406 ((FormData
->ScreenDimensions
->BottomRow
- FormData
->ScreenDimensions
->TopRow
) > STATUS_BAR_HEIGHT
+
407 FRONT_PAGE_HEADER_HEIGHT
+ gFooterHeight
+ 3)) {
408 CopyMem (&gScreenDimensions
, (VOID
*) FormData
->ScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
410 return EFI_INVALID_PARAMETER
;
419 Get the string based on the StringId and HII Package List Handle.
421 @param Token The String's ID.
422 @param HiiHandle The package list in the HII database to search for
423 the specified string.
425 @return The output string.
430 IN EFI_STRING_ID Token
,
431 IN EFI_HII_HANDLE HiiHandle
436 String
= HiiGetString (HiiHandle
, Token
, NULL
);
437 if (String
== NULL
) {
438 String
= AllocateCopyPool (StrSize (mLibUnknownString
), mLibUnknownString
);
439 ASSERT (String
!= NULL
);
442 return (CHAR16
*) String
;
447 Count the storage space of a Unicode string.
449 This function handles the Unicode string with NARROW_CHAR
450 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
451 does not count in the resultant output. If a WIDE_CHAR is
452 hit, then 2 Unicode character will consume an output storage
453 space with size of CHAR16 till a NARROW_CHAR is hit.
455 If String is NULL, then ASSERT ().
457 @param String The input string to be counted.
459 @return Storage space for the input string.
469 UINTN IncrementValue
;
471 ASSERT (String
!= NULL
);
472 if (String
== NULL
) {
482 // Advance to the null-terminator or to the first width directive
485 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
486 Index
++, Count
= Count
+ IncrementValue
491 // We hit the null-terminator, we now have a count
493 if (String
[Index
] == 0) {
497 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
498 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
500 if (String
[Index
] == NARROW_CHAR
) {
502 // Skip to the next character
508 // Skip to the next character
513 } while (String
[Index
] != 0);
516 // Increment by one to include the null-terminator in the size
520 return Count
* sizeof (CHAR16
);
524 Show all registered HotKey help strings on bottom Rows.
526 @param FormData The curent input form data info.
530 PrintHotKeyHelpString (
531 IN FORM_DISPLAY_ENGINE_FORM
*FormData
536 UINTN BottomRowOfHotKeyHelp
;
539 EFI_SCREEN_DESCRIPTOR LocalScreen
;
541 BROWSER_HOT_KEY
*HotKey
;
543 if (IsListEmpty (&FormData
->HotKeyListHead
)) {
547 CopyMem (&LocalScreen
, &gScreenDimensions
, sizeof (EFI_SCREEN_DESCRIPTOR
));
548 ColumnWidth
= (LocalScreen
.RightColumn
- LocalScreen
.LeftColumn
) / 3;
549 BottomRowOfHotKeyHelp
= LocalScreen
.BottomRow
- STATUS_BAR_HEIGHT
- 3;
552 // Calculate total number of Register HotKeys.
555 Link
= GetFirstNode (&FormData
->HotKeyListHead
);
556 while (!IsNull (&FormData
->HotKeyListHead
, Link
)) {
557 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
559 // Help string can't exceed ColumnWidth. One Row will show three Help information.
561 if (StrLen (HotKey
->HelpString
) > ColumnWidth
) {
562 HotKey
->HelpString
[ColumnWidth
] = L
'\0';
565 // Calculate help information Column and Row.
567 if ((Index
% 3) != 2) {
568 CurrentCol
= LocalScreen
.LeftColumn
+ (2 - Index
% 3) * ColumnWidth
;
570 CurrentCol
= LocalScreen
.LeftColumn
+ 2;
572 CurrentRow
= BottomRowOfHotKeyHelp
- Index
/ 3;
574 // Print HotKey help string on bottom Row.
576 PrintStringAt (CurrentCol
, CurrentRow
, HotKey
->HelpString
);
581 Link
= GetNextNode (&FormData
->HotKeyListHead
, Link
);
589 Get step info from numeric opcode.
591 @param[in] OpCode The input numeric op code.
593 @return step info for this opcode.
597 IN EFI_IFR_OP_HEADER
*OpCode
600 EFI_IFR_NUMERIC
*NumericOp
;
603 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
605 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
606 case EFI_IFR_NUMERIC_SIZE_1
:
607 Step
= NumericOp
->data
.u8
.Step
;
610 case EFI_IFR_NUMERIC_SIZE_2
:
611 Step
= NumericOp
->data
.u16
.Step
;
614 case EFI_IFR_NUMERIC_SIZE_4
:
615 Step
= NumericOp
->data
.u32
.Step
;
618 case EFI_IFR_NUMERIC_SIZE_8
:
619 Step
= NumericOp
->data
.u64
.Step
;
631 Initialize the HII String Token to the correct values.
635 InitializeLibStrings (
639 mLibUnknownString
= L
"!";
641 gEnterString
= LibGetToken (STRING_TOKEN (ENTER_STRING
), mCDLStringPackHandle
);
642 gEnterCommitString
= LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING
), mCDLStringPackHandle
);
643 gEnterEscapeString
= LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING
), mCDLStringPackHandle
);
644 gEscapeString
= LibGetToken (STRING_TOKEN (ESCAPE_STRING
), mCDLStringPackHandle
);
645 gMoveHighlight
= LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT
), mCDLStringPackHandle
);
646 gDecNumericInput
= LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT
), mCDLStringPackHandle
);
647 gHexNumericInput
= LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT
), mCDLStringPackHandle
);
648 gToggleCheckBox
= LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX
), mCDLStringPackHandle
);
650 gAreYouSure
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE
), mCDLStringPackHandle
);
651 gYesResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES
), mCDLStringPackHandle
);
652 gNoResponse
= LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO
), mCDLStringPackHandle
);
653 gPlusString
= LibGetToken (STRING_TOKEN (PLUS_STRING
), mCDLStringPackHandle
);
654 gMinusString
= LibGetToken (STRING_TOKEN (MINUS_STRING
), mCDLStringPackHandle
);
655 gAdjustNumber
= LibGetToken (STRING_TOKEN (ADJUST_NUMBER
), mCDLStringPackHandle
);
656 gSaveChanges
= LibGetToken (STRING_TOKEN (SAVE_CHANGES
), mCDLStringPackHandle
);
658 gLibEmptyString
= LibGetToken (STRING_TOKEN (EMPTY_STRING
), mCDLStringPackHandle
);
660 gNvUpdateMessage
= LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE
), mCDLStringPackHandle
);
661 gInputErrorMessage
= LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE
), mCDLStringPackHandle
);
666 mSpaceBuffer
= AllocatePool ((SPACE_BUFFER_SIZE
+ 1) * sizeof (CHAR16
));
667 ASSERT (mSpaceBuffer
!= NULL
);
668 LibSetUnicodeMem (mSpaceBuffer
, SPACE_BUFFER_SIZE
, L
' ');
669 mSpaceBuffer
[SPACE_BUFFER_SIZE
] = L
'\0';
682 FreePool (gEnterString
);
683 FreePool (gEnterCommitString
);
684 FreePool (gEnterEscapeString
);
685 FreePool (gEscapeString
);
686 FreePool (gMoveHighlight
);
687 FreePool (gDecNumericInput
);
688 FreePool (gHexNumericInput
);
689 FreePool (gToggleCheckBox
);
691 FreePool (gAreYouSure
);
692 FreePool (gYesResponse
);
693 FreePool (gNoResponse
);
694 FreePool (gPlusString
);
695 FreePool (gMinusString
);
696 FreePool (gAdjustNumber
);
697 FreePool (gSaveChanges
);
699 FreePool (gLibEmptyString
);
701 FreePool (gNvUpdateMessage
);
702 FreePool (gInputErrorMessage
);
704 FreePool (mSpaceBuffer
);
708 Wait for a key to be pressed by user.
710 @param Key The key which is pressed by user.
712 @retval EFI_SUCCESS The function always completed successfully.
717 OUT EFI_INPUT_KEY
*Key
724 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, Key
);
725 if (!EFI_ERROR (Status
)) {
729 if (Status
!= EFI_NOT_READY
) {
733 gBS
->WaitForEvent (1, &gST
->ConIn
->WaitForKey
, &Index
);
740 Set Buffer to Value for Size bytes.
742 @param Buffer Memory to set.
743 @param Size Number of bytes to set
744 @param Value Value of the set operation.
757 while ((Size
--) != 0) {
763 The internal function prints to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
766 @param Width Width of string to be print.
767 @param Column The position of the output string.
768 @param Row The position of the output string.
769 @param Out The EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
770 @param Fmt The format string.
771 @param Args The additional argument for the variables in the format string.
773 @return Number of Unicode character printed.
781 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*Out
,
787 CHAR16
*BackupBuffer
;
795 // For now, allocate an arbitrarily long buffer
797 Buffer
= AllocateZeroPool (0x10000);
798 BackupBuffer
= AllocateZeroPool (0x10000);
800 ASSERT (BackupBuffer
);
802 if (Column
!= (UINTN
) -1) {
803 Out
->SetCursorPosition (Out
, Column
, Row
);
806 UnicodeVSPrint (Buffer
, 0x10000, Fmt
, Args
);
808 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
810 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
819 for (; (Buffer
[Index
] != NARROW_CHAR
) && (Buffer
[Index
] != WIDE_CHAR
) && (Buffer
[Index
] != 0); Index
++) {
820 BackupBuffer
[Index
] = Buffer
[Index
];
823 if (Buffer
[Index
] == 0) {
827 // Null-terminate the temporary string
829 BackupBuffer
[Index
] = 0;
832 // Print this out, we are about to switch widths
834 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
835 Count
+= StrLen (&BackupBuffer
[PreviousIndex
]);
836 PrintWidth
+= Count
* CharWidth
;
839 // Preserve the current index + 1, since this is where we will start printing from next
841 PreviousIndex
= Index
+ 1;
844 // We are at a narrow or wide character directive. Set attributes and strip it and print it
846 if (Buffer
[Index
] == NARROW_CHAR
) {
848 // Preserve bits 0 - 6 and zero out the rest
850 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
851 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
855 // Must be wide, set bit 7 ON
857 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
| EFI_WIDE_ATTRIBUTE
;
858 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
864 } while (Buffer
[Index
] != 0);
867 // We hit the end of the string - print it
869 Out
->OutputString (Out
, &BackupBuffer
[PreviousIndex
]);
870 Count
+= StrLen (&BackupBuffer
[PreviousIndex
]);
871 PrintWidth
+= Count
* CharWidth
;
872 if (PrintWidth
< Width
) {
873 Out
->Mode
->Attribute
= Out
->Mode
->Attribute
& 0x7f;
874 Out
->SetAttribute (Out
, Out
->Mode
->Attribute
);
875 Out
->OutputString (Out
, &mSpaceBuffer
[SPACE_BUFFER_SIZE
- Width
+ PrintWidth
]);
879 FreePool (BackupBuffer
);
884 Prints a formatted unicode string to the default console, at
885 the supplied cursor position.
887 @param Width Width of String to be printed.
888 @param Column The cursor position to print the string at.
889 @param Row The cursor position to print the string at.
890 @param Fmt Format string.
891 @param ... Variable argument list for format string.
893 @return Length of string printed to the console
907 UINTN LengthOfPrinted
;
909 VA_START (Args
, Fmt
);
910 LengthOfPrinted
= PrintInternal (Width
, Column
, Row
, gST
->ConOut
, Fmt
, Args
);
912 return LengthOfPrinted
;