#hex-editor #tui #cross-platform #data #ascii #ui #modifying

bin+lib heh

A cross-platform terminal UI used for modifying file data in hex or ASCII

8 releases (4 breaking)

0.5.0 Apr 8, 2024
0.4.1 Jul 31, 2023
0.3.1 Mar 20, 2023
0.3.0 Feb 28, 2023
0.1.1 Aug 8, 2022

#45 in Text editors

Download history 1/week @ 2024-02-13 14/week @ 2024-02-20 5/week @ 2024-02-27 5/week @ 2024-03-05 9/week @ 2024-03-12 1/week @ 2024-03-26 145/week @ 2024-04-02 73/week @ 2024-04-09 13/week @ 2024-04-16 13/week @ 2024-04-23

245 downloads per month

MIT license

150KB
2.5K SLoC

heh

Crates.io Codecov Dependency status

The HEx Helper is a cross-platform terminal hex editor used for modifying file data in hex or ASCII. It aims to replicate some of the look of hexyl while functionally acting like a terminal UI version of GHex.

[!WARNING] heh is currently in alpha - it's not ready to be used in any production manner. It lacks a variety of quality of life features and does not store backups if killed or crashing.

screenshot of heh

Installation and Usage

heh is available via cargo:

cargo install heh

From heh --help:

...
Terminal UI Commands:
    ALT=                Increase the stream length by 1
    ALT-                Decrease the stream length by 1
    CNTRLs              Save
    CNTRLq              Quit
    CNTRLj              Jump to Byte
    CNTRLe              Change endianness
    CNTRLd              Page Down
    CNTRLu              Page Up
    CNTRLf or /         Search
    CNTRLn or Enter     Next Search Match
    CNTRLp              Prev Search Match

Left-clicking on a label will copy the contents to the clipboard.
Left-clicking on the ASCII or hex table will focus it.

Zooming in and out will change the size of the components.

USAGE:
    heh <FILE>

ARGS:
    <FILE>
            

OPTIONS:
    -h, --help
            Print help information

    -V, --version
            Print version information

Distro packages

Packaging status

Packaging status

If your distribution has packaged heh, you can use that package for the installation.

Arch Linux

You can use pacman to install from the extra repository:

pacman -S heh

Alpine Linux

heh is available for Alpine Edge. It can be installed via apk after enabling the testing repository.

apk add heh

Using as a Ratatui widget

heh can be used a library and embedded into other TUI applications which use Ratatui and crossterm.

Add heh to your dependencies in Cargo.toml:

[dependencies]
ratatui = "0.24"
crossterm = "0.27"
heh = "0.4"

Create the application:

use heh::app::Application as Heh;
use heh::decoder::Encoding;

let file = std::fs::OpenOptions::new().read(true).write(true).open(path).unwrap();
let heh = Heh::new(file, Encoding::Ascii, 0).unwrap();

Then you can render a frame as follows:

terminal.draw(|frame| {
    heh.render_frame(frame, frame.size());
});

To handle key events:

heh.handle_input(&crossterm::event::Event::Key(/* */)).unwrap();

See the binsider project for an example use case.

Contributing

See CONTRIBUTING.md.

Dependencies

~7–18MB
~253K SLoC