Skip to content

Commit ab71a8a

Browse files
Merge pull request #52 from CableSynth/display-hex-dump-block
display hex block
2 parents aadf1c6 + e074c23 commit ab71a8a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ui/hexdump.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ fn to_hexdump_str(data: &[u8]) -> String {
3434

3535
pub fn draw_hexdump(app: &mut App, f: &mut Frame, hexdump: Rect) {
3636
let last_read = app.hexdump.lock().unwrap();
37+
let block = Block::default()
38+
.borders(Borders::ALL)
39+
.title("Hexdump (up(k), down(j), 50 up(K), 50 down(J))".fg(ORANGE));
3740
if let Some(r) = last_read.as_ref() {
3841
let data = &r.1;
3942

@@ -45,9 +48,6 @@ pub fn draw_hexdump(app: &mut App, f: &mut Frame, hexdump: Rect) {
4548
let skip = if len <= max as usize { 0 } else { app.hexdump_scroll };
4649
app.hexdump_scroll_state = app.hexdump_scroll_state.content_length(len);
4750

48-
let block = Block::default()
49-
.borders(Borders::ALL)
50-
.title("Hexdump (up(k), down(j), 50 up(K), 50 down(J))".fg(ORANGE));
5151
let lines: Vec<&str> = data.lines().skip(skip).collect();
5252
let paragraph =
5353
Paragraph::new(lines.join("\n")).block(block).style(Style::default().fg(Color::White));
@@ -57,5 +57,7 @@ pub fn draw_hexdump(app: &mut App, f: &mut Frame, hexdump: Rect) {
5757
hexdump,
5858
&mut app.hexdump_scroll_state,
5959
);
60+
} else {
61+
f.render_widget(Paragraph::new("").block(block), hexdump);
6062
}
6163
}

0 commit comments

Comments
 (0)