aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml8
-rw-r--r--src/epub.rs2
-rw-r--r--src/main.rs24
4 files changed, 25 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 09d3bee..d548319 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -299,9 +299,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "roxmltree"
-version = "0.11.0"
+version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5001f134077069d87f77c8b9452b690df2445f7a43f1c7ca4a1af8dd505789d"
+checksum = "17dfc6c39f846bfc7d2ec442ad12055d79608d501380789b965d22f9354451f2"
dependencies = [
"xmlparser",
]
@@ -347,9 +347,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
[[package]]
name = "syn"
-version = "1.0.31"
+version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6"
+checksum = "a994520748611c17d163e81b6c4a4b13d11b7f63884362ab2efac3aa9cf16d00"
dependencies = [
"proc-macro2",
"quote",
diff --git a/Cargo.toml b/Cargo.toml
index 6219287..d204c03 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,11 +11,11 @@ readme = "README.md"
repository = "https://github.com/aeosynth/bk"
[dependencies]
-argh = "0.1"
-crossterm = "0.17"
-roxmltree = "0.11"
+argh = "0"
+crossterm = "0"
+roxmltree = "0"
[dependencies.zip]
-version = "0.5"
+version = "0"
default-features = false
features = ["deflate"]
diff --git a/src/epub.rs b/src/epub.rs
index d74bd2a..491398b 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -98,7 +98,7 @@ impl Epub {
let doc = Document::parse(&xml).unwrap();
// zip expects unix path even on windows
let rootdir = match path.rfind('/') {
- Some(n) => &path[..n + 1],
+ Some(n) => &path[..=n],
None => "",
};
diff --git a/src/main.rs b/src/main.rs
index dffbfff..789ed46 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -80,9 +80,8 @@ trait View {
struct Mark;
impl View for Mark {
fn run(&self, bk: &mut Bk, kc: KeyCode) {
- match kc {
- KeyCode::Char(c) => bk.mark(c),
- _ => (),
+ if let KeyCode::Char(c) = kc {
+ bk.mark(c)
}
bk.view = Some(&Page)
}
@@ -94,9 +93,8 @@ impl View for Mark {
struct Jump;
impl View for Jump {
fn run(&self, bk: &mut Bk, kc: KeyCode) {
- match kc {
- KeyCode::Char(c) => bk.jump(c),
- _ => (),
+ if let KeyCode::Char(c) = kc {
+ bk.jump(c)
}
bk.view = Some(&Page);
}
@@ -377,7 +375,13 @@ impl Bk<'_> {
}
Bk {
- line: min(args.line, chapters[args.chapter].lines.len().saturating_sub(rows as usize)),
+ line: min(
+ args.line,
+ chapters[args.chapter]
+ .lines
+ .len()
+ .saturating_sub(rows as usize),
+ ),
chapters,
chapter: args.chapter,
mark: HashMap::new(),
@@ -530,7 +534,11 @@ struct Props {
fn restore(save_path: &str) -> Option<(String, Props)> {
let args: Args = argh::from_env();
let width = args.width;
- let path = args.path.map(|s| fs::canonicalize(s).unwrap().to_str().unwrap().to_string());
+ // XXX we shouldn't panic, but it gives a useful error, and we
+ // don't want to load the saved path if an invalid path is given
+ let path = args
+ .path
+ .map(|s| fs::canonicalize(s).unwrap().to_str().unwrap().to_string());
let save = fs::read_to_string(save_path).and_then(|s| {
let mut lines = s.lines();
Ok((