aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index ad62b77..9add0c0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,9 +3,8 @@ extern crate serde_json;
3extern crate cursive; 3extern crate cursive;
4 4
5use cursive::Cursive; 5use cursive::Cursive;
6use cursive::align::HAlign;
7use cursive::traits::*; 6use cursive::traits::*;
8use cursive::views::{ TextView, Dialog, EditView, SelectView, LinearLayout, DummyView }; 7use cursive::views::{ TextView, Dialog, EditView, SelectView, OnEventView };
9 8
10pub mod content; 9pub mod content;
11use content::*; 10use content::*;
@@ -16,11 +15,6 @@ fn main() {
16 15
17 main.add_global_callback('q', |s| s.quit()); 16 main.add_global_callback('q', |s| s.quit());
18 main.add_global_callback('s', |s| search(s)); 17 main.add_global_callback('s', |s| search(s));
19 main.add_global_callback('t', |s| match s.pop_layer() {
20 Some(_) => (),
21 None => s.add_layer( Dialog::text("Stack is empty!")
22 .title("Error")
23 )});
24 18
25 main.run(); 19 main.run();
26} 20}
@@ -38,13 +32,14 @@ fn search(s: &mut Cursive){
38 .with_all_str(result) 32 .with_all_str(result)
39 .on_submit(on_submit); 33 .on_submit(on_submit);
40 s.add_layer(Dialog::around(choose_result) 34 s.add_layer(Dialog::around(choose_result)
41 .title("Search Results")); 35 .title("Search Results")
36 .fixed_size(( 45,8 )));
42 } 37 }
43 38
44 s.add_layer(Dialog::around(EditView::new() 39 s.add_layer(Dialog::around(EditView::new()
45 .on_submit(go) 40 .on_submit(go)
46 .with_id("search") 41 .with_id("search")
47 .fixed_size(( 15,2 ))) 42 )
48 .title("Search for a page") 43 .title("Search for a page")
49 .button("Go", |s| { 44 .button("Go", |s| {
50 let search_txt = s.call_on_id( "search", |v: &mut EditView| { 45 let search_txt = s.call_on_id( "search", |v: &mut EditView| {
@@ -72,10 +67,13 @@ fn on_submit(s: &mut Cursive, name: &String) {
72 }; 67 };
73 68
74 s.add_layer( 69 s.add_layer(
75 Dialog::around(TextView::new(extract)) 70 Dialog::around(
71 OnEventView::new(TextView::new(extract))
72 .on_event('t', |s| match s.pop_layer() { _ => () })
73 )
76 .title(heading) 74 .title(heading)
77 .padding_right(5) 75 .padding_right(2)
78 .padding_left(5) 76 .padding_left(2)
79 .max_width(80) 77 .max_width(80)
80 ); 78 );
81} 79}