--- /dev/null
+2009-08-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Hotkey support
+
+ * include/grub/menu.h (grub_menu_entry): New field 'hotkey'.
+ * normal/main.c (hotkey_aliases): New variable.
+ (grub_normal_add_menu_entry): Parse "--hotkey".
+ * normal/menu_text.c (run_menu): Handle hotkeys.
+
}
}
+static struct
+{
+ char *name;
+ int key;
+} hotkey_aliases[] =
+ {
+ {"backspace", '\b'},
+ {"tab", '\t'},
+ {"delete", GRUB_TERM_DC}
+ };
+
/* Add a menu entry to the current menu context (as given by the environment
variable data slot `menu'). As the configuration file is read, the script
parser calls this when a menu entry is to be created. */
struct grub_menu_entry_class *classes_head; /* Dummy head node for list. */
struct grub_menu_entry_class *classes_tail;
char *users = NULL;
+ int hotkey = 0;
/* Allocate dummy head node for class list. */
classes_head = grub_zalloc (sizeof (struct grub_menu_entry_class));
continue;
}
+ else if (grub_strcmp(arg, "hotkey") == 0)
+ {
+ unsigned j;
+
+ i++;
+ if (args[i][1] == 0)
+ {
+ hotkey = args[i][0];
+ continue;
+ }
+
+ for (j = 0; j < ARRAY_SIZE (hotkey_aliases); j++)
+ if (grub_strcmp (args[i], hotkey_aliases[j].name) == 0)
+ {
+ hotkey = hotkey_aliases[j].key;
+ break;
+ }
+
+ if (j < ARRAY_SIZE (hotkey_aliases))
+ continue;
+
+ failed = 1;
+ grub_error (GRUB_ERR_MENU,
+ "Invalid hotkey: '%s'.", args[i]);
+ break;
+ }
else
{
/* Handle invalid argument. */
}
(*last)->title = menutitle;
+ (*last)->hotkey = hotkey;
(*last)->classes = classes_head;
if (users)
(*last)->restricted = 1;
viewers = NULL;
}
-/* FIXME: allow text menu in parallel with gfxmenu. */
-grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
- int nested) = NULL;
static void
menu_init (int entry, grub_menu_t menu, int nested)
{
goto refresh;
default:
+ {
+ grub_menu_entry_t entry;
+ int i;
+ for (i = 0, entry = menu->entry_list; i < menu->size;
+ i++, entry = entry->next)
+ if (entry->hotkey == c)
+ {
+ menu_fini ();
+ *auto_boot = 0;
+ return i;
+ }
+ }
break;
}
}