ui

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 58 Imported by: 0

Documentation

Overview

Package ui implements the Bubble Tea TUI for exex.

Package ui implements the Bubble Tea terminal interface for exploring loaded binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LooksLikeText

func LooksLikeText(data []byte) bool

LooksLikeText reports whether data (a prefix of a file is fine) is plausibly a text file: no NUL bytes and overwhelmingly printable/UTF-8. Used to decide whether a non-binary argument should open in the text viewer.

func NewText

func NewText(path string, cfg config.Config) (tea.Model, error)

NewText builds the text-viewer model for a script/text file.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the root Bubble Tea model.

func New

func New(f *binfile.File, opts ...Options) (*Model, error)

New constructs a Bubble Tea model for a loaded binary.

func NewArchive

func NewArchive(path string, members []binfile.ArchiveMember, opts Options) (*Model, error)

NewArchive builds the model for a static library: it loads the first parseable member as the active object and opens the Info view in its members-list mode. The caller must keep the archive image (which members slice into) mapped for the model's lifetime.

func (*Model) Activate

func (m *Model) Activate(t palettemodal.Target, hasSel bool, typed string)

Activate acts on the highlighted result, routing it to the natural view for its kind; with no results it falls back to a bare address parse. It satisfies palette.Host.

func (*Model) CancelFullScan

func (m *Model) CancelFullScan()

CancelFullScan satisfies syscalls.Host: the overlay abandons the library scan when it leaves the full scope, or jumps away.

func (*Model) CancelSearch

func (m *Model) CancelSearch()

CancelSearch abandons any source scans still in flight. It satisfies findresults.Host: the overlay closes itself, and the shell stops the work.

func (*Model) CopyToClipboard

func (m *Model) CopyToClipboard(text, label string)

func (*Model) CycleSetting

func (m *Model) CycleSetting(i, dir int)

CycleSetting steps field i by dir and applies the change. It satisfies settings.Host; the index is the position in settings.Metas.

func (*Model) GotoAddr

func (m *Model) GotoAddr(addr uint64)

func (*Model) HasPhysAddrs

func (m *Model) HasPhysAddrs() bool

HasPhysAddrs satisfies palette.Host.

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) JumpDisasmAtAddr

func (m *Model) JumpDisasmAtAddr(addr uint64)

func (*Model) JumpHexAtAddr

func (m *Model) JumpHexAtAddr(addr uint64)

func (*Model) JumpRawAtAddr

func (m *Model) JumpRawAtAddr(addr uint64)

func (*Model) ListPage

func (m *Model) ListPage() int

func (*Model) LoadDisasmAt

func (m *Model) LoadDisasmAt(addr uint64)

Model satisfies modal.Host. SetStatus is already provided for view.Host.

func (*Model) OpenCaretIn

func (m *Model) OpenCaretIn(id int)

OpenCaretIn performs the jump for a target row. It satisfies jumpto.Host; the id is the destination view's mode.

func (*Model) OpenHexAt

func (m *Model) OpenHexAt(addr uint64)

func (*Model) OpenHit

func (m *Model) OpenHit(h findresultsmodal.Hit)

OpenHit navigates to a hit in the view its facet belongs to. It satisfies findresults.Host.

func (*Model) OpenRawAt

func (m *Model) OpenRawAt(off uint64)

func (*Model) OpenSourceFile

func (m *Model) OpenSourceFile(file string)

func (*Model) OpenSymbol

func (m *Model) OpenSymbol(sym binfile.Symbol)

func (*Model) OpenSymbolsForLib

func (m *Model) OpenSymbolsForLib(lib string)

func (*Model) PersistSettings

func (m *Model) PersistSettings()

PersistSettings saves the live config, reporting the outcome. It satisfies settings.Host; closing the overlay is the overlay's own business.

func (*Model) Search

func (m *Model) Search(val string, sc scope.Scope, phys bool) []palettemodal.Target

Search builds the palette's result list. Each scope searches its corpus; "all" spans symbols + sections and offers a parseable address. Strings/libraries are their own scopes (the string corpus is large enough that scanning it on every keystroke must be opt-in). It satisfies palette.Host.

func (*Model) SearchCaseChanged

func (m *Model) SearchCaseChanged()

SearchCaseChanged drops the disasm search cache, whose hits were computed under the previous case setting. It satisfies search.Host.

func (*Model) SearchHint

func (m *Model) SearchHint() string

SearchHint describes what the active view searches. It satisfies search.Host.

func (*Model) SetPageRows

func (m *Model) SetPageRows(n int)

func (*Model) SetStatus

func (m *Model) SetStatus(msg string, isErr bool)

Model satisfies view.Host via thin exported wrappers over its existing methods, so views call a stable interface while the internals keep their names.

func (*Model) SettingValue

func (m *Model) SettingValue(i int) string

SettingValue returns field i's current value as a display string. It satisfies settings.Host; the index is the position in settings.Metas.

func (*Model) ShowDisasmView

func (m *Model) ShowDisasmView()

ShowDisasmView implements disasmview.Host.

func (*Model) StartFullScan

func (m *Model) StartFullScan() tea.Cmd

startSyscallFullScan scans the binary and its linked libraries off the UI goroutine (opening and decoding each library is I/O- and CPU-heavy, so it must not block rendering). The result feeds the modal's full scope. StartFullScan satisfies syscalls.Host: the overlay asks for the library scan the first time its full scope is selected.

func (*Model) StartSearch

func (m *Model) StartSearch(s findtomodal.Seed) tea.Cmd

StartSearch opens the results modal and launches the per-source scans for the selected seed. Each applicable source runs as its own command, so tea.Batch executes them concurrently and their hits stream into the list as each finishes — the fast data/strings/relocs scans appear almost immediately while the disasm decode (the slow one) fills in when it completes.

It satisfies findto.Host. Closing the seed picker first is what keeps the picker and the results overlay from both being open (see modalOrder).

func (*Model) StartTextSearch

func (m *Model) StartTextSearch(text string, caseSensitive bool) tea.Cmd

StartTextSearch runs the global search for a typed query. It satisfies findquery.Host: the prompt hands over raw text, and the shell decides what it means (a 0x… literal is an address; anything else is content).

func (*Model) SubmitSearch

func (m *Model) SubmitSearch(query string, o searchmodal.Options) tea.Cmd

SubmitSearch runs the typed query in the active view, re-pinning the byte views when the search moved the cursor. It satisfies search.Host.

func (*Model) SymbolNamesChanged

func (m *Model) SymbolNamesChanged()

func (*Model) ToggleWrap

func (m *Model) ToggleWrap()

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Model) View

func (m *Model) View() tea.View

View renders the screen.

type Options

type Options struct {
	Config *config.Config
	// Goto is an optional startup target (an address like "0x1000" or a symbol
	// name) navigated to once the model is built, overriding the default view.
	Goto string
	// SearchString, when set, searches the printable strings on startup: a single
	// match opens the Hex (or Raw) view at it, several open the Strings view
	// filtered by it.
	SearchString string
}

Options contains application-owned dependencies and policy values used to construct a UI model. Omitted options keep built-in defaults.

type PerfStat

type PerfStat struct {
	View  string
	Dur   time.Duration // best wall time of `runs` full-frame renders
	Alloc uint64        // bytes allocated by one render
}

PerfStat is one view's measured render cost.

func RenderViewStats

func RenderViewStats(f *binfile.File, w, h, runs int) []PerfStat

RenderViewStats builds a model at w×h on f and measures every view's full-frame render: best wall time over `runs` and the bytes one render allocates. Background disasm decoding is completed synchronously so the disasm view is fully populated, mirroring what the interactive program renders.

type Theme

type Theme struct {
	// contains filtered or unexported fields
}

Theme contains all Lip Gloss styles used by a Model.

func DefaultTheme

func DefaultTheme() Theme

DefaultTheme returns the built-in visual palette. It sets only the non-colour attributes that each style needs (bold/underline/padding/border/alignment); every foreground/background colour comes from the colorBindings table via applyDefaults, so a default colour lives in exactly one place. Styles not listed here are left zero and tinted purely by their binding.

func NewTheme

func NewTheme(cfg config.Config) Theme

NewTheme builds a theme from a config: it starts from the built-in dark palette, applies the selected named preset, then layers the user's individual colour overrides on top (so a single `colors:` entry always wins over the preset). It also rebuilds the global hex byte ramp when a palette is supplied.

func (*Theme) ApplyColors

func (t *Theme) ApplyColors(c config.Colors)

ApplyColors overlays the user's config.Colors onto the built-in palette. The scalar fg/bg roles come from the single colorBindings table; the handful that aren't a plain fg/bg on one style are applied below.

Directories

Path Synopsis
Package asmhl highlights a single line of disassembled instruction text.
Package asmhl highlights a single line of disassembled instruction text.
Package layout holds the pure, Model-independent scroll/viewport geometry the TUI views share: given a cursor, a window height and a per-row height function, it computes which row to anchor at the top and which logical item sits at a visual row.
Package layout holds the pure, Model-independent scroll/viewport geometry the TUI views share: given a cursor, a window height and a per-row height function, it computes which row to anchor at the top and which logical item sits at a visual row.
Package modal is the neutral contract between the exex TUI shell (package ui) and the overlay modals, mirroring what package view is for the top-level views.
Package modal is the neutral contract between the exex TUI shell (package ui) and the overlay modals, mirroring what package view is for the top-level views.
modals
cpufeat
Package cpufeat is the CPU-features overlay: the set of optional instruction families (SSE/AVX/NEON/…) a binary requires, the baseline they imply, and how often each is used.
Package cpufeat is the CPU-features overlay: the set of optional instruction families (SSE/AVX/NEON/…) a binary requires, the baseline they imply, and how often each is used.
findquery
Package findquery is the free-text global-search prompt (the `l` key): type a symbol name, a string, or a hex address, and it runs the same content scan the caret-seeded Find does.
Package findquery is the free-text global-search prompt (the `l` key): type a symbol name, a string, or a hex address, and it runs the same content scan the caret-seeded Find does.
findresults
Package findresults is the global value search's results overlay: every place a value occurs across the binary — disasm operands, data words, string contents, relocation targets — in one list, tagged by the view it belongs to and filterable by that view.
Package findresults is the global value search's results overlay: every place a value occurs across the binary — disasm operands, data words, string contents, relocation targets — in one list, tagged by the view it belongs to and filterable by that view.
findto
Package findto is the "Find from here" seed picker (the `f` key): it lists the things at the caret — its address, the pointer it holds, the symbol or section covering it, a string, a library path — and on selection launches the global value search for that seed.
Package findto is the "Find from here" seed picker (the `f` key): it lists the things at the caret — its address, the pointer it holds, the symbol or section covering it, a string, a library path — and on selection launches the global value search for that seed.
help
Package help is the keybinding cheat-sheet overlay (the `?` key): a static, two-column table of every binding, scrolled when it is taller than the terminal and dismissed by any other key.
Package help is the keybinding cheat-sheet overlay (the `?` key): a static, two-column table of every binding, scrolled when it is taller than the terminal and dismissed by any other key.
jumpto
Package jumpto is the "open caret position in…" overlay: take the address under the cursor and offer to reopen it in each of the other views, each row previewing exactly where it would land, above a header describing what the address *is*.
Package jumpto is the "open caret position in…" overlay: take the address under the cursor and offer to reopen it in each of the other views, each row previewing exactly where it would land, above a header describing what the address *is*.
palette
Package palette is the "Jump to" command palette (the `g` key): type a query, pick a scope, and jump to a symbol, section, string, library or address.
Package palette is the "Jump to" command palette (the `g` key): type a query, pick a scope, and jump to a symbol, section, string, library or address.
rawheader
Package rawheader is the raw container-header overlay (⇧H): the ELF e_* fields, the Mach-O mach_header and load commands, or the PE COFF/optional header, as an aligned field table.
Package rawheader is the raw container-header overlay (⇧H): the ELF e_* fields, the Mach-O mach_header and load commands, or the PE COFF/optional header, as an aligned field table.
search
Package search is the in-view search prompt (the `/` key): a query box above a strip of clickable toggles for the match mode, case sensitivity, direction and origin.
Package search is the in-view search prompt (the `/` key): a query box above a strip of clickable toggles for the match mode, case sensitivity, direction and origin.
settings
Package settings is the settings overlay: a scrollable list of preferences grouped under headings, cycled left/right, applied live, and saved on Enter.
Package settings is the settings overlay: a scrollable list of preferences grouped under headings, cycled left/right, applied live, and saved on Enter.
syscalls
Package syscalls is the system-calls results overlay: every place the binary enters the kernel, grouped by scope (this function / the whole binary / one row per distinct call / the binary plus its linked libraries), sortable, filterable and followable with Enter.
Package syscalls is the system-calls results overlay: every place the binary enters the kernel, grouped by scope (this function / the whole binary / one row per distinct call / the binary plus its linked libraries), sortable, filterable and followable with Enter.
textoverlay
Package textoverlay is the shared behaviour of exex's scrollable text overlays: the keybinding cheat-sheet and the raw container header.
Package textoverlay is the shared behaviour of exex's scrollable text overlays: the keybinding cheat-sheet and the raw container header.
xref
Package xref is the cross-references results overlay: every instruction that references the address under the disasm cursor, sortable, filterable, and followable with Enter.
Package xref is the cross-references results overlay: every instruction that references the address under the disasm cursor, sortable, filterable, and followable with Enter.
Package scope names what a search looks through.
Package scope names what a search looks through.
Package view is the neutral contract between the exex TUI shell (package ui) and the individual views.
Package view is the neutral contract between the exex TUI shell (package ui) and the individual views.
views
disasm
Package disasm implements the disassembly view: the column geometry the rows are laid out on, and the rendering built over it.
Package disasm implements the disassembly view: the column geometry the rows are laid out on, and the rendering built over it.
hexraw
Package hexraw implements the Hex and Raw byte-dump views.
Package hexraw implements the Hex and Raw byte-dump views.
info
Package info implements the normal Info overview page: the file header re-aligned into one column, plus overview, hardening, dynamic-linking and toolchain blocks.
Package info implements the normal Info overview page: the file header re-aligned into one column, plus overview, hardening, dynamic-linking and toolchain blocks.
libs
Package libs implements the dynamic-libraries view: the DT_NEEDED entries together with the linkage context (interpreter, libc kind, RPATH, RUNPATH), as a flat list or a collapsible path tree, with name filtering and an on-disk/in-cache availability lens.
Package libs implements the dynamic-libraries view: the DT_NEEDED entries together with the linkage context (interpreter, libc kind, RPATH, RUNPATH), as a flat list or a collapsible path tree, with name filtering and an on-disk/in-cache availability lens.
relocs
Package relocs implements the Relocations view: a filterable table of the binary's relocations — the GOT/PLT slots and base fixups the loader patches.
Package relocs implements the Relocations view: a filterable table of the binary's relocations — the GOT/PLT slots and base fixups the loader patches.
sections
Package sections implements the Sections view: a filterable table of the binary's sections.
Package sections implements the Sections view: a filterable table of the binary's sections.
sources
Package sources implements the Sources view's file list (DWARF only): every source file referenced by the line table, as a project-first flat list or a directory tree, with name filtering and an on-disk availability lens.
Package sources implements the Sources view's file list (DWARF only): every source file referenced by the line table, as a project-first flat list or a directory tree, with name filtering and an on-disk availability lens.
strs
Package strs implements the Strings view: the printable runs found in the file (à la strings(1)), each annotated with its file offset and — when the bytes are mapped — the virtual address and owning section.
Package strs implements the Strings view: the printable runs found in the file (à la strings(1)), each annotated with its file offset and — when the bytes are mapped — the virtual address and owning section.
symbols
Package symbols implements the Symbols view: a filterable, sortable table of the merged symbol table (matching on both raw and demangled names), with an alternative collapsible namespace-tree mode, kind/scope/bind facet filters, clickable facet chips on the status row, and per-row or global abbreviation of bracketed argument/template lists.
Package symbols implements the Symbols view: a filterable, sortable table of the merged symbol table (matching on both raw and demangled names), with an alternative collapsible namespace-tree mode, kind/scope/bind facet filters, clickable facet chips on the status row, and per-row or global abbreviation of bracketed argument/template lists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL