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