Skip to main content

Module hex_view

Module hex_view 

Source
Expand description

The hex view: any local file as its bytes, a row of them at a time.

The file is memory-mapped by a worker (crate::formats::fixed_records::Bytes::map) and never read whole: drawing slices the map for the rows on screen, and a find reads it on a worker, a window at a time, so a stop is seen between windows. How many bytes a row holds is decided at draw time from the width (8, 16, 32 or 64), unless a record size fixes it, so that records line up.

Everything here is pure: the layout, the cursor’s moves, the parsers for an offset and a pattern, the search, and the byte inspector’s readings. The App drives it.

Structs§

Found
The last find: its pattern, where it landed, and what it says about a record size.
Geometry
How the view is laid out at one width.
HexFindRun
A find under way on a worker.
HexHit
A find’s answer.
HexSource
A local file, mapped.
HexView
The hex view’s state.
Pattern
A find’s pattern: each byte, or None for ??.
Reading
One line of the inspector: what the bytes read as, little-endian and, where the order matters, big-endian.
Stopped
The find was stopped.

Enums§

ByteClass
What a byte is, which picks its color.
Origin
Where a hex view was opened from, which decides where Esc and q go.
PromptKind
The prompt open at the foot of the view.

Constants§

ASCII_MIN_WIDTH
Below this many columns the ASCII gutter is left out.
INSPECTED
Bytes from the cursor the inspector reads: enough for its text.
MAX_PATTERN
The longest pattern a find takes, in bytes.
MAX_RECORD_SIZE
The longest record size a row may be fixed to.
PANEL_WIDTH
Columns the inspector panel takes beside the bytes, not counting its rule.
WIDTHS
The widths a row takes on its own, smallest first.

Functions§

auto_per_row
Bytes a row holds when nothing fixes it: the widest of WIDTHS that fits, or as many as fit when not even eight do.
bits
Bits of bytes, most significant first, a space between bytes.
class
find
Find pattern in hay: forward from from (a match there counts), round to the start; or backward from from (inclusive), round to the end. Reads a window at a time, looking at stop between, and tells progress how many bytes it has read.
fit
The most bytes a row of width columns shows, at least one.
hex_width
Columns the hex bytes of a row of n take: a space between bytes, one more between groups of four, and another between groups of eight.
hex_x
The column, from the start of the hex bytes, where byte i of a row starts.
offset_digits
Digits an offset into a file of len bytes takes: at least eight.
parse_offset
Where a typed offset points: decimal, 0x hex, +N and -N from the cursor, and e-N from the end (e-1 is the last byte). Past either end is an error.
parse_pattern
A find’s pattern from what was typed:
readings
Everything the bytes at the cursor read as. bytes is the cursor’s byte and what follows it, as far as the file goes (sixteen is enough).
row_width
Columns a row of n bytes takes: the offset, the hex bytes, and the ASCII gutter.
sentinels
The null sentinels the bytes at the cursor hold: the smallest signed integer, the largest unsigned one, a NaN.
stride
The distance between the matches after hit, when the next few are all the same distance apart: a sync word or a magic that starts every record.
text_at
The text at the front of bytes, up to the first NUL: printable ASCII and UTF-8, anything else ending it.
varint
A LEB128 varint at the front of bytes: its value and the bytes it took.