diff --git a/src/history.rs.rej b/src/history.rs.rej new file mode 100644 index 0000000..623cf6a --- /dev/null +++ b/src/history.rs.rej @@ -0,0 +1,10 @@ +diff a/src/history.rs b/src/history.rs (rejected hunks) +@@ -2,7 +2,7 @@ use url::Url; + use std::sync::Mutex; + + lazy_static! { +- static ref HISTORY: Mutex> = Mutex::new(vec![]); ++ static ref HISTORY: Mutex> = Mutex::new(vec![]); + } + + pub fn init() { diff --git a/src/main.rs b/src/main.rs index fbf4dc5..1b85cc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use cursive::theme::Effect; use cursive::traits::*; use cursive::utils::markup::StyledString; use cursive::view::Scrollable; -use cursive::views::{Dialog, EditView, Panel, SelectView}; +use cursive::views::{Dialog, EditView, Panel, SelectView, TextView}; use cursive::Cursive; use std::str::FromStr; @@ -74,6 +74,24 @@ fn prompt_for_url(s: &mut Cursive) { ); } +fn prompt_for_answer(s: &mut Cursive, url: Url, message: String) { + s.add_layer( + Dialog::new() + .title(message) + // Padding is (left, right, top, bottom) + .padding((1, 1, 1, 0)) + .content( + EditView::new() + .on_submit(move |s, response| { + let link = format!("{}?query={}", url.to_string(), response); + s.pop_layer(); + follow_link(s, &link); + }).fixed_width(60) + ) + .with_id("url_query"), + ); +} + fn goto_url(s: &mut Cursive, url: &str) { // Prepend gemini scheme if needed if url.starts_with("gemini://") { @@ -136,6 +154,8 @@ fn draw_content(s: &mut Cursive, url: Url, content: String) { let mut main_view = s.find_id::("main").unwrap(); let mut container = s.find_id::("container").unwrap(); + let url_copy = url.clone(); + // handle response status if let Some(status_line) = content.lines().next() { if let Ok(status) = Status::from_str(status_line) { @@ -155,6 +175,9 @@ fn draw_content(s: &mut Cursive, url: Url, content: String) { )); return; } + Status::Input(message) => { + prompt_for_answer(s, url_copy, message); + } other_status => { s.add_layer(Dialog::info(format!("ERROR: {:?}", other_status))); return;