cleanups
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Cadey Ratio 2020-07-25 14:42:51 -04:00
parent 02558b4dff
commit ec3020e5b1
2 changed files with 34 additions and 1 deletions

View File

@ -9,5 +9,6 @@ edition = "2018"
[dependencies]
cursive = "0.15"
log = "0.4"
url = "2"
maj = { path = ".." }

View File

@ -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
}