src/global/structs/status.rs

43 lines · 1061 bytes

 1use tui::layout::Rect;
 2use tui_additions::widgets::TextField;
 3use typemap::Key;
 4
 5/// a struct for storing different info, currently only stores one info
 6#[derive(Clone)]
 7pub struct Status {
 8    /// is there is a popup opened
 9    pub popup_opened: bool,
10    /// is search filter popup opened
11    pub search_filter_opened: bool,
12    /// to prevent rerendering the same image
13    pub render_image: bool,
14    /// the textfield for command capture
15    pub command_capture: Option<TextField>,
16    /// if true, exit in the next iteration
17    pub exit: bool,
18    /// stores the area of the previously rendered frame
19    pub prev_frame: Option<Rect>,
20}
21
22impl Key for Status {
23    type Value = Self;
24}
25
26impl Default for Status {
27    fn default() -> Self {
28        Self {
29            popup_opened: false,
30            search_filter_opened: false,
31            render_image: true,
32            command_capture: None,
33            exit: false,
34            prev_frame: None,
35        }
36    }
37}
38
39impl Status {
40    pub fn reset(&mut self) {
41        *self = Self::default();
42    }
43}