From 85e427014b280de7c14e1244b553b651033b5823 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Tue, 10 Jul 2018 17:58:27 +0530 Subject: Add link view --- src/main.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index ebf72d0..bd009e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,11 @@ extern crate cursive; use cursive::Cursive; use cursive::traits::*; -use cursive::views::{ TextView, Dialog, EditView, - SelectView, OnEventView, LinearLayout }; +use cursive::views::{ + TextView, Dialog, EditView, + SelectView, OnEventView, LinearLayout, + DummyView +}; pub mod content; use content::*; @@ -84,22 +87,21 @@ fn on_submit(s: &mut Cursive, name: &String) { }; // get the act together - let mut article = TextView::new(heading); - article.append(String::from("\n\n")); - article.append(extract_formatter(extract)); + let mut article_content = TextView::new(heading); + article_content.append(String::from("\n\n")); + article_content.append(extract_formatter(extract)); let links = SelectView::::new() .with_all_str(link_vec) .on_submit(on_submit); s.add_layer( - LinearLayout::horizontal() - .child( - OnEventView::new( - article.fixed_width(72) - ) - .on_event('t', |s| match s.pop_layer() { _ => () }) - ) - .child(links) + OnEventView::new( + LinearLayout::horizontal() + .child(article_content.fixed_width(72)) + .child(DummyView) + .child(links) + ) + .on_event('t', |s| match s.pop_layer() { _ => () }) ); } -- cgit v1.2.3