summaryrefslogtreecommitdiffstats
path: root/src/hex
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-12-13 16:41:35 +0100
committerCanop <cano.petrole@gmail.com>2020-12-13 17:22:07 +0100
commit2c06c7ca0a580618d932325e15d8d40e7640f24d (patch)
tree5764d009d564a514a285426be6ce497cc65660c9 /src/hex
parentee4f93f4919be4e716bb9b73476473bbc8bd7159 (diff)
keep selection visible on unfiltering
The selection was sometimes scrolled away on unfiltering. Also change some formatting.
Diffstat (limited to 'src/hex')
-rw-r--r--src/hex/byte.rs2
-rw-r--r--src/hex/hex_view.rs16
-rw-r--r--src/hex/mod.rs5
3 files changed, 9 insertions, 14 deletions
diff --git a/src/hex/byte.rs b/src/hex/byte.rs
index 1195ff4..6337590 100644
--- a/src/hex/byte.rs
+++ b/src/hex/byte.rs
@@ -37,7 +37,7 @@ impl Byte {
}
}
- pub fn style(self, styles: & StyleMap) -> & CompoundStyle {
+ pub fn style(self, styles: &StyleMap) -> &CompoundStyle {
match self.category() {
ByteCategory::Null => &styles.hex_null,
ByteCategory::AsciiGraphic => &styles.hex_ascii_graphic,
diff --git a/src/hex/hex_view.rs b/src/hex/hex_view.rs
index b230060..07ebba0 100644
--- a/src/hex/hex_view.rs
+++ b/src/hex/hex_view.rs
@@ -1,10 +1,8 @@
use {
- super::{
- byte::Byte,
- },
+ super::byte::Byte,
crate::{
- command::{ScrollCommand},
- display::{CropWriter, SPACE_FILLING, Screen, W},
+ command::ScrollCommand,
+ display::{CropWriter, Screen, SPACE_FILLING, W},
errors::ProgramError,
skin::PanelSkin,
},
@@ -84,8 +82,8 @@ impl HexView {
while start_idx < self.len {
let line_len = 16.min(self.len - start_idx);
let mut bytes: Vec<u8> = vec![0; line_len];
- bytes[0..line_len].copy_from_slice(&mmap[start_idx..start_idx+line_len]);
- lines.push(HexLine{bytes});
+ bytes[0..line_len].copy_from_slice(&mmap[start_idx..start_idx + line_len]);
+ lines.push(HexLine { bytes });
if lines.len() >= line_count {
break;
}
@@ -175,7 +173,7 @@ impl HexView {
}
let line = &page[y];
for x in 0..16 {
- if x==8 && hex_middle_space {
+ if x == 8 && hex_middle_space {
cw.queue_char(&styles.default, ' ')?;
}
if let Some(b) = line.bytes.get(x) {
@@ -192,7 +190,7 @@ impl HexView {
if chars {
cw.queue_char(&styles.default, ' ')?;
for x in 0..16 {
- if x==8 && chars_middle_space {
+ if x == 8 && chars_middle_space {
cw.queue_char(&styles.default, ' ')?;
}
if let Some(b) = line.bytes.get(x) {
diff --git a/src/hex/mod.rs b/src/hex/mod.rs
index 378e56f..7946376 100644
--- a/src/hex/mod.rs
+++ b/src/hex/mod.rs
@@ -3,7 +3,4 @@
mod byte;
mod hex_view;
-pub use {
- hex_view::HexView,
-};
-
+pub use hex_view::HexView;