summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-04-10 23:37:20 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:44 +0300
commit9bc76e3bcb837352b9c31d8875514d9974b84119 (patch)
tree2d7db5426d690f5868f304fa7b614c615e0585a8
parent106744c7ca4e5444d993a04c23bc04d93e2bfa6a (diff)
ui: unwrap UIEventType
-rw-r--r--src/bin.rs16
-rw-r--r--ui/src/components.rs2
-rw-r--r--ui/src/components/contacts.rs25
-rw-r--r--ui/src/components/contacts/contact_list.rs19
-rw-r--r--ui/src/components/indexer.rs8
-rw-r--r--ui/src/components/indexer/index.rs14
-rw-r--r--ui/src/components/mail.rs14
-rw-r--r--ui/src/components/mail/accounts.rs19
-rw-r--r--ui/src/components/mail/compose.rs84
-rw-r--r--ui/src/components/mail/listing.rs6
-rw-r--r--ui/src/components/mail/listing/compact.rs51
-rw-r--r--ui/src/components/mail/listing/plain.rs43
-rw-r--r--ui/src/components/mail/listing/thread.rs43
-rw-r--r--ui/src/components/mail/view.rs124
-rw-r--r--ui/src/components/mail/view/envelope.rs100
-rw-r--r--ui/src/components/mail/view/html.rs43
-rw-r--r--ui/src/components/mail/view/thread.rs42
-rw-r--r--ui/src/components/notifications.rs4
-rw-r--r--ui/src/components/utilities.rs69
-rw-r--r--ui/src/components/utilities/widgets.rs68
-rw-r--r--ui/src/conf/accounts.rs4
-rw-r--r--ui/src/state.rs53
-rw-r--r--ui/src/types.rs16
23 files changed, 378 insertions, 489 deletions
diff --git a/src/bin.rs b/src/bin.rs
index f7bcaa0e..9c241c98 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -118,11 +118,11 @@ fn main() {
},
Key::Char(' ') => {
state.mode = UIMode::Execute;
- state.rcv_event(UIEvent { id: 0, event_type: UIEventType::ChangeMode(UIMode::Execute)});
+ state.rcv_event(UIEvent::ChangeMode(UIMode::Execute));
state.redraw();
}
key => {
- state.rcv_event(UIEvent { id: 0, event_type: UIEventType::Input(key)});
+ state.rcv_event(UIEvent::Input(key));
state.redraw();
},
}
@@ -131,11 +131,11 @@ fn main() {
match k {
Key::Char('\n') | Key::Esc => {
state.mode = UIMode::Normal;
- state.rcv_event(UIEvent { id: 0, event_type: UIEventType::ChangeMode(UIMode::Normal)});
+ state.rcv_event(UIEvent::ChangeMode(UIMode::Normal));
state.redraw();
},
k => {
- state.rcv_event(UIEvent { id: 0, event_type: UIEventType::InsertInput(k)});
+ state.rcv_event(UIEvent::InsertInput(k));
state.redraw();
},
}
@@ -144,11 +144,11 @@ fn main() {
match k {
Key::Char('\n') | Key::Esc => {
state.mode = UIMode::Normal;
- state.rcv_event(UIEvent { id: 0, event_type: UIEventType::ChangeMode(UIMode::Normal)});
+ state.rcv_event(UIEvent::ChangeMode(UIMode::Normal));
state.redraw();
},
k => {
- state.rcv_event(UIEvent { id: 0, event_type: UIEventType::ExInput(k)});
+ state.rcv_event(UIEvent::ExInput(k));
state.redraw();
},
}
@@ -162,14 +162,14 @@ fn main() {
state.refresh_event(*event);
state.redraw();
},
- ThreadEvent::UIEvent(UIEventType::ChangeMode(f)) => {
+ ThreadEvent::UIEvent(UIEvent::ChangeMode(f)) => {
state.mode = f;
if f == UIMode::Fork {
break 'inner; // `goto` 'reap loop, and wait on child.
}
}
ThreadEvent::UIEvent(e) => {
- state.rcv_event(UIEvent { id: 0, event_type: e});
+ state.rcv_event(e);
state.render();
},
ThreadEvent::ThreadJoin(id) => {
diff --git a/ui/src/components.rs b/ui/src/components.rs
index f5b843d6..96a70b24 100644
--- a/ui/src/components.rs
+++ b/ui/src/components.rs
@@ -48,7 +48,7 @@ use std::ops::{Deref, DerefMut};
use fnv::FnvHashMap;
use uuid::Uuid;
-use super::{Key, StatusEvent, UIEvent, UIEventType};
+use super::{Key, StatusEvent, UIEvent};
/// The upper and lower boundary char.
const HORZ_BOUNDARY: char = '─';
/// The left and right boundary char.
diff --git a/ui/src/components/contacts.rs b/ui/src/components/contacts.rs
index 592db0b1..5bc9fbdf 100644
--- a/ui/src/components/contacts.rs
+++ b/ui/src/components/contacts.rs
@@ -161,32 +161,25 @@ impl Component for ContactManager {
context.accounts[self.account_pos]
.address_book
.add_card(new_card);
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::StatusEvent(StatusEvent::DisplayMessage(
+ context
+ .replies
+ .push_back(UIEvent::StatusEvent(StatusEvent::DisplayMessage(
"Saved.".into(),
- )),
- });
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::ComponentKill(self.id),
- });
+ )));
+ context.replies.push_back(UIEvent::ComponentKill(self.id));
}
Some(false) => {
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::ComponentKill(self.id),
- });
+ context.replies.push_back(UIEvent::ComponentKill(self.id));
}
}
return true;
}
/*
- match event.event_type {
- UIEventType::Input(Key::Char('\n')) => {
+ match *event {
+ UIEvent::Input(Key::Char('\n')) => {
context.replies.push_back(UIEvent {
id: 0,
- event_type: UIEventType::ComponentKill(self.id),
+ event_type: UIEvent::ComponentKill(self.id),
});
return true;
},
diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs
index e124a2a5..45966c6c 100644
--- a/ui/src/components/contacts/contact_list.rs
+++ b/ui/src/components/contacts/contact_list.rs
@@ -168,10 +168,7 @@ impl ContactList {
impl Component for ContactList {
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
if let ViewMode::Close(u) = self.mode {
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Action(Tab(Kill(u))),
- });
+ context.replies.push_back(UIEvent::Action(Tab(Kill(u))));
return;
}
@@ -232,8 +229,8 @@ impl Component for ContactList {
}
}
let shortcuts = self.get_shortcuts(context);
- match event.event_type {
- UIEventType::Input(ref key) if *key == shortcuts["create_contact"] => {
+ match *event {
+ UIEvent::Input(ref key) if *key == shortcuts["create_contact"] => {
let mut manager = ContactManager::default();
manager.account_pos = self.account_pos;
let component = Box::new(manager);
@@ -244,7 +241,7 @@ impl Component for ContactList {
return true;
}
- UIEventType::Input(ref key) if *key == shortcuts["edit_contact"] && self.length > 0 => {
+ UIEvent::Input(ref key) if *key == shortcuts["edit_contact"] && self.length > 0 => {
let account = &mut context.accounts[self.account_pos];
let book = &mut account.address_book;
let card = book[&self.id_positions[self.cursor_pos]].clone();
@@ -258,7 +255,7 @@ impl Component for ContactList {
return true;
}
- UIEventType::Input(Key::Char('n')) => {
+ UIEvent::Input(Key::Char('n')) => {
let card = Card::new();
let mut manager = ContactManager::default();
manager.card = card;
@@ -269,17 +266,17 @@ impl Component for ContactList {
return true;
}
- UIEventType::Input(Key::Up) => {
+ UIEvent::Input(Key::Up) => {
self.set_dirty();
self.new_cursor_pos = self.cursor_pos.saturating_sub(1);
return true;
}
- UIEventType::Input(Key::Down) if self.cursor_pos < self.length.saturating_sub(1) => {
+ UIEvent::Input(Key::Down) if self.cursor_pos < self.length.saturating_sub(1) => {
self.set_dirty();
self.new_cursor_pos += 1;
return true;
}
- UIEventType::ComponentKill(ref kill_id) if self.mode == ViewMode::View(*kill_id) => {
+ UIEvent::ComponentKill(ref kill_id) if self.mode == ViewMode::View(*kill_id) => {
self.mode = ViewMode::List;
self.view.take();
self.set_dirty();
diff --git a/ui/src/components/indexer.rs b/ui/src/components/indexer.rs
index 89a0996d..35981fc0 100644
--- a/ui/src/components/indexer.rs
+++ b/ui/src/components/indexer.rs
@@ -105,14 +105,14 @@ impl Component for Indexer {
}
}
- match event.event_type {
- UIEventType::RefreshMailbox(_) => {
+ match *event {
+ UIEvent::RefreshMailbox(_) => {
self.dirty = true;
}
- UIEventType::ChangeMode(UIMode::Normal) => {
+ UIEvent::ChangeMode(UIMode::Normal) => {
self.dirty = true;
}
- UIEventType::Resize => {
+ UIEvent::Resize => {
self.dirty = true;
}
_ => {}
diff --git a/ui/src/components/indexer/index.rs b/ui/src/components/indexer/index.rs
index 17272d25..0472e67a 100644
--- a/ui/src/components/indexer/index.rs
+++ b/ui/src/components/indexer/index.rs
@@ -128,35 +128,35 @@ impl Component for Index {
if self.content.process_event(event, context) {
return true;
}
- match event.event_type {
- UIEventType::Input(Key::Up) => {
+ match *event {
+ UIEvent::Input(Key::Up) => {
if self.cursor_pos > 0 {
self.new_cursor_pos = self.new_cursor_pos.saturating_sub(1);
self.set_dirty();
}
return true;
}
- UIEventType::Input(Key::Down) => {
+ UIEvent::Input(Key::Down) => {
if self.length > 0 && self.new_cursor_pos < self.length - 1 {
self.new_cursor_pos += 1;
self.set_dirty();
}
return true;
}
- UIEventType::Input(Key::Char('\n')) if self.state == IndexState::Listing => {
+ UIEvent::Input(Key::Char('\n')) if self.state == IndexState::Listing => {
self.state = IndexState::Unfocused;
self.set_dirty();
return true;
}
- UIEventType::Input(Key::Char('i')) if self.state == IndexState::Unfocused => {
+ UIEvent::Input(Key::Char('i')) if self.state == IndexState::Unfocused => {
self.state = IndexState::Listing;
self.set_dirty();
return true;
}
- UIEventType::ChangeMode(UIMode::Normal) => {
+ UIEvent::ChangeMode(UIMode::Normal) => {
self.set_dirty();
}
- UIEventType::Resize => {
+ UIEvent::Resize => {
self.set_dirty();
}
_ => {}
diff --git a/ui/src/components/mail.rs b/ui/src/components/mail.rs
index 0eda5942..c51b0d18 100644
--- a/ui/src/components/mail.rs
+++ b/ui/src/components/mail.rs
@@ -263,25 +263,25 @@ impl Component for AccountMenu {
context.dirty_areas.push_back(area);
}
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
- match event.event_type {
- UIEventType::RefreshMailbox(c) => {
+ match *event {
+ UIEvent::RefreshMailbox(c) => {
self.cursor = Some(c);
self.dirty = true;
}
- UIEventType::ChangeMode(UIMode::Normal) => {
+ UIEvent::ChangeMode(UIMode::Normal) => {
self.dirty = true;
}
- UIEventType::Resize => {
+ UIEvent::Resize => {
self.dirty = true;
}
- UIEventType::Input(Key::Char('`')) => {
+ UIEvent::Input(Key::Char('`')) => {
self.visible = !self.visible;
self.dirty = true;
}
- UIEventType::StartupCheck(_) => {
+ UIEvent::StartupCheck(_) => {
self.dirty = true;
}
- UIEventType::MailboxUpdate(_) => {
+ UIEvent::MailboxUpdate(_) => {
self.dirty = true;
}
_ => {}
diff --git a/ui/src/components/mail/accounts.rs b/ui/src/components/mail/accounts.rs
index afd49ee4..70fa4077 100644
--- a/ui/src/components/mail/accounts.rs
+++ b/ui/src/components/mail/accounts.rs
@@ -49,29 +49,28 @@ impl Component for AccountsPanel {
context.dirty_areas.push_back(area);
}
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
- match event.event_type {
- UIEventType::Input(Key::Up) => {
+ match *event {
+ UIEvent::Input(Key::Up) => {
self.cursor = self.cursor.saturating_sub(1);
self.dirty = true;
return true;
}
- UIEventType::Input(Key::Down) => {
+ UIEvent::Input(Key::Down) => {
if self.cursor + 1 < context.accounts.len() {
self.cursor += 1;
self.dirty = true;
}
return true;
}
- UIEventType::Input(Key::Char('\n')) => {
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Action(Tab(TabOpen(Some(Box::new(
+ UIEvent::Input(Key::Char('\n')) => {
+ context
+ .replies
+ .push_back(UIEvent::Action(Tab(TabOpen(Some(Box::new(
ContactList::for_account(self.cursor),
- ))))),
- });
+ ))))));
return true;
}
- UIEventType::MailboxUpdate(_) => {
+ UIEvent::MailboxUpdate(_) => {
self.dirty = true;
}
_ => {}
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs
index d449147c..e7c6583f 100644
--- a/ui/src/components/mail/compose.rs
+++ b/ui/src/components/mail/compose.rs
@@ -431,9 +431,9 @@ impl Component for Composer {
}
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
- match (&mut self.mode, &mut self.reply_context, &event.event_type) {
+ match (&mut self.mode, &mut self.reply_context, &event) {
// don't pass Reply command to thread view in reply_context
- (_, _, UIEventType::Input(Key::Char('R'))) => {}
+ (_, _, UIEvent::Input(Key::Char('R'))) => {}
(ViewMode::Overview, Some((_, ref mut view)), _) => {
if view.process_event(event, context) {
self.dirty = true;
@@ -456,13 +456,13 @@ impl Component for Composer {
return true;
}
- match event.event_type {
- UIEventType::Resize => {
+ match *event {
+ UIEvent::Resize => {
self.set_dirty();
}
/*
/* Switch e-mail From: field to the `left` configured account. */
- UIEventType::Input(Key::Left) if self.cursor == Cursor::From => {
+ UIEvent::Input(Key::Left) if self.cursor == Cursor::From => {
self.account_cursor = self.account_cursor.saturating_sub(1);
self.draft.headers_mut().insert(
"From".into(),
@@ -472,7 +472,7 @@ impl Component for Composer {
return true;
}
/* Switch e-mail From: field to the `right` configured account. */
- UIEventType::Input(Key::Right) if self.cursor == Cursor::From => {
+ UIEvent::Input(Key::Right) if self.cursor == Cursor::From => {
if self.account_cursor + 1 < context.accounts.len() {
self.account_cursor += 1;
self.draft.headers_mut().insert(
@@ -483,19 +483,16 @@ impl Component for Composer {
}
return true;
}*/
- UIEventType::Input(Key::Up) => {
+ UIEvent::Input(Key::Up) => {
self.cursor = Cursor::Headers;
}
- UIEventType::Input(Key::Down) => {
+ UIEvent::Input(Key::Down) => {
self.cursor = Cursor::Body;
}
- UIEventType::Input(Key::Char(key)) if self.mode.is_discard() => {
+ UIEvent::Input(Key::Char(key)) if self.mode.is_discard() => {
match (key, &self.mode) {
('x', ViewMode::Discard(u)) => {
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Action(Tab(Kill(*u))),
- });
+ context.replies.push_back(UIEvent::Action(Tab(Kill(*u))));
return true;
}
('n', _) => {}
@@ -506,18 +503,12 @@ impl Component for Composer {
if cfg!(feature = "debug_log") {
eprintln!("{:?} could not save draft", e);
}
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Notification(
- Some("Could not save draft.".into()),
- e.into(),
- ),
- });
+ context.replies.push_back(UIEvent::Notification(
+ Some("Could not save draft.".into()),
+ e.into(),
+ ));
}
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Action(Tab(Kill(*u))),
- });
+ context.replies.push_back(UIEvent::Action(Tab(Kill(*u))));
return true;
}
_ => {
@@ -529,18 +520,18 @@ impl Component for Composer {
return true;
}
/* Switch to Overview mode if we're on Edit mode */
- UIEventType::Input(Key::Char('v')) if self.mode.is_edit() => {
+ UIEvent::Input(Key::Char('v')) if self.mode.is_edit() => {
self.mode = ViewMode::Overview;
self.set_dirty();
return true;
}
/* Switch to Edit mode if we're on Overview mode */
- UIEventType::Input(Key::Char('o')) if self.mode.is_overview() => {
+ UIEvent::Input(Key::Char('o')) if self.mode.is_overview() => {
self.mode = ViewMode::Edit;
self.set_dirty();
return true;
}
- UIEventType::Input(Key::Char('s')) if self.mode.is_overview() => {
+ UIEvent::Input(Key::Char('s')) if self.mode.is_overview() => {
use std::io::Write;
use std::process::{Command, Stdio};
let settings = &context.settings;
@@ -568,31 +559,25 @@ impl Component for Composer {
if cfg!(feature = "debug_log") {
eprintln!("{:?} could not save sent msg", e);
}
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Notification(
- Some("Could not save in 'Sent' folder.".into()),
- e.into(),
- ),
- });
+ context.replies.push_back(UIEvent::Notification(
+ Some("Could not save in 'Sent' folder.".into()),
+ e.into(),
+ ));
}
}
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Notification(
- Some("Sent.".into()),
- format!(
- "Mailer output: {:#?}",
- msmtp
- .wait_with_output()
- .expect("Failed to wait on filter")
- .stdout
- ),
+ context.replies.push_back(UIEvent::Notification(
+ Some("Sent.".into()),
+ format!(
+ "Mailer output: {:#?}",
+ msmtp
+ .wait_with_output()
+ .expect("Failed to wait on filter")
+ .stdout
),
- });
+ ));
return true;
}
- UIEventType::Input(Key::Char('e')) if self.cursor == Cursor::Body => {
+ UIEvent::Input(Key::Char('e')) if self.cursor == Cursor::Body => {
/* Edit draft in $EDITOR */
use std::process::{Command, Stdio};
/* Kill input thread so that spawned command can be sole receiver of stdin */
@@ -616,10 +601,7 @@ impl Component for Composer {
let result = f.read_to_string();
self.draft = Draft::from_str(result.as_str()).unwrap();
self.initialized = false;
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Fork(ForkType::Finished),
- });
+ context.replies.push_back(UIEvent::Fork(ForkType::Finished));
context.restore_input();
/*
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index f108d9f8..9bee7206 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -75,9 +75,9 @@ impl Component for Listing {
return true;
}
- match event.event_type {
- UIEventType::Resize => self.set_dirty(),
- UIEventType::Action(ref action) => match action {
+ match *event {
+ UIEvent::Resize => self.set_dirty(),
+ UIEvent::Action(ref action) => match action {
Action::Listing(ListingAction::SetPlain) => {
let new_l = match self {
Listing::Plain(_) => {
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs
index a22942d6..7d7c833b 100644
--- a/ui/src/components/mail/listing/compact.rs
+++ b/ui/src/components/mail/listing/compact.rs
@@ -106,10 +106,10 @@ impl MailboxView {
self.cursor_pos.0 = self.new_cursor_pos.0;
// Inform State that we changed the current folder view.
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::RefreshMailbox((self.cursor_pos.0, self.cursor_pos.1)),
- });
+ context.replies.push_back(UIEvent::RefreshMailbox((
+ self.cursor_pos.0,
+ self.cursor_pos.1,
+ )));
// Get mailbox as a reference.
//
match context.accounts[self.cursor_pos.0].status(self.cursor_pos.1) {
@@ -386,41 +386,41 @@ impl Component for MailboxView {
}
let shortcuts = self.get_shortcuts(context);
- match event.event_type {
- UIEventType::Input(Key::Up) => {
+ match *event {
+ UIEvent::Input(Key::Up) => {
if self.cursor_pos.2 > 0 {
self.new_cursor_pos.2 = self.new_cursor_pos.2.saturating_sub(1);
self.dirty = true;
}
return true;
}
- UIEventType::Input(Key::Down) => {
+ UIEvent::Input(Key::Down) => {
if self.length > 0 && self.new_cursor_pos.2 < self.length - 1 {
self.new_cursor_pos.2 += 1;
self.dirty = true;
}
return true;
}
- UIEventType::Input(ref k) if !self.unfocused && *k == shortcuts["open_thread"] => {
+ UIEvent::Input(ref k) if !self.unfocused && *k == shortcuts["open_thread"] => {
self.view = ThreadView::new(self.cursor_pos, None, context);
self.unfocused = true;
self.dirty = true;
return true;
}
- UIEventType::Input(ref key) if *key == shortcuts["prev_page"] => {
+ UIEvent::Input(ref key) if *key == shortcuts["prev_page"] => {
self.movement = Some(PageMovement::PageUp);
self.set_dirty();
}
- UIEventType::Input(ref key) if *key == shortcuts["next_page"] => {
+ UIEvent::Input(ref key) if *key == shortcuts["next_page"] => {
self.movement = Some(PageMovement::PageDown);
self.set_dirty();
}
- UIEventType::Input(ref k) if self.unfocused && *k == shortcuts["exit_thread"] => {
+ UIEvent::Input(ref k) if self.unfocused && *k == shortcuts["exit_thread"] => {
self.unfocused = false;
self.dirty = true;
return true;
}
- UIEventType::Input(Key::Char(k @ 'J')) | UIEventType::Input(Key::Char(k @ 'K')) => {
+ UIEvent::Input(Key::Char(k @ 'J')) | UIEvent::Input(Key::Char(k @ 'K')) => {
let folder_length = context.accounts[self.cursor_pos.0].len();
match k {
'J' if folder_length > 0 && self.new_cursor_pos.1 < folder_length - 1 => {
@@ -435,28 +435,28 @@ impl Component for MailboxView {
}
return true;
}
- UIEventType::RefreshMailbox(_) => {
+ UIEvent::RefreshMailbox(_) => {
self.dirty = true;
}
- UIEventType::MailboxUpdate((ref idxa, ref idxf))
+ UIEvent::MailboxUpdate((ref idxa, ref idxf))
if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 =>
{
self.refresh_mailbox(context);
self.set_dirty();
}
- UIEventType::StartupCheck(ref f)
+ UIEvent::StartupCheck(ref f)
if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) =>
{
self.refresh_mailbox(context);
self.set_dirty();
}
- UIEventType::ChangeMode(UIMode::Normal) => {
+ UIEvent::ChangeMode(UIMode::Normal) => {
self.dirty = true;
}
- UIEventType::Resize => {
+ UIEvent::Resize => {
self.dirty = true;
}
- UIEventType::Action(ref action) => match action {
+ UIEvent::Action(ref action) => match action {
Action::ViewMailbox(idx) => {
self.new_cursor_pos.1 = *idx;
self.refresh_mailbox(context);
@@ -480,11 +480,10 @@ impl Component for MailboxView {
}
_ => {}
},
- UIEventType::Input(Key::Char('m')) if !self.unfocused => {
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::Action(Tab(NewDraft(self.cursor_pos.0))),
- });
+ UIEvent::Input(Key::Char('m')) if !self.unfocused => {
+ context
+ .replies
+ .push_back(UIEvent::Action(Tab(NewDraft(self.cursor_pos.0))));
return true;
}
_ => {}
@@ -665,8 +664,8 @@ impl Component for CompactListing {
if self.views.is_empty() {
return false;
}
- match event.event_type {
- UIEventType::Input(Key::Char(k @ 'J')) | UIEventType::Input(Key::Char(k @ 'K')) => {
+ match *event {
+ UIEvent::Input(Key::Char(k @ 'J')) | UIEvent::Input(Key::Char(k @ 'K')) => {
let folder_length = context.accounts[self.views[self.cursor].cursor_pos.0].len();
match k {
'J' if folder_length > 0 => {
@@ -684,7 +683,7 @@ impl Component for CompactListing {
self.views[self.cursor].refresh_mailbox(context);
return true;
}
- UIEventType::Input(Key::Char(k @ 'h')) | UIEventType::Input(Key::Char(k @ 'l')) => {
+ UIEvent::Input(Key::Char(k @ 'h')) | UIEvent::Input(Key::Char(k @ 'l')) => {
let binary_search_account = |entries: &[MailboxView], x: usize| -> Option<usize> {
if entries.is_empty() {
return None;
diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs
index 30fae2bb..4ea9713b 100644
--- a/ui/src/components/mail/listing/plain.rs
+++ b/ui/src/components/mail/listing/plain.rs
@@ -107,10 +107,10 @@ impl PlainListing {
self.cursor_pos.1 = self.new_cursor_pos.1;
// Inform State that we changed the current folder view.
- context.replies.push_back(UIEvent {
- id: 0,
- event_type: UIEventType::RefreshMailbox((self.cursor_pos.0, self.cursor_pos.1)),
- });
+ context.replies.push_back(UIEvent::RefreshMailbox((
+ self.cursor_pos.0,
+ self.cursor_pos.1,
+ )));
// Get mailbox as a reference.
//
// Get mailbox as a reference.
@@ -416,40 +416,39 @@ impl Component for PlainListing {
return true;
}
}
- match event.event_type {
- UIEventType::Input(Key::Up) => {
+ match *event {
+ UIEvent::Input(Key::Up) => {
if self.cursor_pos.2 > 0 {
self.new_cursor_pos.2 -= 1;
self.dirty = true;
}
return true;
}
- UIEventType::Input(Key::Down) => {
+ UIEvent::Input(Key::Down) => {
if self.length > 0 && self.new_cursor_pos.2 < self.length - 1 {
self.new_cursor_pos.2 += 1;
self.dirty = true;
}
return true;
}
- UIEventType::Input(Key::Char('\n')) if !self.unfocused => {
+ UIEvent::Input(Key::Char('\n')) if !self.unfocused => {
self.unfocused = true;
self.dirty = true;
return true;
}
- UIEventType::Input(Key::Char('m')) if !self.unfocused => {
- context.replies.push_back(UIEvent {</