Skip to content

Commit

Permalink
Improve 'Shortcut Key' Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dakanji committed Nov 12, 2024
1 parent cb2d13b commit d3ff12c
Show file tree
Hide file tree
Showing 6 changed files with 372 additions and 213 deletions.
3 changes: 1 addition & 2 deletions BootMaster/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ typedef struct _refit_menu_entry {
CHAR16 *Title;
UINTN Tag;
UINTN Row;
CHAR16 ShortcutDigit;
CHAR16 ShortcutLetter;
CHAR16 ShortcutKey;
EG_IMAGE *Image;
EG_IMAGE *BadgeImage;
struct _refit_menu_screen *SubScreen;
Expand Down
38 changes: 17 additions & 21 deletions BootMaster/launch_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,19 +746,14 @@ VOID AddLegacyEntry (
REFIT_MENU_SCREEN *SubScreen;
CHAR16 *VolDesc;
CHAR16 *LegacyTitle;
CHAR16 ShortcutLetter;


ShortcutLetter = 0;
if (LoaderTitle == NULL) {
if (Volume->OSName == NULL) {
LoaderTitle = L"Legacy Bootcode";
}
else {
LoaderTitle = Volume->OSName;
if (LoaderTitle[0] == 'W' || LoaderTitle[0] == 'L') {
ShortcutLetter = LoaderTitle[0];
}
}
}

Expand Down Expand Up @@ -796,18 +791,19 @@ VOID AddLegacyEntry (

SetVolumeBadgeIcon (Volume);

Entry->me.Row = 0;
Entry->Enabled = TRUE;
Entry->me.Tag = TAG_LEGACY;
Entry->me.Title = LegacyTitle;
Entry->me.SubScreen = NULL; // Initial Setting
Entry->me.ShortcutLetter = ShortcutLetter;
Entry->me.Image = LoadOSIcon (Volume->OSIconName, L"legacy", FALSE);
Entry->Volume = CopyVolume (Volume);
Entry->me.BadgeImage = egCopyImage (Volume->VolBadgeImage);
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL)
? L"CD"
: ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD");
Entry->me.Row = 0;
Entry->Enabled = TRUE;
Entry->me.Tag = TAG_LEGACY;
Entry->me.Title = LegacyTitle;
Entry->me.SubScreen = NULL; // Initial Setting
Entry->me.ShortcutKey = 0;
Entry->me.Image = LoadOSIcon (Volume->OSIconName, L"legacy", FALSE);
Entry->Volume = CopyVolume (Volume);
Entry->me.BadgeImage = egCopyImage (Volume->VolBadgeImage);
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL)
? L"CD"
: (Volume->DiskKind == DISK_KIND_EXTERNAL)
? L"USB" : L"HD";

#if REFIT_DEBUG > 0
LOG_MSG(
Expand Down Expand Up @@ -927,10 +923,10 @@ VOID AddLegacyEntryUEFI (
);
#endif

Entry->me.Row = 0;
Entry->me.Tag = TAG_LEGACY_UEFI;
Entry->me.SubScreen = NULL; // Initial Setting
Entry->me.ShortcutLetter = 0;
Entry->me.Row = 0;
Entry->me.Tag = TAG_LEGACY_UEFI;
Entry->me.SubScreen = NULL; // Initial Setting
Entry->me.ShortcutKey = 0;
if (GlobalConfig.HelpIcon) {
Entry->me.Image = egFindIcon (
L"os_legacy",
Expand Down
20 changes: 10 additions & 10 deletions BootMaster/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ BOOLEAN SubScreenBoot = FALSE;
REFIT_MENU_ENTRY MenuEntryNo = {
L"No",
TAG_RETURN,
1, 0, 0,
1, 0,
NULL, NULL, NULL
};
REFIT_MENU_ENTRY MenuEntryYes = {
L"Yes",
TAG_RETURN,
1, 0, 0,
1, 0,
NULL, NULL, NULL
};

Expand Down Expand Up @@ -604,14 +604,14 @@ INTN FindMenuShortcutEntry (
}

if (Shortcut[0]) {
for (i = 0; i < Screen->EntryCount; i++) {
if (Screen->Entries[i]->ShortcutDigit == Shortcut[0] ||
Screen->Entries[i]->ShortcutLetter == Shortcut[0]
) {
FoundMatch = TRUE;
break;
}
} // for
if (Shortcut[0] != 0 && Shortcut[0] != 'O') {
for (i = 0; i < Screen->EntryCount; i++) {
if (Screen->Entries[i]->ShortcutKey == Shortcut[0]) {
FoundMatch = TRUE;
break;
}
} // for
}
}
} // if/else StrLen (Shortcut) > 1

Expand Down
Loading

0 comments on commit d3ff12c

Please sign in to comment.