summaryrefslogtreecommitdiffstats
path: root/src/hex
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-07-23 18:53:23 +0200
committerCanop <cano.petrole@gmail.com>2020-07-23 18:53:23 +0200
commiteffe1f8ea6e4970634ce12418fa8289177d5f8ea (patch)
tree4f4f2f0b551e6729e63fca411f240564b3cb53e5 /src/hex
parenteb5f98c420a943c33e4cb8abfee964036014b016 (diff)
:select_first and :select_last implemented in preview
Diffstat (limited to 'src/hex')
-rw-r--r--src/hex/hex_view.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/hex/hex_view.rs b/src/hex/hex_view.rs
index c9efbe2..79d5af9 100644
--- a/src/hex/hex_view.rs
+++ b/src/hex/hex_view.rs
@@ -46,7 +46,7 @@ impl HexView {
})
}
pub fn line_count(&self) -> usize {
- self.len / 16
+ self.len / 16 + if self.len % 16 != 0 { 1 } else { 0 }
}
pub fn try_scroll(
&mut self,
@@ -56,6 +56,14 @@ impl HexView {
self.scroll = cmd.apply(self.scroll, self.line_count(), self.page_height);
self.scroll != old_scroll
}
+ pub fn select_first(&mut self) {
+ self.scroll = 0;
+ }
+ pub fn select_last(&mut self) {
+ if self.page_height < self.line_count() {
+ self.scroll = self.line_count() - self.page_height;
+ }
+ }
pub fn get_page(
&mut self,
start_line_idx: usize,