Skip to content

Commit 26bd22b

Browse files
committed
fix: Added better support for non-graphical terminfos
1 parent f14a55a commit 26bd22b

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

docs/src/installation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ h5v works in regular terminals, but **image previews and chart previews work bes
6363

6464
h5v uses `ratatui-image` to detect and drive terminal image backends such as Kitty, Sixel, and iTerm2. If no graphics protocol is available, preview quality depends on the available fallback path and will usually be less crisp than in Kitty-class terminals.
6565

66+
If your terminal shows a blank or badly garbled screen, start h5v with:
67+
68+
```bash
69+
h5v --no-terminal-graphics path/to/file.h5
70+
```
71+
72+
That disables terminal graphics probing and forces the safer text-only preview path. It is especially useful in browser-backed terminals and other xterm-like environments with partial graphics support.
73+
6674
## Write mode
6775

6876
h5v opens files read-only unless you pass `-w`:

docs/src/troubleshooting.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ Check the HDF5 image metadata first:
2020

2121
If those attributes are missing, h5v falls back to normal dataset handling.
2222

23+
## The UI is blank or badly garbled
24+
25+
Some terminals partially respond to graphics capability probes but do not render the resulting protocol correctly.
26+
27+
Start h5v with:
28+
29+
```bash
30+
h5v --no-terminal-graphics file.h5
31+
```
32+
33+
That forces the safer text-only preview path and is a good first workaround on browser-backed or otherwise unusual terminal emulators.
34+
2335
## A compound dataset does not show in matrix mode
2436

2537
That is expected for the compound container itself. The root compound node shows a recursive schema preview. Drill down to a projected leaf field if you want normal preview or matrix rendering.

src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ struct Args {
5252
/// Validate startup commands and print a summary without launching the UI.
5353
#[clap(long = "script-test")]
5454
script_test: bool,
55+
56+
/// Disable terminal graphics probing and force text-only preview rendering.
57+
#[clap(long = "no-terminal-graphics")]
58+
no_terminal_graphics: bool,
5559
}
5660

5761
fn main() -> Result<(), AppError> {
@@ -76,11 +80,18 @@ fn main() -> Result<(), AppError> {
7680
Args::command().print_long_help()?;
7781
std::process::exit(1);
7882
}
79-
[single] => ui::app::init(single.clone(), false, args.write, &startup.commands),
83+
[single] => ui::app::init(
84+
single.clone(),
85+
false,
86+
args.write,
87+
args.no_terminal_graphics,
88+
&startup.commands,
89+
),
8090
multiple => ui::app::init(
8191
linking::link(multiple)?,
8292
true,
8393
args.write,
94+
args.no_terminal_graphics,
8495
&startup.commands,
8596
),
8697
}
@@ -323,6 +334,7 @@ mod tests {
323334
commands: Vec::new(),
324335
scripts: Vec::new(),
325336
script_test: false,
337+
no_terminal_graphics: false,
326338
}
327339
}
328340

src/ui/app.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ pub fn init(
380380
filename: String,
381381
link: bool,
382382
writable: bool,
383+
no_terminal_graphics: bool,
383384
startup_commands: &[StartupCommand],
384385
) -> Result<()> {
385386
stdout().execute(EnterAlternateScreen)?;
@@ -397,6 +398,7 @@ pub fn init(
397398
filename.clone(),
398399
link,
399400
writable,
401+
no_terminal_graphics,
400402
startup_commands,
401403
) {
402404
Ok(_) => break,
@@ -469,6 +471,7 @@ fn main_recover_loop(
469471
filename: String,
470472
link: bool,
471473
writable: bool,
474+
no_terminal_graphics: bool,
472475
startup_commands: &[StartupCommand],
473476
) -> Result<IntendedMainLoopBreak> {
474477
let h5f = h5f::H5F::open(filename.clone(), link, writable).map_err(|e| {
@@ -480,7 +483,11 @@ fn main_recover_loop(
480483

481484
let (tx_events, rx_events) = channel();
482485
#[allow(deprecated)]
483-
let mut picker = Picker::from_query_stdio().unwrap_or(Picker::from_fontsize((7, 14)));
486+
let mut picker = if no_terminal_graphics {
487+
Picker::halfblocks()
488+
} else {
489+
Picker::from_query_stdio().unwrap_or(Picker::halfblocks())
490+
};
484491
let (bg_r, bg_g, bg_b) = color_consts::rgb_channels(color_consts::BG_COLOR);
485492
picker.set_background_color(Rgba([bg_r, bg_g, bg_b, 255]));
486493
let image_cell_size = picker.font_size();

0 commit comments

Comments
 (0)