#define MENU_FUNCTION_PAINT_ALL (2)
#define MENU_FUNCTION_PAINT_SELECTION (3)
#define MENU_FUNCTION_PAINT_TIMEOUT (4)
+#define MENU_FUNCTION_PAINT_HINTS (5)
typedef VOID (*MENU_STYLE_FUNC)(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText);
//
// generic menu function
//
-static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC StyleFunc, IN INTN DefaultEntryIndex, OUT REFIT_MENU_ENTRY **ChosenEntry)
+static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex,
+ OUT REFIT_MENU_ENTRY **ChosenEntry)
{
SCROLL_STATE State;
EFI_STATUS Status;
StyleFunc(Screen, &State, MENU_FUNCTION_INIT, NULL);
IdentifyRows(&State, Screen);
// override the starting selection with the default index, if any
- if (DefaultEntryIndex >= 0 && DefaultEntryIndex <= State.MaxIndex) {
- State.CurrentSelection = DefaultEntryIndex;
+ if (*DefaultEntryIndex >= 0 && *DefaultEntryIndex <= State.MaxIndex) {
+ State.CurrentSelection = *DefaultEntryIndex;
UpdateScroll(&State, SCROLL_NONE);
}
+ State.PaintAll = TRUE;
while (!MenuExit) {
// update the screen
if (ChosenEntry)
*ChosenEntry = Screen->Entries[State.CurrentSelection];
+ *DefaultEntryIndex = State.CurrentSelection;
return MenuExit;
} /* static UINTN RunGenericMenu() */
MenuPosY = 4;
if (Screen->InfoLineCount > 0)
MenuPosY += Screen->InfoLineCount + 1;
- MenuHeight = ConHeight - MenuPosY;
+ MenuHeight = ConHeight - MenuPosY - 2;
if (Screen->TimeoutSeconds > 0)
MenuHeight -= 2;
InitScroll(State, Screen->EntryCount, MenuHeight);
if (MenuWidth < ItemWidth)
MenuWidth = ItemWidth;
}
- if (MenuWidth > ConWidth - 6)
- MenuWidth = ConWidth - 6;
+ MenuWidth += 2;
+ if (MenuWidth > ConWidth - 3)
+ MenuWidth = ConWidth - 3;
// prepare strings for display
DisplayStrings = AllocatePool(sizeof(CHAR16 *) * Screen->EntryCount);
refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, ArrowDown);
else
refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, L" ");
+ if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_HINTS)) {
+ refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, ConHeight - 1);
+ refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut,
+ L"Use arrow keys to move cursor; Enter to boot; Insert or F2 for more options");
+ }
break;
case MENU_FUNCTION_PAINT_SELECTION:
// redraw selection cursor
- refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 2, MenuPosY + (State->PreviousSelection - State->FirstVisible));
+ refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 2,
+ MenuPosY + (State->PreviousSelection - State->FirstVisible));
refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_CHOICE_BASIC);
refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, DisplayStrings[State->PreviousSelection]);
- refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 2, MenuPosY + (State->CurrentSelection - State->FirstVisible));
+ refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 2,
+ MenuPosY + (State->CurrentSelection - State->FirstVisible));
refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_CHOICE_CURRENT);
refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, DisplayStrings[State->CurrentSelection]);
break;
if (ParamText[0] == 0) {
// clear message
refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_BASIC);
- refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, ConHeight - 1);
+ refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, ConHeight - 2);
refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, BlankLine + 1);
} else {
// paint or update message
refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_ERROR);
- refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 3, ConHeight - 1);
+ refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 3, ConHeight - 2);
SPrint(TimeoutMessage, 255, L"%s ", ParamText);
refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, TimeoutMessage);
}
DrawMenuText(Screen->Entries[i]->Title, (i == State->CurrentSelection) ? MenuWidth : 0,
EntriesPosX, EntriesPosY + i * TEXT_LINE_HEIGHT);
}
+ if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_HINTS)) {
+ if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+ DrawMenuText(L"Use arrow keys to move cursor; Enter to boot", 0,
+ (UGAWidth - (45 * FONT_CELL_WIDTH)) / 2, UGAHeight - (FONT_CELL_HEIGHT * 3));
+ } else {
+ DrawMenuText(L"Use arrow keys to move cursor; Enter to boot;", 0,
+ (UGAWidth - (45 * FONT_CELL_WIDTH)) / 2, UGAHeight - (FONT_CELL_HEIGHT * 3));
+ DrawMenuText(L"Insert or F2 to edit options; Esc to return to main menu", 0,
+ (UGAWidth - (56 * FONT_CELL_WIDTH)) / 2, UGAHeight - (FONT_CELL_HEIGHT * 2));
+ } // if/else
+ } // if
break;
case MENU_FUNCTION_PAINT_SELECTION:
if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL))
DrawMainMenuText(Screen->Entries[State->CurrentSelection]->Title,
(UGAWidth - LAYOUT_TEXT_WIDTH) >> 1, textPosY);
+
+ if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_HINTS)) {
+ DrawMainMenuText(L"Use arrow keys to move cursor; Enter to boot;",
+ (UGAWidth - LAYOUT_TEXT_WIDTH) / 2, UGAHeight - (FONT_CELL_HEIGHT * 3));
+ DrawMainMenuText(L"Insert or F2 for more options; Esc to refresh",
+ (UGAWidth - LAYOUT_TEXT_WIDTH) / 2, UGAHeight - (FONT_CELL_HEIGHT * 2));
+ } // if
} // static VOID PaintAll()
// Move the selection to State->CurrentSelection, adjusting icon row if necessary...
static BOOLEAN EditOptions(LOADER_ENTRY *MenuEntry) {
UINTN x_max, y_max;
CHAR16 *EditedOptions;
-// CHAR16 message[] = L"Use cursor keys to edit, Esc to exit, Enter to boot with edited options";
- EG_PIXEL DarkBackgroundPixel = { 0x0, 0x0, 0x0, 0 };
BOOLEAN retval = FALSE;
+ if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+ return FALSE;
+ }
+
refit_call4_wrapper(ST->ConOut->QueryMode, ST->ConOut, ST->ConOut->Mode->Mode, &x_max, &y_max);
if (!GlobalConfig.TextOnly)
SwitchToText(TRUE);
- egClearScreen(&DarkBackgroundPixel);
-
- refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, y_max - 1);
-// refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, message);
- refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut,
- L"Use cursor keys to edit, Esc to exit, Enter to boot with edited options");
-
- if (line_edit(MenuEntry->LoadOptions, &EditedOptions, x_max, 1)) {
+ if (line_edit(MenuEntry->LoadOptions, &EditedOptions, x_max)) {
MyFreePool(MenuEntry->LoadOptions);
MenuEntry->LoadOptions = EditedOptions;
retval = TRUE;
UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_MENU_ENTRY **ChosenEntry)
{
+ INTN DefaultEntry = -1;
MENU_STYLE_FUNC Style = TextMenuStyle;
if (AllowGraphicsMode)
Style = GraphicsMenuStyle;
- return RunGenericMenu(Screen, Style, -1, ChosenEntry);
+ return RunGenericMenu(Screen, Style, &DefaultEntry, ChosenEntry);
}
UINTN RunMainMenu(IN REFIT_MENU_SCREEN *Screen, IN CHAR16* DefaultSelection, OUT REFIT_MENU_ENTRY **ChosenEntry)
MENU_STYLE_FUNC MainStyle = TextMenuStyle;
REFIT_MENU_ENTRY *TempChosenEntry;
UINTN MenuExit = 0;
- UINTN DefaultEntryIndex = -1;
+ INTN DefaultEntryIndex = -1;
+ INTN DefaultSubmenuIndex = -1;
if (DefaultSelection != NULL) {
// Find a menu entry that includes *DefaultSelection as a substring
DefaultEntryIndex = FindMenuShortcutEntry(Screen, DefaultSelection);
- // If that didn't work, should we scan more characters? For now, no.
}
if (AllowGraphicsMode) {
}
while (!MenuExit) {
- MenuExit = RunGenericMenu(Screen, MainStyle, DefaultEntryIndex, &TempChosenEntry);
+ MenuExit = RunGenericMenu(Screen, MainStyle, &DefaultEntryIndex, &TempChosenEntry);
Screen->TimeoutSeconds = 0;
- if (MenuExit == MENU_EXIT_DETAILS && TempChosenEntry->SubScreen != NULL) {
- MenuExit = RunGenericMenu(TempChosenEntry->SubScreen, Style, -1, &TempChosenEntry);
- if (MenuExit == MENU_EXIT_ESCAPE || TempChosenEntry->Tag == TAG_RETURN)
- MenuExit = 0;
- if (MenuExit == MENU_EXIT_DETAILS) {
- if (!EditOptions((LOADER_ENTRY *) TempChosenEntry))
- MenuExit = 0;
- } // if
- }
+ if (MenuExit == MENU_EXIT_DETAILS) {
+ if (TempChosenEntry->SubScreen != NULL) {
+ MenuExit = RunGenericMenu(TempChosenEntry->SubScreen, Style, &DefaultSubmenuIndex, &TempChosenEntry);
+ if (MenuExit == MENU_EXIT_ESCAPE || TempChosenEntry->Tag == TAG_RETURN)
+ MenuExit = 0;
+ if (MenuExit == MENU_EXIT_DETAILS) {
+ if (!EditOptions((LOADER_ENTRY *) TempChosenEntry))
+ MenuExit = 0;
+ } // if
+ } else { // no sub-screen; ignore keypress
+ MenuExit = 0;
+ }
+ } // Enter sub-screen
}
if (ChosenEntry)