2 Entry and initialization module for the browser.
4 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. 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.
16 #include "FormDisplay.h"
19 // Search table for UiDisplayMenu()
21 SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation
[] = {
52 UINTN mScanCodeNumber
= sizeof (gScanCodeToOperation
) / sizeof (gScanCodeToOperation
[0]);
54 SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag
[] = {
97 EFI_GUID gDisplayEngineGuid
= {
98 0xE38C1029, 0xE38F, 0x45b9, {0x8F, 0x0D, 0xE2, 0xE6, 0x0B, 0xC9, 0xB2, 0x62}
101 FORM_ENTRY_INFO gFormEntryInfo
;
103 EFI_SCREEN_DESCRIPTOR gStatementDimensions
;
104 BOOLEAN mStatementLayoutIsChanged
= TRUE
;
105 USER_INPUT
*gUserInput
;
106 FORM_DISPLAY_ENGINE_FORM
*gFormData
;
107 EFI_HII_HANDLE gHiiHandle
;
109 LIST_ENTRY gMenuOption
;
110 DISPLAY_HIGHLIGHT_MENU_INFO gHighligthMenuInfo
= {0};
111 BOOLEAN mIsFirstForm
= TRUE
;
112 FORM_ENTRY_INFO gOldFormEntry
= {0};
115 // Browser Global Strings
117 CHAR16
*gFormNotFound
;
119 CHAR16
*gBrwoserError
;
121 CHAR16
*gNoSubmitIfFailed
;
122 CHAR16
*gSaveProcess
;
123 CHAR16
*gSaveNoSubmitProcess
;
124 CHAR16
*gDiscardChange
;
125 CHAR16
*gJumpToFormSet
;
127 CHAR16
*gPromptForData
;
128 CHAR16
*gPromptForPassword
;
129 CHAR16
*gPromptForNewPassword
;
130 CHAR16
*gConfirmPassword
;
131 CHAR16
*gConfirmError
;
132 CHAR16
*gPassowordInvalid
;
134 CHAR16
*gEmptyString
;
136 CHAR16
*gOptionMismatch
;
137 CHAR16
*gFormSuppress
;
138 CHAR16
*gProtocolNotFound
;
140 CHAR16 gModalSkipColumn
;
141 CHAR16 gPromptBlockWidth
;
142 CHAR16 gOptionBlockWidth
;
143 CHAR16 gHelpBlockWidth
;
144 CHAR16
*mUnknownString
;
146 FORM_DISPLAY_DRIVER_PRIVATE_DATA mPrivateData
= {
147 FORM_DISPLAY_DRIVER_SIGNATURE
,
151 DriverClearDisplayPage
,
158 Get the string based on the StringId and HII Package List Handle.
160 @param Token The String's ID.
161 @param HiiHandle The package list in the HII database to search for
162 the specified string.
164 @return The output string.
169 IN EFI_STRING_ID Token
,
170 IN EFI_HII_HANDLE HiiHandle
175 String
= HiiGetString (HiiHandle
, Token
, NULL
);
176 if (String
== NULL
) {
177 String
= AllocateCopyPool (StrSize (mUnknownString
), mUnknownString
);
178 ASSERT (String
!= NULL
);
181 return (CHAR16
*) String
;
186 Initialize the HII String Token to the correct values.
190 InitializeDisplayStrings (
194 mUnknownString
= GetToken (STRING_TOKEN (UNKNOWN_STRING
), gHiiHandle
);
195 gSaveFailed
= GetToken (STRING_TOKEN (SAVE_FAILED
), gHiiHandle
);
196 gNoSubmitIfFailed
= GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED
), gHiiHandle
);
197 gSaveProcess
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP
), gHiiHandle
);
198 gSaveNoSubmitProcess
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK
), gHiiHandle
);
199 gDiscardChange
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD
), gHiiHandle
);
200 gJumpToFormSet
= GetToken (STRING_TOKEN (DISCARD_OR_JUMP_JUMP
), gHiiHandle
);
201 gCheckError
= GetToken (STRING_TOKEN (DISCARD_OR_CHECK_CHECK
), gHiiHandle
);
202 gPromptForData
= GetToken (STRING_TOKEN (PROMPT_FOR_DATA
), gHiiHandle
);
203 gPromptForPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD
), gHiiHandle
);
204 gPromptForNewPassword
= GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD
), gHiiHandle
);
205 gConfirmPassword
= GetToken (STRING_TOKEN (CONFIRM_PASSWORD
), gHiiHandle
);
206 gConfirmError
= GetToken (STRING_TOKEN (CONFIRM_ERROR
), gHiiHandle
);
207 gPassowordInvalid
= GetToken (STRING_TOKEN (PASSWORD_INVALID
), gHiiHandle
);
208 gPressEnter
= GetToken (STRING_TOKEN (PRESS_ENTER
), gHiiHandle
);
209 gEmptyString
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
210 gMiniString
= GetToken (STRING_TOKEN (MINI_STRING
), gHiiHandle
);
211 gOptionMismatch
= GetToken (STRING_TOKEN (OPTION_MISMATCH
), gHiiHandle
);
212 gFormSuppress
= GetToken (STRING_TOKEN (FORM_SUPPRESSED
), gHiiHandle
);
213 gProtocolNotFound
= GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND
), gHiiHandle
);
214 gFormNotFound
= GetToken (STRING_TOKEN (STATUS_BROWSER_FORM_NOT_FOUND
), gHiiHandle
);
215 gNoSubmitIf
= GetToken (STRING_TOKEN (STATUS_BROWSER_NO_SUBMIT_IF
), gHiiHandle
);
216 gBrwoserError
= GetToken (STRING_TOKEN (STATUS_BROWSER_ERROR
), gHiiHandle
);
220 Free up the resource allocated for all strings required
229 FreePool (mUnknownString
);
230 FreePool (gEmptyString
);
231 FreePool (gSaveFailed
);
232 FreePool (gNoSubmitIfFailed
);
233 FreePool (gSaveProcess
);
234 FreePool (gSaveNoSubmitProcess
);
235 FreePool (gDiscardChange
);
236 FreePool (gJumpToFormSet
);
237 FreePool (gCheckError
);
238 FreePool (gPromptForData
);
239 FreePool (gPromptForPassword
);
240 FreePool (gPromptForNewPassword
);
241 FreePool (gConfirmPassword
);
242 FreePool (gConfirmError
);
243 FreePool (gPassowordInvalid
);
244 FreePool (gPressEnter
);
245 FreePool (gMiniString
);
246 FreePool (gOptionMismatch
);
247 FreePool (gFormSuppress
);
248 FreePool (gProtocolNotFound
);
249 FreePool (gBrwoserError
);
250 FreePool (gNoSubmitIf
);
251 FreePool (gFormNotFound
);
255 Get prompt string id from the opcode data buffer.
257 @param OpCode The input opcode buffer.
259 @return The prompt string id.
264 IN EFI_IFR_OP_HEADER
*OpCode
267 EFI_IFR_STATEMENT_HEADER
*Header
;
269 if (OpCode
->Length
<= sizeof (EFI_IFR_OP_HEADER
)) {
273 Header
= (EFI_IFR_STATEMENT_HEADER
*) (OpCode
+ 1);
275 return Header
->Prompt
;
279 Get the supported width for a particular op-code
281 @param MenuOption The menu option.
282 @param AdjustWidth The width which is saved for the space.
284 @return Returns the number of CHAR16 characters that is support.
289 IN UI_MENU_OPTION
*MenuOption
,
290 OUT UINT16
*AdjustWidth
295 EFI_IFR_TEXT
*TestOp
;
297 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
299 Statement
= MenuOption
->ThisTag
;
302 // For modal form, clean the entire row.
304 if ((gFormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
305 if (AdjustWidth
!= NULL
) {
306 *AdjustWidth
= LEFT_SKIPPED_COLUMNS
;
308 return (UINT16
)(gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gModalSkipColumn
+ LEFT_SKIPPED_COLUMNS
));
314 // See if the second text parameter is really NULL
316 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
317 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
318 if (TestOp
->TextTwo
!= 0) {
319 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
320 Size
= StrLen (String
);
325 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
326 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
327 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
328 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
329 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
331 // Allow a wide display if text op-code and no secondary text op-code
333 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
337 // Return the space width.
339 if (AdjustWidth
!= NULL
) {
343 // Keep consistent with current behavior.
345 ReturnWidth
= (UINT16
) (gPromptBlockWidth
+ gOptionBlockWidth
- 2);
347 if (AdjustWidth
!= NULL
) {
351 ReturnWidth
= (UINT16
) (gPromptBlockWidth
- 1);
355 // For nest in statement, should the subtitle indent.
357 if (MenuOption
->NestInStatement
) {
358 ReturnWidth
-= SUBTITLE_INDENT
;
365 Will copy LineWidth amount of a string in the OutputString buffer and return the
366 number of CHAR16 characters that were copied into the OutputString buffer.
367 The output string format is:
368 Glyph Info + String info + '\0'.
370 In the code, it deals \r,\n,\r\n same as \n\r, also it not process the \r or \g.
372 @param InputString String description for this option.
373 @param LineWidth Width of the desired string to extract in CHAR16
375 @param GlyphWidth The glyph width of the begin of the char in the string.
376 @param Index Where in InputString to start the copy process
377 @param OutputString Buffer to copy the string into
379 @return Returns the number of CHAR16 characters that were copied into the OutputString
380 buffer, include extra glyph info and '\0' info.
385 IN CHAR16
*InputString
,
387 IN OUT UINT16
*GlyphWidth
,
389 OUT CHAR16
**OutputString
394 UINT16 OriginalGlyphWidth
;
396 UINT16 LastSpaceOffset
;
397 UINT16 LastGlyphWidth
;
399 if (InputString
== NULL
|| Index
== NULL
|| OutputString
== NULL
) {
403 if (LineWidth
== 0 || *GlyphWidth
== 0) {
408 // Save original glyph width.
410 OriginalGlyphWidth
= *GlyphWidth
;
411 LastGlyphWidth
= OriginalGlyphWidth
;
416 // NARROW_CHAR can not be printed in screen, so if a line only contain the two CHARs: 'NARROW_CHAR + CHAR_CARRIAGE_RETURN' , it is a empty line in Screen.
417 // To avoid displaying this empty line in screen, just skip the two CHARs here.
419 if ((InputString
[*Index
] == NARROW_CHAR
) && (InputString
[*Index
+ 1] == CHAR_CARRIAGE_RETURN
)) {
424 // Fast-forward the string and see if there is a carriage-return in the string
426 for (StrOffset
= 0, GlyphOffset
= 0; GlyphOffset
<= LineWidth
; StrOffset
++) {
427 switch (InputString
[*Index
+ StrOffset
]) {
436 case CHAR_CARRIAGE_RETURN
:
443 GlyphOffset
= GlyphOffset
+ *GlyphWidth
;
446 // Record the last space info in this line. Will be used in rewind.
448 if ((InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) && (GlyphOffset
<= LineWidth
)) {
449 LastSpaceOffset
= StrOffset
;
450 LastGlyphWidth
= *GlyphWidth
;
461 // Rewind the string from the maximum size until we see a space to break the line
463 if (GlyphOffset
> LineWidth
) {
465 // Rewind the string to last space char in this line.
467 if (LastSpaceOffset
!= 0) {
468 StrOffset
= LastSpaceOffset
;
469 *GlyphWidth
= LastGlyphWidth
;
472 // Roll back to last char in the line width.
479 // The CHAR_NULL has process last time, this time just return 0 to stand for the end.
481 if (StrOffset
== 0 && (InputString
[*Index
+ StrOffset
] == CHAR_NULL
)) {
486 // Need extra glyph info and '\0' info, so +2.
488 *OutputString
= AllocateZeroPool (((UINTN
) (StrOffset
+ 2) * sizeof(CHAR16
)));
489 if (*OutputString
== NULL
) {
494 // Save the glyph info at the begin of the string, will used by Print function.
496 if (OriginalGlyphWidth
== 1) {
497 *(*OutputString
) = NARROW_CHAR
;
499 *(*OutputString
) = WIDE_CHAR
;
502 CopyMem ((*OutputString
) + 1, &InputString
[*Index
], StrOffset
* sizeof(CHAR16
));
504 if (InputString
[*Index
+ StrOffset
] == CHAR_SPACE
) {
506 // Skip the space info at the begin of next line.
508 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
509 } else if (InputString
[*Index
+ StrOffset
] == CHAR_LINEFEED
) {
511 // Skip the /n or /n/r info.
513 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_CARRIAGE_RETURN
) {
514 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
516 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
518 } else if (InputString
[*Index
+ StrOffset
] == CHAR_CARRIAGE_RETURN
) {
520 // Skip the /r or /r/n info.
522 if (InputString
[*Index
+ StrOffset
+ 1] == CHAR_LINEFEED
) {
523 *Index
= (UINT16
) (*Index
+ StrOffset
+ 2);
525 *Index
= (UINT16
) (*Index
+ StrOffset
+ 1);
528 *Index
= (UINT16
) (*Index
+ StrOffset
);
532 // Include extra glyph info and '\0' info, so +2.
534 return StrOffset
+ 2;
538 Add one menu option by specified description and context.
540 @param Statement Statement of this Menu Option.
541 @param MenuItemCount The index for this Option in the Menu.
542 @param NestIn Whether this statement is nest in another statement.
547 IN FORM_DISPLAY_ENGINE_STATEMENT
*Statement
,
548 IN UINT16
*MenuItemCount
,
552 UI_MENU_OPTION
*MenuOption
;
556 UINT16 NumberOfLines
;
560 CHAR16
*OutputString
;
561 EFI_STRING_ID PromptId
;
569 PromptId
= GetPrompt (Statement
->OpCode
);
570 ASSERT (PromptId
!= 0);
572 String
= GetToken (PromptId
, gFormData
->HiiHandle
);
573 ASSERT (String
!= NULL
);
575 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
579 for (Index
= 0; Index
< Count
; Index
++) {
580 MenuOption
= AllocateZeroPool (sizeof (UI_MENU_OPTION
));
583 MenuOption
->Signature
= UI_MENU_OPTION_SIGNATURE
;
584 MenuOption
->Description
= String
;
585 MenuOption
->Handle
= gFormData
->HiiHandle
;
586 MenuOption
->ThisTag
= Statement
;
587 MenuOption
->NestInStatement
= NestIn
;
588 MenuOption
->EntryNumber
= *MenuItemCount
;
590 MenuOption
->Sequence
= Index
;
592 if ((Statement
->Attribute
& HII_DISPLAY_GRAYOUT
) != 0) {
593 MenuOption
->GrayOut
= TRUE
;
595 MenuOption
->GrayOut
= FALSE
;
598 if ((Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
599 MenuOption
->GrayOut
= TRUE
;
603 // If the form or the question has the lock attribute, deal same as grayout.
605 if ((gFormData
->Attribute
& HII_DISPLAY_LOCK
) != 0 || (Statement
->Attribute
& HII_DISPLAY_LOCK
) != 0) {
606 MenuOption
->GrayOut
= TRUE
;
609 switch (Statement
->OpCode
->OpCode
) {
610 case EFI_IFR_ORDERED_LIST_OP
:
611 case EFI_IFR_ONE_OF_OP
:
612 case EFI_IFR_NUMERIC_OP
:
613 case EFI_IFR_TIME_OP
:
614 case EFI_IFR_DATE_OP
:
615 case EFI_IFR_CHECKBOX_OP
:
616 case EFI_IFR_PASSWORD_OP
:
617 case EFI_IFR_STRING_OP
:
619 // User could change the value of these items
621 MenuOption
->IsQuestion
= TRUE
;
623 case EFI_IFR_TEXT_OP
:
624 if (FeaturePcdGet (PcdBrowserGrayOutTextStatement
)) {
626 // Initializing GrayOut option as TRUE for Text setup options
627 // so that those options will be Gray in colour and un selectable.
629 MenuOption
->GrayOut
= TRUE
;
633 MenuOption
->IsQuestion
= FALSE
;
637 if ((Statement
->Attribute
& HII_DISPLAY_READONLY
) != 0) {
638 MenuOption
->ReadOnly
= TRUE
;
639 if (FeaturePcdGet (PcdBrowerGrayOutReadOnlyMenu
)) {
640 MenuOption
->GrayOut
= TRUE
;
645 (Statement
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
646 (Statement
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
647 Width
= GetWidth (MenuOption
, NULL
);
648 for (; GetLineByWidth (String
, Width
, &GlyphWidth
,&ArrayEntry
, &OutputString
) != 0x0000;) {
650 // If there is more string to process print on the next row and increment the Skip value
652 if (StrLen (&String
[ArrayEntry
]) != 0) {
655 FreePool (OutputString
);
659 // Add three MenuOptions for Date/Time
660 // Data format : [01/02/2004] [11:22:33]
661 // Line number : 0 0 1 0 0 1
668 // Override LineNumber for the MenuOption in Date/Time sequence
670 MenuOption
->Skip
= 1;
672 MenuOption
->Skip
= NumberOfLines
;
675 InsertTailList (&gMenuOption
, &MenuOption
->Link
);
682 Create the menu list base on the form data info.
686 ConvertStatementToMenu (
690 UINT16 MenuItemCount
;
692 LIST_ENTRY
*NestLink
;
693 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
694 FORM_DISPLAY_ENGINE_STATEMENT
*NestStatement
;
697 InitializeListHead (&gMenuOption
);
699 Link
= GetFirstNode (&gFormData
->StatementListHead
);
700 while (!IsNull (&gFormData
->StatementListHead
, Link
)) {
701 Statement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link
);
702 Link
= GetNextNode (&gFormData
->StatementListHead
, Link
);
705 // Skip the opcode not recognized by Display core.
707 if (Statement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
711 UiAddMenuOption (Statement
, &MenuItemCount
, FALSE
);
714 // Check the statement nest in this host statement.
716 NestLink
= GetFirstNode (&Statement
->NestStatementList
);
717 while (!IsNull (&Statement
->NestStatementList
, NestLink
)) {
718 NestStatement
= FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink
);
719 NestLink
= GetNextNode (&Statement
->NestStatementList
, NestLink
);
722 // Skip the opcode not recognized by Display core.
724 if (NestStatement
->OpCode
->OpCode
== EFI_IFR_GUID_OP
) {
728 UiAddMenuOption (NestStatement
, &MenuItemCount
, TRUE
);
734 Count the storage space of a Unicode string.
736 This function handles the Unicode string with NARROW_CHAR
737 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
738 does not count in the resultant output. If a WIDE_CHAR is
739 hit, then 2 Unicode character will consume an output storage
740 space with size of CHAR16 till a NARROW_CHAR is hit.
742 If String is NULL, then ASSERT ().
744 @param String The input string to be counted.
746 @return Storage space for the input string.
756 UINTN IncrementValue
;
758 ASSERT (String
!= NULL
);
759 if (String
== NULL
) {
769 // Advance to the null-terminator or to the first width directive
772 (String
[Index
] != NARROW_CHAR
) && (String
[Index
] != WIDE_CHAR
) && (String
[Index
] != 0);
773 Index
++, Count
= Count
+ IncrementValue
778 // We hit the null-terminator, we now have a count
780 if (String
[Index
] == 0) {
784 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
785 // and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
787 if (String
[Index
] == NARROW_CHAR
) {
789 // Skip to the next character
795 // Skip to the next character
800 } while (String
[Index
] != 0);
803 // Increment by one to include the null-terminator in the size
807 return Count
* sizeof (CHAR16
);
811 Base on the input option string to update the skip value for a menu option.
813 @param MenuOption The MenuOption to be checked.
814 @param OptionString The input option string.
818 UpdateSkipInfoForMenu (
819 IN UI_MENU_OPTION
*MenuOption
,
820 IN CHAR16
*OptionString
826 CHAR16
*OutputString
;
829 Width
= (UINT16
) gOptionBlockWidth
;
833 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
834 if (StrLen (&OptionString
[Index
]) != 0) {
838 FreePool (OutputString
);
841 if ((Row
> MenuOption
->Skip
) &&
842 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_DATE_OP
) &&
843 (MenuOption
->ThisTag
->OpCode
->OpCode
!= EFI_IFR_TIME_OP
)) {
844 MenuOption
->Skip
= Row
;
849 Update display lines for a Menu Option.
851 @param MenuOption The MenuOption to be checked.
855 UpdateOptionSkipLines (
856 IN UI_MENU_OPTION
*MenuOption
859 CHAR16
*OptionString
;
863 ProcessOptions (MenuOption
, FALSE
, &OptionString
, TRUE
);
864 if (OptionString
!= NULL
) {
865 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
867 FreePool (OptionString
);
870 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
871 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
873 if (OptionString
!= NULL
) {
874 UpdateSkipInfoForMenu (MenuOption
, OptionString
);
876 FreePool (OptionString
);
882 Check whether this Menu Option could be print.
884 Check Prompt string, option string or text two string not NULL.
886 This is an internal function.
888 @param MenuOption The MenuOption to be checked.
890 @retval TRUE This Menu Option is printable.
891 @retval FALSE This Menu Option could not be printable.
896 UI_MENU_OPTION
*MenuOption
900 EFI_STRING OptionString
;
904 if (MenuOption
->Description
[0] != '\0') {
908 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
909 if (EFI_ERROR (Status
)) {
912 if (OptionString
!= NULL
&& OptionString
[0] != '\0') {
913 FreePool (OptionString
);
917 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
!= 0)) {
918 OptionString
= GetToken (((EFI_IFR_TEXT
*)MenuOption
->ThisTag
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
919 ASSERT (OptionString
!= NULL
);
920 if (OptionString
[0] != '\0'){
921 FreePool (OptionString
);
930 Check whether this Menu Option could be highlighted.
932 This is an internal function.
934 @param MenuOption The MenuOption to be checked.
936 @retval TRUE This Menu Option is selectable.
937 @retval FALSE This Menu Option could not be selected.
942 UI_MENU_OPTION
*MenuOption
945 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
946 MenuOption
->GrayOut
|| MenuOption
->ReadOnly
|| !PrintableMenu (MenuOption
)) {
954 Move to next selectable statement.
956 This is an internal function.
958 @param GoUp The navigation direction. TRUE: up, FALSE: down.
959 @param CurrentPosition Current position.
960 @param GapToTop Gap position to top or bottom.
961 @param FindInForm Whether find menu in current form or beyond.
963 @return The row distance from current MenuOption to next selectable MenuOption.
965 @retval -1 Reach the begin of the menu, still can't find the selectable menu.
966 @retval Value Find the selectable menu, maybe the truly selectable, maybe the
967 first menu showing beyond current form or last menu showing in
969 The value is the line number between the new selected menu and the
970 current select menu, not include the new selected menu.
974 MoveToNextStatement (
976 IN OUT LIST_ENTRY
**CurrentPosition
,
978 IN BOOLEAN FindInForm
983 UI_MENU_OPTION
*NextMenuOption
;
984 UI_MENU_OPTION
*PreMenuOption
;
987 Pos
= *CurrentPosition
;
989 if (Pos
== &gMenuOption
) {
993 PreMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
996 NextMenuOption
= MENU_OPTION_FROM_LINK (Pos
);
998 // NextMenuOption->Row == 0 means this menu has not calculate
999 // the NextMenuOption->Skip value yet, just calculate here.
1001 if (NextMenuOption
->Row
== 0) {
1002 UpdateOptionSkipLines (NextMenuOption
);
1005 if (IsSelectable (NextMenuOption
)) {
1010 // In this case, still can't find the selectable menu,
1011 // return the first one beyond the showing form.
1013 if ((UINTN
) Distance
+ NextMenuOption
->Skip
> GapToTop
) {
1015 NextMenuOption
= PreMenuOption
;
1020 Distance
+= NextMenuOption
->Skip
;
1023 // Arrive at begin of the menu list.
1025 if ((GoUp
? Pos
->BackLink
: Pos
->ForwardLink
) == &gMenuOption
) {
1030 Pos
= (GoUp
? Pos
->BackLink
: Pos
->ForwardLink
);
1031 PreMenuOption
= NextMenuOption
;
1034 *CurrentPosition
= &NextMenuOption
->Link
;
1040 Process option string for date/time opcode.
1042 @param MenuOption Menu option point to date/time.
1043 @param OptionString Option string input for process.
1044 @param AddOptCol Whether need to update MenuOption->OptCol.
1048 ProcessStringForDateTime (
1049 UI_MENU_OPTION
*MenuOption
,
1050 CHAR16
*OptionString
,
1056 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1060 ASSERT (MenuOption
!= NULL
&& OptionString
!= NULL
);
1062 Statement
= MenuOption
->ThisTag
;
1065 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1066 Date
= (EFI_IFR_DATE
*) Statement
->OpCode
;
1067 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1068 Time
= (EFI_IFR_TIME
*) Statement
->OpCode
;
1072 // If leading spaces on OptionString - remove the spaces
1074 for (Index
= 0; OptionString
[Index
] == L
' '; Index
++) {
1076 // Base on the blockspace to get the option column info.
1079 MenuOption
->OptCol
++;
1083 for (Count
= 0; OptionString
[Index
] != CHAR_NULL
; Index
++) {
1084 OptionString
[Count
] = OptionString
[Index
];
1087 OptionString
[Count
] = CHAR_NULL
;
1090 // Enable to suppress field in the opcode base on the flag.
1092 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) {
1094 // OptionString format is: <**: **: ****>
1098 if ((Date
->Flags
& EFI_QF_DATE_MONTH_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1100 // At this point, only "<**:" in the optionstring.
1101 // Clean the day's ** field, after clean, the format is "< :"
1103 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1104 } else if ((Date
->Flags
& EFI_QF_DATE_DAY_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1106 // At this point, only "**:" in the optionstring.
1107 // Clean the month's "**" field, after clean, the format is " :"
1109 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1110 } else if ((Date
->Flags
& EFI_QF_DATE_YEAR_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1112 // At this point, only "****>" in the optionstring.
1113 // Clean the year's "****" field, after clean, the format is " >"
1115 SetUnicodeMem (&OptionString
[0], 4, L
' ');
1117 } else if (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1119 // OptionString format is: <**: **: **>
1120 // |hour|minute|second|
1123 if ((Time
->Flags
& QF_TIME_HOUR_SUPPRESS
) && (MenuOption
->Sequence
== 0)) {
1125 // At this point, only "<**:" in the optionstring.
1126 // Clean the hour's ** field, after clean, the format is "< :"
1128 SetUnicodeMem (&OptionString
[1], 2, L
' ');
1129 } else if ((Time
->Flags
& QF_TIME_MINUTE_SUPPRESS
) && (MenuOption
->Sequence
== 1)) {
1131 // At this point, only "**:" in the optionstring.
1132 // Clean the minute's "**" field, after clean, the format is " :"
1134 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1135 } else if ((Time
->Flags
& QF_TIME_SECOND_SUPPRESS
) && (MenuOption
->Sequence
== 2)) {
1137 // At this point, only "**>" in the optionstring.
1138 // Clean the second's "**" field, after clean, the format is " >"
1140 SetUnicodeMem (&OptionString
[0], 2, L
' ');
1147 Adjust Data and Time position accordingly.
1148 Data format : [01/02/2004] [11:22:33]
1149 Line number : 0 0 1 0 0 1
1151 This is an internal function.
1153 @param DirectionUp the up or down direction. False is down. True is
1155 @param CurrentPosition Current position. On return: Point to the last
1156 Option (Year or Second) if up; Point to the first
1157 Option (Month or Hour) if down.
1159 @return Return line number to pad. It is possible that we stand on a zero-advance
1160 @return data or time opcode, so pad one line when we judge if we are going to scroll outside.
1164 AdjustDateAndTimePosition (
1165 IN BOOLEAN DirectionUp
,
1166 IN OUT LIST_ENTRY
**CurrentPosition
1170 LIST_ENTRY
*NewPosition
;
1171 UI_MENU_OPTION
*MenuOption
;
1172 UINTN PadLineNumber
;
1175 NewPosition
= *CurrentPosition
;
1176 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1178 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) ||
1179 (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
1181 // Calculate the distance from current position to the last Date/Time MenuOption
1184 while (MenuOption
->Skip
== 0) {
1186 NewPosition
= NewPosition
->ForwardLink
;
1187 MenuOption
= MENU_OPTION_FROM_LINK (NewPosition
);
1191 NewPosition
= *CurrentPosition
;
1194 // Since the behavior of hitting the up arrow on a Date/Time MenuOption is intended
1195 // to be one that back to the previous set of MenuOptions, we need to advance to the first
1196 // Date/Time MenuOption and leave the remaining logic in CfUiUp intact so the appropriate
1197 // checking can be done.
1199 while (Count
++ < 2) {
1200 NewPosition
= NewPosition
->BackLink
;
1204 // Since the behavior of hitting the down arrow on a Date/Time MenuOption is intended
1205 // to be one that progresses to the next set of MenuOptions, we need to advance to the last
1206 // Date/Time MenuOption and leave the remaining logic in CfUiDown intact so the appropriate
1207 // checking can be done.
1209 while (Count
-- > 0) {
1210 NewPosition
= NewPosition
->ForwardLink
;
1214 *CurrentPosition
= NewPosition
;
1217 return PadLineNumber
;
1221 Get step info from numeric opcode.
1223 @param[in] OpCode The input numeric op code.
1225 @return step info for this opcode.
1229 IN EFI_IFR_OP_HEADER
*OpCode
1232 EFI_IFR_NUMERIC
*NumericOp
;
1235 NumericOp
= (EFI_IFR_NUMERIC
*) OpCode
;
1237 switch (NumericOp
->Flags
& EFI_IFR_NUMERIC_SIZE
) {
1238 case EFI_IFR_NUMERIC_SIZE_1
:
1239 Step
= NumericOp
->data
.u8
.Step
;
1242 case EFI_IFR_NUMERIC_SIZE_2
:
1243 Step
= NumericOp
->data
.u16
.Step
;
1246 case EFI_IFR_NUMERIC_SIZE_4
:
1247 Step
= NumericOp
->data
.u32
.Step
;
1250 case EFI_IFR_NUMERIC_SIZE_8
:
1251 Step
= NumericOp
->data
.u64
.Step
;
1263 Find the registered HotKey based on KeyData.
1265 @param[in] KeyData A pointer to a buffer that describes the keystroke
1266 information for the hot key.
1268 @return The registered HotKey context. If no found, NULL will return.
1271 GetHotKeyFromRegisterList (
1272 IN EFI_INPUT_KEY
*KeyData
1276 BROWSER_HOT_KEY
*HotKey
;
1278 Link
= GetFirstNode (&gFormData
->HotKeyListHead
);
1279 while (!IsNull (&gFormData
->HotKeyListHead
, Link
)) {
1280 HotKey
= BROWSER_HOT_KEY_FROM_LINK (Link
);
1282 if (HotKey
->KeyData
->ScanCode
== KeyData
->ScanCode
) {
1286 Link
= GetNextNode (&gFormData
->HotKeyListHead
, Link
);
1294 Determine if the menu is the last menu that can be selected.
1296 This is an internal function.
1298 @param Direction The scroll direction. False is down. True is up.
1299 @param CurrentPos The current focus.
1301 @return FALSE -- the menu isn't the last menu that can be selected.
1302 @return TRUE -- the menu is the last menu that can be selected.
1307 IN BOOLEAN Direction
,
1308 IN LIST_ENTRY
*CurrentPos
1313 Temp
= Direction
? CurrentPos
->BackLink
: CurrentPos
->ForwardLink
;
1315 if (Temp
== &gMenuOption
) {
1323 Wait for a given event to fire, or for an optional timeout to expire.
1325 @param Event The event to wait for
1327 @retval UI_EVENT_TYPE The type of the event which is trigged.
1339 EFI_EVENT TimerEvent
;
1340 EFI_EVENT WaitList
[3];
1341 UI_EVENT_TYPE EventType
;
1344 Timeout
= FormExitTimeout(gFormData
);
1347 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
1350 // Set the timer event
1359 WaitList
[0] = Event
;
1361 if (gFormData
->FormRefreshEvent
!= NULL
) {
1362 WaitList
[EventNum
] = gFormData
->FormRefreshEvent
;
1367 WaitList
[EventNum
] = TimerEvent
;
1371 Status
= gBS
->WaitForEvent (EventNum
, WaitList
, &Index
);
1372 ASSERT_EFI_ERROR (Status
);
1376 EventType
= UIEventKey
;
1380 if (gFormData
->FormRefreshEvent
!= NULL
) {
1381 EventType
= UIEventDriver
;
1383 ASSERT (Timeout
!= 0 && EventNum
== 2);
1384 EventType
= UIEventTimeOut
;
1389 ASSERT (Index
== 2 && EventNum
== 3);
1390 EventType
= UIEventTimeOut
;
1395 gBS
->CloseEvent (TimerEvent
);
1402 Get question id info from the input opcode header.
1404 @param OpCode The input opcode header pointer.
1406 @retval The question id for this opcode.
1411 IN EFI_IFR_OP_HEADER
*OpCode
1414 EFI_IFR_QUESTION_HEADER
*QuestionHeader
;
1416 if (OpCode
->Length
< sizeof (EFI_IFR_OP_HEADER
) + sizeof (EFI_IFR_QUESTION_HEADER
)) {
1420 QuestionHeader
= (EFI_IFR_QUESTION_HEADER
*)((UINT8
*) OpCode
+ sizeof(EFI_IFR_OP_HEADER
));
1422 return QuestionHeader
->QuestionId
;
1427 Find the top of screen menu base on the current menu.
1429 @param CurPos Current input menu.
1430 @param Rows Totol screen rows.
1431 @param SkipValue SkipValue for this new form.
1433 @retval TopOfScreen Top of screen menu for the new form.
1437 FindTopOfScreenMenu (
1438 IN LIST_ENTRY
*CurPos
,
1440 OUT UINTN
*SkipValue
1444 LIST_ENTRY
*TopOfScreen
;
1445 UI_MENU_OPTION
*PreviousMenuOption
;
1448 PreviousMenuOption
= NULL
;
1450 while (Link
->BackLink
!= &gMenuOption
) {
1451 Link
= Link
->BackLink
;
1452 PreviousMenuOption
= MENU_OPTION_FROM_LINK (Link
);
1453 if (PreviousMenuOption
->Row
== 0) {
1454 UpdateOptionSkipLines (PreviousMenuOption
);
1456 if (Rows
<= PreviousMenuOption
->Skip
) {
1459 Rows
= Rows
- PreviousMenuOption
->Skip
;
1462 if (Link
->BackLink
== &gMenuOption
) {
1463 TopOfScreen
= gMenuOption
.ForwardLink
;
1464 if (PreviousMenuOption
!= NULL
&& Rows
< PreviousMenuOption
->Skip
) {
1465 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1471 *SkipValue
= PreviousMenuOption
->Skip
- Rows
;
1478 Find the first menu which will be show at the top.
1480 @param FormData The data info for this form.
1481 @param TopOfScreen The link_entry pointer to top menu.
1482 @param HighlightMenu The menu which will be highlight.
1483 @param SkipValue The skip value for the top menu.
1488 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
1489 OUT LIST_ENTRY
**TopOfScreen
,
1490 OUT LIST_ENTRY
**HighlightMenu
,
1491 OUT UINTN
*SkipValue
1497 UI_MENU_OPTION
*SavedMenuOption
;
1501 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
1502 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
;
1505 // If not has input highlight statement, just return the first one in this form.
1507 if (FormData
->HighLightedStatement
== NULL
) {
1508 *TopOfScreen
= gMenuOption
.ForwardLink
;
1509 *HighlightMenu
= gMenuOption
.ForwardLink
;
1510 if (!IsListEmpty (&gMenuOption
)) {
1511 MoveToNextStatement (FALSE
, HighlightMenu
, BottomRow
- TopRow
, TRUE
);
1518 // Now base on the input highlight menu to find the top menu in this page.
1519 // Will base on the highlight menu show at the bottom to find the top menu.
1521 NewPos
= gMenuOption
.ForwardLink
;
1522 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1524 while ((SavedMenuOption
->ThisTag
!= FormData
->HighLightedStatement
) ||
1525 (SavedMenuOption
->Sequence
!= gSequence
)) {
1526 NewPos
= NewPos
->ForwardLink
;
1527 if (NewPos
== &gMenuOption
) {
1529 // Not Found it, break
1533 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1535 ASSERT (SavedMenuOption
->ThisTag
== FormData
->HighLightedStatement
);
1537 *HighlightMenu
= NewPos
;
1539 AdjustDateAndTimePosition(FALSE
, &NewPos
);
1540 SavedMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
1541 UpdateOptionSkipLines (SavedMenuOption
);
1544 // FormRefreshEvent != NULL means this form will auto exit at an interval, display engine
1545 // will try to keep highlight on the current position after this form exit and re-enter.
1547 // HiiHandle + QuestionId can find the only one question in the system.
1549 // If this question has question id, save the question id info to find the question.
1550 // else save the opcode buffer to find it.
1552 if (gFormData
->FormRefreshEvent
!= NULL
&& gFormData
->HiiHandle
== gHighligthMenuInfo
.HiiHandle
) {
1553 if (gHighligthMenuInfo
.QuestionId
!= 0) {
1554 if (gHighligthMenuInfo
.QuestionId
== GetQuestionIdInfo(SavedMenuOption
->ThisTag
->OpCode
)) {
1555 BottomRow
= gHighligthMenuInfo
.DisplayRow
+ SavedMenuOption
->Skip
;
1557 // SkipValue only used for menu at the top of the form.
1558 // If Highlight menu is not at the top, this value will be update later.
1560 TmpValue
= gHighligthMenuInfo
.SkipValue
;
1562 } else if (gHighligthMenuInfo
.OpCode
!= NULL
){
1563 if (!CompareMem (gHighligthMenuInfo
.OpCode
, SavedMenuOption
->ThisTag
->OpCode
, gHighligthMenuInfo
.OpCode
->Length
)) {
1564 BottomRow
= gHighligthMenuInfo
.DisplayRow
+ SavedMenuOption
->Skip
;
1566 // SkipValue only used for menu at the top of the form.
1567 // If Highlight menu is not at the top, this value will be update later.
1569 TmpValue
= gHighligthMenuInfo
.SkipValue
;
1574 if (SavedMenuOption
->Skip
>= BottomRow
- TopRow
) {
1575 *TopOfScreen
= NewPos
;
1577 *TopOfScreen
= FindTopOfScreenMenu(NewPos
, BottomRow
- TopRow
- SavedMenuOption
->Skip
, &TmpValue
);
1579 AdjustDateAndTimePosition(TRUE
, TopOfScreen
);
1581 *SkipValue
= TmpValue
;
1585 Update highlight menu info.
1587 @param MenuOption The menu opton which is highlight.
1588 @param SkipValue The skipvalue info for this menu.
1589 SkipValue only used for the menu at the top of the form.
1593 UpdateHighlightMenuInfo (
1594 IN UI_MENU_OPTION
*MenuOption
,
1598 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1601 // This is the current selected statement
1603 Statement
= MenuOption
->ThisTag
;
1606 // Get the highlight statement.
1608 gUserInput
->SelectedStatement
= Statement
;
1609 gSequence
= (UINT16
) MenuOption
->Sequence
;
1612 // FormRefreshEvent != NULL means this form will auto exit at an interval, display engine
1613 // will try to keep highlight on the current position after this form exit and re-enter.
1615 // HiiHandle + QuestionId can find the only one question in the system.
1617 // If this question has question id, base on the question id info to find the question.
1618 // else base on the opcode buffer to find it.
1620 if (gFormData
->FormRefreshEvent
!= NULL
) {
1621 gHighligthMenuInfo
.HiiHandle
= gFormData
->HiiHandle
;
1622 gHighligthMenuInfo
.QuestionId
= GetQuestionIdInfo(Statement
->OpCode
);
1625 // if question id == 0, save the opcode buffer for later use.
1627 if (gHighligthMenuInfo
.QuestionId
== 0) {
1628 if (gHighligthMenuInfo
.OpCode
!= NULL
) {
1629 FreePool (gHighligthMenuInfo
.OpCode
);
1631 gHighligthMenuInfo
.OpCode
= AllocateCopyPool (Statement
->OpCode
->Length
, Statement
->OpCode
);
1632 ASSERT (gHighligthMenuInfo
.OpCode
!= NULL
);
1634 gHighligthMenuInfo
.DisplayRow
= (UINT16
) MenuOption
->Row
;
1635 gHighligthMenuInfo
.SkipValue
= (UINT16
) SkipValue
;
1637 gHighligthMenuInfo
.HiiHandle
= NULL
;
1638 gHighligthMenuInfo
.QuestionId
= 0;
1639 if (gHighligthMenuInfo
.OpCode
!= NULL
) {
1640 FreePool (gHighligthMenuInfo
.OpCode
);
1641 gHighligthMenuInfo
.OpCode
= NULL
;
1643 gHighligthMenuInfo
.DisplayRow
= 0;
1644 gHighligthMenuInfo
.SkipValue
= 0;
1647 RefreshKeyHelp(gFormData
, Statement
, FALSE
);
1651 Update attribut for this menu.
1653 @param MenuOption The menu opton which this attribut used to.
1654 @param Highlight Whether this menu will be highlight.
1658 SetDisplayAttribute (
1659 IN UI_MENU_OPTION
*MenuOption
,
1660 IN BOOLEAN Highlight
1663 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1665 Statement
= MenuOption
->ThisTag
;
1668 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHighlightTextColor ());
1672 if (MenuOption
->GrayOut
) {
1673 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetGrayedTextColor ());
1675 if (Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) {
1676 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetSubTitleTextColor ());
1678 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
1684 Print string for this menu option.
1686 @param MenuOption The menu opton which this attribut used to.
1687 @param Col The column that this string will be print at.
1688 @param Row The row that this string will be print at.
1689 @param String The string which need to print.
1690 @param Width The width need to print, if string is less than the
1691 width, the block space will be used.
1692 @param Highlight Whether this menu will be highlight.
1697 IN UI_MENU_OPTION
*MenuOption
,
1702 IN BOOLEAN Highlight
1708 // Print string with normal color.
1711 PrintStringAtWithWidth (Col
, Row
, String
, Width
);
1716 // Print the highlight menu string.
1717 // First print the highlight string.
1719 SetDisplayAttribute(MenuOption
, TRUE
);
1720 Length
= PrintStringAt (Col
, Row
, String
);
1723 // Second, clean the empty after the string.
1725 SetDisplayAttribute(MenuOption
, FALSE
);
1726 PrintStringAtWithWidth (Col
+ Length
, Row
, L
"", Width
- Length
);
1730 Check whether this menu can has option string.
1732 @param MenuOption The menu opton which this attribut used to.
1734 @retval TRUE This menu option can have option string.
1735 @retval FALSE This menu option can't have option string.
1740 IN UI_MENU_OPTION
*MenuOption
1743 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1746 EFI_IFR_TEXT
*TestOp
;
1749 Statement
= MenuOption
->ThisTag
;
1752 // See if the second text parameter is really NULL
1754 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
1755 TestOp
= (EFI_IFR_TEXT
*) Statement
->OpCode
;
1756 if (TestOp
->TextTwo
!= 0) {
1757 String
= GetToken (TestOp
->TextTwo
, gFormData
->HiiHandle
);
1758 Size
= StrLen (String
);
1763 if ((Statement
->OpCode
->OpCode
== EFI_IFR_SUBTITLE_OP
) ||
1764 (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
) ||
1765 (Statement
->OpCode
->OpCode
== EFI_IFR_PASSWORD_OP
) ||
1766 (Statement
->OpCode
->OpCode
== EFI_IFR_ACTION_OP
) ||
1767 (Statement
->OpCode
->OpCode
== EFI_IFR_RESET_BUTTON_OP
) ||
1769 // Allow a wide display if text op-code and no secondary text op-code
1771 ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (Size
== 0))
1782 Print string for this menu option.
1784 @param MenuOption The menu opton which this attribut used to.
1785 @param SkipWidth The skip width between the left to the start of the prompt.
1786 @param BeginCol The begin column for one menu.
1787 @param SkipLine The skip line for this menu.
1788 @param BottomRow The bottom row for this form.
1789 @param Highlight Whether this menu will be highlight.
1790 @param UpdateCol Whether need to update the column info for Date/Time.
1792 @retval EFI_SUCESSS Process the user selection success.
1797 IN UI_MENU_OPTION
*MenuOption
,
1802 IN BOOLEAN Highlight
,
1803 IN BOOLEAN UpdateCol
1806 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
1811 CHAR16
*OptionString
;
1812 CHAR16
*OutputString
;
1820 UINTN PromptLineNum
;
1821 UINTN OptionLineNum
;
1825 Statement
= MenuOption
->ThisTag
;
1835 // Set default color.
1837 SetDisplayAttribute (MenuOption
, FALSE
);
1840 // 1. Paint the option string.
1842 Status
= ProcessOptions (MenuOption
, FALSE
, &OptionString
, FALSE
);
1843 if (EFI_ERROR (Status
)) {
1847 if (OptionString
!= NULL
) {
1848 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1850 // Adjust option string for date/time opcode.
1852 ProcessStringForDateTime(MenuOption
, OptionString
, UpdateCol
);
1855 Width
= (UINT16
) gOptionBlockWidth
- 1;
1856 Row
= MenuOption
->Row
;
1860 for (Index
= 0; GetLineByWidth (OptionString
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1861 if (((Temp2
== 0)) && (Row
<= BottomRow
)) {
1862 if (Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
|| Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
) {
1864 // For date/time question, it has three menu options for this qustion.
1865 // The first/second menu options with the skip value is 0. the last one
1866 // with skip value is 1.
1868 if (MenuOption
->Skip
!= 0) {
1870 // For date/ time, print the last past (year for date and second for time)
1871 // - 7 means skip [##/##/ for date and [##:##: for time.
1873 DisplayMenuString (MenuOption
,MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1 - 7, Highlight
);
1876 // For date/ time, print the first and second past (year for date and second for time)
1877 // The OutputString has a NARROW_CHAR or WIDE_CHAR at the begin of the string,
1878 // so need to - 1 to remove it, otherwise, it will clean 1 extr char follow it.
1879 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, StrLen (OutputString
) - 1, Highlight
);
1882 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1888 // If there is more string to process print on the next row and increment the Skip value
1890 if (StrLen (&OptionString
[Index
]) != 0) {
1894 // Since the Number of lines for this menu entry may or may not be reflected accurately
1895 // since the prompt might be 1 lines and option might be many, and vice versa, we need to do
1896 // some testing to ensure we are keeping this in-sync.
1898 // If the difference in rows is greater than or equal to the skip value, increase the skip value
1900 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1906 FreePool (OutputString
);
1914 FreePool (OptionString
);
1918 // 2. Paint the description.
1920 PromptWidth
= GetWidth (MenuOption
, &AdjustValue
);
1921 Row
= MenuOption
->Row
;
1925 if (MenuOption
->Description
== NULL
|| MenuOption
->Description
[0] == '\0') {
1926 PrintStringAtWithWidth (BeginCol
, Row
, L
"", PromptWidth
+ AdjustValue
+ SkipWidth
);
1929 for (Index
= 0; GetLineByWidth (MenuOption
->Description
, PromptWidth
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1930 if ((Temp
== 0) && (Row
<= BottomRow
)) {
1932 // 1.Clean the start LEFT_SKIPPED_COLUMNS
1934 PrintStringAtWithWidth (BeginCol
, Row
, L
"", SkipWidth
);
1936 if (Statement
->OpCode
->OpCode
== EFI_IFR_REF_OP
&& MenuOption
->Col
>= 2) {
1938 // Print Arrow for Goto button.
1941 MenuOption
->Col
- 2,
1943 GEOMETRICSHAPE_RIGHT_TRIANGLE
1946 DisplayMenuString (MenuOption
, MenuOption
->Col
, Row
, OutputString
, PromptWidth
+ AdjustValue
, Highlight
);
1950 // If there is more string to process print on the next row and increment the Skip value
1952 if (StrLen (&MenuOption
->Description
[Index
]) != 0) {
1958 FreePool (OutputString
);
1969 // 3. If this is a text op with secondary text information
1971 if ((Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) && (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
!= 0)) {
1972 StringPtr
= GetToken (((EFI_IFR_TEXT
*)Statement
->OpCode
)->TextTwo
, gFormData
->HiiHandle
);
1974 Width
= (UINT16
) gOptionBlockWidth
- 1;
1975 Row
= MenuOption
->Row
;
1979 for (Index
= 0; GetLineByWidth (StringPtr
, Width
, &GlyphWidth
, &Index
, &OutputString
) != 0x0000;) {
1980 if ((Temp3
== 0) && (Row
<= BottomRow
)) {
1981 DisplayMenuString (MenuOption
, MenuOption
->OptCol
, Row
, OutputString
, Width
+ 1, Highlight
);
1985 // If there is more string to process print on the next row and increment the Skip value
1987 if (StrLen (&StringPtr
[Index
]) != 0) {
1991 // If the rows for text two is greater than or equal to the skip value, increase the skip value
1993 if ((Row
- MenuOption
->Row
) >= MenuOption
->Skip
) {
1999 FreePool (OutputString
);
2005 FreePool (StringPtr
);
2009 // 4.Line number for Option string and prompt string are not equal.
2010 // Clean the column whose line number is less.
2012 if (HasOptionString(MenuOption
) && (OptionLineNum
!= PromptLineNum
)) {
2013 Col
= OptionLineNum
< PromptLineNum
? MenuOption
->OptCol
: BeginCol
;
2014 Row
= (OptionLineNum
< PromptLineNum
? OptionLineNum
: PromptLineNum
) + MenuOption
->Row
;
2015 Width
= (UINT16
) (OptionLineNum
< PromptLineNum
? gOptionBlockWidth
: PromptWidth
+ AdjustValue
+ SkipWidth
);
2016 MaxRow
= (OptionLineNum
< PromptLineNum
? PromptLineNum
: OptionLineNum
) + MenuOption
->Row
- 1;
2018 while (Row
<= MaxRow
) {
2019 DisplayMenuString (MenuOption
, Col
, Row
++, L
"", Width
, FALSE
);
2027 Display menu and wait for user to select one menu option, then return it.
2028 If AutoBoot is enabled, then if user doesn't select any option,
2029 after period of time, it will automatically return the first menu option.
2031 @param FormData The current form data info.
2033 @retval EFI_SUCESSS Process the user selection success.
2034 @retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
2039 IN FORM_DISPLAY_ENGINE_FORM
*FormData
2044 UINTN DistanceValue
;
2053 CHAR16
*OptionString
;
2055 CHAR16
*HelpHeaderString
;
2056 CHAR16
*HelpBottomString
;
2065 LIST_ENTRY
*TopOfScreen
;
2066 LIST_ENTRY
*SavedListEntry
;
2067 UI_MENU_OPTION
*MenuOption
;
2068 UI_MENU_OPTION
*NextMenuOption
;
2069 UI_MENU_OPTION
*SavedMenuOption
;
2070 UI_CONTROL_FLAG ControlFlag
;
2071 UI_SCREEN_OPERATION ScreenOperation
;
2072 FORM_DISPLAY_ENGINE_STATEMENT
*Statement
;
2073 BROWSER_HOT_KEY
*HotKey
;
2074 UINTN HelpPageIndex
;
2075 UINTN HelpPageCount
;
2078 UINTN HelpHeaderLine
;
2079 UINTN HelpBottomLine
;
2080 BOOLEAN MultiHelpPage
;
2081 UINT16 EachLineWidth
;
2082 UINT16 HeaderLineWidth
;
2083 UINT16 BottomLineWidth
;
2084 EFI_STRING_ID HelpInfo
;
2085 UI_EVENT_TYPE EventType
;
2086 BOOLEAN SkipHighLight
;
2088 EventType
= UIEventNone
;
2089 Status
= EFI_SUCCESS
;
2091 HelpHeaderString
= NULL
;
2092 HelpBottomString
= NULL
;
2093 OptionString
= NULL
;
2094 ScreenOperation
= UiNoOperation
;
2102 MultiHelpPage
= FALSE
;
2104 HeaderLineWidth
= 0;
2105 BottomLineWidth
= 0;
2109 SkipHighLight
= FALSE
;
2111 NextMenuOption
= NULL
;
2112 SavedMenuOption
= NULL
;
2116 gModalSkipColumn
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 6;
2118 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
2120 TopRow
= gStatementDimensions
.TopRow
+ SCROLL_ARROW_HEIGHT
;
2121 BottomRow
= gStatementDimensions
.BottomRow
- SCROLL_ARROW_HEIGHT
- 1;
2124 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2125 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gModalSkipColumn
;
2127 Col
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
;
2130 FindTopMenu(FormData
, &TopOfScreen
, &NewPos
, &SkipValue
);
2132 gST
->ConOut
->EnableCursor (gST
->ConOut
, FALSE
);
2134 ControlFlag
= CfInitialization
;
2136 switch (ControlFlag
) {
2137 case CfInitialization
:
2138 if ((gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
) ||
2139 (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))) {
2141 // Clear Statement range if different formset is painted.
2144 gStatementDimensions
.LeftColumn
,
2145 gStatementDimensions
.RightColumn
,
2146 TopRow
- SCROLL_ARROW_HEIGHT
,
2147 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2148 GetFieldTextColor ()
2152 ControlFlag
= CfRepaint
;
2156 ControlFlag
= CfRefreshHighLight
;
2166 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2169 // 1. Check whether need to print the arrow up.
2171 if (!ValueIsScroll (TRUE
, TopOfScreen
)) {
2175 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2176 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2178 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, TopRow
- 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2181 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2183 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2184 TopRow
- SCROLL_ARROW_HEIGHT
,
2187 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2191 // 2.Paint the menu.
2193 for (Link
= TopOfScreen
; Link
!= &gMenuOption
; Link
= Link
->ForwardLink
) {
2194 MenuOption
= MENU_OPTION_FROM_LINK (Link
);
2195 MenuOption
->Row
= Row
;
2196 MenuOption
->Col
= Col
;
2197 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2198 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
+ gModalSkipColumn
;
2200 MenuOption
->OptCol
= gStatementDimensions
.LeftColumn
+ LEFT_SKIPPED_COLUMNS
+ gPromptBlockWidth
;
2203 if (MenuOption
->NestInStatement
) {
2204 MenuOption
->Col
+= SUBTITLE_INDENT
;
2208 // Save the highlight menu, will be used in CfRefreshHighLight case.
2210 if (Link
== NewPos
) {
2211 SavedMenuOption
= MenuOption
;
2212 SkipHighLight
= TRUE
;
2215 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2216 Status
= DisplayOneMenu (MenuOption
,
2217 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2218 gStatementDimensions
.LeftColumn
+ gModalSkipColumn
,
2219 Link
== TopOfScreen
? SkipValue
: 0,
2221 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2225 Status
= DisplayOneMenu (MenuOption
,
2226 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2227 gStatementDimensions
.LeftColumn
,
2228 Link
== TopOfScreen
? SkipValue
: 0,
2230 (BOOLEAN
) ((Link
== NewPos
) && IsSelectable(MenuOption
)),
2235 if (EFI_ERROR (Status
)) {
2239 // 3. Update the row info which will be used by next menu.
2241 if (Link
== TopOfScreen
) {
2242 Row
+= MenuOption
->Skip
- SkipValue
;
2244 Row
+= MenuOption
->Skip
;
2247 if (Row
> BottomRow
) {
2248 if (!ValueIsScroll (FALSE
, Link
)) {
2252 Row
= BottomRow
+ 1;
2258 // 3. Menus in this form may not cover all form, clean the remain field.
2260 while (Row
<= BottomRow
) {
2261 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2262 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * gModalSkipColumn
);
2264 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, Row
++, L
"", gStatementDimensions
.RightColumn
- gHelpBlockWidth
- gStatementDimensions
.LeftColumn
);
2269 // 4. Print the down arrow row.
2271 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2272 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
+ gModalSkipColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * + gModalSkipColumn
);
2274 PrintStringAtWithWidth(gStatementDimensions
.LeftColumn
, BottomRow
+ 1, L
"", gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
);
2277 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetArrowColor ());
2279 gStatementDimensions
.LeftColumn
+ gPromptBlockWidth
+ gOptionBlockWidth
+ 1,
2280 BottomRow
+ SCROLL_ARROW_HEIGHT
,
2283 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetFieldTextColor ());
2290 case CfRefreshHighLight
:
2293 // MenuOption: Last menu option that need to remove hilight
2294 // MenuOption is set to NULL in Repaint
2295 // NewPos: Current menu option that need to hilight
2297 ControlFlag
= CfUpdateHelpString
;
2299 if (SkipHighLight
) {
2300 MenuOption
= SavedMenuOption
;
2301 SkipHighLight
= FALSE
;
2302 UpdateHighlightMenuInfo (MenuOption
, TopOfScreen
== &MenuOption
->Link
? SkipValue
: 0);
2306 if (IsListEmpty (&gMenuOption
)) {
2308 // No menu option, just update the hotkey filed.
2310 RefreshKeyHelp(gFormData
, NULL
, FALSE
);
2314 if (MenuOption
!= NULL
&& TopOfScreen
== &MenuOption
->Link
) {
2319 if (NewPos
== TopOfScreen
) {
2325 if (NewPos
!= NULL
&& (MenuOption
== NULL
|| NewPos
!= &MenuOption
->Link
)) {
2326 if (MenuOption
!= NULL
) {
2328 // Remove the old highlight menu.
2330 Status
= DisplayOneMenu (MenuOption
,
2331 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2332 gStatementDimensions
.LeftColumn
,
2341 // This is the current selected statement
2343 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2344 Statement
= MenuOption
->ThisTag
;
2346 UpdateHighlightMenuInfo (MenuOption
, Temp2
);
2348 if (!IsSelectable (MenuOption
)) {
2352 Status
= DisplayOneMenu (MenuOption
,
2353 MenuOption
->Col
- gStatementDimensions
.LeftColumn
,
2354 gStatementDimensions
.LeftColumn
,
2363 case CfUpdateHelpString
:
2364 ControlFlag
= CfPrepareToReadKey
;
2365 if ((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) {
2370 // NewLine means only update highlight menu (remove old highlight and highlith
2371 // the new one), not need to full repain the form.
2373 if (Repaint
|| NewLine
) {
2374 if (IsListEmpty (&gMenuOption
)) {
2376 // Don't print anything if no mwnu option.
2378 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2381 // Don't print anything if it is a NULL help token
2383 ASSERT(MenuOption
!= NULL
);
2384 HelpInfo
= ((EFI_IFR_STATEMENT_HEADER
*) ((CHAR8
*)MenuOption
->ThisTag
->OpCode
+ sizeof (EFI_IFR_OP_HEADER
)))->Help
;
2385 if (HelpInfo
== 0 || !IsSelectable (MenuOption
)) {
2386 StringPtr
= GetToken (STRING_TOKEN (EMPTY_STRING
), gHiiHandle
);
2388 StringPtr
= GetToken (HelpInfo
, gFormData
->HiiHandle
);
2392 RowCount
= BottomRow
- TopRow
+ 1;
2395 // 1.Calculate how many line the help string need to print.
2397 if (HelpString
!= NULL
) {
2398 FreePool (HelpString
);
2401 HelpLine
= ProcessHelpString (StringPtr
, &HelpString
, &EachLineWidth
, RowCount
);
2402 FreePool (StringPtr
);
2404 if (HelpLine
> RowCount
) {
2405 MultiHelpPage
= TRUE
;
2406 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_UP
), gHiiHandle
);
2407 if (HelpHeaderString
!= NULL
) {
2408 FreePool (HelpHeaderString
);
2409 HelpHeaderString
= NULL
;
2411 HelpHeaderLine
= ProcessHelpString (StringPtr
, &HelpHeaderString
, &HeaderLineWidth
, 0);
2412 FreePool (StringPtr
);
2413 StringPtr
= GetToken (STRING_TOKEN(ADJUST_HELP_PAGE_DOWN
), gHiiHandle
);
2414 if (HelpBottomString
!= NULL
) {
2415 FreePool (HelpBottomString
);
2416 HelpBottomString
= NULL
;
2418 HelpBottomLine
= ProcessHelpString (StringPtr
, &HelpBottomString
, &BottomLineWidth
, 0);
2419 FreePool (StringPtr
);
2421 // Calculate the help page count.
2423 if (HelpLine
> 2 * RowCount
- 2) {
2424 HelpPageCount
= (HelpLine
- RowCount
+ 1) / (RowCount
- 2) + 1;
2425 if ((HelpLine
- RowCount
+ 1) % (RowCount
- 2) > 1) {
2432 MultiHelpPage
= FALSE
;
2437 // Check whether need to show the 'More(U/u)' at the begin.
2438 // Base on current direct info, here shows aligned to the right side of the column.
2439 // If the direction is multi line and aligned to right side may have problem, so
2440 // add ASSERT code here.
2442 if (HelpPageIndex
> 0) {
2443 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2444 for (Index
= 0; Index
< HelpHeaderLine
; Index
++) {
2445 ASSERT (HelpHeaderLine
== 1);
2446 ASSERT (GetStringWidth (HelpHeaderString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2447 PrintStringAtWithWidth (
2448 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2454 gStatementDimensions
.RightColumn
- GetStringWidth (HelpHeaderString
) / 2 - 1,
2456 &HelpHeaderString
[Index
* HeaderLineWidth
]
2461 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetHelpTextColor ());
2463 // Print the help string info.
2465 if (!MultiHelpPage
) {
2466 for (Index
= 0; Index
< HelpLine
; Index
++) {
2467 PrintStringAtWithWidth (
2468 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2470 &HelpString
[Index
* EachLineWidth
],
2474 for (; Index
< RowCount
; Index
++) {
2475 PrintStringAtWithWidth (
2476 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2482 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2484 if (HelpPageIndex
== 0) {
2485 for (Index
= 0; Index
< RowCount
- HelpBottomLine
; Index
++) {
2486 PrintStringAtWithWidth (
2487 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2489 &HelpString
[Index
* EachLineWidth
],
2494 for (Index
= 0; (Index
< RowCount
- HelpBottomLine
- HelpHeaderLine
) &&
2495 (Index
+ HelpPageIndex
* (RowCount
- 2) + 1 < HelpLine
); Index
++) {
2496 PrintStringAtWithWidth (
2497 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2498 Index
+ TopRow
+ HelpHeaderLine
,
2499 &HelpString
[(Index
+ HelpPageIndex
* (RowCount
- 2) + 1)* EachLineWidth
],
2503 if (HelpPageIndex
== HelpPageCount
- 1) {
2504 for (; Index
< RowCount
- HelpHeaderLine
; Index
++) {
2505 PrintStringAtWithWidth (
2506 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2507 Index
+ TopRow
+ HelpHeaderLine
,
2512 gST
->ConOut
->SetCursorPosition(gST
->ConOut
, gStatementDimensions
.RightColumn
-1, BottomRow
);
2518 // Check whether need to print the 'More(D/d)' at the bottom.
2519 // Base on current direct info, here shows aligned to the right side of the column.
2520 // If the direction is multi line and aligned to right side may have problem, so
2521 // add ASSERT code here.
2523 if (HelpPageIndex
< HelpPageCount
- 1 && MultiHelpPage
) {
2524 gST
->ConOut
->SetAttribute (gST
->ConOut
, GetInfoTextColor ());
2525 for (Index
= 0; Index
< HelpBottomLine
; Index
++) {
2526 ASSERT (HelpBottomLine
== 1);
2527 ASSERT (GetStringWidth (HelpBottomString
) / 2 < (UINTN
) (gHelpBlockWidth
- 1));
2528 PrintStringAtWithWidth (
2529 gStatementDimensions
.RightColumn
- gHelpBlockWidth
,
2530 BottomRow
+ Index
- HelpBottomLine
+ 1,
2535 gStatementDimensions
.RightColumn
- GetStringWidth (HelpBottomString
) / 2 - 1,
2536 BottomRow
+ Index
- HelpBottomLine
+ 1,
2537 &HelpBottomString
[Index
* BottomLineWidth
]
2542 // Reset this flag every time we finish using it.
2548 case CfPrepareToReadKey
:
2549 ControlFlag
= CfReadKey
;
2550 ScreenOperation
= UiNoOperation
;
2554 ControlFlag
= CfScreenOperation
;
2557 // Wait for user's selection
2560 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2561 if (!EFI_ERROR (Status
)) {
2562 EventType
= UIEventKey
;
2567 // If we encounter error, continue to read another key in.
2569 if (Status
!= EFI_NOT_READY
) {
2573 EventType
= UiWaitForEvent(gST
->ConIn
->WaitForKey
);
2574 if (EventType
== UIEventKey
) {
2575 gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2580 if (EventType
== UIEventDriver
) {
2581 gUserInput
->Action
= BROWSER_ACTION_NONE
;
2582 ControlFlag
= CfExit
;
2586 if (EventType
== UIEventTimeOut
) {
2587 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2588 ControlFlag
= CfExit
;
2592 switch (Key
.UnicodeChar
) {
2593 case CHAR_CARRIAGE_RETURN
:
2594 if(MenuOption
== NULL
|| MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2595 ControlFlag
= CfReadKey
;
2599 ScreenOperation
= UiSelect
;
2604 // We will push the adjustment of these numeric values directly to the input handler
2605 // NOTE: we won't handle manual input numeric
2610 // If the screen has no menu items, and the user didn't select UiReset
2611 // ignore the selection and go back to reading keys.
2613 ASSERT(MenuOption
!= NULL
);
2614 if(IsListEmpty (&gMenuOption
) || MenuOption
->GrayOut
|| MenuOption
->ReadOnly
) {
2615 ControlFlag
= CfReadKey
;
2619 Statement
= MenuOption
->ThisTag
;
2620 if ((Statement
->OpCode
->OpCode
== EFI_IFR_DATE_OP
)
2621 || (Statement
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)
2622 || ((Statement
->OpCode
->OpCode
== EFI_IFR_NUMERIC_OP
) && (GetFieldFromNum(Statement
->OpCode
) != 0))
2624 if (Key
.UnicodeChar
== '+') {
2625 gDirection
= SCAN_RIGHT
;
2627 gDirection
= SCAN_LEFT
;
2630 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2631 if (OptionString
!= NULL
) {
2632 FreePool (OptionString
);
2634 if (EFI_ERROR (Status
)) {
2636 // Repaint to clear possible error prompt pop-up
2641 ControlFlag
= CfExit
;
2647 ScreenOperation
= UiUp
;
2652 ScreenOperation
= UiDown
;
2656 if(IsListEmpty (&gMenuOption
)) {
2657 ControlFlag
= CfReadKey
;
2661 ASSERT(MenuOption
!= NULL
);
2662 if (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_CHECKBOX_OP
&& !MenuOption
->GrayOut
&& !MenuOption
->ReadOnly
) {
2663 ScreenOperation
= UiSelect
;
2669 if (!MultiHelpPage
) {
2670 ControlFlag
= CfReadKey
;
2673 ControlFlag
= CfUpdateHelpString
;
2674 HelpPageIndex
= HelpPageIndex
< HelpPageCount
- 1 ? HelpPageIndex
+ 1 : HelpPageCount
- 1;
2679 if (!MultiHelpPage
) {
2680 ControlFlag
= CfReadKey
;
2683 ControlFlag
= CfUpdateHelpString
;
2684 HelpPageIndex
= HelpPageIndex
> 0 ? HelpPageIndex
- 1 : 0;
2688 for (Index
= 0; Index
< mScanCodeNumber
; Index
++) {
2689 if (Key
.ScanCode
== gScanCodeToOperation
[Index
].ScanCode
) {
2690 ScreenOperation
= gScanCodeToOperation
[Index
].ScreenOperation
;
2695 if (((FormData
->Attribute
& HII_DISPLAY_MODAL
) != 0) && (Key
.ScanCode
== SCAN_ESC
|| Index
== mScanCodeNumber
)) {
2697 // ModalForm has no ESC key and Hot Key.
2699 ControlFlag
= CfReadKey
;
2700 } else if (Index
== mScanCodeNumber
) {
2702 // Check whether Key matches the registered hot key.
2705 HotKey
= GetHotKeyFromRegisterList (&Key
);
2706 if (HotKey
!= NULL
) {
2707 ScreenOperation
= UiHotKey
;
2714 case CfScreenOperation
:
2715 if ((ScreenOperation
!= UiReset
) && (ScreenOperation
!= UiHotKey
)) {
2717 // If the screen has no menu items, and the user didn't select UiReset or UiHotKey
2718 // ignore the selection and go back to reading keys.
2720 if (IsListEmpty (&gMenuOption
)) {
2721 ControlFlag
= CfReadKey
;
2727 Index
< sizeof (gScreenOperationToControlFlag
) / sizeof (gScreenOperationToControlFlag
[0]);
2730 if (ScreenOperation
== gScreenOperationToControlFlag
[Index
].ScreenOperation
) {
2731 ControlFlag
= gScreenOperationToControlFlag
[Index
].ControlFlag
;
2738 ControlFlag
= CfRepaint
;
2740 ASSERT(MenuOption
!= NULL
);
2741 Statement
= MenuOption
->ThisTag
;
2742 if (Statement
->OpCode
->OpCode
== EFI_IFR_TEXT_OP
) {
2746 switch (Statement
->OpCode
->OpCode
) {
2747 case EFI_IFR_REF_OP
:
2748 case EFI_IFR_ACTION_OP
:
2749 case EFI_IFR_RESET_BUTTON_OP
:
2750 ControlFlag
= CfExit
;
2755 // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
2757 RefreshKeyHelp (gFormData
, Statement
, TRUE
);
2758 Status
= ProcessOptions (MenuOption
, TRUE
, &OptionString
, TRUE
);
2760 if (OptionString
!= NULL
) {
2761 FreePool (OptionString
);
2764 if (EFI_ERROR (Status
)) {
2767 RefreshKeyHelp (gFormData
, Statement
, FALSE
);
2770 ControlFlag
= CfExit
;
2778 // We come here when someone press ESC
2779 // If the policy is not exit front page when user press ESC, process here.
2781 if (!FormExitPolicy()) {
2784 ControlFlag
= CfRepaint
;
2789 // When user press ESC, it will try to show another menu, should clean the gSequence info.
2791 if (gSequence
!= 0) {
2795 gUserInput
->Action
= BROWSER_ACTION_FORM_EXIT
;
2796 ControlFlag
= CfExit
;
2800 ControlFlag
= CfRepaint
;
2802 ASSERT (HotKey
!= NULL
);
2803 gUserInput
->Action
= HotKey
->Action
;
2804 ControlFlag
= CfExit
;
2808 ControlFlag
= CfRepaint
;
2809 ASSERT(MenuOption
!= NULL
);
2810 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2811 if (MenuOption
->Sequence
!= 0) {
2813 // In the middle or tail of the Date/Time op-code set, go left.
2815 ASSERT(NewPos
!= NULL
);
2816 NewPos
= NewPos
->BackLink
;
2822 ControlFlag
= CfRepaint
;
2823 ASSERT(MenuOption
!= NULL
);
2824 if ((MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_DATE_OP
) || (MenuOption
->ThisTag
->OpCode
->OpCode
== EFI_IFR_TIME_OP
)) {
2825 if (MenuOption
->Sequence
!= 2) {
2827 // In the middle or tail of the Date/Time op-code set, go left.
2829 ASSERT(NewPos
!= NULL
);
2830 NewPos
= NewPos
->ForwardLink
;
2836 ControlFlag
= CfRepaint
;
2839 SavedListEntry
= NewPos
;
2840 ASSERT(NewPos
!= NULL
);
2842 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2843 ASSERT (MenuOption
!= NULL
);
2846 // Adjust Date/Time position before we advance forward.
2848 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2850 NewPos
= NewPos
->BackLink
;
2852 // Find next selectable menu or the first menu beyond current form.
2854 Difference
= MoveToNextStatement (TRUE
, &NewPos
, MenuOption
->Row
- TopRow
, FALSE
);
2855 if (Difference
< 0) {
2857 // We hit the begining MenuOption that can be focused
2858 // so we simply scroll to the top.
2861 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
2862 TopOfScreen
= gMenuOption
.ForwardLink
;
2863 NewPos
= SavedListEntry
;
2867 // Scroll up to the last page when we have arrived at top page.
2869 TopOfScreen
= FindTopOfScreenMenu (gMenuOption
.BackLink
, BottomRow
- TopRow
, &SkipValue
);
2870 NewPos
= gMenuOption
.BackLink
;
2871 MoveToNextStatement (TRUE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
2874 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
2876 if (MenuOption
->Row
< TopRow
+ Difference
+ NextMenuOption
->Skip
) {
2878 // Previous focus MenuOption is above the TopOfScreen, so we need to scroll
2880 TopOfScreen
= NewPos
;
2886 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
2888 // BottomRow - TopRow + 1 means the total rows current forms supported.
2889 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
2890 // and new top menu. New top menu will all shows in next form, but last highlight menu
2891 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
2892 // last highlight menu.
2894 if (!IsSelectable(NextMenuOption
) && IsSelectable(MenuOption
) &&
2895 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
2896 NewPos
= SavedListEntry
;
2900 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2903 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2905 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2906 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2911 // SkipValue means lines is skipped when show the top menu option.
2913 ControlFlag
= CfRepaint
;
2919 // First minus the menu of the top screen, it's value is SkipValue.
2921 if (SkipValue
>= BottomRow
- TopRow
+ 1) {
2923 // SkipValue > (BottomRow - TopRow + 1) means current menu has more than one
2924 // form of options to be show, so just update the SkipValue to show the next
2925 // parts of options.
2927 SkipValue
-= BottomRow
- TopRow
+ 1;
2928 NewPos
= TopOfScreen
;
2931 Index
= (BottomRow
+ 1) - SkipValue
- TopRow
;
2934 TopOfScreen
= FindTopOfScreenMenu(TopOfScreen
, Index
, &SkipValue
);
2935 NewPos
= TopOfScreen
;
2936 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, FALSE
);
2938 UpdateStatusBar (INPUT_ERROR
, FALSE
);
2941 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
2942 // Don't do this when we are already in the first page.
2944 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
2945 AdjustDateAndTimePosition (TRUE
, &NewPos
);
2950 // SkipValue means lines is skipped when show the top menu option.
2952 ControlFlag
= CfRepaint
;
2957 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2958 Index
= TopRow
+ NextMenuOption
->Skip
- SkipValue
;
2960 // Count to the menu option which will show at the top of the next form.
2962 while ((Index
<= BottomRow
+ 1) && (Link
->ForwardLink
!= &gMenuOption
)) {
2963 Link
= Link
->ForwardLink
;
2964 NextMenuOption
= MENU_OPTION_FROM_LINK (Link
);
2965 Index
= Index
+ NextMenuOption
->Skip
;
2968 if ((Link
->ForwardLink
== &gMenuOption
) && (Index
<= BottomRow
+ 1)) {
2970 // Highlight on the last menu which can be highlight.
2973 MoveToNextStatement (TRUE
, &Link
, Index
- TopRow
, TRUE
);
2976 // Calculate the skip line for top of screen menu.
2978 if (Link
== TopOfScreen
) {
2980 // The top of screen menu option occupies the entire form.
2982 SkipValue
+= BottomRow
- TopRow
+ 1;
2984 SkipValue
= NextMenuOption
->Skip
- (Index
- (BottomRow
+ 1));
2989 // Move to the Next selectable menu.
2991 MoveToNextStatement (FALSE
, &Link
, BottomRow
- TopRow
, TRUE
);
2995 // Save the menu as the next highlight menu.
2999 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3002 // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.
3003 // Don't do this when we are already in the last page.
3005 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3006 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3011 // SkipValue means lines is skipped when show the top menu option.
3012 // NewPos points to the menu which is highlighted now.
3014 ControlFlag
= CfRepaint
;
3017 if (NewPos
== TopOfScreen
) {
3023 SavedListEntry
= NewPos
;
3025 // Since the behavior of hitting the down arrow on a Date/Time op-code is intended
3026 // to be one that progresses to the next set of op-codes, we need to advance to the last
3027 // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate
3028 // checking can be done. The only other logic we need to introduce is that if a Date/Time
3029 // op-code is the last entry in the menu, we need to rewind back to the first op-code of
3030 // the Date/Time op-code.
3032 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3034 MenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3035 NewPos
= NewPos
->ForwardLink
;
3037 // Find the next selectable menu.
3039 if (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
> BottomRow
+ 1) {
3040 if (gMenuOption
.ForwardLink
== NewPos
|| &gMenuOption
== NewPos
) {
3046 Difference
= MoveToNextStatement (FALSE
, &NewPos
, BottomRow
+ 1 - (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
), FALSE
);
3048 if (Difference
< 0) {
3050 // Scroll to the first page.
3052 if (TopOfScreen
!= gMenuOption
.ForwardLink
|| SkipValue
!= 0) {
3053 TopOfScreen
= gMenuOption
.ForwardLink
;
3057 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3059 NewPos
= gMenuOption
.ForwardLink
;
3060 MoveToNextStatement (FALSE
, &NewPos
, BottomRow
- TopRow
, TRUE
);
3064 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3066 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3067 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3072 // Get next selected menu info.
3074 AdjustDateAndTimePosition (FALSE
, &NewPos
);
3075 NextMenuOption
= MENU_OPTION_FROM_LINK (NewPos
);
3076 if (NextMenuOption
->Row
== 0) {
3077 UpdateOptionSkipLines (NextMenuOption
);
3081 // Calculate new highlight menu end row.
3083 Temp
= (MenuOption
->Row
+ MenuOption
->Skip
- Temp2
) + Difference
+ NextMenuOption
->Skip
- 1;
3084 if (Temp
> BottomRow
) {
3086 // Get the top screen menu info.
3088 AdjustDateAndTimePosition (FALSE
, &TopOfScreen
);
3089 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3092 // Current Top screen menu occupy (SavedMenuOption->Skip - SkipValue) rows.
3093 // Full shows the new selected menu need to skip (Temp - BottomRow - 1) rows.
3095 if ((Temp
- BottomRow
) >= (SavedMenuOption
->Skip
- SkipValue
)) {
3097 // Skip the top op-code
3099 TopOfScreen
= TopOfScreen
->ForwardLink
;
3100 DistanceValue
= (Temp
- BottomRow
) - (SavedMenuOption
->Skip
- SkipValue
);
3102 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3105 // If we have a remainder, skip that many more op-codes until we drain the remainder
3106 // Special case is the selected highlight menu has more than one form of menus.
3108 while (DistanceValue
>= SavedMenuOption
->Skip
&& TopOfScreen
!= NewPos
) {
3110 // Since the Difference is greater than or equal to this op-code's skip value, skip it
3112 DistanceValue
= DistanceValue
- (INTN
) SavedMenuOption
->Skip
;
3113 TopOfScreen
= TopOfScreen
->ForwardLink
;
3114 SavedMenuOption
= MENU_OPTION_FROM_LINK (TopOfScreen
);
3117 // Since we will act on this op-code in the next routine, and increment the
3118 // SkipValue, set the skips to one less than what is required.
3120 if (TopOfScreen
!= NewPos
) {
3121 SkipValue
= DistanceValue
;
3127 // Since we will act on this op-code in the next routine, and increment the
3128 // SkipValue, set the skips to one less than what is required.
3130 SkipValue
+= Temp
- BottomRow
;
3133 } else if (!IsSelectable (NextMenuOption
)) {
3135 // Continue to go down until scroll to next page or the selectable option is found.
3137 ScreenOperation
= UiDown
;
3138 ControlFlag
= CfScreenOperation
;
3142 MenuOption
= MENU_OPTION_FROM_LINK (SavedListEntry
);
3145 // Check whether new highlight menu is selectable, if not, keep highlight on the old one.
3147 // BottomRow - TopRow + 1 means the total rows current forms supported.
3148 // Difference + NextMenuOption->Skip + 1 means the distance between last highlight menu
3149 // and new top menu. New top menu will all shows in next form, but last highlight menu
3150 // may only shows 1 line. + 1 at right part means at least need to keep 1 line for the
3151 // last highlight menu.
3153 if (!IsSelectable (NextMenuOption
) && IsSelectable (MenuOption
) &&
3154 (BottomRow
- TopRow
+ 1 >= Difference
+ NextMenuOption
->Skip
+ 1)) {
3155 NewPos
= SavedListEntry
;
3158 UpdateStatusBar (INPUT_ERROR
, FALSE
);
3161 // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.
3163 AdjustDateAndTimePosition (TRUE
, &TopOfScreen
);
3164 AdjustDateAndTimePosition (TRUE
, &NewPos
);
3167 case CfUiNoOperation
:
3168 ControlFlag
= CfRepaint
;
3172 gST
->ConOut
->SetAttribute (gST
->ConOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
3173 if (HelpString
!= NULL
) {
3174 FreePool (HelpString
);
3176 if (HelpHeaderString
!= NULL
) {
3177 FreePool (HelpHeaderString
);
3179 if (HelpBottomString
!= NULL
) {
3180 FreePool (HelpBottomString
);
3192 Base on the browser status info to show an pop up message.
3196 BrowserStatusProcess (
3202 EFI_EVENT WaitList
[2];
3203 EFI_EVENT RefreshIntervalEvent
;
3204 EFI_EVENT TimeOutEvent
;
3208 WARNING_IF_CONTEXT EventContext
;
3209 EFI_IFR_OP_HEADER
*OpCodeBuf
;
3210 EFI_STRING_ID StringToken
;
3211 CHAR16 DiscardChange
;
3212 CHAR16 JumpToFormSet
;
3213 CHAR16
*PrintString
;
3215 if (gFormData
->BrowserStatus
== BROWSER_SUCCESS
) {
3220 TimeOutEvent
= NULL
;
3221 RefreshIntervalEvent
= NULL
;
3223 if (gFormData
->HighLightedStatement
!= NULL
) {
3224 OpCodeBuf
= gFormData
->HighLightedStatement
->OpCode
;
3227 if (gFormData
->BrowserStatus
== (BROWSER_WARNING_IF
)) {
3228 ASSERT (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_WARNING_IF_OP
);
3230 TimeOut
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->TimeOut
;
3231 StringToken
= ((EFI_IFR_WARNING_IF
*) OpCodeBuf
)->Warning
;
3234 if ((gFormData
->BrowserStatus
== (BROWSER_NO_SUBMIT_IF
)) &&
3235 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_NO_SUBMIT_IF_OP
)) {
3236 StringToken
= ((EFI_IFR_NO_SUBMIT_IF
*) OpCodeBuf
)->Error
;
3237 } else if ((gFormData
->BrowserStatus
== (BROWSER_INCONSISTENT_IF
)) &&
3238 (OpCodeBuf
!= NULL
&& OpCodeBuf
->OpCode
== EFI_IFR_INCONSISTENT_IF_OP
)) {
3239 StringToken
= ((EFI_IFR_INCONSISTENT_IF
*) OpCodeBuf
)->Error
;
3243 if (StringToken
!= 0) {
3244 ErrorInfo
= GetToken (StringToken
, gFormData
->HiiHandle
);
3245 } else if (gFormData
->ErrorString
!= NULL
) {
3247 // Only used to compatible with old setup browser.
3248 // Not use this field in new browser core.
3250 ErrorInfo
= gFormData
->ErrorString
;
3252 switch (gFormData
->BrowserStatus
) {
3253 case BROWSER_SUBMIT_FAIL
:
3254 ErrorInfo
= gSaveFailed
;
3257 case BROWSER_FORM_NOT_FOUND
:
3258 ErrorInfo
= gFormNotFound
;
3261 case BROWSER_FORM_SUPPRESS
:
3262 ErrorInfo
= gFormSuppress
;
3265 case BROWSER_PROTOCOL_NOT_FOUND
:
3266 ErrorInfo
= gProtocolNotFound
;
3269 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3270 ErrorInfo
= gNoSubmitIfFailed
;
3274 ErrorInfo
= gBrwoserError
;
3279 switch (gFormData
->BrowserStatus
) {
3280 case BROWSER_SUBMIT_FAIL
:
3281 case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF
:
3282 ASSERT (gUserInput
!= NULL
);
3283 if (gFormData
->BrowserStatus
== (BROWSER_SUBMIT_FAIL
)) {
3284 PrintString
= gSaveProcess
;
3285 JumpToFormSet
= gJumpToFormSet
[0];
3287 PrintString
= gSaveNoSubmitProcess
;
3288 JumpToFormSet
= gCheckError
[0];
3290 DiscardChange
= gDiscardChange
[0];
3293 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, PrintString
, gEmptyString
, NULL
);
3294 } while (((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) &&
3295 ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) != (JumpToFormSet
| UPPER_LOWER_CASE_OFFSET
)));
3297 if ((Key
.UnicodeChar
| UPPER_LOWER_CASE_OFFSET
) == (DiscardChange
| UPPER_LOWER_CASE_OFFSET
)) {
3298 gUserInput
->Action
= BROWSER_ACTION_DISCARD
;
3300 gUserInput
->Action
= BROWSER_ACTION_GOTO
;
3307 CreateDialog (&Key
, gEmptyString
, ErrorInfo
, gPressEnter
, gEmptyString
, NULL
);
3308 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
3310 Status
= gBS
->CreateEvent (EVT_NOTIFY_WAIT
, TPL_CALLBACK
, EmptyEventProcess
, NULL
, &TimeOutEvent
);
3311 ASSERT_EFI_ERROR (Status
);
3313 EventContext
.SyncEvent
= TimeOutEvent
;
3314 EventContext
.TimeOut
= &TimeOut
;
3315 EventContext
.ErrorInfo
= ErrorInfo
;
3317 Status
= gBS
->CreateEvent (EVT_TIMER
| EVT_NOTIFY_SIGNAL
, TPL_CALLBACK
, RefreshTimeOutProcess
, &EventContext
, &RefreshIntervalEvent
);
3318 ASSERT_EFI_ERROR (Status
);
3321 // Show the dialog first to avoid long time not reaction.
3323 gBS
->SignalEvent (RefreshIntervalEvent
);
3325 Status
= gBS
->SetTimer (RefreshIntervalEvent
, TimerPeriodic
, ONE_SECOND
);
3326 ASSERT_EFI_ERROR (Status
);
3329 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
3330 if (!EFI_ERROR (Status
) && Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
3334 if (Status
!= EFI_NOT_READY
) {
3338 WaitList
[0] = TimeOutEvent
;
3339 WaitList
[1] = gST
->ConIn
->WaitForKey
;
3341 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
3342 ASSERT_EFI_ERROR (Status
);
3346 // Timeout occur, close the hoot time out event.
3352 gBS
->CloseEvent (TimeOutEvent
);
3353 gBS
->CloseEvent (RefreshIntervalEvent
);
3358 if (StringToken
!= 0) {
3359 FreePool (ErrorInfo
);
3364 Display one form, and return user input.
3366 @param FormData Form Data to be shown.
3367 @param UserInputData User input data.
3369 @retval EFI_SUCCESS 1.Form Data is shown, and user input is got.
3370 2.Error info has show and return.
3371 @retval EFI_INVALID_PARAMETER The input screen dimension is not valid
3372 @retval EFI_NOT_FOUND New form data has some error.
3377 IN FORM_DISPLAY_ENGINE_FORM
*FormData
,
3378 OUT USER_INPUT
*UserInputData
3383 ASSERT (FormData
!= NULL
);
3384 if (FormData
== NULL
) {
3385 return EFI_INVALID_PARAMETER
;
3388 gUserInput
= UserInputData
;
3389 gFormData
= FormData
;
3392 // Process the status info first.
3394 BrowserStatusProcess();
3395 if (gFormData
->BrowserStatus
!= BROWSER_SUCCESS
) {
3397 // gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here.
3402 Status
= DisplayPageFrame (FormData
, &gStatementDimensions
);
3403 if (EFI_ERROR (Status
)) {
3408 // Global Widths should be initialized before any MenuOption creation
3409 // or the GetWidth() used in UiAddMenuOption() will return incorrect value.
3413 // |<-.->|<-.........->|<- .........->|<-...........->|
3414 // Skip Prompt Option Help
3416 gOptionBlockWidth
= (CHAR16
) ((gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
) / 3) + 1;
3417 gHelpBlockWidth
= (CHAR16
) (gOptionBlockWidth
- 1 - LEFT_SKIPPED_COLUMNS
);
3418 gPromptBlockWidth
= (CHAR16
) (gStatementDimensions
.RightColumn
- gStatementDimensions
.LeftColumn
- 2 * (gOptionBlockWidth
- 1) - 1);
3420 ConvertStatementToMenu();
3423 // Check whether layout is changed.
3426 || (gOldFormEntry
.HiiHandle
!= FormData
->HiiHandle
)
3427 || (!CompareGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
))
3428 || (gOldFormEntry
.FormId
!= FormData
->FormId
)) {
3429 mStatementLayoutIsChanged
= TRUE
;
3431 mStatementLayoutIsChanged
= FALSE
;
3434 Status
= UiDisplayMenu(FormData
);
3437 // Backup last form info.
3439 mIsFirstForm
= FALSE
;
3440 gOldFormEntry
.HiiHandle
= FormData
->HiiHandle
;
3441 CopyGuid (&gOldFormEntry
.FormSetGuid
, &FormData
->FormSetGuid
);
3442 gOldFormEntry
.FormId
= FormData
->FormId
;
3448 Clear Screen to the initial state.
3452 DriverClearDisplayPage (
3456 ClearDisplayPage ();
3457 mIsFirstForm
= TRUE
;
3461 Set Buffer to Value for Size bytes.
3463 @param Buffer Memory to set.
3464 @param Size Number of bytes to set
3465 @param Value Value of the set operation.
3478 while ((Size
--) != 0) {
3484 Initialize Setup Browser driver.
3486 @param ImageHandle The image handle.
3487 @param SystemTable The system table.
3489 @retval EFI_SUCCESS The Setup Browser module is initialized correctly..
3490 @return Other value if failed to initialize the Setup Browser module.
3495 InitializeDisplayEngine (
3496 IN EFI_HANDLE ImageHandle
,
3497 IN EFI_SYSTEM_TABLE
*SystemTable
3501 EFI_INPUT_KEY HotKey
;
3502 EFI_STRING NewString
;
3503 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL
*FormBrowserEx2
;
3506 // Publish our HII data
3508 gHiiHandle
= HiiAddPackages (
3509 &gDisplayEngineGuid
,
3511 DisplayEngineStrings
,
3514 ASSERT (gHiiHandle
!= NULL
);
3517 // Install Form Display protocol
3519 Status
= gBS
->InstallProtocolInterface (
3520 &mPrivateData
.Handle
,
3521 &gEdkiiFormDisplayEngineProtocolGuid
,
3522 EFI_NATIVE_INTERFACE
,
3523 &mPrivateData
.FromDisplayProt
3525 ASSERT_EFI_ERROR (Status
);
3527 InitializeDisplayStrings();
3529 ZeroMem (&gHighligthMenuInfo
, sizeof (gHighligthMenuInfo
));
3530 ZeroMem (&gOldFormEntry
, sizeof (gOldFormEntry
));
3533 // Use BrowserEx2 protocol to register HotKey.
3535 Status
= gBS
->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid
, NULL
, (VOID
**) &FormBrowserEx2
);
3536 if (!EFI_ERROR (Status
)) {
3538 // Register the default HotKey F9 and F10 again.
3540 HotKey
.UnicodeChar
= CHAR_NULL
;
3541 HotKey
.ScanCode
= SCAN_F10
;
3542 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_TEN_STRING
), NULL
);
3543 ASSERT (NewString
!= NULL
);
3544 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_SUBMIT
, 0, NewString
);
3546 HotKey
.ScanCode
= SCAN_F9
;
3547 NewString
= HiiGetString (gHiiHandle
, STRING_TOKEN (FUNCTION_NINE_STRING
), NULL
);
3548 ASSERT (NewString
!= NULL
);
3549 FormBrowserEx2
->RegisterHotKey (&HotKey
, BROWSER_ACTION_DEFAULT
, EFI_HII_DEFAULT_CLASS_STANDARD
, NewString
);
3556 This is the default unload handle for display core drivers.
3558 @param[in] ImageHandle The drivers' driver image.
3560 @retval EFI_SUCCESS The image is unloaded.
3561 @retval Others Failed to unload the image.
3566 UnloadDisplayEngine (
3567 IN EFI_HANDLE ImageHandle
3570 HiiRemovePackages(gHiiHandle
);
3572 FreeDisplayStrings ();
3574 if (gHighligthMenuInfo
.OpCode
!= NULL
) {
3575 FreePool (gHighligthMenuInfo
.OpCode
);