summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-15 14:10:06 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-15 23:38:31 +0300
commitaf38b7e7cbadfacefd5aa848415c83c9e39d41c1 (patch)
treec48df8df9f8dde1dabbb6841081694665a4968fa /ui
parent817c338a1371b92edc7ebafed2d4bf66512a44b3 (diff)
ui: add envelope views in new tab action
Diffstat (limited to 'ui')
-rw-r--r--ui/src/components/mail/view.rs28
-rw-r--r--ui/src/components/mail/view/thread.rs25
-rw-r--r--ui/src/components/utilities.rs6
-rw-r--r--ui/src/execute.rs13
-rw-r--r--ui/src/execute/actions.rs1
5 files changed, 67 insertions, 6 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index a8cc3d80..43bcbf70 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -37,7 +37,7 @@ pub use self::envelope::*;
use mime_apps::query_default_app;
-#[derive(PartialEq, Debug)]
+#[derive(PartialEq, Debug, Clone)]
enum ViewMode {
Normal,
Url,
@@ -77,6 +77,18 @@ pub struct MailView {
id: ComponentId,
}
+impl Clone for MailView {
+ fn clone(&self) -> Self {
+ MailView {
+ subview: None,
+ cmd_buf: String::with_capacity(4),
+ pager: self.pager.clone(),
+ mode: self.mode.clone(),
+ ..*self
+ }
+ }
+}
+
impl fmt::Display for MailView {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// TODO display subject/info
@@ -974,6 +986,12 @@ impl Component for MailView {
}
}
}
+ UIEvent::Action(Listing(OpenInNewTab)) => {
+ context
+ .replies
+ .push_back(UIEvent::Action(Tab(New(Some(Box::new(self.clone()))))));
+ return true;
+ }
_ => {}
}
false
@@ -1035,7 +1053,15 @@ impl Component for MailView {
fn id(&self) -> ComponentId {
self.id
}
+
fn set_id(&mut self, id: ComponentId) {
self.id = id;
}
+
+ fn kill(&mut self, id: ComponentId, context: &mut Context) {
+ debug_assert!(self.id == id);
+ context
+ .replies
+ .push_back(UIEvent::Action(Tab(Kill(self.id))));
+ }
}
diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs
index 7c74c0a0..a329788a 100644
--- a/ui/src/components/mail/view/thread.rs
+++ b/ui/src/components/mail/view/thread.rs
@@ -44,7 +44,7 @@ struct ThreadEntry {
heading: String,
}
-#[derive(Debug, Default)]
+#[derive(Debug, Default, Clone)]
pub struct ThreadView {
new_cursor_pos: usize,
cursor_pos: usize,
@@ -896,9 +896,24 @@ impl Component for ThreadView {
}
}
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
+ match event {
+ UIEvent::Action(Listing(OpenInNewTab)) => {
+ /* Handle this before self.mailview does */
+ context
+ .replies
+ .push_back(UIEvent::Action(Tab(New(Some(Box::new(Self {
+ initiated: false,
+ ..self.clone()
+ }))))));
+ return true;
+ }
+ _ => {}
+ }
+
if self.show_mailview && self.mailview.process_event(event, context) {
return true;
}
+
let shortcuts = &self.get_shortcuts(context)[ThreadView::DESCRIPTION];
match *event {
UIEvent::Input(Key::Char('R')) => {
@@ -1102,7 +1117,15 @@ impl Component for ThreadView {
fn id(&self) -> ComponentId {
self.id
}
+
fn set_id(&mut self, id: ComponentId) {
self.id = id;
}
+
+ fn kill(&mut self, id: ComponentId, context: &mut Context) {
+ debug_assert!(self.id == id);
+ context
+ .replies
+ .push_back(UIEvent::Action(Tab(Kill(self.id))));
+ }
}
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs
index 4b676385..c73d2344 100644
--- a/ui/src/components/utilities.rs
+++ b/ui/src/components/utilities.rs
@@ -263,7 +263,7 @@ impl Component for VSplit {
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
pub enum PageMovement {
Home,
PageUp,
@@ -274,7 +274,7 @@ pub enum PageMovement {
/// A pager for text.
/// `Pager` holds its own content in its own `CellBuffer` and when `draw` is called, it draws the
/// current view of the text. It is responsible for scrolling etc.
-#[derive(Default, Debug)]
+#[derive(Default, Debug, Clone)]
pub struct Pager {
text: String,
cursor_pos: usize,
@@ -1393,7 +1393,7 @@ impl Component for Tabbed {
type EntryIdentifier = Vec<u8>;
/// Shows selection to user
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Clone)]
pub struct Selector {
single_only: bool,
/// allow only one selection
diff --git a/ui/src/execute.rs b/ui/src/execute.rs
index a65881a4..18e3a47e 100644
--- a/ui/src/execute.rs
+++ b/ui/src/execute.rs
@@ -285,6 +285,17 @@ define_commands!([
)
);
)
+ },
+ { tags: ["open-in-tab"],
+ desc: "opens envelope view in new tab",
+ parser:(
+ named!( open_in_new_tab<Action>,
+ do_parse!(
+ ws!(tag!("open-in-tab"))
+ >> (Listing(OpenInNewTab))
+ )
+ );
+ )
}
]);
@@ -334,7 +345,7 @@ named!(
named!(
listing_action<Action>,
- alt_complete!(toggle | envelope_action | filter | toggle_thread_snooze)
+ alt_complete!(toggle | envelope_action | filter | toggle_thread_snooze | open_in_new_tab)
);
named!(
diff --git a/ui/src/execute/actions.rs b/ui/src/execute/actions.rs
index 135b66df..23605402 100644
--- a/ui/src/execute/actions.rs
+++ b/ui/src/execute/actions.rs
@@ -42,6 +42,7 @@ pub enum ListingAction {
SetSeen,
SetUnseen,
Delete,
+ OpenInNewTab,
}
#[derive(Debug)]