tui

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tui is the terminal frontend built with Bubble Tea v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyActions added in v0.2.0

func KeyActions() []string

KeyActions lists the action names [keys] accepts, sorted.

func RenderStyles

func RenderStyles() render.Styles

RenderStyles are the dark output colours; the CLI uses them.

func RenderStylesFor added in v0.2.0

func RenderStylesFor(dark bool) render.Styles

RenderStylesFor returns the output colours of the dark or light theme.

func Run

func Run(reg *registry.Registry, opts Options) (history.Session, error)

Run starts the Bubble Tea program. Run runs the TUI and returns the session for the history.

Types

type App

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

App is the root model.

func New

func New(reg *registry.Registry, opts Options) *App

New builds the App with the sidebar's first tool active.

func (*App) Init

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

func (*App) Session added in v0.2.0

func (a *App) Session() history.Session

Session returns the active tool and the options and inputs of every tool opened in this session.

func (*App) Update

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

func (*App) View

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

type Clipboard

type Clipboard interface {
	Read() (string, error)
	Write(text string) error
	UseOSC52() bool // true: copy with tea.SetClipboard (OSC 52)
}

Clipboard is what the TUI needs from the clipboard.

type KeyMap

type KeyMap struct {
	NextFocus     key.Binding
	PrevFocus     key.Binding
	ToggleSidebar key.Binding
	Run           key.Binding // F5: non-live tools and large inputs
	ClearInput    key.Binding // leaves large input mode
	CopyOutput    key.Binding
	PasteInput    key.Binding
	DetectClip    key.Binding
	OpenPalette   key.Binding
	UseOutput     key.Binding
	EditInput     key.Binding
	SaveOutput    key.Binding
	Help          key.Binding
	Quit          key.Binding
	QuitOutside   key.Binding // "q": only outside text fields
	Sidebar       sidebar.KeyMap
	Options       options.KeyMap
	Palette       palette.KeyMap
}

KeyMap is the TUI's central keymap.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

func (*KeyMap) Apply added in v0.2.0

func (k *KeyMap) Apply(over map[string]string) []string

Apply overrides bindings with the config's [keys]: each value is one key ("ctrl+y"), several separated by commas ("ctrl+y, alt+c") or "none" to turn the action off. All overrides apply first, so actions can swap keys; then an override whose key another action still uses goes back to its default with a warning, as do unknown actions and empty values.

func (KeyMap) FullHelp

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

FullHelp implements help.KeyMap.

func (KeyMap) ShortHelp

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

ShortHelp implements help.KeyMap.

type Options

type Options struct {
	Debounce      time.Duration // wait between the last key and the run
	Clipboard     Clipboard     // nil: no clipboard
	DetectOnStart bool          // --clipboard: detect the clipboard on start
	// ToolDefaults are the [tools.<id>] option values from the config.
	ToolDefaults map[string]tool.Values
	// Limits are the large input thresholds; zero uses DefaultLimits.
	Limits workspace.Limits
	// Warnings (config problems) are shown in the statusbar on start.
	Warnings []string
	// Theme is "dark" (also when empty), "light" or "auto", which asks the
	// terminal for its background colour.
	Theme string
	// Mouse turns on clicks and the wheel (config "mouse", on by default).
	// The terminal then needs Shift to select text with the mouse.
	Mouse bool
	// Keys are the [keys] overrides from the config.
	Keys map[string]string
	// Restore is the previous session from the history: last tool, options
	// (over ToolDefaults) and inputs.
	Restore history.Session
	// Editor builds the external editor command (Ctrl+E); nil uses
	// $VISUAL/$EDITOR. Tests replace it.
	Editor func(path string) *exec.Cmd
}

Options configures the App.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions are the plan's values (120 ms debounce).

type Theme

type Theme struct {
	Dark      bool
	Frame     frame.Styles // the boxes: Tools here, the rest in the workspace
	Palette   palette.Styles
	Status    statusbar.Styles
	Sidebar   sidebar.Styles
	Workspace workspace.Styles
	Help      help.Styles
}

Theme gathers every TUI style. No other file defines colours or inline styles (the colour swatch of render.Swatch is data, not theme).

func DarkTheme

func DarkTheme() Theme

DarkTheme uses only the 16 ANSI colours.

func LightTheme added in v0.2.0

func LightTheme() Theme

LightTheme is for terminals with a light background.

func ThemeFor added in v0.2.0

func ThemeFor(dark bool) Theme

ThemeFor builds the dark or light theme.

Directories

Path Synopsis
Package frame draws the boxes that group the TUI sections: a square border with the title inside its top edge.
Package frame draws the boxes that group the TUI sections: a square border with the title inside its top edge.
Package palette is the command palette (Ctrl+P): fuzzy search over tools and actions, drawn over the view.
Package palette is the command palette (Ctrl+P): fuzzy search over tools and actions, drawn over the view.
Package sidebar shows the registry's categories and tools, with a fuzzy filter opened with "/".
Package sidebar shows the registry's categories and tools, with a fuzzy filter opened with "/".
Package statusbar draws the TUI's last row: the active tool's status on the left and the contextual help on the right.
Package statusbar draws the TUI's last row: the active tool's status on the left and the contextual help on the right.
Package workspace shows the active tool's options, inputs and output.
Package workspace shows the active tool's options, inputs and output.
options
Package options builds a tool's options panel from Spec.Options: Toggle is a checkbox, Select a ◀ ▶ selector and Number or String a validated textinput.
Package options builds a tool's options panel from Spec.Options: Toggle is a checkbox, Select a ◀ ▶ selector and Number or String a validated textinput.

Jump to

Keyboard shortcuts

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