diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 3f78541..af06dd5 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -4,7 +4,13 @@ extern crate cursive; | |||
4 | 4 | ||
5 | use cursive::Cursive; | 5 | use cursive::Cursive; |
6 | use cursive::traits::*; | 6 | use cursive::traits::*; |
7 | use cursive::views::{ TextView, Dialog, EditView, SelectView, OnEventView }; | 7 | use cursive::views::{ TextView, Dialog, EditView, |
8 | SelectView, OnEventView }; | ||
9 | use cursive::theme::PaletteColor::*; | ||
10 | use cursive::theme::Color::*; | ||
11 | use cursive::theme::BaseColor::*; | ||
12 | use cursive::theme; | ||
13 | use cursive::theme::BorderStyle; | ||
8 | 14 | ||
9 | pub mod content; | 15 | pub mod content; |
10 | use content::*; | 16 | use content::*; |
@@ -13,6 +19,32 @@ fn main() { | |||
13 | // Initial setup | 19 | // Initial setup |
14 | let mut main = Cursive::default(); | 20 | let mut main = Cursive::default(); |
15 | 21 | ||
22 | // basic theme | ||
23 | let mut wikitheme = main.current_theme().clone(); | ||
24 | |||
25 | // set the theme's | ||
26 | // shadow | ||
27 | wikitheme.shadow = false; | ||
28 | // border | ||
29 | wikitheme.borders = BorderStyle::Simple; | ||
30 | // and palette | ||
31 | let mut palette: theme::Palette = theme::Palette::default(); | ||
32 | palette.set_color("background" , Dark(Black)); | ||
33 | palette.set_color("shadow" , Dark(White)); | ||
34 | palette.set_color("view" , Dark(Black)); | ||
35 | palette.set_color("primary" , Dark(White)); | ||
36 | palette.set_color("secondary" , Dark(Blue)); | ||
37 | palette.set_color("teritary" , Dark(Green)); | ||
38 | palette.set_color("title_primary" , Dark(Blue)); | ||
39 | palette.set_color("title_secondary" , Dark(Green)); | ||
40 | palette.set_color("highlight" , Dark(Blue)); | ||
41 | palette.set_color("highlight_inactive" , Dark(Red)); | ||
42 | |||
43 | wikitheme.palette = palette; | ||
44 | |||
45 | // set theme | ||
46 | main.set_theme(wikitheme); | ||
47 | |||
16 | main.add_global_callback('q', |s| s.quit()); | 48 | main.add_global_callback('q', |s| s.quit()); |
17 | main.add_global_callback('s', |s| search(s)); | 49 | main.add_global_callback('s', |s| search(s)); |
18 | 50 | ||
@@ -34,7 +66,7 @@ fn search(s: &mut Cursive){ | |||
34 | s.add_layer(Dialog::around(choose_result) | 66 | s.add_layer(Dialog::around(choose_result) |
35 | .title("Search Results") | 67 | .title("Search Results") |
36 | .button("Cancel", |s| match s.pop_layer() { _ => () }) | 68 | .button("Cancel", |s| match s.pop_layer() { _ => () }) |
37 | .fixed_size(( 45,8 ))); | 69 | .fixed_size(( 45,10 ))); |
38 | } | 70 | } |
39 | 71 | ||
40 | s.add_layer(Dialog::around(EditView::new() | 72 | s.add_layer(Dialog::around(EditView::new() |
@@ -59,7 +91,6 @@ fn on_submit(s: &mut Cursive, name: &String) { | |||
59 | let heading: String = name.clone(); | 91 | let heading: String = name.clone(); |
60 | let url = query_url_gen(&name.replace(" ", "_")); | 92 | let url = query_url_gen(&name.replace(" ", "_")); |
61 | let res = reqwest::get(&url).unwrap(); | 93 | let res = reqwest::get(&url).unwrap(); |
62 | |||
63 | let mut extract = String::new(); | 94 | let mut extract = String::new(); |
64 | 95 | ||
65 | match get_extract(res) { | 96 | match get_extract(res) { |
@@ -75,6 +106,5 @@ fn on_submit(s: &mut Cursive, name: &String) { | |||
75 | .title(heading) | 106 | .title(heading) |
76 | .padding_right(2) | 107 | .padding_right(2) |
77 | .padding_left(2) | 108 | .padding_left(2) |
78 | .max_width(80) | ||
79 | ); | 109 | ); |
80 | } | 110 | } |