]> code.delx.au - refind/commitdiff
Refinement to hint function for greater context sensitivity.
authorsrs5694 <srs5694@users.sourceforge.net>
Wed, 19 Dec 2012 05:43:37 +0000 (00:43 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Wed, 19 Dec 2012 05:43:37 +0000 (00:43 -0500)
NEWS.txt
libeg/screen.c
libeg/text.c
refind/global.h
refind/lib.c
refind/lib.h
refind/main.c
refind/menu.c
refind/screen.c

index 5561a438315b26214f0b7a7783697d885fd6d448..534c400a38d2b1a7232e6480d8bdda61b58d2fa9 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,11 +1,13 @@
 0.6.1 (12/??/2012):
 -------------------
 
+- Refined hints displays to be more context-sensitive, particularly in text
+  mode.
+
 - Instead of displaying a blank filesystem label when a filesystem has
-  none, rEFInd now displays the size of the filesystem, as in "boot
-  EFI\foo\bar.efi from 200 MiB volume" rather than "boot EFI\foo\bar.efi
-  from". For some filesystems, the filesystem type is included, as in "boot
-  EFI\foo\bar.efi from 200 MiB ext3 volume".
+  none, rEFInd now displays the size and/or type of the filesystem, as in
+  "boot EFI\foo\bar.efi from 200 MiB ext3 volume" rather than "boot
+  EFI\foo\bar.efi from".
 
 - Fixed a bug that caused the screen to clear after displaying an error
   message but before displaying the "Hit any key to continue" message when
index 8200438d3826b2d0864d199d4991ff993d755031..bac1f005d4be07f5353060f20d094e494ad41ae0 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+/*
+ * Modifications copyright (c) 2012 Roderick W. Smith
+ *
+ * Modifications distributed under the terms of the GNU General Public
+ * License (GPL) version 3 (GPLv3), a copy of which must be distributed
+ * with this source code or binaries made from it.
+ *
+ */
 
 #include "libegint.h"
 #include "../refind/screen.h"
index d84eeb7de3ca3c7e13816af6e458512acc104e26..93551b2b082558d615166eb3b392cfa2a83d2e50 100644 (file)
@@ -64,7 +64,11 @@ VOID egRenderText(IN CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN UINTN PosX, IN
     UINTN           i, c;
 
     // clip the text
-    TextLength = StrLen(Text);
+    if (Text)
+       TextLength = StrLen(Text);
+    else
+       TextLength = 0;
+
     if (TextLength * FONT_CELL_WIDTH + PosX > CompImage->Width)
         TextLength = (CompImage->Width - PosX) / FONT_CELL_WIDTH;
 
index 1d4a1842d6c31b5e8e808925607de1f0df1d4ddd..511dcace4ee70fc645781c8f953e9e3652b9fe36 100644 (file)
  */
 /*
  * Modifications copyright (c) 2012 Roderick W. Smith
- * 
+ *
  * Modifications distributed under the terms of the GNU General Public
  * License (GPL) version 3 (GPLv3), a copy of which must be distributed
  * with this source code or binaries made from it.
- * 
+ *
  */
 
 #ifndef __GLOBAL_H_
@@ -182,6 +182,8 @@ typedef struct _refit_menu_screen {
    REFIT_MENU_ENTRY **Entries;
    UINTN       TimeoutSeconds;
    CHAR16      *TimeoutText;
+   CHAR16      *Hint1;
+   CHAR16      *Hint2;
 } REFIT_MENU_SCREEN;
 
 typedef struct {
index 048b301e099637e40ae5991802b8b326ff0af2b3..347a176f5065b98ddfb8ae36a6061dd91967d491 100644 (file)
@@ -680,7 +680,7 @@ static CHAR16 *GetVolumeName(IN REFIT_VOLUME *Volume) {
    CHAR16                  *SISize, *TypeName;
 
    FileSystemInfoPtr = LibFileSystemInfo(Volume->RootDir);
-   if (FileSystemInfoPtr != NULL) {
+   if (FileSystemInfoPtr != NULL) { // we have filesystem information (size, label)....
        if ((FileSystemInfoPtr->VolumeLabel != NULL) && (StrLen(FileSystemInfoPtr->VolumeLabel) > 0)) {
           FoundName = StrDuplicate(FileSystemInfoPtr->VolumeLabel);
        }
@@ -692,7 +692,7 @@ static CHAR16 *GetVolumeName(IN REFIT_VOLUME *Volume) {
           FoundName = NULL;
        } // if rEFInd HFS+ driver suspected
 
-       if (FoundName == NULL) { // filesystem has no name....
+       if (FoundName == NULL) { // filesystem has no name, so use fs type and size
           FoundName = AllocateZeroPool(sizeof(CHAR16) * 256);
           if (FoundName != NULL) {
              SISize = SizeInIEEEUnits(FileSystemInfoPtr->VolumeSize);
@@ -703,10 +703,10 @@ static CHAR16 *GetVolumeName(IN REFIT_VOLUME *Volume) {
 
        FreePool(FileSystemInfoPtr);
 
-   } else {
+   } else { // fs driver not returning info; fall back on our own information....
       FoundName = AllocateZeroPool(sizeof(CHAR16) * 256);
       if (FoundName != NULL) {
-         TypeName = FSTypeName(Volume->FSType); // NOTE: Don't free TypeName; fn returns constant
+         TypeName = FSTypeName(Volume->FSType); // NOTE: Don't free TypeName; function returns constant
          if (StrLen(TypeName) > 0)
             SPrint(FoundName, 255, L"%s volume", FSTypeName(Volume->FSType));
          else
index 7245191e78d32bb99f54d4cf3e3799c9a8a8739f..4e936a8323d2fe69db2efdfeb99cb76963cfd11f 100644 (file)
  */
 /*
  * Modifications copyright (c) 2012 Roderick W. Smith
- * 
+ *
  * Modifications distributed under the terms of the GNU General Public
  * License (GPL) version 3 (GPLv3), a copy of which must be distributed
  * with this source code or binaries made from it.
- * 
+ *
  */
 
 #ifndef __LIB_H_
index 011489b69e7d74e5c647031450c8993187c13303..15b8771f9050d82999345c6aabc436cf4034fffd 100644 (file)
 // a ".efi" extension to be found when scanning for boot loaders.
 #define LINUX_MATCH_PATTERNS    L"vmlinuz*,bzImage*"
 
+// Default hint text
+#define SUBSCREEN_HINT1            L"Use arrow keys to move cursor; Enter to boot;"
+#define SUBSCREEN_HINT2            L"Insert or F2 to edit options; Esc to return to main menu"
+#define SUBSCREEN_HINT2_NO_EDITOR  L"Esc to return to main menu"
+
 static REFIT_MENU_ENTRY MenuEntryAbout    = { L"About rEFInd", TAG_ABOUT, 1, 0, 'A', NULL, NULL, NULL };
 static REFIT_MENU_ENTRY MenuEntryReset    = { L"Reboot Computer", TAG_REBOOT, 1, 0, 'R', NULL, NULL, NULL };
 static REFIT_MENU_ENTRY MenuEntryShutdown = { L"Shut Down Computer", TAG_SHUTDOWN, 1, 0, 'U', NULL, NULL, NULL };
 static REFIT_MENU_ENTRY MenuEntryReturn   = { L"Return to Main Menu", TAG_RETURN, 0, 0, 0, NULL, NULL, NULL };
 static REFIT_MENU_ENTRY MenuEntryExit     = { L"Exit rEFInd", TAG_EXIT, 1, 0, 0, NULL, NULL, NULL };
 
-static REFIT_MENU_SCREEN MainMenu       = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" };
-static REFIT_MENU_SCREEN AboutMenu      = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL };
+static REFIT_MENU_SCREEN MainMenu       = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot",
+                                            L"Use arrow keys to move cursor; Enter to boot;",
+                                            L"Insert or F2 for more options; Esc to refresh" };
+static REFIT_MENU_SCREEN AboutMenu      = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL, L"Press Enter to return to main menu", L"" };
 
 REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 0, 20, 0, 0, GRAPHICS_FOR_OSX, LEGACY_TYPE_MAC, 0,
                               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -395,6 +402,8 @@ static REFIT_MENU_SCREEN* CopyMenuScreen(REFIT_MENU_SCREEN *Entry) {
       for (i = 0; i < Entry->EntryCount && NewEntry->Entries; i++) {
          AddMenuEntry(NewEntry, Entry->Entries[i]);
       } // for
+      NewEntry->Hint1 = (Entry->Hint1) ? StrDuplicate(Entry->Hint1) : NULL;
+      NewEntry->Hint2 = (Entry->Hint2) ? StrDuplicate(Entry->Hint2) : NULL;
    } // if
    return (NewEntry);
 } // static REFIT_MENU_SCREEN* CopyMenuScreen()
@@ -501,6 +510,12 @@ REFIT_MENU_SCREEN *InitializeSubScreen(IN LOADER_ENTRY *Entry) {
             MyFreePool(MainOptions);
             AddMenuEntry(SubScreen, (REFIT_MENU_ENTRY *)SubEntry);
          } // if (SubEntry != NULL)
+         SubScreen->Hint1 = StrDuplicate(SUBSCREEN_HINT1);
+         if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+            SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2_NO_EDITOR);
+         } else {
+            SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2);
+         } // if/else
       } // if (SubScreen != NULL)
    } else { // existing subscreen; less initialization, and just add new entry later....
       SubScreen = Entry->me.SubScreen;
@@ -1270,6 +1285,12 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo
     SubScreen->Title = AllocateZeroPool(256 * sizeof(CHAR16));
     SPrint(SubScreen->Title, 255, L"Boot Options for %s on %s", LoaderTitle, VolDesc);
     SubScreen->TitleImage = Entry->me.Image;
+    SubScreen->Hint1 = StrDuplicate(SUBSCREEN_HINT1);
+    if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+       SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2_NO_EDITOR);
+    } else {
+       SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2);
+    } // if/else
 
     // default entry
     SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
@@ -1338,6 +1359,12 @@ static LEGACY_ENTRY * AddLegacyEntryUEFI(BDS_COMMON_OPTION *BdsOption, IN UINT16
     SubScreen->Title = AllocateZeroPool(256 * sizeof(CHAR16));
     SPrint(SubScreen->Title, 255, L"No boot options for legacy target");
     SubScreen->TitleImage = Entry->me.Image;
+    SubScreen->Hint1 = StrDuplicate(SUBSCREEN_HINT1);
+    if (GlobalConfig.HideUIFlags & HIDEUI_FLAG_EDITOR) {
+       SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2_NO_EDITOR);
+    } else {
+       SubScreen->Hint2 = StrDuplicate(SUBSCREEN_HINT2);
+    } // if/else
 
     // default entry
     SubEntry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
index ec54eb10aff0a7b4bbad77ea850268f461d373e1..7de9d8bc3b9d462a0d590984cd00bc9ef7a61287 100644 (file)
  */
 /*
  * Modifications copyright (c) 2012 Roderick W. Smith
- * 
+ *
  * Modifications distributed under the terms of the GNU General Public
  * License (GPL) version 3 (GPLv3), a copy of which must be distributed
  * with this source code or binaries made from it.
- * 
+ *
  */
 
 #include "global.h"
@@ -512,7 +512,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             MenuPosY = 4;
             if (Screen->InfoLineCount > 0)
                 MenuPosY += Screen->InfoLineCount + 1;
-            MenuHeight = ConHeight - MenuPosY - 2;
+            MenuHeight = ConHeight - MenuPosY - 3;
             if (Screen->TimeoutSeconds > 0)
                 MenuHeight -= 2;
             InitScroll(State, Screen->EntryCount, MenuHeight);
@@ -595,9 +595,14 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             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");
+               if (Screen->Hint1 != NULL) {
+                  refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, ConHeight - 2);
+                  refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, Screen->Hint1);
+               }
+               if (Screen->Hint2 != NULL) {
+                  refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, ConHeight - 1);
+                  refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, Screen->Hint2);
+               }
             }
             break;
 
@@ -617,12 +622,12 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State,
             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 - 2);
+                refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 0, ConHeight - 3);
                 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 - 2);
+                refit_call3_wrapper(ST->ConOut->SetCursorPosition, ST->ConOut, 3, ConHeight - 3);
                 SPrint(TimeoutMessage, 255, L"%s  ", ParamText);
                 refit_call2_wrapper(ST->ConOut->OutputString, ST->ConOut, TimeoutMessage);
             }
@@ -717,15 +722,14 @@ static VOID GraphicsMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *Sta
                              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 ((Screen->Hint1 != NULL) && (StrLen(Screen->Hint1) > 0)) {
+                  DrawMenuText(Screen->Hint1, 0, (UGAWidth - (StrLen(Screen->Hint1) * FONT_CELL_WIDTH)) / 2,
+                               UGAHeight - (FONT_CELL_HEIGHT * 3));
+               }
+               if ((Screen->Hint2 != NULL) && (StrLen(Screen->Hint2) > 0)) {
+                  DrawMenuText(Screen->Hint2, 0, (UGAWidth - (StrLen(Screen->Hint2) * FONT_CELL_WIDTH)) / 2,
+                               UGAHeight - (FONT_CELL_HEIGHT * 2));
+               } // if
             } // if
             break;
 
@@ -799,10 +803,8 @@ static VOID PaintAll(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, UINTN
                        (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));
+      DrawMainMenuText(Screen->Hint1, (UGAWidth - LAYOUT_TEXT_WIDTH) / 2, UGAHeight - (FONT_CELL_HEIGHT * 3));
+      DrawMainMenuText(Screen->Hint2, (UGAWidth - LAYOUT_TEXT_WIDTH) / 2, UGAHeight - (FONT_CELL_HEIGHT * 2));
    } // if
 } // static VOID PaintAll()
 
index 7f485a42d303ea48255048f599bc0b0fc12e7b00..32711d60e43df1ef466db8d4e01e0f13770f5a3a 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+/*
+ * Modifications copyright (c) 2012 Roderick W. Smith
+ *
+ * Modifications distributed under the terms of the GNU General Public
+ * License (GPL) version 3 (GPLv3), a copy of which must be distributed
+ * with this source code or binaries made from it.
+ *
+ */
 
 #include "global.h"
 #include "screen.h"