From ec3020e5b1da663445cfd3aa9ac30ae3d2b664e0 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 25 Jul 2020 14:42:51 -0400 Subject: [PATCH] cleanups --- majc/Cargo.toml | 1 + majc/src/main.rs | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/majc/Cargo.toml b/majc/Cargo.toml index 8782781..e1546b6 100644 --- a/majc/Cargo.toml +++ b/majc/Cargo.toml @@ -9,5 +9,6 @@ edition = "2018" [dependencies] cursive = "0.15" log = "0.4" +url = "2" maj = { path = ".." } diff --git a/majc/src/main.rs b/majc/src/main.rs index eecabb4..48167a7 100644 --- a/majc/src/main.rs +++ b/majc/src/main.rs @@ -1,7 +1,7 @@ use cursive::{ event::Key, menu::MenuTree, - theme::{Effect, Style}, + theme::{Effect, Style, Color, PaletteColor, Theme}, traits::*, utils::markup::StyledString, views::{Dialog, EditView, Panel, ResizedView, TextView}, @@ -15,6 +15,9 @@ fn main() { let mut siv = cursive::default(); + let theme = custom_theme_from_cursive(&siv); + siv.set_theme(theme); + siv.add_global_callback('c', |s| { s.pop_layer(); }); @@ -129,6 +132,26 @@ fn show(siv: &mut Cursive, url: &str, resp: Response) { open(siv, resp.meta.as_str()); } + Input => { + siv.add_layer(Dialog::info("needs input support")); + return; + // siv.add_layer( + // Dialog::around(EditView::new().with_name("input").fixed_width(50)) + // .title(resp.meta) + // .button("Ok", |s| { + // let inp = s + // .call_on_name("input", |view: &mut EditView| view.get_content()) + // .unwrap(); + // let url = { + // let mut u = url::Url::parse(url).unwrap(); + // u.set_query(Some(&inp)); + // u.as_str() + // }; + // open(s, url); + // }), + // ); + } + _ => { siv.add_layer(Dialog::info(format!("{:?}: {}", resp.status, resp.meta))); return; @@ -164,3 +187,12 @@ fn render_gemini(body: &str) -> StyledString { styled } + +fn custom_theme_from_cursive(siv: &Cursive) -> Theme { + // We'll return the current theme with a small modification. + let mut theme = siv.current_theme().clone(); + + theme.palette[PaletteColor::Background] = Color::TerminalDefault; + + theme +}