tui_pages/focus/intent.rs
1use crate::focus::FocusTarget;
2
3/// `O` is the application's overlay type (see [`FocusTarget`]); `M` is the
4/// payload carried by a generic modal overlay (e.g. dialog content under the
5/// `dialog` feature). Both default to `()`.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum FocusIntent<O = (), M = ()> {
8 Next,
9 Prev,
10 Set(FocusTarget<O>),
11 Open(FocusTarget<O>),
12 Close(FocusTarget<O>),
13 Toggle(FocusTarget<O>),
14 RegisterPage(Vec<FocusTarget<O>>),
15 RegisterPageAndEnterSection {
16 targets: Vec<FocusTarget<O>>,
17 section: usize,
18 item_count: usize,
19 item: usize,
20 },
21 /// Open a modal overlay carrying `data` with `count` selectable items
22 /// (`0` for a non-interactive modal such as a loading dialog).
23 ShowModal {
24 data: M,
25 count: usize,
26 },
27 /// Replace the open modal's data and item count in place.
28 UpdateModal {
29 data: M,
30 count: usize,
31 },
32 ClearOverlay,
33 ExitCanvasForward,
34 ExitCanvasBackward,
35 EnterSection {
36 item_count: usize,
37 },
38 LeaveSection,
39 /// Act on the currently focused target: enter it if it is a section
40 /// registered with an item count, otherwise do nothing. Lets an
41 /// application route activation (Enter) to the focus manager instead of
42 /// matching on focus itself. See [`FocusManager::activate`].
43 ///
44 /// [`FocusManager::activate`]: crate::FocusManager::activate
45 Activate,
46}