From 0179d18834a17779a1b5b6da8573f3d575788e94 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Thu, 5 Jul 2018 19:01:00 +0530 Subject: Begin working on theme --- src/main.rs | 38 ++++++++++++++++++++++++++++++++++---- 1 file 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; use cursive::Cursive; use cursive::traits::*; -use cursive::views::{ TextView, Dialog, EditView, SelectView, OnEventView }; +use cursive::views::{ TextView, Dialog, EditView, + SelectView, OnEventView }; +use cursive::theme::PaletteColor::*; +use cursive::theme::Color::*; +use cursive::theme::BaseColor::*; +use cursive::theme; +use cursive::theme::BorderStyle; pub mod content; use content::*; @@ -13,6 +19,32 @@ fn main() { // Initial setup let mut main = Cursive::default(); + // basic theme + let mut wikitheme = main.current_theme().clone(); + + // set the theme's + // shadow + wikitheme.shadow = false; + // border + wikitheme.borders = BorderStyle::Simple; + // and palette + let mut palette: theme::Palette = theme::Palette::default(); + palette.set_color("background" , Dark(Black)); + palette.set_color("shadow" , Dark(White)); + palette.set_color("view" , Dark(Black)); + palette.set_color("primary" , Dark(White)); + palette.set_color("secondary" , Dark(Blue)); + palette.set_color("teritary" , Dark(Green)); + palette.set_color("title_primary" , Dark(Blue)); + palette.set_color("title_secondary" , Dark(Green)); + palette.set_color("highlight" , Dark(Blue)); + palette.set_color("highlight_inactive" , Dark(Red)); + + wikitheme.palette = palette; + + // set theme + main.set_theme(wikitheme); + main.add_global_callback('q', |s| s.quit()); main.add_global_callback('s', |s| search(s)); @@ -34,7 +66,7 @@ fn search(s: &mut Cursive){ s.add_layer(Dialog::around(choose_result) .title("Search Results") .button("Cancel", |s| match s.pop_layer() { _ => () }) - .fixed_size(( 45,8 ))); + .fixed_size(( 45,10 ))); } s.add_layer(Dialog::around(EditView::new() @@ -59,7 +91,6 @@ fn on_submit(s: &mut Cursive, name: &String) { let heading: String = name.clone(); let url = query_url_gen(&name.replace(" ", "_")); let res = reqwest::get(&url).unwrap(); - let mut extract = String::new(); match get_extract(res) { @@ -75,6 +106,5 @@ fn on_submit(s: &mut Cursive, name: &String) { .title(heading) .padding_right(2) .padding_left(2) - .max_width(80) ); } -- cgit v1.2.3