$ show ndd7xv/heh
heh (HEx Helper) is a cross-platform terminal hex editor written in Rust. It provides a TUI for viewing and editing binary files in both hexadecimal and ASCII representations, with features like search (hex/ASCII), jump-to-byte, undo, clipboard integration, and configurable endianness. The architecture follows a clean separation of concerns: `app.rs` orchestrates state and event handling, `screen.rs` manages rendering via ratatui, `input.rs` dispatches keyboard/mouse events to pluggable `KeyHandler` implementations (editor, popups), and `buffer.rs` implements an asynchronous memory-mapped buffer for responsive editing of large files. The codebase demonstrates strong Rust practices, including use of traits for extensibility, iterator patterns for decoding, and a custom `OverlappingChunks` iterator for handling UTF-8 boundary issues. It is primarily an application but includes a library interface for embedding as a ratatui widget.
The LLM identified 2 files worth highlighting for reuse:
Implements `OverlappingChunks`, a generic iterator that yields overlapping windows of a slice. This is a clean, reusable pattern for processing data where boundaries may split multi-byte characters (e.g., UTF-8). It is self-contained, has no internal dependencies, and can be extracted into any Rust project needing overlapping window iteration.
Contains `get_next_match_index`, a function that uses binary search to find the next match index in a sorted list of offsets, wrapping around the file. This is a small, well-tested utility that solves a common problem in cyclic search scenarios. It is independent of the rest of the application and can be reused in any project requiring forward/backward search with wrap-around.