diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-01-17 17:17:08 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-01-17 17:17:08 +0100 |
commit | 112fcf5b3144419dd94d227cd5078db01ef7f372 (patch) | |
tree | 4e3a1ee9a897006af5b249d81b091f7cf9b136a3 | |
parent | ae02b290903bf078d404984b9bf0feda801b7d56 (diff) |
Remove accidentially unused code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/mailview.rs | 80 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/main_view.rs | 31 |
3 files changed, 0 insertions, 112 deletions
diff --git a/src/mailview.rs b/src/mailview.rs deleted file mode 100644 index 236eea5..0000000 --- a/src/mailview.rs +++ /dev/null @@ -1,80 +0,0 @@ -use cursive::Printer; -use cursive::Rect; -use cursive::View; -use cursive::XY; -use cursive::direction::Direction; -use cursive::event::Event; -use cursive::event::EventResult; -use cursive::view::Selector; -use cursive::views::TextView; -use itertools::Itertools; - -use crate::maillist_view::MailListingData; - -pub struct MailView(TextView); - -impl MailView { - pub fn create_for(mldata: MailListingData) -> Self { - let text = indoc::formatdoc!(r#" - Id : {id} - Tags : {tags} - Date : {date} - From : {from} - To : {to} - Subject: {subject} - "#, - id = mldata.mail_id(), - tags = mldata.tags().iter().join(", "), - date = mldata.date(), - from = mldata.from(), - to = mldata.to(), - subject = mldata.subject(), - ); - MailView(TextView::new(text)) - } -} - -impl View for MailView { - fn draw(&self, printer: &Printer) { - self.0.draw(printer) - } - - fn layout(&mut self, xy: XY<usize>) { - self.0.layout(xy) - } - - fn needs_relayout(&self) -> bool { - self.0.needs_relayout() - } - - fn required_size(&mut self, constraint: XY<usize>) -> XY<usize> { - self.0.required_size(constraint) - } - - fn on_event(&mut self, e: Event) -> EventResult { - self.0.on_event(e) - } - - fn call_on_any<'a>(&mut self, s: &Selector, tpl: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)) { - self.0.call_on_any(s, tpl); - } - - fn focus_view(&mut self, s: &Selector) -> Result<(), ()> { - self.0.focus_view(s) - } - - fn take_focus(&mut self, source: Direction) -> bool { - self.0.take_focus(source) - } - - fn important_area(&self, view_size: XY<usize>) -> Rect { - self.0.important_area(view_size) - } - - fn type_name(&self) -> &'static str { - self.0.type_name() - } - -} - - diff --git a/src/main.rs b/src/main.rs index 906da9e..89cdab8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,6 @@ mod main_view; mod mail_view; mod maillist_view; mod configuration; -mod mailview; mod util; use configuration::Configuration; diff --git a/src/main_view.rs b/src/main_view.rs index c0dcd08..a3b0be7 100644 --- a/src/main_view.rs +++ b/src/main_view.rs @@ -188,35 +188,4 @@ impl MainView { }) } - fn add_mailview(siv: &mut Cursive, muxroot: cursive_multiplex::Id) { - debug!("Creating mailview"); - siv.call_on_name(MAIN_MAIL_LIST_NAME, |maillist_view: &mut MaillistView| { - if let Some(ml_data) = maillist_view.item().and_then(move |idx| maillist_view.borrow_item(idx)) { - debug!("Found item"); - Ok(ml_data.clone()) - } else { - unimplemented!() - } - }) - .map(|maillist_item: Result<MailListingData>| { - if let Ok(mldata) = maillist_item { - let _ = siv.call_on_name(MAIN_MUX_NAME, |mux: &mut Mux| { - debug!("Adding mux pane"); - let _ = mux.add_right_of(crate::mailview::MailView::create_for(mldata), muxroot); // TODO handle error - }); // TODO handle error. - } else { - // do something - } - - Ok(()) - }) - .unwrap_or_else(|| { - siv.add_layer(crate::util::dialog_for("Failed to find View")); - Ok(()) - }) - .unwrap_or_else(|e: anyhow::Error| { - siv.add_layer(crate::util::error_dialog_for(e)) - }); - } - } |