tui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package tui is the ant terminal console: a full-screen, keyboard-driven browser over the whole resource-URI namespace, built on Bubble Tea v2. It is the third human surface beside the CLI and the web console, and like the web console it adds no data capability of its own: every screen is a thin render of an ant.Engine method, reached through the Deref seam, so the program is fully testable against a network-free fake (8000_ant_tui §6, §16).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, e Deref, b Build, initial string) error

Run starts the terminal console over e. If initial is non-empty it is resolved (offline, the same Resolve the omnibox uses) and opened on launch, so `ant tui goodreads://book/2767052` lands straight on the record. Run blocks until the user quits or ctx is cancelled by the signal handler.

Types

type App

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

App is the root model: it owns the screen stack, the omnibox, the help overlay, and the chrome (title bar + status bar). Screens never touch the stack directly; they emit navigate/push/back messages and the App is the single place that mutates it, which is what makes back/forward restore a screen exactly as it was left (8000_ant_tui §5, §12).

func (*App) Init

func (a *App) Init() tea.Cmd

func (*App) Update

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

func (*App) View

func (a *App) View() tea.View

type Build

type Build struct {
	Version string
	Commit  string
	Date    string
}

Build is the binary's release identity, surfaced on the dashboard and the help overlay. It mirrors web.Build so the command wiring passes the same value.

type Deref

type Deref interface {
	Domains() []ant.DomainInfo
	Domain(scheme string) (ant.DomainInfo, bool)
	Resolve(input, on string) (kit.URI, error)
	URL(u kit.URI) (string, error)
	Get(ctx context.Context, u kit.URI) (kit.Envelope, error)
	Dereference(ctx context.Context, u kit.URI, refresh bool) (ant.Fetched, error)
	Lookup(u kit.URI) (ant.Fetched, bool)
	Cached(u kit.URI) bool
	BodyOf(env kit.Envelope) (string, bool)
	List(ctx context.Context, u kit.URI, n int) ([]kit.Envelope, error)
	Searchable(scheme string) bool
	Search(ctx context.Context, scheme, query string, n int) ([]kit.Envelope, error)
	Links(ctx context.Context, u kit.URI) ([]kit.URI, error)
	Walk(ctx context.Context, u kit.URI, depth int) (*ant.Graph, error)
	Export(ctx context.Context, u kit.URI, follow int, md bool) (*ant.ExportReport, error)
	LL(prefix string) ([]string, error)
	Root() string
}

Deref is the slice of *ant.Engine the TUI renders, the exact seam the web console depends on (web.Deref). Keeping it an interface means the screens are driven by their Update logic alone and the whole program is testable against a network-free fake (8000_ant_tui §6.4, §17).

type Screen

type Screen interface {
	// Init returns the command that kicks off the screen's first load. The App
	// runs it after sizing the screen.
	Init() tea.Cmd
	// Update advances the screen and returns its next self plus any command. A
	// screen never mutates the stack directly: it asks via navigate/push/back
	// messages carried on the returned command.
	Update(tea.Msg) (Screen, tea.Cmd)
	// View renders the screen body into the given content box (the area between
	// the title and status bars).
	View(width, height int) string
	// Title is the short label shown in the title bar and breadcrumb.
	Title() string
	// Subject is the URI this screen is about, if any, for the omnibox default
	// and the copy/url/graph actions.
	Subject() (kit.URI, bool)
	// Loading reports whether a fetch this screen issued is still in flight, so
	// the App shows the spinner.
	Loading() bool
	// Cached reports whether the screen is showing a record served from the
	// on-disk cache, so the title bar can badge it (8000_ant_tui §4).
	Cached() bool
	// Capturing reports that the screen wants raw key input (a text field is
	// focused), so the App routes every key to it and suspends the global keymap,
	// the same deal the omnibox gets while open (8000_ant_tui §10.3).
	Capturing() bool
	// ShortHelp is the footer key hints; FullHelp the help overlay grid.
	ShortHelp() []key.Binding
	FullHelp() [][]key.Binding
}

Screen is one place in the program: a render plus the Update that drives it. It is the unit the App pushes and pops. A screen owns its own scroll position and loaded data, so going back restores it exactly as left, the place k9s loses (8000_ant_tui §5.2, §12).

Jump to

Keyboard shortcuts

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