summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-01-30 13:01:05 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-01-30 13:01:35 +0100
commit1fefb24af0f03f6c0512d3b1d3fad7f943c6edd3 (patch)
tree3101c58faef5d3f3dfa29433e083a635a1b4ae69
parente5e72a6d36c9bacc61efd3ed3453867c7f4d970f (diff)
Add opening of a mail on the right side
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/tabs.rs2
-rw-r--r--src/views/maillist.rs17
-rw-r--r--src/views/main.rs28
3 files changed, 34 insertions, 13 deletions
diff --git a/src/tabs.rs b/src/tabs.rs
index 8132f1c..3f8f97d 100644
--- a/src/tabs.rs
+++ b/src/tabs.rs
@@ -102,7 +102,9 @@ impl View for Tabs {
}
+#[derive(getset::Getters, getset::MutGetters)]
pub struct Tab {
+ #[getset(get = "pub", get_mut = "pub")]
mux: cursive_multiplex::Mux,
nodes: Vec<cursive_multiplex::Id>,
rt: Rc<Runtime>,
diff --git a/src/views/maillist.rs b/src/views/maillist.rs
index 4f68790..303efe6 100644
--- a/src/views/maillist.rs
+++ b/src/views/maillist.rs
@@ -83,17 +83,23 @@ impl MaillistView {
.items(items)
.selected_item(0)
.on_submit(move |siv: &mut Cursive, row: usize, _: usize| {
+ debug!("Submit: row = {}", row);
let (mail_id, filename) = siv.call_on_name(crate::views::main::MAIN_VIEW_NAME, move |main: &mut crate::views::main::MainView| {
+ debug!("Got main view.");
main.get_current_mux()
.map(|mux| {
- if let Some(table) = mux.downcast_ref::<TableView<MailListingData, MailListingColumn>>() {
- table
+ debug!("Got mux view.");
+ if let Some(ml) = mux.downcast_ref::<MaillistView>() {
+ debug!("Got table, finding item now.");
+ ml.view
+ .get_inner()
.borrow_item(row)
.map(|data| {
- debug!("Opening: {:?}", data);
+ debug!("Found item: {:?}", data);
(data.mail_id.clone(), data.filename.clone())
})
} else {
+ debug!("Did not find table.");
unimplemented!()
}
})
@@ -107,8 +113,9 @@ impl MaillistView {
siv.call_on_name(crate::views::main::MAIN_VIEW_NAME , move |main: &mut crate::views::main::MainView| {
main.get_current_tab_mut()
- .map(|mux: &mut cursive_multiplex::Mux| {
- mux.add_right_of(mv, mux.focus());
+ .map(|tab: &mut crate::tabs::Tab| {
+ let foc = tab.mux().focus();
+ tab.mux_mut().add_right_of(mv, foc);
})
});
diff --git a/src/views/main.rs b/src/views/main.rs
index 98b8849..e1e9f1d 100644
--- a/src/views/main.rs
+++ b/src/views/main.rs
@@ -43,35 +43,47 @@ impl MainView {
self.tabs.add_tab_for_query(self.rt.clone(), query)
}
- pub fn get_current_tab(&self) -> Option<&cursive_multiplex::Mux> {
+ pub fn get_current_tab(&self) -> Option<&crate::tabs::Tab> {
+ debug!("Getting current tab");
if let Some(mux) = self.tabs.get_active_tab() {
- mux.downcast_ref::<cursive_multiplex::Mux>()
+ debug!("Found current tab, returning mux: {:?}", mux.type_id());
+ mux.downcast_ref::<crate::tabs::Tab>()
} else {
+ debug!("No current tab found");
None
}
}
pub fn get_current_mux(&self) -> Option<&Box<dyn cursive::View>> {
- if let Some(mux) = self.get_current_tab() {
- return mux.get_current_view()
+ debug!("Get current mux");
+ if let Some(tab) = self.get_current_tab() {
+ debug!("Some(mux) found, getting current view");
+ return tab.mux().get_current_view()
}
+ debug!("No mux found");
None
}
- pub fn get_current_tab_mut(&mut self) -> Option<&mut cursive_multiplex::Mux> {
+ pub fn get_current_tab_mut(&mut self) -> Option<&mut crate::tabs::Tab> {
+ debug!("Getting current tab (mut)");
if let Some(mux) = self.tabs.get_active_tab_mut() {
- mux.downcast_mut::<cursive_multiplex::Mux>()
+ debug!("Got current tab (mut), casting ot crate::tabs::Tab");
+ mux.downcast_mut::<crate::tabs::Tab>()
} else {
+ debug!("Did not get current tab (mut)");
None
}
}
pub fn get_current_mux_mut(&mut self) -> Option<&mut Box<dyn cursive::View>> {
- if let Some(mut mux) = self.get_current_tab_mut() {
- return mux.get_current_view_mut()
+ debug!("Getting current tab (mut)");
+ if let Some(mut tab) = self.get_current_tab_mut() {
+ debug!("Got current tab (mut), getting view from mux (mut)");
+ return tab.mux_mut().get_current_view_mut()
}
+ debug!("Did not get current tab (mut))");
None
}