remove stub

pull/6/head
dvkt 5 years ago
parent f1f68ad5a6
commit 8244dadb5e

@ -12,7 +12,7 @@
</a>
</p>
`phetch` is a terminal gopher client designed for quick keyboard navigation. It is the spiritual successor to [GILD](https://github.com/dvkt/gild).
`phetch` is a terminal gopher client designed to help you quickly navigate the gophersphere. It is the spiritual successor to [GILD](https://github.com/dvkt/gild).
**features:**

@ -5,7 +5,6 @@ extern crate termion;
mod gopher;
mod help;
mod menu;
mod stub;
mod text;
mod ui;
use std::process::exit;

@ -1,29 +0,0 @@
use ui::{Action, Key, View};
pub struct Stub {
url: String,
}
impl View for Stub {
fn respond(&mut self, key: Key) -> Action {
Action::Keypress(key)
}
fn render(&self) -> String {
self.url()
}
fn url(&self) -> String {
self.url.to_string()
}
fn raw(&self) -> String {
self.url()
}
fn term_size(&mut self, _cols: usize, _rows: usize) {}
}
impl Stub {
pub fn from(url: &str) -> Stub {
Stub {
url: url.to_string(),
}
}
}

@ -11,7 +11,6 @@ use gopher::io_error;
use gopher::Type;
use help;
use menu::Menu;
use stub::Stub;
use text::Text;
pub type Key = termion::event::Key;
@ -192,9 +191,7 @@ impl UI {
if let Ok(file) = std::fs::OpenOptions::new().read(true).open(history) {
let buffered = BufReader::new(file);
let mut lines = buffered.lines();
while let Some(Ok(url)) = lines.next() {
self.add_page(Stub::from(&url));
}
while let Some(Ok(url)) = lines.next() {}
}
}
@ -209,15 +206,13 @@ impl UI {
out.push_str(&page.url());
out.push('\n');
}
let history_tmp = dotdir.join("history.tmp");
let history = dotdir.join("history");
if let Ok(mut file) = std::fs::OpenOptions::new()
.write(true)
.append(true)
.create(true)
.open(history_tmp.clone())
.open(history)
{
file.write_all(out.as_ref());
let history = dotdir.join("history");
std::fs::rename(history_tmp, history);
}
}

Loading…
Cancel
Save