src/global/structs/status.rs
41 lines · 988 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 pub popup_opened: bool,
9 pub search_filter_opened: bool,
10 /// to prevent rerendering the same image
11 pub render_image: bool,
12 /// the textfield for command capture
13 pub command_capture: Option<TextField>,
14 /// if true, exit in the next iteration
15 pub exit: bool,
16 /// stores the area of the previously rendered frame
17 pub prev_frame: Option<Rect>,
18}
19
20impl Key for Status {
21 type Value = Self;
22}
23
24impl Default for Status {
25 fn default() -> Self {
26 Self {
27 popup_opened: false,
28 search_filter_opened: false,
29 render_image: true,
30 command_capture: None,
31 exit: false,
32 prev_frame: None,
33 }
34 }
35}
36
37impl Status {
38 pub fn reset(&mut self) {
39 *self = Self::default();
40 }
41}