From c843a8b146bbae3b6a83cee976e6c205a765bc65 Mon Sep 17 00:00:00 2001 From: dvkt Date: Tue, 17 Dec 2019 00:44:20 -0800 Subject: [PATCH] ok --- src/menu.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/menu.rs b/src/menu.rs index c2aac97..136b30a 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -16,6 +16,7 @@ pub struct Menu { raw: String, // raw gopher response } +#[derive(Debug)] pub struct Line { name: String, url: String, @@ -34,6 +35,10 @@ impl View for MenuView { a => a, } } + + fn url(&self) -> String { + self.menu.url.to_string() + } } impl MenuView { @@ -84,7 +89,7 @@ impl MenuView { } out.push(' '); out.push_str("\x1b[95m"); - if line.link - 1 < 10 { + if line.link < 10 { out.push(' '); } out.push_str(&line.link.to_string()); @@ -140,7 +145,7 @@ impl MenuView { } fn action_down(&mut self) -> Action { - if self.link < self.links().count() - 1 { + if self.link < self.links().count() { self.link += 1; Action::Redraw } else { @@ -308,6 +313,7 @@ impl Menu { if typ != Type::Info { link += 1; } + let link = if typ == Type::Info { 0 } else { link }; lines.push(Line { name,