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.
- HexFind
Run - 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
Nonefor??. - 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§
- Byte
Class - What a byte is, which picks its color.
- Origin
- Where a hex view was opened from, which decides where Esc and
qgo. - Prompt
Kind - 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
WIDTHSthat 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
patterninhay: forward fromfrom(a match there counts), round to the start; or backward fromfrom(inclusive), round to the end. Reads a window at a time, looking atstopbetween, and tellsprogresshow many bytes it has read. - fit
- The most bytes a row of
widthcolumns shows, at least one. - hex_
width - Columns the hex bytes of a row of
ntake: 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
iof a row starts. - offset_
digits - Digits an offset into a file of
lenbytes takes: at least eight. - parse_
offset - Where a typed offset points: decimal,
0xhex,+Nand-Nfrom the cursor, ande-Nfrom the end (e-1is 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.
bytesis the cursor’s byte and what follows it, as far as the file goes (sixteen is enough). - row_
width - Columns a row of
nbytes 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.