diff --git a/src/menu.rs b/src/menu.rs index 6dbf371..43caf9e 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -55,10 +55,15 @@ pub struct Menu { /// It must exist in the context of a Menu struct, and its `link` /// field will point to its index in the Menu's `links` Vec. pub struct Line { + /// Text of the line. pub name: String, + /// URL, if it's a link. pub url: String, + /// Gopher Item Type. pub typ: Type, - pub link: usize, // link #, if any + /// Index of this link in the Menu::links vector, if it's a + /// `gopher::Type.is_link()` + pub link: usize, } /// Direction of a given link relative to the visible screen. @@ -106,6 +111,8 @@ impl View for Menu { } impl Menu { + /// Create a representation of a Gopher Menu from a raw Gopher + /// response and a few options. pub fn from(url: String, response: String, tls: bool, tor: bool) -> Menu { Menu { tls, diff --git a/src/ui/view.rs b/src/ui/view.rs index a7c6824..78aa2bf 100644 --- a/src/ui/view.rs +++ b/src/ui/view.rs @@ -3,11 +3,20 @@ use std::fmt; /// Views represent what's on screen, a Gopher Menu/Text/etc item. pub trait View: fmt::Display { + /// Respond to a user action, specifically a keypress, by + /// returning an Action enum. fn respond(&mut self, key: ui::Key) -> ui::Action; + /// Create a String of the current view's state that can be + /// printed to the screen. fn render(&mut self, cfg: &Config) -> String; + /// Was this View's content fetched using TLS? fn is_tls(&self) -> bool; + /// Was this View's content fetched over Tor? fn is_tor(&self) -> bool; + /// The Gopher URL this View represents. fn url(&self) -> String; + /// The raw Gopher representation of this View. fn raw(&self) -> String; + /// Set the current screen size. fn term_size(&mut self, cols: usize, rows: usize); }