diff options
author | NerdyPepper <[email protected]> | 2018-06-19 16:20:28 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2018-06-19 16:20:28 +0100 |
commit | db450a92257e19946ca42f01841e7d2990a51976 (patch) | |
tree | e55c5c9a3f5929eb24afa2d05b27f6e01e2e7b95 /src | |
parent | 2e5296aea2c6aa6dfc90b9daf6f20b82ead89bc0 (diff) |
Fix broken imports, add missing import
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 24 |
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; | |||
5 | use serde_json::Value; | 5 | use serde_json::Value; |
6 | 6 | ||
7 | use cursive::Cursive; | 7 | use cursive::Cursive; |
8 | use cursive::{TextView, Dialog, EditView, SelectView}; | 8 | use cursive::traits::*; |
9 | use cursive::views::{TextView, Dialog, EditView, SelectView}; | ||
9 | 10 | ||
10 | pub mod content; | 11 | pub 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 | ||
21 | fn search(s: &mut Cursive){ | 24 | fn 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 | } |