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
pub mod input;
pub mod literal;
use crate::coordinator::Coordinator;
use crate::layout::LayoutAccessor;
use crate::Result;
use termion::event::Key;
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ElementId {
step_index: usize,
element_index: usize,
}
impl ElementId {
pub(crate) fn new(step_index: usize, element_index: usize) -> Self {
Self {
step_index,
element_index,
}
}
}
pub trait Element {
fn set_id(&mut self, element_id: ElementId);
fn render(&mut self, coordinator: &mut Coordinator) -> Result<()>;
fn update_layout(&mut self, layout_accessor: &mut LayoutAccessor);
fn is_input(&self) -> bool;
fn captures_enter(&self) -> bool;
fn update(&mut self, key: Key) -> bool;
}