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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* meli - ui crate.
*
* Copyright 2017-2018 Manos Pitsidianakis
*
* This file is part of meli.
*
* meli is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* meli is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
pub mod accounts;
pub use self::accounts::{Account, LoadMailboxResult};
#[macro_use]
mod position;
#[macro_use]
mod cells;
#[macro_use]
mod helpers;
#[macro_use]
mod keys;
pub use self::cells::*;
pub use self::helpers::*;
pub use self::keys::*;
pub use self::position::*;
use super::execute::Action;
use melib::RefreshEvent;
use std;
use std::fmt;
use std::thread;
/// `ThreadEvent` encapsulates all of the possible values we need to transfer between our threads
/// to the main process.
#[derive(Debug)]
pub enum ThreadEvent {
ThreadJoin(thread::ThreadId),
/// User input.
Input(Key),
/// A watched folder has been refreshed.
RefreshMailbox {
hash: u64,
},
UIEvent(UIEventType),
//Decode { _ }, // For gpg2 signature check
}
impl From<RefreshEvent> for ThreadEvent {
fn from(event: RefreshEvent) -> Self {
ThreadEvent::RefreshMailbox { hash: event.hash }
}
}
#[derive(Debug)]
pub enum ForkType {
Generic(std::process::Child),
NewDraft(File, std::process::Child),
}
#[derive(Debug)]
pub enum UIEventType {
Input(Key),
ExInput(Key),
RefreshMailbox((usize, usize)),
//Quit?
Resize,
/// Force redraw.
Fork(ForkType),
ChangeMailbox(usize),
ChangeMode(UIMode),
Command(String),
Notification(String),
EditDraft(File),
Action(Action),
StatusNotification(String),
MailboxUpdate((usize, usize)),
StartupCheck,
}
/// An event passed from `State` to its Entities.
#[derive(Debug)]
pub struct UIEvent {
pub id: u64,
pub event_type: UIEventType,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum UIMode {
Normal,
Execute,
Fork,
}
impl fmt::Display for UIMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match *self {
UIMode::Normal => "NORMAL",
UIMode::Execute => "EX",
UIMode::Fork => "FORK",
}
)
}
}
/// An event notification that is passed to Entities for handling.
pub struct Notification {
_title: String,
_content: String,
_timestamp: std::time::Instant,
}
|