diff options
author | James Campos <james.r.campos@gmail.com> | 2020-06-21 00:22:49 -0700 |
---|---|---|
committer | James Campos <james.r.campos@gmail.com> | 2020-06-21 00:22:49 -0700 |
commit | 02beff981b6c25bedaf4dc4dcb4d84ffc66ae148 (patch) | |
tree | 29fb9e95d011c53d439aaee9983461a85619f60f /src/main.rs | |
parent | dec535da812928d6dc0036e7f4760af17774dcbf (diff) | |
download | bk-02beff981b6c25bedaf4dc4dcb4d84ffc66ae148.tar.gz |
-t switch
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 789ed46..695e70a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -374,6 +374,15 @@ impl Bk<'_> { }); } + let mut mark = HashMap::new(); + let view: &dyn View = if args.toc { + // need an initial mark to reset to + mark.insert('\'', (args.chapter, args.line)); + &Nav + } else { + &Page + }; + Bk { line: min( args.line, @@ -384,11 +393,11 @@ impl Bk<'_> { ), chapters, chapter: args.chapter, - mark: HashMap::new(), + mark, cols, rows: rows as usize, max_width: args.width, - view: Some(&Page), + view: Some(view), dir: Direction::Forward, nav_top: 0, query: String::new(), @@ -523,12 +532,17 @@ struct Args { /// characters per line #[argh(option, short = 'w', default = "75")] width: u16, + + /// start with table of contents open + #[argh(switch, short = 't')] + toc: bool, } struct Props { chapter: usize, line: usize, width: u16, + toc: bool, } fn restore(save_path: &str) -> Option<(String, Props)> { @@ -567,6 +581,7 @@ fn restore(save_path: &str) -> Option<(String, Props)> { chapter, line, width, + toc: args.toc, }, )) } |