summaryrefslogtreecommitdiffstats
path: root/src/app/event.rs
blob: f727050dbeb36e4395df79fa3bfa882b203df997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pub mod multi_key;
pub use multi_key::*;

/// These are "signals" that are sent along with an [`WidgetEventResult`] to signify a potential additional action
/// that the caller must do, along with the "core" result of either drawing or redrawing.
#[derive(Debug)]
pub enum ReturnSignal {
    /// A signal returned when some process widget was told to try to kill a process (or group of processes).
    ///
    /// This return signal should trigger a redraw when handled.
    KillProcess,

    /// A signal returned when a widget needs the app state to re-trigger its update call. Usually needed for
    /// widgets where the displayed contents are built only on update.
    ///
    /// This return signal should trigger a redraw when handled.
    Update,
}

/// The results of handling an event by the [`AppState`].
#[derive(Debug)]
pub enum EventResult {
    /// Kill the program.
    Quit,
    /// Trigger a redraw.
    Redraw,
    /// Don't trigger a redraw.
    NoRedraw,
}

/// The results of a widget handling some event, like a mouse or key event,
/// signifying what the program should then do next.
#[derive(Debug)]
pub enum ComponentEventResult {
    /// The event isn't handled by the widget, and should be propagated to the parent.
    Unhandled,
    /// Trigger a redraw.
    Redraw,
    /// Don't trigger a redraw.
    NoRedraw,
    /// Return a signal.
    Signal(ReturnSignal),
}

/// How a widget should handle a widget selection request.
pub enum SelectionAction {
    /// This event occurs if the widget internally handled the selection action. A redraw is required.
    Handled,
    /// This event occurs if the widget did not handle the selection action; the caller must handle it.
    NotHandled,
}