-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheditor.rs
70 lines (64 loc) · 1.62 KB
/
editor.rs
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
use chrono::{DateTime, Local, NaiveDate};
pub use cursor::Cursor;
mod copy_paste;
mod cursor;
mod editor_state;
mod scroll;
mod search;
mod text;
pub use editor_state::EditorState;
pub use search::Search;
pub use text::Text;
#[derive(Debug)]
pub struct Editor {
pub state: EditorState,
pub text: Text,
pub creation_date: NaiveDate,
pub last_edited: DateTime<Local>,
pub scroll_offset: (u16, u16),
pub screen_size: (u16, u16),
pub write: bool,
pub side_panel: bool,
}
#[allow(dead_code)]
impl Editor {
pub fn new() -> Editor {
let now = Local::now();
Editor {
state: EditorState::Edit,
text: Text::new(),
creation_date: now.date_naive(),
last_edited: now,
scroll_offset: (0, 0),
screen_size: (0, 0),
write: false,
side_panel: true,
}
}
pub fn from_string(text: String) -> Editor {
let now = Local::now();
Editor {
state: EditorState::Edit,
text: Text::from_string(text),
creation_date: now.date_naive(),
last_edited: now,
scroll_offset: (0, 0),
screen_size: (0, 0),
write: false,
side_panel: true,
}
}
pub fn default() -> Editor {
let now = Local::now();
Editor {
state: EditorState::Edit,
text: Text::new(),
creation_date: now.date_naive(),
last_edited: now,
scroll_offset: (0, 0),
screen_size: (0, 0),
write: false,
side_panel: true,
}
}
}