summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-01-14 19:57:32 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-01-14 20:55:30 +0100
commit328601602712958ad5e201d239f62440a1b02401 (patch)
tree051e24bc8a4cbf0261f9368b41545d308ed7d682
parent48e862f21dfee6b2bf31cf16625a64f73527feda (diff)
Wrap view in a cursive_multiplex
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--Cargo.toml8
-rw-r--r--src/main_view.rs23
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<String>,
}
@@ -96,16 +97,26 @@ impl View for MainView {
impl MainView {
pub fn new(config: Configuration) -> Result<NamedView<Self>> {
+ 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<T: View>(&mut self, id: String, view: T) {