A terminal UI to edit bytes by the nibble.

Overview

heh

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

heh is currently in alpha - it's not ready to be used in any production manner. Notably, it does not store backups if killed or crashing and there is no undo option after deleting a byte.

screenshot of heh

Installation and Usage

heh is currently only 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

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

Contributing

Thanks for you interest in contributing! Changes of all types are welcome, from feature additions and major code refactoring to the tiniest typo fix. If you want to make change,

  1. Fork this repository
  2. Make desired changes in (a) descriptive commit(s)
  3. Make a PR, linking any issues that may be related

...and follow the Rust Code of Conduct all the way through!

Comments
  • for terminals without clipboard access, `Clipboard::new().unwrap()` crashes at startup

    for terminals without clipboard access, `Clipboard::new().unwrap()` crashes at startup

    https://github.com/ndd7xv/heh/blob/9970480f2cb0825e918c268bb8b02b80d5b5ab5c/src/app.rs#L64

    This line is crashing at startup for my shell which does not support clipboard interaction.

    A common way to avoid the crash is to use this pattern instead of unwrap():

    clipboard: Clipboard::new().unwrap_or_else(|e| {
        eprintln!("Failed to construct a Clipboard object: {}", e);
        std::process::exit(1)
    }),
    
    opened by nzrq 3
  • Add sample data

    Add sample data

    Hello,

    When I ran in your repo few days ago, I wanted to try the tool but realized there was no sample data anywhere that could help me to test your tool.

    Since I had no data to test the tool on either, I couldn't test.

    Maybe it would be a good idea to add sample data for people that just want to have a look on your project ? :smile:

    opened by nag763 2
  • feat: make navigation inside Hex window more unixy using hjkl, and 'q'

    feat: make navigation inside Hex window more unixy using hjkl, and 'q'

    Hi, Thanks for heh -- it's a cool tool for viewing hex data, just like less is for text.

    Just added navigation when inside of Hex window, to align with other traditional Unix tool.

    hjkl - for arrow navigation ^, $ - for start / end of line q - to quit, without any modifier

    It made sense to me for two reasons:

    1. The first time I tried heh it felt lightweight, like less, so to quit I just went for muscle memory hitting 'q'.
    2. When typing non-hex chars inside Hex window, you just get an error notification -- we can do better by responding to these specific keys, which are already popular bindings in Unixy tools
    opened by jondot 1
  • Add Unicode Support

    Add Unicode Support

    Suggested in a Reddit comment, but putting it here if there are any ideas.

    I think it'll be complicated to do this, and I don't think many hex editors support Unicode. Many files inspected with a hex editor (such as binaries or specific file formats) often have random bytes that are not ASCII printable but also not Unicode. Thus, there probably needs to be a way to differentiate between a byte stream that can represent Unicode and just a byte stream that's random bytes.

    There may also be other concerns that aren't coming to mind right now.

    enhancement 
    opened by ndd7xv 1
  • Implement

    Implement "Jump to byte" Feature

    In larger files, keying your way to the selected byte isn't going to cut it. GHex has a "Goto/Jump to Byte" feature that allows a user to input a byte they want to select - it can interpret decimal or hex (e.g., 10 or 0xA). The shortcut to use it is Ctrl+J.

    image

    I'm thinking that this could be done by creating a popup (example), though I'm open to other ideas - having text input update in the "Notifications" label wouldn't sound half bad if it weren't for the fact that I called it "Notifications."

    enhancement 
    opened by ndd7xv 1
  • feature: allow drag selection

    feature: allow drag selection

    This currently allows dragging in the viewports to hilight a selected area. In the future, this should allow for copy and paste of hex and ascii, as well as mass deletion.

    opened by ndd7xv 0
  • Implement Undo

    Implement Undo

    Background

    heh currently has no way to undo a deleted or back-spaced byte. It would also be convenient for users to "un-type" things are go back to a position the cursor was previously located at.

    Task

    I'm thinking to implement something basic, we could have a Vector of Actions, which would be an enumeration of the different actions a user will be able to undo. Hitting ctrl+z would pop actions from the vector and undo that command, while doing an action would push it to the vector.

    opened by ndd7xv 0
  • fix: resize issues

    fix: resize issues

    Previously, resizing would always keep the starting address of the bytes the editors displayed fixed. This caused problems with how we calculated where to display the offset.

    Now, we readjust offset so that 0 is ALWAYS the beginning offset, which not only fixes some bugs but also made me realize I could simplify adjust offset .

    opened by ndd7xv 0
  • Check if stdout is TTY device

    Check if stdout is TTY device

    The editor only works if the stdout is a TTY device. For example, if we run below command, the editor should exit early and print an error message.

    $ heh file > output
    
    opened by yuankunzhang 0
  • Refactoring

    Refactoring

    Fixes #20

    I'd love some (brutally honest) feedback on this refactoring - if it sucks, I want to know because I care about the state of this repository. 5abcc5a2d2a7eec5b1ba867755334ac0d3f5ce53 is probably the most important one. I made a preliminary change to the way input is handled, while also trying to fix up so code/documentation in some places. Predominant goals of this "spike":

    Break down handle_input

    I changed CI in this PR to make linting run the clippy::pedantic category, and along with fixing a bunch of small things also tried to break down handle_input because clippy complained that the function was more than 100 lines. I think I will try and move the handling into input.rs as seen in https://github.com/ndd7xv/heh/pull/22.

    Make future features easier to implement

    Instead of a series if statements to determine what the handle_input function should do, I created the trait InputHandler and anything that implements it should be able to uniquely handle input.

    My reasoning behind this is that 1) the if logic was hard to follow and 2) as we build out more features (like maybe control+find, or a help "page" which is a popup over the entire screen you can arrow through for information) this makes it easier to have these new features handle input differently.

    Make things more readable

    Honestly, this might be a mild step back. I had tried to aggregate necessary fields in ApplicationData so that InputHandler's parameters weren't so long, but this leads to an extra step to get to a field (for example, app_info.offset instead of just `offset).

    Tried to add some documentation/comments here and there, but it's still very much a WIP.

    opened by ndd7xv 0
  • Refactor Input Handling

    Refactor Input Handling

    As a part of my self code-review/ramblings in https://github.com/ndd7xv/heh/pull/19, the input is being handled based off of the FocusedWindow is becoming too long and should be refactored.

    One potential solution is using traits, described in https://github.com/ndd7xv/heh/pull/19#discussion_r948092282. We could also just keep Popup(PopupData) in the enum and impl each case.

    Welcoming other suggestions as well! :smile:

    opened by ndd7xv 0
  • Implement Crash Handling

    Implement Crash Handling

    Background

    If you run something like

    kill <heh pid> # which you can probably get with $(ps -ef | grep heh | grep -v grep | awk '{print $2}')
    

    heh will terminate and fail to save any progress or changes made. It will also remain with raw mode enabled, rendering the terminal session extremely difficult to use.

    Task

    When running the command mentioned above, heh should have some sort of graceful way of preventing data loss, or at least a way to alert the user and leave the terminal session usable. Doing the same thing for vim prints out

    Vim: Caught deadly signal TERM
    Vim: preserving files...
    Vim: Finished.
    

    For saving things, we could try using .swp files.

    opened by ndd7xv 0
  • Improve repository readability and documentation

    Improve repository readability and documentation

    As per this feedback,

    • Give more spacing between functions
    • Add comments to generate rustdoc
    • Add additional comments on obscure code

    I'm extending this beyond the listed recommendations because the suggestions are a part of the bigger idea to make this repo understandable - if there's anything that needs to be changed (or you think should be added) in the README, typos in a comment, or a refactoring of unidiomatic/messy code, those changes (whether they be in a different PR or not) are welcome to reference this issue.

    documentation 
    opened by ndd7xv 0
Releases(v0.2.0)
  • v0.2.0(Sep 3, 2022)

    The first update since I initially revealed heh to the world! These are some pretty nice baby steps to making it genuinely usable.

    Features:

    • The editor warns you about unsaved changes
    • The hex editor's cursor now selects a nibble instead of the entire byte
    • Similar to GHex, jump to a byte with the shortcut Control+J. You can specify in decimal or in hex (prefix it with 0x)
    • You can scroll with your mouse (thanks @yuankunzhang!)
    • The Home/End key to move to the start and end of the current row (thanks @yuankunzhang!)
    • When the hex editor is selected, some unix-like shortcuts are enabled (hjkl arrow navigation, q for quitting, ^ and $ for start and end of line) (thanks @jondot!)

    Bugfixes:

    • heh no longer crashes terminals without clipboards
    • heh recognizes when it's not in a tty (thanks @yuankunzhang!)
    Source code(tar.gz)
    Source code(zip)
Owner
nathan
nathan
Edit a file directly on Amazon S3 in CLI.

s3-edit-rs The original idea for this project comes from s3-edit written in Go by tsub. I started this project for educational purposes, and it is my

Gor Hayrapetyan 6 Jul 12, 2020
Bulk edit files.

bulke Bulk edit files. Example (not working yet) $ cat ./ap/jp.yaml // ... region: ap country: jp $ cat ./eu/de.yaml // ... region: eu country: de //

null 3 Jan 10, 2022
A tool that allows you to modify, edit, and recompile the AST script of Artemis engine.

Artemis AST Script Processor This utility offers a set of Rust functions to parse and manipulate Artemis AST-based scripts. Features Tokenization: Con

xmoe 7 Sep 19, 2023
Scriptable tool to read and write UEFI variables from EFI shell. View, save, edit and restore hidden UEFI (BIOS) Setup settings faster than with the OEM menu forms.

UEFI Variable Tool (UVT) UEFI Variable Tool (UVT) is a command-line application that runs from the UEFI shell. It can be launched in seconds from any

null 4 Dec 11, 2023
Encode and decode dynamically constructed values of arbitrary shapes to/from SCALE bytes

scale-value · This crate provides a Value type, which is a runtime representation that is compatible with scale_info::TypeDef. It somewhat analogous t

Parity Technologies 15 Jun 24, 2023
A rust crate to view a structure as raw bytes (&[u8])

rawbytes A Rust crate to view a structure as a plain byte array (&[u8]). Super simple. Tiny. Zero dependencies. This is a safer interface to slice::fr

Frank Denis 4 Sep 7, 2023
Patch binary file using IDA signatures and defined replacement bytes in YAML.

fabricbin Patch binary file using IDA signatures and defined replacement bytes in YAML. Install: cargo install --git https://github.com/makindotcc/fab

makin 3 Oct 24, 2023
Base 32 + 64 encoding and decoding identifiers + bytes in rust, quickly

fast32 Base32 and base64 encoding in Rust. Primarily for integer (u64, u128) and UUID identifiers (behind feature uuid), as well as arbitrary byte arr

Chris Rogus 9 Dec 18, 2023
A terminal ASCII media player. View images, gifs, videos, webcam, YouTube, etc.. directly in the terminal as ASCII art.

Terminal Media Player View images, videos (files or YouTube links), webcam, etc directly in the terminal as ASCII. All images you see below are just m

Max Curzi 36 May 8, 2023
ask.sh: AI terminal assistant that can read and write your terminal directly!

ask.sh: AI terminal assistant that read from & write to your terminal ask.sh is an AI terminal assistant based on OpenAI APIs such as GPT-3.5/4! What'

hmirin 5 Jun 20, 2023
A simple and efficient terminal UI implementation with ratatui.rs for getting quick insights from csv files right on the terminal

CSV-GREP csv-grep is an intuitive TUI application writting with ratatui.rs for reading, viewing and quickly analysing csv files right on the terminal.

Anthony Ezeabasili 16 Mar 10, 2024
:large_orange_diamond: Build beautiful terminal tables with automatic content wrapping

Comfy-table Comfy-table tries to provide utility for building beautiful tables, while being easy to use. Features: Dynamic arrangement of content to a

Arne Beer 525 Jan 8, 2023
🛎 60+ Elegant terminal spinners for Rust

Spinners - ?? 60+ Elegant terminal spinners for Rust ❤️ Shameless plug Charts, simple as a URL. No more server-side rendering pain, 1 url = 1 chart Lo

Francois-Guillaume Ribreau 435 Dec 26, 2022
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
Rust library for ANSI terminal colours and styles (bold, underline)

rust-ansi-term This is a library for controlling colours and formatting, such as red bold text or blue underlined text, on ANSI terminals. View the Ru

Benjamin Sago 407 Jan 2, 2023
Cross-platform Rust library for coloring and formatting terminal output

Coloring terminal output Documentation term-painter is a cross-platform (i.e. also non-ANSI terminals) Rust library for coloring and formatting termin

Lukas Kalbertodt 75 Jul 28, 2022
create and test the style and formatting of text in your terminal applications

description: create and test the style and formatting of text in your terminal applications docs: https://docs.rs/termstyle termstyle is a library tha

Rett Berg 18 Jul 3, 2021
A dead simple ANSI terminal color painting library for Rust.

yansi A dead simple ANSI terminal color painting library for Rust. use yansi::Paint; print!("{} light, {} light!", Paint::green("Green"), Paint::red(

Sergio Benitez 169 Dec 25, 2022
(Rust) Coloring terminal so simple you already know how to do it !

Colored Coloring terminal so simple, you already know how to do it! "this is blue".blue(); "this is red".red(); "this is red on blue".red(

Thomas Wickham 1.2k Jan 4, 2023