1
//! The open menu: moves the selection, applies the chosen entry, closes.
2

            
3
use super::{Intent, apply};
4
use crate::app::App;
5

            
6
78
pub(super) fn handle(app: &mut App, intent: Intent) {
7
78
    match intent {
8
5
        Intent::CloseMenu => app.close_menu(),
9
9
        Intent::MenuNext => app.menu_next(),
10
4
        Intent::MenuPrev => app.menu_prev(),
11
1
        Intent::MenuFirst => app.menu_first(),
12
2
        Intent::MenuLast => app.menu_last(),
13
3
        Intent::MenuLeft => app.menu_left(),
14
11
        Intent::MenuRight => app.menu_right(),
15
43
        Intent::MenuSelect => select(app),
16
        _ => {}
17
    }
18
78
}
19

            
20
/// Closes the menu, then applies the chosen entry as its key would; a disabled one does nothing.
21
43
fn select(app: &mut App) {
22
43
    if let Some(intent) = app.menu_choice() {
23
41
        app.close_menu();
24
41
        apply(app, intent);
25
2
    }
26
43
}