tui

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 23 Imported by: 1 module, 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 mdsh's interactive mode: a terminal UI that shows a document, runs its blocks as they are picked, and saves their output back to the file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(d *doc.Document, opts Options) error

Run shows d full screen until the user quits.

Types

type Model

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

Model is the TUI's state. It is a tea.Model.

func New

func New(d *doc.Document, opts Options) (*Model, error)

New sets up the TUI for d. Close the model when done with it.

func (*Model) Close

func (m *Model) Close()

Close ends the shells blocks ran in.

func (*Model) Init

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

Init starts listening for run events.

func (*Model) Update

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

Update handles a key, a window size or a run event.

func (*Model) View

func (m *Model) View() string

View draws the document above a status line and a key help line.

type Options

type Options struct {
	// Run are the options every run uses. Run.File must be set. The TUI
	// sets Confirm and OnEvent itself.
	Run run.Options
	// Yes runs confirm blocks, and every block in step mode, without
	// asking.
	Yes bool
	// Save writes the document's new contents to Run.File.
	Save func([]byte) error
	// AutoSave saves after every block that runs. Otherwise output is
	// saved when w is pressed.
	AutoSave bool
	// Images turns on image previews, drawn with colored half blocks.
	Images bool
	// Protocol is how v shows an image at full size. With termimg.None
	// it is drawn with half blocks, as large as the terminal allows.
	Protocol termimg.Protocol
	// Style is the glamour style prose is drawn in, such as "dark",
	// "light" or "notty".
	Style string
}

Options configure the TUI.

Jump to

Keyboard shortcuts

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