aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2018-06-19 16:20:28 +0100
committerNerdyPepper <[email protected]>2018-06-19 16:20:28 +0100
commitdb450a92257e19946ca42f01841e7d2990a51976 (patch)
treee55c5c9a3f5929eb24afa2d05b27f6e01e2e7b95 /src
parent2e5296aea2c6aa6dfc90b9daf6f20b82ead89bc0 (diff)
Fix broken imports, add missing import
Diffstat (limited to 'src')
-rw-r--r--src/main.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 6ed1480..bc1188d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,7 +5,8 @@ extern crate cursive;
5use serde_json::Value; 5use serde_json::Value;
6 6
7use cursive::Cursive; 7use cursive::Cursive;
8use cursive::{TextView, Dialog, EditView, SelectView}; 8use cursive::traits::*;
9use cursive::views::{TextView, Dialog, EditView, SelectView};
9 10
10pub mod content; 11pub mod content;
11 12
@@ -13,20 +14,23 @@ fn main() {
13 // Initial setup 14 // Initial setup
14 let mut main = Cursive::default(); 15 let mut main = Cursive::default();
15 16
16 main.add_layer(TextView::new("Welcome!"))); 17 main.add_layer(TextView::new("Welcome!"));
17 main.add_global_callback('q', |s| s.quit()); 18 main.add_global_callback('q', |s| s.quit());
18 main.add_global_callback('s', search())); 19 main.add_global_callback('s', |s| search(s));
20
21 main.run();
19} 22}
20 23
21fn search(s: &mut Cursive){ 24fn search(s: &mut Cursive){
25
22 fn go(s: &mut Cursive, search: &str) { 26 fn go(s: &mut Cursive, search: &str) {
23 s.pop_layer(); 27 s.pop_layer();
24 let search_results: Vec<String> = content::get_search_results(); 28 let results = content::get_search_results(search);
25 let sv = SelectView::with_all_strs(search_results.iter()); 29 s.add_layer(SelectView::new().with_all_str(results));
26 } 30 }
27 31
28 s.add_layer(Dialog::around(EditView::new() 32 s.add_layer(Dialog::around(EditView::new()
29 .on_submit(render_page()) 33 .on_submit(go)
30 .with_id("search") 34 .with_id("search")
31 .fixed_width(10)) 35 .fixed_width(10))
32 .title("Search for a page") 36 .title("Search for a page")
@@ -34,8 +38,10 @@ fn search(s: &mut Cursive){
34 let search_txt = s.call_on_id( "search", |v: &mut EditView| { 38 let search_txt = s.call_on_id( "search", |v: &mut EditView| {
35 v.get_content() 39 v.get_content()
36 }).unwrap(); 40 }).unwrap();
37 41 go(s, &search_txt);
38 go(s, search_txt);
39 }) 42 })
40 .button("Cancel", |s| s.pop_layer())); 43 .button("Cancel", |s| match s.pop_layer(){
44 Some(_) => (),
45 None => (),
46 }));
41} 47}