Help us shape the future of Go! Take the 2026 Go Developer Survey

tui

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tui holds the full-screen terminal editors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens url with the system's opener.

func Plural

func Plural(n int, unit string) string

Plural formats a count with a unit, e.g. "1 commit" or "3 commits".

func Run

func Run(m tea.Model, in io.Reader, out io.Writer) (tea.Model, error)

Run runs a model full-screen on in/out and returns the final model.

Types

type Item

type Item struct {
	Title  string
	Detail string
	Tab    int // index into Picker.Tabs; ignored without tabs
}

Item is one entry in a Picker.

type ModifyEditor

type ModifyEditor struct {
	Nodes   []*ModifyNode
	Applied bool
	// Details returns text for the f (files) and c (commits) panels.
	Details func(branch, kind string) string
	// ValidName, if set, checks a new or renamed layer's name (orig is the
	// layer's original branch, "" for an inserted one) and returns why it is
	// unusable, or "". Names are checked here so that the staged changes
	// survive a bad name.
	ValidName func(name, orig string) string
	// contains filtered or unexported fields
}

ModifyEditor stages structural changes to a stack. Nodes are bottom first.

func NewModifyEditor

func NewModifyEditor(nodes []*ModifyNode) *ModifyEditor

NewModifyEditor returns an editor focused on the top layer.

func (*ModifyEditor) Init

func (e *ModifyEditor) Init() tea.Cmd

func (*ModifyEditor) Update

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

func (*ModifyEditor) View

func (e *ModifyEditor) View() string

type ModifyNode

type ModifyNode struct {
	Name    string
	Orig    string   // original branch, "" for an inserted layer
	Sources []string // original layers whose commits this layer holds
	Commits int      // commit count of the original layer (for display)
	Dropped bool
}

ModifyNode is one layer in the modify editor.

type Picker

type Picker struct {
	Title   string
	Tabs    []string
	Items   []Item
	Initial int // item index to start on

	Chosen int // index into Items, -1 when cancelled
	// contains filtered or unexported fields
}

Picker is a searchable list with optional tabs. The first tab, if any, shows every item.

func NewPicker

func NewPicker(title string, items []Item) *Picker

NewPicker returns a picker with nothing chosen yet.

func (*Picker) Init

func (p *Picker) Init() tea.Cmd

func (*Picker) Update

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

func (*Picker) View

func (p *Picker) View() string

type SubmitEditor

type SubmitEditor struct {
	Nodes     []*SubmitNode
	Submitted bool
	Cancelled bool
	LinkOnly  bool // ^b: only link the existing PRs

	// OpenURL opens a URL in the browser (^o).
	OpenURL func(url string) error
	// Ref formats a CR number, e.g. "!12"; nil writes "#12".
	Ref func(n int) string
	// CR names a change request, e.g. "MR"; "" is "PR".
	CR string
	// contains filtered or unexported fields
}

SubmitEditor lets the user pick which branches become PRs and edit their title, description and draft state. Nodes are ordered bottom first.

func NewSubmitEditor

func NewSubmitEditor(nodes []*SubmitNode) *SubmitEditor

NewSubmitEditor returns an editor focused on the topmost branch.

func (*SubmitEditor) Init

func (e *SubmitEditor) Init() tea.Cmd

func (*SubmitEditor) Update

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

func (*SubmitEditor) View

func (e *SubmitEditor) View() string

type SubmitNode

type SubmitNode struct {
	Branch string
	Target string
	// Existing PR, if any (Number > 0). Existing PRs are always kept.
	Number int
	URL    string
	State  string // "open", "draft", ...

	// For new PRs: the editable draft.
	Include bool
	Title   string
	Body    string
	Draft   bool
}

SubmitNode is one branch in the submit editor.

Jump to

Keyboard shortcuts

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