ui: add envelope views in new tab action
parent
817c338a13
commit
af38b7e7cb
|
@ -37,7 +37,7 @@ pub use self::envelope::*;
|
||||||
|
|
||||||
use mime_apps::query_default_app;
|
use mime_apps::query_default_app;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug, Clone)]
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
Normal,
|
Normal,
|
||||||
Url,
|
Url,
|
||||||
|
@ -77,6 +77,18 @@ pub struct MailView {
|
||||||
id: ComponentId,
|
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 {
|
impl fmt::Display for MailView {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
// TODO display subject/info
|
// 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
|
false
|
||||||
|
@ -1035,7 +1053,15 @@ impl Component for MailView {
|
||||||
fn id(&self) -> ComponentId {
|
fn id(&self) -> ComponentId {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_id(&mut self, id: ComponentId) {
|
fn set_id(&mut self, id: ComponentId) {
|
||||||
self.id = id;
|
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))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct ThreadEntry {
|
||||||
heading: String,
|
heading: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct ThreadView {
|
pub struct ThreadView {
|
||||||
new_cursor_pos: usize,
|
new_cursor_pos: usize,
|
||||||
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 {
|
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) {
|
if self.show_mailview && self.mailview.process_event(event, context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let shortcuts = &self.get_shortcuts(context)[ThreadView::DESCRIPTION];
|
let shortcuts = &self.get_shortcuts(context)[ThreadView::DESCRIPTION];
|
||||||
match *event {
|
match *event {
|
||||||
UIEvent::Input(Key::Char('R')) => {
|
UIEvent::Input(Key::Char('R')) => {
|
||||||
|
@ -1102,7 +1117,15 @@ impl Component for ThreadView {
|
||||||
fn id(&self) -> ComponentId {
|
fn id(&self) -> ComponentId {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_id(&mut self, id: ComponentId) {
|
fn set_id(&mut self, id: ComponentId) {
|
||||||
self.id = id;
|
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))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl Component for VSplit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum PageMovement {
|
pub enum PageMovement {
|
||||||
Home,
|
Home,
|
||||||
PageUp,
|
PageUp,
|
||||||
|
@ -274,7 +274,7 @@ pub enum PageMovement {
|
||||||
/// A pager for text.
|
/// A pager for text.
|
||||||
/// `Pager` holds its own content in its own `CellBuffer` and when `draw` is called, it draws the
|
/// `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.
|
/// current view of the text. It is responsible for scrolling etc.
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct Pager {
|
pub struct Pager {
|
||||||
text: String,
|
text: String,
|
||||||
cursor_pos: usize,
|
cursor_pos: usize,
|
||||||
|
@ -1393,7 +1393,7 @@ impl Component for Tabbed {
|
||||||
|
|
||||||
type EntryIdentifier = Vec<u8>;
|
type EntryIdentifier = Vec<u8>;
|
||||||
/// Shows selection to user
|
/// Shows selection to user
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct Selector {
|
pub struct Selector {
|
||||||
single_only: bool,
|
single_only: bool,
|
||||||
/// allow only one selection
|
/// allow only one selection
|
||||||
|
|
|
@ -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!(
|
named!(
|
||||||
listing_action<Action>,
|
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!(
|
named!(
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub enum ListingAction {
|
||||||
SetSeen,
|
SetSeen,
|
||||||
SetUnseen,
|
SetUnseen,
|
||||||
Delete,
|
Delete,
|
||||||
|
OpenInNewTab,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
Loading…
Reference in New Issue