Make Entity `Send`
parent
bac75b96dd
commit
00abea5bff
|
@ -50,8 +50,9 @@ pub struct Card {
|
||||||
url: String,
|
url: String,
|
||||||
key: String,
|
key: String,
|
||||||
|
|
||||||
|
color: u8,
|
||||||
last_edited: DateTime<Local>,
|
last_edited: DateTime<Local>,
|
||||||
extra_properties: FnvHashMap<String, String>
|
extra_properties: FnvHashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddressBook {
|
impl AddressBook {
|
||||||
|
@ -102,6 +103,7 @@ impl Card {
|
||||||
|
|
||||||
last_edited: Local::now(),
|
last_edited: Local::now(),
|
||||||
extra_properties: FnvHashMap::default(),
|
extra_properties: FnvHashMap::default(),
|
||||||
|
color: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl Entity {
|
||||||
/// Types implementing this Trait can draw on the terminal and receive events.
|
/// Types implementing this Trait can draw on the terminal and receive events.
|
||||||
/// If a type wants to skip drawing if it has not changed anything, it can hold some flag in its
|
/// If a type wants to skip drawing if it has not changed anything, it can hold some flag in its
|
||||||
/// fields (eg self.dirty = false) and act upon that in their `draw` implementation.
|
/// fields (eg self.dirty = false) and act upon that in their `draw` implementation.
|
||||||
pub trait Component: Display + Debug {
|
pub trait Component: Display + Debug + Send {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context);
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context);
|
||||||
fn process_event(&mut self, event: &UIEvent, context: &mut Context) -> bool;
|
fn process_event(&mut self, event: &UIEvent, context: &mut Context) -> bool;
|
||||||
fn is_dirty(&self) -> bool {
|
fn is_dirty(&self) -> bool {
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl Component for ContactList {
|
||||||
if self.dirty {
|
if self.dirty {
|
||||||
self.initialize(context);
|
self.initialize(context);
|
||||||
clear_area(grid, area);
|
clear_area(grid, area);
|
||||||
copy_area(grid, &self.content, area, ((0, 0), (MAX_COLS - 1, self.content.size().1 - 1)));
|
copy_area(grid, &self.content, area, ((0, 0), (MAX_COLS - 1, self.content.size().1.saturating_sub(1))));
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ impl Component for ContactList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
UIEventType::Input(Key::Char('e')) => {
|
UIEventType::Input(Key::Char('e')) if self.length > 0 => {
|
||||||
let account = &mut context.accounts[self.account_pos];
|
let account = &mut context.accounts[self.account_pos];
|
||||||
let book = &mut account.address_book;
|
let book = &mut account.address_book;
|
||||||
let card = book[&self.id_positions[self.cursor_pos]].clone();
|
let card = book[&self.id_positions[self.cursor_pos]].clone();
|
||||||
|
|
|
@ -323,7 +323,7 @@ impl Component for MailView {
|
||||||
self.pager = None;
|
self.pager = None;
|
||||||
self.mode = ViewMode::Subview;
|
self.mode = ViewMode::Subview;
|
||||||
}
|
}
|
||||||
ViewMode::Subview => {}
|
ViewMode::Subview | ViewMode::ContactSelector(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
let buf = {
|
let buf = {
|
||||||
let text = self.attachment_to_text(&body);
|
let text = self.attachment_to_text(&body);
|
||||||
|
@ -349,7 +349,8 @@ impl Component for MailView {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ViewMode::ContactSelector(ref mut s) => {
|
ViewMode::ContactSelector(ref mut s) => {
|
||||||
s.draw(grid, (set_y(upper_left, y + 1), bottom_right), context);
|
clear_area(grid, (set_y(upper_left, y + 1), bottom_right));
|
||||||
|
s.draw(grid, (set_y(upper_left, y + 1), bottom_right), context);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(p) = self.pager.as_mut() {
|
if let Some(p) = self.pager.as_mut() {
|
||||||
|
@ -415,6 +416,7 @@ impl Component for MailView {
|
||||||
entries.push((envelope.from()[0].get_email().into_bytes(), format!("{}", envelope.from()[0])));
|
entries.push((envelope.from()[0].get_email().into_bytes(), format!("{}", envelope.from()[0])));
|
||||||
entries.push((String::from("foo@bar.de").into_bytes(), String::from("Johann de Vir <foo@bar.de>")));
|
entries.push((String::from("foo@bar.de").into_bytes(), String::from("Johann de Vir <foo@bar.de>")));
|
||||||
self.mode = ViewMode::ContactSelector(Selector::new(entries, true));
|
self.mode = ViewMode::ContactSelector(Selector::new(entries, true));
|
||||||
|
self.dirty = true;
|
||||||
//context.accounts.context(self.coordinates.0).address_book.add_card(new_card);
|
//context.accounts.context(self.coordinates.0).address_book.add_card(new_card);
|
||||||
},
|
},
|
||||||
UIEventType::Input(Key::Esc) | UIEventType::Input(Key::Alt('')) => {
|
UIEventType::Input(Key::Esc) | UIEventType::Input(Key::Alt('')) => {
|
||||||
|
@ -604,6 +606,11 @@ impl Component for MailView {
|
||||||
self.dirty
|
self.dirty
|
||||||
|| self.pager.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
|
|| self.pager.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
|
||||||
|| self.subview.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
|
|| self.subview.as_ref().map(|p| p.is_dirty()).unwrap_or(false)
|
||||||
|
|| if let ViewMode::ContactSelector(ref s) = self.mode {
|
||||||
|
s.is_dirty()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn set_dirty(&mut self) {
|
fn set_dirty(&mut self) {
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
|
|
|
@ -864,6 +864,7 @@ impl fmt::Display for Selector {
|
||||||
|
|
||||||
impl Component for Selector {
|
impl Component for Selector {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
|
eprintln!("drawing");
|
||||||
let (width, height) = self.content.size();
|
let (width, height) = self.content.size();
|
||||||
copy_area_with_break(
|
copy_area_with_break(
|
||||||
grid,
|
grid,
|
||||||
|
@ -897,14 +898,17 @@ impl Component for Selector {
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
UIEventType::Input(Key::Up) if self.cursor > 0 => {
|
UIEventType::Input(Key::Up) if self.cursor > 0 => {
|
||||||
self.cursor -= 1;
|
self.cursor -= 1;
|
||||||
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
UIEventType::Input(Key::Down) if self.cursor < height.saturating_sub(1) => {
|
UIEventType::Input(Key::Down) if self.cursor < height.saturating_sub(1) => {
|
||||||
self.cursor += 1;
|
self.cursor += 1;
|
||||||
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -8,6 +8,13 @@ enum FormFocus {
|
||||||
TextInput,
|
TextInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
enum Field {
|
||||||
|
Text(String),
|
||||||
|
Choice(Vec<String>),
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
impl Default for FormFocus {
|
impl Default for FormFocus {
|
||||||
fn default() -> FormFocus {
|
fn default() -> FormFocus {
|
||||||
FormFocus::Fields
|
FormFocus::Fields
|
||||||
|
@ -195,7 +202,7 @@ impl Component for FormWidget {
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct ButtonWidget<T> where T: std::fmt::Debug + Default{
|
pub struct ButtonWidget<T> where T: std::fmt::Debug + Default + Send{
|
||||||
buttons: FnvHashMap<String, T>,
|
buttons: FnvHashMap<String, T>,
|
||||||
layout: Vec<String>,
|
layout: Vec<String>,
|
||||||
|
|
||||||
|
@ -203,13 +210,13 @@ pub struct ButtonWidget<T> where T: std::fmt::Debug + Default{
|
||||||
cursor: usize,
|
cursor: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> fmt::Display for ButtonWidget<T> where T: std::fmt::Debug + Default {
|
impl<T> fmt::Display for ButtonWidget<T> where T: std::fmt::Debug + Default + Send {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
Display::fmt("", f)
|
Display::fmt("", f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ButtonWidget<T> where T: std::fmt::Debug + Default {
|
impl<T> ButtonWidget<T> where T: std::fmt::Debug + Default + Send {
|
||||||
pub fn new(init_val: (String, T)) -> ButtonWidget<T> {
|
pub fn new(init_val: (String, T)) -> ButtonWidget<T> {
|
||||||
ButtonWidget {
|
ButtonWidget {
|
||||||
layout: vec![init_val.0.clone()],
|
layout: vec![init_val.0.clone()],
|
||||||
|
@ -230,7 +237,7 @@ impl<T> ButtonWidget<T> where T: std::fmt::Debug + Default {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default {
|
impl<T> Component for ButtonWidget<T> where T: std::fmt::Debug + Default + Send {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
let upper_left = upper_left!(area);
|
let upper_left = upper_left!(area);
|
||||||
let bottom_right = bottom_right!(area);
|
let bottom_right = bottom_right!(area);
|
||||||
|
|
|
@ -24,26 +24,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub use melib::mailbox::{SortField, SortOrder};
|
pub use melib::mailbox::{SortField, SortOrder};
|
||||||
|
use components::Entity;
|
||||||
|
|
||||||
extern crate uuid;
|
extern crate uuid;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, )]
|
||||||
pub enum ListingAction {
|
pub enum ListingAction {
|
||||||
SetPlain,
|
SetPlain,
|
||||||
SetThreaded,
|
SetThreaded,
|
||||||
SetCompact,
|
SetCompact,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, )]
|
||||||
pub enum TabAction {
|
pub enum TabAction {
|
||||||
|
EntityOpen(Entity),
|
||||||
NewDraft,
|
NewDraft,
|
||||||
Reply((usize, usize, usize), usize), // thread coordinates (account, mailbox, root_set idx) and message idx
|
Reply((usize, usize, usize), usize), // thread coordinates (account, mailbox, root_set idx) and message idx
|
||||||
Close,
|
Close,
|
||||||
Kill(Uuid),
|
Kill(Uuid),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, )]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
Listing(ListingAction),
|
Listing(ListingAction),
|
||||||
ViewMailbox(usize),
|
ViewMailbox(usize),
|
||||||
|
|
Loading…
Reference in New Issue