From d09560fa20287e5033cca5229649eac140f81e63 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 16 May 2020 02:22:35 -0700 Subject: meta --- Cargo.toml | 2 ++ README.md | 25 +++++++++++++++++++++---- src/epub.rs | 1 - src/main.rs | 6 +++--- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 81bb2bf..d2c58f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ version = "0.1.0" authors = ["James Campos "] edition = "2018" license = "MIT" +description = "Terminal Epub reader" +repository = "https://github.com/aeosynth/bk" [dependencies] crossterm = "0.17" diff --git a/README.md b/README.md index 5c00a80..aefe1ee 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,30 @@ # bk -bk is a WIP terminal epub reader. currently only tested on linux. +bk is a terminal Epub reader. Currently only Linux is tested, but macOS and Windows support is planned. -# install +# Usage cargo install --path . + bk path/to/epub -# usage +Type F1 or ? to see the commands. -type ? to see the commands +Running `bk` without an argument will load the most recent Epub. + +# Features +- Single binary, instant startup +- Epub 2/3 support +- Incremental search +- Vim bindings + +# TODO +- macOS, Windows +- configuration +- links +- better unicode support +- better html rendering +- mobi? +- css? +- gui? # inspiration diff --git a/src/epub.rs b/src/epub.rs index f80e2bc..90a53b5 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -28,7 +28,6 @@ impl Epub { // UnknownEntityReference for HTML entities let doc = Document::parse(&xml).unwrap(); let body = doc.root_element().last_element_child().unwrap(); - // XXX no initial string, buf.last is none let mut chapter = String::new(); Epub::render(&mut chapter, body); epub.chapters.push(chapter); diff --git a/src/main.rs b/src/main.rs index 9c27522..ee50d78 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ use crossterm::{ }; mod epub; -use epub::Epub; fn wrap(text: &str, width: usize) -> Vec<(usize, String)> { // XXX assumes a char is 1 unit wide @@ -301,9 +300,10 @@ struct Bk<'a> { } impl Bk<'_> { - fn new(epub: Epub, line: &Position, max_width: u16) -> Self { + fn new(epub: epub::Epub, line: &Position, max_width: u16) -> Self { let (cols, rows) = terminal::size().unwrap(); let width = std::cmp::min(cols, max_width) as usize; + let mut chapters = Vec::with_capacity(epub.chapters.len()); for text in epub.chapters { let wrap = wrap(&text, width); @@ -467,7 +467,7 @@ fn main() { std::process::exit(1); }); - let epub = Epub::new(&line.0).unwrap_or_else(|e| { + let epub = epub::Epub::new(&line.0).unwrap_or_else(|e| { println!("error reading epub: {}", e); std::process::exit(1); }); -- cgit v1.2.3