Start making `missing_docs` happy

pull/14/head
chris west 4 years ago
parent eecaf79d8a
commit 537be056cb

@ -18,6 +18,8 @@ pub struct ArgError {
}
impl ArgError {
/// An ArgError represents an error in the user-supplied command
/// line arguments.
pub fn new(err: impl fmt::Display) -> ArgError {
ArgError {
details: format!("{}", err),

@ -30,6 +30,7 @@ macro_rules! color {
/// println!("{}Error: {}{}", color::Red, msg, color::Reset);
macro_rules! define_color {
($color:ident, $code:literal) => {
#[allow(missing_docs)]
pub struct $color;
impl fmt::Display for $color {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

@ -41,12 +41,18 @@ emoji no
/// such as the UI mode (Print, Run, Raw, etc).
#[derive(Debug)]
pub struct Config {
/// Gopher URL to open on bare launch
pub start: String,
/// Whether to use TLS or not
pub tls: bool,
/// Using Tor proxy?
pub tor: bool,
/// Wide mode
pub wide: bool,
/// Render connection status as emoji
pub emoji: bool,
pub mode: ui::Mode, // can't be set in conf file
/// UI mode. Can't be set in conf file.
pub mode: ui::Mode,
}
impl Default for Config {

@ -25,6 +25,7 @@ pub use self::r#type::Type;
/// Some Gopher servers can be kind of slow, we may want to up this or
/// make it configurable eventually.
pub const TCP_TIMEOUT_IN_SECS: u64 = 8;
/// Based on `TCP_TIMEOUT_IN_SECS` but a `Duration` type.
pub const TCP_TIMEOUT_DURATION: Duration = Duration::from_secs(TCP_TIMEOUT_IN_SECS);
trait ReadWrite: Read + Write {}

@ -1,4 +1,5 @@
/// Gopher types are defined according to RFC 1436.
#[allow(missing_docs)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Type {
Text, // 0 | cyan

@ -21,20 +21,34 @@ use termion::{clear, cursor};
/// navigation" feature using number entry and the "incremental search"
/// (over menu links) feature using text entry.
pub struct Menu {
pub url: String, // gopher url
pub lines: Vec<Line>, // lines
pub links: Vec<usize>, // links (index of line in lines vec)
pub longest: usize, // size of the longest line
pub raw: String, // raw response
pub input: String, // user's inputted value
pub mode: ui::Mode, // interactive or print mode?
pub link: usize, // selected link
pub scroll: usize, // scrolling offset
pub searching: bool, // search mode?
pub tls: bool, // retrieved via tls?
pub tor: bool, // retrieved via tor?
pub size: (usize, usize), // cols, rows
pub wide: bool, // in wide mode?
/// Gopher URL
pub url: String,
/// Lines in the menu. Not all are links.
pub lines: Vec<Line>,
/// Indexes of links in the `lines` vector. Pauper's pointers.
pub links: Vec<usize>,
/// Currently selected link. Index of the `links` vec.
pub link: usize,
/// Size of the longest line, for wrapping purposes
pub longest: usize,
/// Actual Gopher response
pub raw: String,
/// User input on a prompt() line
pub input: String,
/// UI mode. Interactive (Run), Printing, Raw mode...
pub mode: ui::Mode,
/// Scrolling offset, in rows.
pub scroll: usize,
/// Incremental search mode?
pub searching: bool,
/// Was this menu retrieved via TLS?
pub tls: bool,
/// Retrieved via Tor?
pub tor: bool,
/// Size of the screen currently, cols and rows
pub size: (usize, usize),
/// Wide mode?
pub wide: bool,
}
/// The Line represents a single line in a Gopher menu.

@ -12,15 +12,24 @@ use termion::clear;
/// The Text View holds the raw Gopher response as well as information
/// about which lines should currently be displayed on screen.
pub struct Text {
/// Gopher URL
url: String,
/// Gopher response
raw_response: String,
scroll: usize, // offset
lines: usize, // # of lines
longest: usize, // longest line
size: (usize, usize), // cols, rows
pub tls: bool, // retrieved via tls?
pub tor: bool, // retrieved via tor?
pub wide: bool, // in wide mode? turns off margins
/// Current scroll offset, in rows
scroll: usize,
/// Number of lines
lines: usize,
/// Size of longest line
longest: usize,
/// Current screen size, cols and rows
size: (usize, usize),
/// Was this page retrieved view TLS?
pub tls: bool,
/// Retrieved via Tor?
pub tor: bool,
/// Currently in wide mode?
pub wide: bool,
}
impl fmt::Display for Text {
@ -151,6 +160,7 @@ impl View for Text {
}
impl Text {
/// Create a Text View from a raw Gopher response and a few options.
pub fn from(url: String, response: String, tls: bool, tor: bool) -> Text {
let mut lines = 0;
let mut longest = 0;

@ -41,7 +41,10 @@ use termion::{
terminal_size,
};
/// Alias for a termion Key event.
pub type Key = termion::event::Key;
/// Alias for either a Menu or Text View.
pub type Page = Box<dyn View>;
/// How many lines to jump by when using page up/down.
@ -54,17 +57,25 @@ pub const MAX_COLS: usize = 77;
/// UI is mainly concerned with drawing to the screen, managing the
/// active Views/pages, and responding to user input.
pub struct UI {
views: Vec<Page>, // loaded views
focused: usize, // currently focused view
dirty: bool, // redraw?
running: bool, // main ui loop running?
pub size: (usize, usize), // cols, rows
status: String, // status message, if any
config: Config, // user config
/// Current loaded Gopher views. Menu or Text
views: Vec<Page>,
/// Index of currently focused View
focused: usize,
/// Does the UI need to be entirely redrawn?
dirty: bool,
/// Is the UI running?
running: bool,
/// Size of screen (cols, rows)
pub size: (usize, usize),
/// Status message to display on screen, if any
status: String,
/// User config. Command line options + phetch.conf
config: Config,
out: RefCell<RawTerminal<Stdout>>,
}
impl UI {
/// Create a new phetch application from a user provided config.
pub fn new(config: Config) -> UI {
let mut size = (0, 0);
if let Ok((cols, rows)) = terminal_size() {

Loading…
Cancel
Save