]> code.delx.au - refind/blobdiff - refind/menu.c
Version 0.7.7 full release
[refind] / refind / menu.c
index 40f26a19a841ec919644162725af04a9f936ae61..eb49b926ba196d0c6c4771780ce96fa8abed1c0c 100644 (file)
@@ -305,29 +305,34 @@ VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry)
 }
 
 
-static INTN FindMenuShortcutEntry(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *Shortcut)
+static INTN FindMenuShortcutEntry(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *Defaults)
 {
-    UINTN i;
-
-    if (Shortcut == NULL)
-       return (-1);
-
-    if (StrLen(Shortcut) == 1) {
-      if (Shortcut[0] >= 'a' && Shortcut[0] <= 'z')
-         Shortcut[0] -= ('a' - 'A');
-      if (Shortcut[0]) {
-         for (i = 0; i < Screen->EntryCount; i++) {
-               if (Screen->Entries[i]->ShortcutDigit == Shortcut[0] || Screen->Entries[i]->ShortcutLetter == Shortcut[0]) {
-                  return i;
-               } // if
-         } // for
-      } // if
-    } else if (StrLen(Shortcut) > 1) {
-       for (i = 0; i < Screen->EntryCount; i++) {
-          if (StriSubCmp(Shortcut, Screen->Entries[i]->Title))
-             return i;
-       } // for
-    }
+    UINTN i, j = 0;
+    CHAR16 *Shortcut;
+
+    while ((Shortcut = FindCommaDelimited(Defaults, j)) != NULL) {
+       if (StrLen(Shortcut) == 1) {
+         if (Shortcut[0] >= 'a' && Shortcut[0] <= 'z')
+            Shortcut[0] -= ('a' - 'A');
+         if (Shortcut[0]) {
+            for (i = 0; i < Screen->EntryCount; i++) {
+                  if (Screen->Entries[i]->ShortcutDigit == Shortcut[0] || Screen->Entries[i]->ShortcutLetter == Shortcut[0]) {
+                     MyFreePool(Shortcut);
+                     return i;
+                  } // if
+            } // for
+         } // if
+       } else if (StrLen(Shortcut) > 1) {
+          for (i = 0; i < Screen->EntryCount; i++) {
+             if (StriSubCmp(Shortcut, Screen->Entries[i]->Title)) {
+                MyFreePool(Shortcut);
+                return i;
+             } // if
+          } // for
+       }
+       MyFreePool(Shortcut);
+       j++;
+    } // while()
     return -1;
 }
 
@@ -339,7 +344,7 @@ static VOID IdentifyRows(IN SCROLL_STATE *State, IN REFIT_MENU_SCREEN *Screen) {
 
    State->FinalRow0 = 0;
    State->InitialRow1 = State->MaxIndex;
-   for (i = 0; i < State->MaxIndex; i++) {
+   for (i = 0; i <= State->MaxIndex; i++) {
       if (Screen->Entries[i]->Row == 0) {
          State->FinalRow0 = i;
       } else if ((Screen->Entries[i]->Row == 1) && (State->InitialRow1 > i)) {
@@ -395,13 +400,15 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
     // override the starting selection with the default index, if any
     if (*DefaultEntryIndex >= 0 && *DefaultEntryIndex <= State.MaxIndex) {
         State.CurrentSelection = *DefaultEntryIndex;
-        UpdateScroll(&State, SCROLL_NONE);
+        if (GlobalConfig.ScreensaverTime != -1)
+           UpdateScroll(&State, SCROLL_NONE);
     }
-    State.PaintAll = TRUE;
+    if (GlobalConfig.ScreensaverTime != -1)
+        State.PaintAll = TRUE;
 
     while (!MenuExit) {
         // update the screen
-        if (State.PaintAll) {
+        if (State.PaintAll && (GlobalConfig.ScreensaverTime != -1)) {
             StyleFunc(Screen, &State, MENU_FUNCTION_PAINT_ALL, NULL);
             State.PaintAll = FALSE;
         } else if (State.PaintSelection) {
@@ -413,7 +420,8 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
             CurrentTime = (TimeoutCountdown + 5) / 10;
             if (CurrentTime != PreviousTime) {
                SPrint(TimeoutMessage, 255, L"%s in %d seconds", Screen->TimeoutText, CurrentTime);
-               StyleFunc(Screen, &State, MENU_FUNCTION_PAINT_TIMEOUT, TimeoutMessage);
+               if (GlobalConfig.ScreensaverTime != -1)
+                  StyleFunc(Screen, &State, MENU_FUNCTION_PAINT_TIMEOUT, TimeoutMessage);
                PreviousTime = CurrentTime;
             }
         }
@@ -449,6 +457,11 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
             // the user pressed a key, cancel the timeout
             StyleFunc(Screen, &State, MENU_FUNCTION_PAINT_TIMEOUT, L"");
             HaveTimeout = FALSE;
+            if (GlobalConfig.ScreensaverTime == -1) { // cancel start-with-blank-screen coding
+               GlobalConfig.ScreensaverTime = 0;
+               if (!GlobalConfig.TextOnly)
+                 BltClearScreen(TRUE);
+            }
         }
 
         // react to key press