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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use super::*;
use crate::melib::text_processing::{TextProcessing, Truncate};
use crate::terminal::boundaries::*;
pub mod mail;
pub use crate::mail::*;
pub mod notifications;
pub mod utilities;
pub use self::utilities::*;
pub mod contacts;
pub use crate::contacts::*;
#[cfg(feature = "svgscreenshot")]
pub mod svg;
use std::fmt;
use std::fmt::{Debug, Display};
use indexmap::IndexMap;
use uuid::Uuid;
pub type ComponentId = Uuid;
pub type ShortcutMap = IndexMap<&'static str, Key>;
pub type ShortcutMaps = IndexMap<&'static str, ShortcutMap>;
#[derive(Debug, Clone, Copy)]
pub enum PageMovement {
Up(usize),
Right(usize),
Left(usize),
Down(usize),
PageUp(usize),
PageDown(usize),
Home,
End,
}
pub trait Component: Display + Debug + Send + Sync {
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context);
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool;
fn is_dirty(&self) -> bool;
fn is_visible(&self) -> bool {
true
}
fn can_quit_cleanly(&mut self, _context: &Context) -> bool {
true
}
fn set_dirty(&mut self, value: bool);
fn kill(&mut self, _id: ComponentId, _context: &mut Context) {}
fn set_id(&mut self, _id: ComponentId) {}
fn id(&self) -> ComponentId;
fn get_shortcuts(&self, _context: &Context) -> ShortcutMaps {
Default::default()
}
fn get_status(&self, _context: &Context) -> String {
String::new()
}
}