tui

package
v1.43.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package tui provides a Bubble Tea TUI for browsing Stripe documentation in a scrollable viewport with keyboard and mouse navigation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMouseEventFilter

func NewMouseEventFilter() func(tea.Model, tea.Msg) tea.Msg

NewMouseEventFilter rate-limits mouse events before they reach the model. This reduces the amount of in-flight wheel input during shutdown.

Types

type KeyMap

type KeyMap struct {
	Quit          key.Binding
	Up            key.Binding
	Down          key.Binding
	PageUp        key.Binding
	PageDown      key.Binding
	Help          key.Binding
	Palette       key.Binding
	Search        key.Binding
	Reference     key.Binding
	OpenInBrowser key.Binding
	Enter         key.Binding
}

KeyMap defines the keybindings for the TUI.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default set of keybindings.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns bindings grouped by column for the full help view.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns bindings for the short help view.

type Model

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

Model is the top-level Bubble Tea model for the docs TUI.

func New

func New(opts ...Option) Model

New creates a Model configured with the given options.

func (Model) Init

func (m Model) Init() tea.Cmd

Init returns the initial command to run when the TUI starts.

func (Model) Update

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

Update handles incoming messages and updates the model state.

func (Model) View

func (m Model) View() tea.View

View renders the current model state to the terminal.

func (*Model) WithOptions

func (m *Model) WithOptions(opts ...Option)

WithOptions applies the given options to the Model.

type Option

type Option func(*Model)

Option configures a Model.

func WithClient

func WithClient(c *docs.Client) Option

WithClient sets the docs client used to fetch pages.

func WithKeyMap

func WithKeyMap(km KeyMap) Option

WithKeyMap sets a custom keymap.

func WithPage

func WithPage(p Page) Option

WithPage sets the page to display. The TUI parses the markdown content internally and derives the title from the first h1 heading.

func WithPaletteInput

func WithPaletteInput(q string) Option

WithPaletteInput opens the command palette on startup with the given text pre-filled. Useful for launching the TUI from a search subcommand so the user lands directly in the search palette.

func WithRenderer

func WithRenderer(r markdown.Renderer) Option

WithRenderer sets the markdown renderer.

func WithRendererOptions

func WithRendererOptions(opts ...markdown.RendererOption) Option

WithRendererOptions sets the options used to build the markdown renderer. The TUI rebuilds the renderer on each window resize, capping word wrap at maxWordWrap or the terminal width, whichever is smaller.

func WithStyles

func WithStyles(s ui.Styles) Option

WithStyles sets custom styles.

func WithWindowSize

func WithWindowSize(width, height int) Option

WithWindowSize pre-seeds the terminal dimensions so the viewport can be initialized in New() without waiting for the first tea.WindowSizeMsg.

type Page

type Page struct {
	Content []byte
	URL     *url.URL
}

Page holds the raw content and metadata needed by the TUI to display a documentation page. Callers construct a Page from a fetched docs response and pass it via WithPage.

func (Page) Copy

func (p Page) Copy() error

Copy writes the raw markdown content to the system clipboard.

func (Page) Open

func (p Page) Open(ctx context.Context) error

Open opens the page URL in the user's default browser.

type Palette

type Palette struct {
	palette.Model
	// contains filtered or unexported fields
}

Palette wraps the foam palette model with visibility state and overlay rendering.

func (*Palette) Dismiss

func (p *Palette) Dismiss()

Dismiss hides the palette and resets its state.

func (*Palette) Open

func (p *Palette) Open() tea.Cmd

Open shows the palette and focuses its input.

func (Palette) View

func (p Palette) View(bg string, width, height int) string

View composites the palette over the given background using the lipgloss Canvas/Layer/Compositor overlay system.

func (Palette) Visible

func (p Palette) Visible() bool

Visible reports whether the palette overlay is showing.

Jump to

Keyboard shortcuts

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