aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2018-06-23 04:13:23 +0100
committerNerdyPepper <[email protected]>2018-06-23 04:13:23 +0100
commit3692828c77246578416d8b1e7642346a6c645393 (patch)
tree2ca0d74f41ab24be8e8a0f1ece36f1325dd49b22 /src
parent6f8a1b75cdffc186f3bf80869cc0e0b5650e0f71 (diff)
Add basic stack functionality
Diffstat (limited to 'src')
-rw-r--r--src/main.rs53
1 files changed, 21 insertions, 32 deletions
diff --git a/src/main.rs b/src/main.rs
index 82b0de0..d38d474 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,9 @@ fn main() {
15 15
16 main.add_global_callback('q', |s| s.quit()); 16 main.add_global_callback('q', |s| s.quit());
17 main.add_global_callback('s', |s| search(s)); 17 main.add_global_callback('s', |s| search(s));
18 main.add_global_callback('t', |s| match s.pop_layer() {
19 _ => ()
20 });
18 21
19 main.run(); 22 main.run();
20} 23}
@@ -30,21 +33,7 @@ fn search(s: &mut Cursive){
30 }; 33 };
31 let choose_result = SelectView::<String>::new() 34 let choose_result = SelectView::<String>::new()
32 .with_all_str(result) 35 .with_all_str(result)
33 .on_submit(|s: &mut Cursive, name: &str| { 36 .on_submit(on_submit);
34 s.pop_layer();
35
36 let url = query_url_gen(&name.replace(" ", "_"));
37 let res = reqwest::get(&url).unwrap();
38
39 let mut extract = String::new();
40
41 match content::get_extract(res) {
42 Ok(x) => extract = x,
43 Err(e) => pop_error(s, content::handler(e))
44 };
45
46 s.add_layer(TextView::new(extract));
47 });
48 s.add_layer(Dialog::around(choose_result) 37 s.add_layer(Dialog::around(choose_result)
49 .title("Search Results")); 38 .title("Search Results"));
50 } 39 }
@@ -65,20 +54,20 @@ fn search(s: &mut Cursive){
65 })); 54 }));
66} 55}
67 56
68// fn on_submit(s: &mut Cursive, name: &String) { 57fn on_submit(s: &mut Cursive, name: &String) {
69// s.pop_layer(); 58 s.pop_layer();
70// 59
71// let title = name.replace(" ", "_"); 60 let title = name.replace(" ", "_");
72// let url = query_url_gen(&title); 61 let url = query_url_gen(&title);
73// let res = reqwest::get(&url).unwrap(); 62 let res = reqwest::get(&url).unwrap();
74// 63
75// let mut extract = String::new(); 64 let mut extract = String::new();
76// 65
77// match content::get_extract(res) { 66 match content::get_extract(res) {
78// 67
79// Ok(x) => extract = x, 68 Ok(x) => extract = x,
80// Err(e) => pop_error(s, content::handler(e)) 69 Err(e) => pop_error(s, content::handler(e))
81// }; 70 };
82// 71
83// s.add_layer(Dialog::around(TextView::new(extract))); 72 s.add_layer(TextView::new(extract));
84// } 73}