aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-04-25 16:10:50 -0700
committerJames Campos <james.r.campos@gmail.com>2020-04-25 16:10:50 -0700
commit9eac5fdb1d4931d3fb776b289883aacc436affbf (patch)
treeaf00dcf70de0971183b73c0b6fd318490dff540f /src/main.rs
parent9157e4ef1a65de7da73527ddcf4ac05ffc2ddac8 (diff)
downloadbk-9eac5fdb1d4931d3fb776b289883aacc436affbf.tar.gz
li
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 68f3b46..7b9c21b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -196,6 +196,7 @@ impl Bk {
rows: rows as usize,
};
bk.get_chapter(chapter_idx);
+ bk.pos = pos;
Ok(bk)
}
fn get_chapter(&mut self, idx: usize) {
@@ -228,6 +229,15 @@ impl Bk {
);
chapter.push(String::from(""));
}
+ "li" => {
+ chapter.push(
+ n.descendants()
+ .filter(|n| n.is_text())
+ .map(|n| format!("- {}", n.text().unwrap()))
+ .collect(),
+ );
+ chapter.push(String::from(""));
+ }
_ => (),
}
}
@@ -306,7 +316,7 @@ impl Bk {
Event::Key(e) => match e.code {
KeyCode::Esc | KeyCode::Char('q') => return false,
KeyCode::Tab => self.start_nav(),
- KeyCode::Char('?') => self.mode = Mode::Help,
+ KeyCode::F(1) | KeyCode::Char('?') => self.mode = Mode::Help,
KeyCode::Char('p') => {
if self.chapter_idx > 0 {
self.get_chapter(self.chapter_idx - 1);
@@ -404,7 +414,7 @@ impl Bk {
fn render_help(&self) {
let text = r#"
Esc q Quit
- ? Help
+ F1 ? Help
Tab Table of Contents
PageDown Right Space f l Page Down
PageUp Left b h Page Up