From 328601602712958ad5e201d239f62440a1b02401 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 14 Jan 2021 19:57:32 +0100 Subject: Wrap view in a cursive_multiplex Signed-off-by: Matthias Beyer --- Cargo.toml | 8 ++++---- src/main_view.rs | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4c95a4a..b089734 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,12 @@ version = "0.1.0" anyhow = "1" chrono = "0.4" config = "0.10" +cursive = "0.15" cursive-async-view = "0.4" cursive-flexi-logger-view = { git = "https://github.com/deinstapel/cursive-flexi-logger-view/" } +cursive-multiplex = "0.4" cursive-tabs = "0.5" +cursive_core = "0.1" cursive_table_view.git = "https://git.sr.ht/~matthiasbeyer/cursive_table_view" env_logger = "0.7" flexi_logger = "*" @@ -18,12 +21,9 @@ handlebars = "3" log = "0.4" mailparse.git = "https://git.sr.ht/~matthiasbeyer/mailparse" notmuch = "0.6" +result-inspect = "0.1" serde = { version = "1.0", features = ["derive"] } walkdir = "2" -result-inspect = "0.1" - -cursive = "0.15" -cursive_core = "0.1" [dependencies.cursive_tree_view] git = "https://github.com/matthiasbeyer/cursive_tree_view" diff --git a/src/main_view.rs b/src/main_view.rs index c5ee920..d7e7e66 100644 --- a/src/main_view.rs +++ b/src/main_view.rs @@ -24,6 +24,7 @@ pub const MAIN_MAIL_LIST_NAME: &'static str = "main_mail_list"; pub struct MainView { config: Configuration, + muxroot: cursive_multiplex::Id, tabs: cursive_tabs::TabPanel, } @@ -96,16 +97,26 @@ impl View for MainView { impl MainView { pub fn new(config: Configuration) -> Result> { + use cursive::view::SizeConstraint; + let mut tab = cursive_multiplex::Mux::new(); + let muxroot = tab.root().build().unwrap(); + + { + let dbpath = config.notmuch_database_path(); + let dbquery = config.notmuch_default_query(); + let mlname = MAIN_MAIL_LIST_NAME.to_string(); + let mlview = MaillistView::create_for(dbpath, dbquery, mlname)?.with_name(MAIN_MAIL_LIST_NAME); + let view = ResizedView::new(SizeConstraint::Full, SizeConstraint::Full, mlview); + + let _ = tab.add_right_of(view, muxroot); + } + let tabs = cursive_tabs::TabPanel::default() .with_bar_alignment(cursive_tabs::Align::Start) .with_bar_placement(cursive_tabs::Placement::HorizontalTop) - .with_tab(config.notmuch_default_query().clone(), { - ResizedView::new(cursive::view::SizeConstraint::Full, - cursive::view::SizeConstraint::Full, - MaillistView::create_for(config.notmuch_database_path().clone(), config.notmuch_default_query(), MAIN_MAIL_LIST_NAME.to_string())?) - }); + .with_tab(config.notmuch_default_query().clone(), tab); - Ok(MainView { config, tabs }.with_name(MAIN_VIEW_NAME)) + Ok(MainView { config, muxroot, tabs }.with_name(MAIN_VIEW_NAME)) } pub fn add_tab(&mut self, id: String, view: T) { -- cgit v1.2.3