aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2018-07-10 13:28:27 +0100
committerNerdyPepper <[email protected]>2018-07-10 13:28:27 +0100
commit85e427014b280de7c14e1244b553b651033b5823 (patch)
tree0e2e89f1424c2b6fc3718be5fcba20119cebff0c
parent55bd0c5836e9b165c337df2856286d00493540ca (diff)
Add link view
-rw-r--r--src/main.rs28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index ebf72d0..bd009e7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,8 +4,11 @@ extern crate cursive;
4 4
5use cursive::Cursive; 5use cursive::Cursive;
6use cursive::traits::*; 6use cursive::traits::*;
7use cursive::views::{ TextView, Dialog, EditView, 7use cursive::views::{
8 SelectView, OnEventView, LinearLayout }; 8 TextView, Dialog, EditView,
9 SelectView, OnEventView, LinearLayout,
10 DummyView
11};
9 12
10pub mod content; 13pub mod content;
11use content::*; 14use content::*;
@@ -84,22 +87,21 @@ fn on_submit(s: &mut Cursive, name: &String) {
84 }; 87 };
85 88
86 // get the act together 89 // get the act together
87 let mut article = TextView::new(heading); 90 let mut article_content = TextView::new(heading);
88 article.append(String::from("\n\n")); 91 article_content.append(String::from("\n\n"));
89 article.append(extract_formatter(extract)); 92 article_content.append(extract_formatter(extract));
90 93
91 let links = SelectView::<String>::new() 94 let links = SelectView::<String>::new()
92 .with_all_str(link_vec) 95 .with_all_str(link_vec)
93 .on_submit(on_submit); 96 .on_submit(on_submit);
94 97
95 s.add_layer( 98 s.add_layer(
96 LinearLayout::horizontal() 99 OnEventView::new(
97 .child( 100 LinearLayout::horizontal()
98 OnEventView::new( 101 .child(article_content.fixed_width(72))
99 article.fixed_width(72) 102 .child(DummyView)
100 ) 103 .child(links)
101 .on_event('t', |s| match s.pop_layer() { _ => () }) 104 )
102 ) 105 .on_event('t', |s| match s.pop_layer() { _ => () })
103 .child(links)
104 ); 106 );
105} 107}