diff options
author | Michael Brown <mcb30@ipxe.org> | 2025-02-19 13:12:29 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2025-02-19 13:12:29 +0000 |
commit | e7595fe88d8c32354cd61055cbc9f2e7b3f91ff8 (patch) | |
tree | 20e060dafdbeb99cd97eb4c7aaf0a5a11e78eb8a /src/hci/tui | |
parent | ccd62005490de907105c92444631a5914500cb32 (diff) | |
download | ipxe-master.tar.gz |
[menu] Allow a post-activity timeout to be definedHEADmastercoverity_scan
Allow the "--retimeout" option to be used to specify a timeout value
that will be (re)applied after each keypress activity. This allows
script authors to ensure that a single (potentially accidental)
keypress will not pause the boot process indefinitely.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci/tui')
-rw-r--r-- | src/hci/tui/menu_ui.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c index b7b52ee62..c7fad4a6b 100644 --- a/src/hci/tui/menu_ui.c +++ b/src/hci/tui/menu_ui.c @@ -53,8 +53,10 @@ struct menu_ui { struct dynamic_ui *dynui; /** Jump scroller */ struct jump_scroller scroll; - /** Timeout (0=indefinite) */ + /** Remaining timeout (0=indefinite) */ unsigned long timeout; + /** Post-activity timeout (0=indefinite) */ + unsigned long retimeout; }; /** @@ -180,8 +182,8 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) { if ( ui->timeout == 0 ) chosen = 1; } else { - /* Cancel any timeout */ - ui->timeout = 0; + /* Reset timeout after activity */ + ui->timeout = ui->retimeout; /* Handle scroll keys */ move = jump_scroll_key ( &ui->scroll, key ); @@ -241,12 +243,14 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) { * Show menu * * @v dynui Dynamic user interface - * @v timeout Timeout period, in ticks (0=indefinite) + * @v timeout Initial timeout period, in ticks (0=indefinite) + * @v retimeout Post-activity timeout period, in ticks (0=indefinite) * @ret selected Selected item * @ret rc Return status code */ int show_menu ( struct dynamic_ui *dynui, unsigned long timeout, - const char *select, struct dynamic_item **selected ) { + unsigned long retimeout, const char *select, + struct dynamic_item **selected ) { struct dynamic_item *item; struct menu_ui ui; char buf[ MENU_COLS + 1 /* NUL */ ]; @@ -258,6 +262,8 @@ int show_menu ( struct dynamic_ui *dynui, unsigned long timeout, ui.dynui = dynui; ui.scroll.rows = MENU_ROWS; ui.timeout = timeout; + ui.retimeout = retimeout; + list_for_each_entry ( item, &dynui->items, list ) { if ( item->name ) { if ( ! named_count ) |