]> code.delx.au - refind/blobdiff - refind/menu.c
Keep .icns files out of tag list when scan_all_linux_kernels is set;
[refind] / refind / menu.c
index a1120ba289f5d67ec41738113ca40129029ab5d4..8b86c352460fb0b31f53729c1cf4fbfdff7d3d9f 100644 (file)
@@ -96,12 +96,12 @@ static VOID InitSelection(VOID)
 {
     UINTN       x, y, src_x, src_y;
     EG_PIXEL    *DestPtr, *SrcPtr;
-    
+
     if (!AllowGraphicsMode)
         return;
     if (SelectionImages[0] != NULL)
         return;
-    
+
     // load small selection image
     if (GlobalConfig.SelectionSmallFileName != NULL) {
         SelectionImages[2] = egLoadImage(SelfDir, GlobalConfig.SelectionSmallFileName, FALSE);
@@ -112,7 +112,7 @@ static VOID InitSelection(VOID)
                                            ROW1_TILESIZE, ROW1_TILESIZE, &MenuBackgroundPixel);
     if (SelectionImages[2] == NULL)
         return;
-    
+
     // load big selection image
     if (GlobalConfig.SelectionBigFileName != NULL) {
         SelectionImages[0] = egLoadImage(SelfDir, GlobalConfig.SelectionBigFileName, FALSE);
@@ -121,14 +121,14 @@ static VOID InitSelection(VOID)
     }
     if (SelectionImages[0] == NULL) {
         // calculate big selection image from small one
-        
+
         SelectionImages[0] = egCreateImage(ROW0_TILESIZE, ROW0_TILESIZE, FALSE);
         if (SelectionImages[0] == NULL) {
             egFreeImage(SelectionImages[2]);
             SelectionImages[2] = NULL;
             return;
         }
-        
+
         DestPtr = SelectionImages[0]->PixelData;
         SrcPtr  = SelectionImages[2]->PixelData;
         for (y = 0; y < ROW0_TILESIZE; y++) {
@@ -138,7 +138,7 @@ static VOID InitSelection(VOID)
                 src_y = (ROW1_TILESIZE >> 1);
             else
                 src_y = y - (ROW0_TILESIZE - ROW1_TILESIZE);
-            
+
             for (x = 0; x < ROW0_TILESIZE; x++) {
                 if (x < (ROW1_TILESIZE >> 1))
                     src_x = x;
@@ -146,12 +146,12 @@ static VOID InitSelection(VOID)
                     src_x = (ROW1_TILESIZE >> 1);
                 else
                     src_x = x - (ROW0_TILESIZE - ROW1_TILESIZE);
-                
+
                 *DestPtr++ = SrcPtr[src_y * ROW1_TILESIZE + src_x];
             }
         }
     }
-    
+
     // non-selected background images
     SelectionImages[1] = egCreateFilledImage(ROW0_TILESIZE, ROW0_TILESIZE, FALSE, &MenuBackgroundPixel);
     SelectionImages[3] = egCreateFilledImage(ROW1_TILESIZE, ROW1_TILESIZE, FALSE, &MenuBackgroundPixel);
@@ -251,8 +251,7 @@ static INTN FindMenuShortcutEntry(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *Short
          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]) {
+               if (Screen->Entries[i]->ShortcutDigit == Shortcut[0] || Screen->Entries[i]->ShortcutLetter == Shortcut[0]) {
                   return i;
                } // if
          } // for
@@ -385,9 +384,9 @@ static UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC Sty
                 break;
         }
     }
-    
+
     StyleFunc(Screen, &State, MENU_FUNCTION_CLEANUP, NULL);
-    
+
     if (ChosenEntry)
         *ChosenEntry = Screen->Entries[State.CurrentSelection];
     return MenuExit;
@@ -404,9 +403,9 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
     static UINTN MenuPosY;
     static CHAR16 **DisplayStrings;
     CHAR16 *TimeoutMessage;
-    
+
     switch (Function) {
-        
+
         case MENU_FUNCTION_INIT:
             // vertical layout
             MenuPosY = 4;
@@ -416,7 +415,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             if (Screen->TimeoutSeconds > 0)
                 MenuHeight -= 2;
             InitScroll(State, Screen->EntryCount, MenuHeight);
-            
+
             // determine width of the menu
             MenuWidth = 20;  // minimum
             for (i = 0; i <= State->MaxIndex; i++) {
@@ -426,7 +425,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             }
             if (MenuWidth > ConWidth - 6)
                 MenuWidth = ConWidth - 6;
-            
+
             // prepare strings for display
             DisplayStrings = AllocatePool(sizeof(CHAR16 *) * Screen->EntryCount);
             for (i = 0; i <= State->MaxIndex; i++)
@@ -434,7 +433,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             // TODO: shorten strings that are too long (PoolPrint doesn't do that...)
             // TODO: use more elaborate techniques for shortening too long strings (ellipses in the middle)
             // TODO: account for double-width characters
-                
+
             // initial painting
             BeginTextScreen(Screen->Title);
             if (Screen->InfoLineCount > 0) {
@@ -444,16 +443,16 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
                     refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, Screen->InfoLines[i]);
                 }
             }
-            
+
             break;
-            
+
         case MENU_FUNCTION_CLEANUP:
             // release temporary memory
             for (i = 0; i <= State->MaxIndex; i++)
                 FreePool(DisplayStrings[i]);
             FreePool(DisplayStrings);
             break;
-            
+
         case MENU_FUNCTION_PAINT_ALL:
             // paint the whole screen (initially and after scrolling)
             for (i = 0; i <= State->MaxIndex; i++) {
@@ -479,7 +478,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             else
                refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, L" ");
             break;
-            
+
         case MENU_FUNCTION_PAINT_SELECTION:
             // redraw selection cursor
             refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 2, MenuPosY + (State->LastSelection - State->FirstVisible));
@@ -489,7 +488,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             refit_call2_wrapper(ST->ConOut->SetAttribute, ST->ConOut, ATTR_CHOICE_CURRENT);
             refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, DisplayStrings[State->CurrentSelection]);
             break;
-            
+
         case MENU_FUNCTION_PAINT_TIMEOUT:
             if (ParamText[0] == 0) {
                 // clear message
@@ -768,21 +767,21 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT
             InitSelection();
             SwitchToGraphicsAndClear();
             break;
-            
+
         case MENU_FUNCTION_CLEANUP:
             FreePool(itemPosX);
             break;
-            
+
         case MENU_FUNCTION_PAINT_ALL:
             BltClearScreen(TRUE);
             PaintAll(Screen, State, itemPosX, row0PosY, row1PosY, textPosY);
             // For PaintIcon() calls, the starting Y position is moved to the midpoint
             // of the surrounding row; PaintIcon() adjusts this back up by half the
             // icon's height to properly center it.
-            if (State->FirstVisible > 0)
+            if ((State->FirstVisible > 0) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_ARROWS)))
                PaintIcon(&egemb_arrow_left, L"icons\\arrow_left.icns", row0PosX - TILE_XSPACING,
                          row0PosY + (ROW0_TILESIZE / 2), ALIGN_RIGHT);
-            if (State->LastVisible < (row0Loaders - 1))
+            if ((State->LastVisible < (row0Loaders - 1)) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_ARROWS)))
                PaintIcon(&egemb_arrow_right, L"icons\\arrow_right.icns",
                          (UGAWidth + (ROW0_TILESIZE + TILE_XSPACING) * State->MaxVisible) / 2 + TILE_XSPACING,
                          row0PosY + (ROW0_TILESIZE / 2), ALIGN_LEFT);
@@ -791,12 +790,12 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT
         case MENU_FUNCTION_PAINT_SELECTION:
             PaintSelection(Screen, State, itemPosX, row0PosY, row1PosY, textPosY);
             break;
-            
+
         case MENU_FUNCTION_PAINT_TIMEOUT:
             if (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_LABEL))
                 DrawMainMenuText(ParamText, (UGAWidth - LAYOUT_TEXT_WIDTH) >> 1, textPosY + TEXT_LINE_HEIGHT);
             break;
-            
+
     }
 }
 
@@ -807,10 +806,10 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT
 UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_MENU_ENTRY **ChosenEntry)
 {
     MENU_STYLE_FUNC Style = TextMenuStyle;
-    
+
     if (AllowGraphicsMode)
         Style = GraphicsMenuStyle;
-    
+
     return RunGenericMenu(Screen, Style, -1, ChosenEntry);
 }
 
@@ -823,8 +822,7 @@ UINTN RunMainMenu(IN REFIT_MENU_SCREEN *Screen, IN CHAR16* DefaultSelection, OUT
     UINTN DefaultEntryIndex = -1;
 
     if (DefaultSelection != NULL) {
-        // Find a menu entry whose shortcut is the first character of DefaultSelection, or
-        // whose 
+        // 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.
     }