/** @file\r
Implementation for handling user input from the User Interfaces.\r
\r
-Copyright (c) 2004 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
\r
**/\r
\r
-#include "Ui.h"\r
#include "Setup.h"\r
\r
\r
//\r
// Display prompt for string\r
//\r
- CreatePopUp (ScreenSize, 4, &NullCharacter, Prompt, Space, &NullCharacter);\r
+ CreateMultiStringPopUp (ScreenSize, 4, &NullCharacter, Prompt, Space, &NullCharacter);\r
\r
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY));\r
\r
break;\r
\r
case SCAN_ESC:\r
- gBS->FreePool (TempString);\r
- gBS->FreePool (BufferedString);\r
+ FreePool (TempString);\r
+ FreePool (BufferedString);\r
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);\r
return EFI_DEVICE_ERROR;\r
case CHAR_CARRIAGE_RETURN:\r
if (GetStringWidth (StringPtr) >= ((Minimum + 1) * sizeof (CHAR16))) {\r
\r
- gBS->FreePool (TempString);\r
- gBS->FreePool (BufferedString);\r
+ FreePool (TempString);\r
+ FreePool (BufferedString);\r
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);\r
return EFI_SUCCESS;\r
CreateDialog (4, TRUE, 0, NULL, &Key, &NullCharacter, gMiniString, gPressEnter, &NullCharacter);\r
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
\r
- gBS->FreePool (TempString);\r
- gBS->FreePool (BufferedString);\r
+ FreePool (TempString);\r
+ FreePool (BufferedString);\r
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);\r
return EFI_DEVICE_ERROR;\r
EFI_STATUS Status;\r
UINTN Column;\r
UINTN Row;\r
- CHAR16 InputText[23];\r
- CHAR16 FormattedNumber[22];\r
- UINT64 PreviousNumber[20];\r
+ CHAR16 InputText[MAX_NUMERIC_INPUT_WIDTH];\r
+ CHAR16 FormattedNumber[MAX_NUMERIC_INPUT_WIDTH - 1];\r
+ UINT64 PreviousNumber[MAX_NUMERIC_INPUT_WIDTH - 3];\r
UINTN Count;\r
UINTN Loop;\r
BOOLEAN ManualInput;\r
Minimum = Question->Minimum;\r
Maximum = Question->Maximum;\r
\r
+ //\r
+ // Only two case, user can enter to this function: Enter and +/- case.\r
+ // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT\r
+ //\r
+ ManualInput = (BOOLEAN)(gDirection == 0 ? TRUE : FALSE);\r
+\r
if ((Question->Operand == EFI_IFR_DATE_OP) || (Question->Operand == EFI_IFR_TIME_OP)) {\r
DateOrTime = TRUE;\r
} else {\r
}\r
}\r
\r
- if (Step == 0) {\r
- ManualInput = TRUE;\r
- } else {\r
- ManualInput = FALSE;\r
- }\r
-\r
if ((Question->Operand == EFI_IFR_NUMERIC_OP) &&\r
((Question->Flags & EFI_IFR_DISPLAY) == EFI_IFR_DISPLAY_UINT_HEX)) {\r
HexInput = TRUE;\r
HexInput = FALSE;\r
}\r
\r
+ //\r
+ // Enter from "Enter" input, clear the old word showing.\r
+ //\r
if (ManualInput) {\r
- if (HexInput) {\r
- InputWidth = Question->StorageWidth * 2;\r
- } else {\r
- switch (Question->StorageWidth) {\r
- case 1:\r
- InputWidth = 3;\r
- break;\r
+ if (Question->Operand == EFI_IFR_NUMERIC_OP) {\r
+ if (HexInput) {\r
+ InputWidth = Question->StorageWidth * 2;\r
+ } else {\r
+ switch (Question->StorageWidth) {\r
+ case 1:\r
+ InputWidth = 3;\r
+ break;\r
\r
- case 2:\r
- InputWidth = 5;\r
- break;\r
+ case 2:\r
+ InputWidth = 5;\r
+ break;\r
\r
- case 4:\r
- InputWidth = 10;\r
- break;\r
+ case 4:\r
+ InputWidth = 10;\r
+ break;\r
\r
- case 8:\r
- InputWidth = 20;\r
- break;\r
+ case 8:\r
+ InputWidth = 20;\r
+ break;\r
\r
- default:\r
- InputWidth = 0;\r
- break;\r
+ default:\r
+ InputWidth = 0;\r
+ break;\r
+ }\r
}\r
+\r
+ InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+ SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+ ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);\r
+ InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+ InputText[InputWidth + 2] = L'\0';\r
+\r
+ PrintAt (Column, Row, InputText);\r
+ Column++;\r
}\r
\r
- InputText[0] = LEFT_NUMERIC_DELIMITER;\r
- SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
- InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
- InputText[InputWidth + 2] = L'\0';\r
+ if (Question->Operand == EFI_IFR_DATE_OP) {\r
+ if (MenuOption->Sequence == 2) {\r
+ InputWidth = 4;\r
+ } else {\r
+ InputWidth = 2;\r
+ }\r
+\r
+ if (MenuOption->Sequence == 0) {\r
+ InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+ SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+ } else {\r
+ SetUnicodeMem (InputText, InputWidth, L' ');\r
+ }\r
\r
- PrintAt (Column, Row, InputText);\r
- Column++;\r
+ if (MenuOption->Sequence == 2) {\r
+ InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+ } else {\r
+ InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+ }\r
+ InputText[InputWidth + 2] = L'\0';\r
+\r
+ PrintAt (Column, Row, InputText);\r
+ if (MenuOption->Sequence == 0) {\r
+ Column++;\r
+ }\r
+ }\r
+\r
+ if (Question->Operand == EFI_IFR_TIME_OP) {\r
+ InputWidth = 2;\r
+\r
+ if (MenuOption->Sequence == 0) {\r
+ InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+ SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+ } else {\r
+ SetUnicodeMem (InputText, InputWidth, L' ');\r
+ }\r
+\r
+ if (MenuOption->Sequence == 2) {\r
+ InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+ } else {\r
+ InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+ }\r
+ InputText[InputWidth + 2] = L'\0';\r
+\r
+ PrintAt (Column, Row, InputText);\r
+ if (MenuOption->Sequence == 0) {\r
+ Column++;\r
+ }\r
+ }\r
}\r
\r
//\r
switch (Key.ScanCode) {\r
case SCAN_LEFT:\r
case SCAN_RIGHT:\r
- if (DateOrTime) {\r
+ if (DateOrTime && !ManualInput) {\r
//\r
// By setting this value, we will return back to the caller.\r
// We need to do this since an auto-refresh will destroy the adjustment\r
gDirection = SCAN_DOWN;\r
}\r
\r
- if (!ManualInput) {\r
+ if ((Step != 0) && !ManualInput) {\r
if (Key.ScanCode == SCAN_LEFT) {\r
if (EditValue > Step) {\r
EditValue = EditValue - Step;\r
//\r
// Year\r
//\r
- UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%04d", EditValue);\r
+ UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%04d", (UINT16) EditValue);\r
} else {\r
//\r
// Month/Day\r
//\r
- UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", EditValue);\r
+ UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", (UINT8) EditValue);\r
}\r
\r
if (MenuOption->Sequence == 0) {\r
+ ASSERT (EraseLen >= 2);\r
FormattedNumber[EraseLen - 2] = DATE_SEPARATOR;\r
} else if (MenuOption->Sequence == 1) {\r
+ ASSERT (EraseLen >= 1);\r
FormattedNumber[EraseLen - 1] = DATE_SEPARATOR;\r
}\r
} else if (Question->Operand == EFI_IFR_TIME_OP) {\r
- UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", EditValue);\r
+ UnicodeSPrint (FormattedNumber, 21 * sizeof (CHAR16), L"%02d", (UINT8) EditValue);\r
\r
if (MenuOption->Sequence == 0) {\r
+ ASSERT (EraseLen >= 2);\r
FormattedNumber[EraseLen - 2] = TIME_SEPARATOR;\r
} else if (MenuOption->Sequence == 1) {\r
+ ASSERT (EraseLen >= 1);\r
FormattedNumber[EraseLen - 1] = TIME_SEPARATOR;\r
}\r
} else {\r
PrintFormattedNumber (Question, FormattedNumber, 21 * sizeof (CHAR16));\r
}\r
\r
- gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r
+ gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND);\r
for (Loop = 0; Loop < EraseLen; Loop++) {\r
PrintAt (MenuOption->OptCol + Loop, MenuOption->Row, L" ");\r
}\r
- gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_HIGHLIGHT | FIELD_BACKGROUND_HIGHLIGHT);\r
+ gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor));\r
\r
if (MenuOption->Sequence == 0) {\r
PrintCharAt (MenuOption->OptCol, Row, LEFT_NUMERIC_DELIMITER);\r
//\r
// NV flag is unnecessary for RTC type of Date/Time\r
//\r
- UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
+ UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
}\r
}\r
\r
// Remove a character\r
//\r
EditValue = PreviousNumber[Count - 1];\r
- UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, FALSE);\r
+ UpdateStatusBar (Selection, INPUT_ERROR, Question->QuestionFlags, FALSE);\r
Count--;\r
Column--;\r
PrintAt (Column, Row, L" ");\r
default:\r
if (ManualInput) {\r
if (HexInput) {\r
- if (!IsHexDigit (&Digital, Key.UnicodeChar)) {\r
- UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);\r
+ if ((Key.UnicodeChar >= L'0') && (Key.UnicodeChar <= L'9')) {\r
+ Digital = (UINT8) (Key.UnicodeChar - L'0');\r
+ } else if ((Key.UnicodeChar >= L'A') && (Key.UnicodeChar <= L'F')) {\r
+ Digital = (UINT8) (Key.UnicodeChar - L'A' + 0x0A);\r
+ } else if ((Key.UnicodeChar >= L'a') && (Key.UnicodeChar <= L'f')) {\r
+ Digital = (UINT8) (Key.UnicodeChar - L'a' + 0x0A);\r
+ } else {\r
+ UpdateStatusBar (Selection, INPUT_ERROR, Question->QuestionFlags, TRUE);\r
break;\r
}\r
} else {\r
if (Key.UnicodeChar > L'9' || Key.UnicodeChar < L'0') {\r
- UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);\r
+ UpdateStatusBar (Selection, INPUT_ERROR, Question->QuestionFlags, TRUE);\r
break;\r
}\r
}\r
}\r
\r
if (EditValue > Maximum) {\r
- UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);\r
+ UpdateStatusBar (Selection, INPUT_ERROR, Question->QuestionFlags, TRUE);\r
+ ASSERT (Count < sizeof (PreviousNumber) / sizeof (PreviousNumber[0]));\r
EditValue = PreviousNumber[Count];\r
break;\r
} else {\r
- UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, FALSE);\r
+ UpdateStatusBar (Selection, INPUT_ERROR, Question->QuestionFlags, FALSE);\r
}\r
\r
Count++;\r
+ ASSERT (Count < (sizeof (PreviousNumber) / sizeof (PreviousNumber[0])));\r
PreviousNumber[Count] = EditValue;\r
\r
PrintCharAt (Column, Row, Key.UnicodeChar);\r
LIST_ENTRY *Link;\r
BOOLEAN OrderedList;\r
UINT8 *ValueArray;\r
+ UINT8 ValueType;\r
EFI_HII_VALUE HiiValue;\r
EFI_HII_VALUE *HiiValueArray;\r
UINTN OptionCount;\r
DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;\r
\r
ValueArray = NULL;\r
+ ValueType = 0;\r
CurrentOption = NULL;\r
ShowDownArrow = FALSE;\r
ShowUpArrow = FALSE;\r
Question = MenuOption->ThisTag;\r
if (Question->Operand == EFI_IFR_ORDERED_LIST_OP) {\r
ValueArray = Question->BufferValue;\r
+ ValueType = Question->ValueType;\r
OrderedList = TRUE;\r
} else {\r
OrderedList = FALSE;\r
//\r
if (OrderedList) {\r
for (Index = 0; Index < Question->MaxContainers; Index++) {\r
- if (ValueArray[Index] == 0) {\r
+ if (GetArrayData (ValueArray, ValueType, Index) == 0) {\r
break;\r
}\r
}\r
Link = GetFirstNode (&Question->OptionListHead);\r
for (Index = 0; Index < OptionCount; Index++) {\r
if (OrderedList) {\r
- HiiValueArray[Index].Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
- HiiValueArray[Index].Value.u8 = ValueArray[Index];\r
+ HiiValueArray[Index].Type = ValueType;\r
+ HiiValueArray[Index].Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
} else {\r
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
CopyMem (&HiiValueArray[Index], &OneOfOption->Value, sizeof (EFI_HII_VALUE));\r
if (StrLen (StringPtr) > PopUpWidth) {\r
PopUpWidth = StrLen (StringPtr);\r
}\r
- gBS->FreePool (StringPtr);\r
+ FreePool (StringPtr);\r
\r
if (!OrderedList && CompareHiiValue (&Question->HiiValue, &OneOfOption->Value, NULL) == 0) {\r
//\r
TempStringPtr = AllocateZeroPool (sizeof (CHAR16) * (PopUpWidth - 1));\r
ASSERT ( TempStringPtr != NULL );\r
CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5)));\r
- gBS->FreePool (StringPtr);\r
+ FreePool (StringPtr);\r
StringPtr = TempStringPtr;\r
StrCat (StringPtr, L"...");\r
}\r
}\r
\r
Index2++;\r
- gBS->FreePool (StringPtr);\r
+ FreePool (StringPtr);\r
}\r
\r
Character = BOXDRAW_UP_RIGHT;\r
if (HighlightOptionIndex > 0) {\r
HighlightOptionIndex--;\r
\r
+ ASSERT (CurrentOption != NULL);\r
SwapListEntries (CurrentOption->Link.BackLink, &CurrentOption->Link);\r
}\r
}\r
if (HighlightOptionIndex < (PopUpMenuLines - 1)) {\r
HighlightOptionIndex++;\r
\r
+ ASSERT (CurrentOption != NULL);\r
SwapListEntries (&CurrentOption->Link, CurrentOption->Link.ForwardLink);\r
}\r
}\r
// Restore link list order for orderedlist\r
//\r
if (OrderedList) {\r
- HiiValue.Type = EFI_IFR_TYPE_NUM_SIZE_8;\r
+ HiiValue.Type = ValueType;\r
HiiValue.Value.u64 = 0;\r
for (Index = 0; Index < Question->MaxContainers; Index++) {\r
- HiiValue.Value.u8 = ValueArray[Index];\r
- if (HiiValue.Value.u8) {\r
+ HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index);\r
+ if (HiiValue.Value.u64 == 0) {\r
break;\r
}\r
\r
}\r
}\r
\r
- gBS->FreePool (HiiValueArray);\r
+ FreePool (HiiValueArray);\r
return EFI_DEVICE_ERROR;\r
\r
default:\r
while (!IsNull (&Question->OptionListHead, Link)) {\r
OneOfOption = QUESTION_OPTION_FROM_LINK (Link);\r
\r
- Question->BufferValue[Index] = OneOfOption->Value.Value.u8;\r
+ SetArrayData (ValueArray, ValueType, Index, OneOfOption->Value.Value.u64);\r
\r
Index++;\r
if (Index > Question->MaxContainers) {\r
Link = GetNextNode (&Question->OptionListHead, Link);\r
}\r
} else {\r
+ ASSERT (CurrentOption != NULL);\r
CopyMem (&Question->HiiValue, &CurrentOption->Value, sizeof (EFI_HII_VALUE));\r
}\r
\r
gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute);\r
- gBS->FreePool (HiiValueArray);\r
+ FreePool (HiiValueArray);\r
\r
Status = ValidateQuestion (Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);\r
if (EFI_ERROR (Status)) {\r
GetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
} else {\r
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
- UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
+ UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
}\r
\r
return Status;\r