mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 23:52:22 +00:00
feat(menu): add a simple boot menu similar to systemd-boot (#100)
The boot menu is now a BootMenu trait with two styles. The basic menu is the existing one that prints entries and selects them by number. The new simple menu is full-screen: entries are centered and highlighted, the arrow keys, home, end, page up and page down move the selection, enter boots it, and any key stops the countdown. The style is picked with --menu-style or menu-style in [options], and defaults to simple. The timer code used to wait for a key is shared between both menus in menu.rs.
This commit is contained in:
7 files changed
+512
-123
No files matched your search
@@ -338,13 +338,21 @@ fn run() -> Result<()> {
|
||||
// Convert the menu timeout to a duration.
|
||||
let menu_timeout = Duration::from_secs(menu_timeout);
|
||||
|
||||
// Determine the menu style based on the options or configuration.
|
||||
// We prefer the options over the configuration to allow for overriding.
|
||||
let menu_style = context
|
||||
.root()
|
||||
.options()
|
||||
.menu_style
|
||||
.unwrap_or(config.options.menu_style);
|
||||
|
||||
// Use the forced boot entry if possible, otherwise pick the first entry using a boot menu.
|
||||
let entry = if !force_boot_menu && let Some(ref force_boot_entry) = force_boot_entry {
|
||||
BootableEntry::find(force_boot_entry, entries.iter())
|
||||
.context(format!("unable to find entry: {force_boot_entry}"))?
|
||||
} else {
|
||||
// Delegate to the menu to select an entry to boot.
|
||||
menu::select(&timer, menu_timeout, &entries)
|
||||
menu::select(&timer, menu_timeout, menu_style, &entries)
|
||||
.context("unable to select entry via boot menu")?
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user