ui

package
v0.151.4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 25 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

Index

Constants

View Source
const (

	// SectionIndent is the leading whitespace applied to body lines.
	// Exported so callers that need to emit body content outside of
	// RenderSection (e.g. when stitching pre-rendered text under a
	// previously emitted section header) can match the same column
	// without re-deriving the literal.
	SectionIndent = "   "
)

SectionLayoutBar / SectionLayoutRule chrome glyphs. Kept as constants so tests can assert on them without re-deriving the literal.

The bar glyph is a full block (U+2588) so the prefix carries real visual weight — a thin ▎ disappears at small zoom levels. It is followed by two spaces so the title text starts at column 4; the body indent below matches that so titles and content stack on the same column.

View Source
const SpinnerStartDelay = 150 * time.Millisecond

SpinnerStartDelay — quick operations finish faster than the first frame, so no spinner ever appears. This avoids a flash of animation that would immediately clear and just add terminal noise.

Variables

View Source
var (
	SectionInfo     = color.New(38, 5, 33, color.Bold)
	SectionCaution  = color.New(38, 5, 136, color.Bold)
	SectionDiverged = color.New(38, 5, 61, color.Bold)
	SectionHealth   = color.New(38, 5, 64, color.Bold)
	SectionAction   = color.New(38, 5, 166, color.Bold)
	SectionMuted    = color.New(color.FgCyan, color.Faint)
)

Solarized-inspired chrome colours for canonical section "intents". Use these directly when a section name doesn't fit the built-in registry; SectionColor takes a name and resolves to the right intent.

xterm-256 codes:

Info      33  (#268BD2 steel blue)   — neutral status / branch
Caution  136  (#B58900 mustard)      — needs-attention / dirty tree
Diverged  61  (#6C71C4 violet)       — branch divergence / merge state
Health    64  (#859900 olive)        — historical / passing checks
Action   166  (#CB4B16 orange)       — call-to-action / next step
Muted     -                         — fallback (faint cyan)

All intents are bold so the title text reads cleanly at small font sizes. fatih/color honours color.NoColor automatically.

View Source
var ErrNonInteractive = errors.New("no TTY: cannot prompt")

ErrNonInteractive is returned when a prompt is requested but stdin/stdout is not a TTY and no default has been provided.

View Source
var ErrPickerAborted = errors.New("picker aborted")

ErrPickerAborted is returned when the user cancels the picker (Ctrl+C / ESC / empty input).

Functions

func Bold

func Bold(text string, noColor bool) string

Bold wraps text in ANSI bold escape codes. Returns plain text when noColor is true.

func Confirm

func Confirm(title string, defaultYes bool) (bool, error)

Confirm shows a yes/no prompt and returns the user's choice. On a non-TTY session it returns ErrNonInteractive so callers can require --yes flags.

func ConfirmTUI

func ConfirmTUI(ctx context.Context, title, desc string, defaultYes bool) (bool, error)

ConfirmTUI presents a yes/no choice. Returns ErrPickerAborted on ctrl+c/esc and ErrNonInteractive when stdout/stdin aren't a TTY. On non-TTY, the caller decides (e.g. honour --yes flag).

func EditTextTUI

func EditTextTUI(ctx context.Context, title, desc, initial string, width, height int) (string, error)

EditTextTUI opens a multi-line textarea pre-populated with initial, returns the edited value when the user presses ctrl+d, or ErrPickerAborted on esc/ctrl+c. width/height pin the editor's visible size — pass zero for sensible defaults.

func FormatJSON

func FormatJSON(data string) string

FormatJSON is a no-op passthrough for --json mode. When JSON mode is active, callers should use this instead of other formatting methods to ensure no Easy Mode formatting is applied.

func IsJSONMode

func IsJSONMode(format string) bool

IsJSONMode checks whether the given format string indicates JSON output. Callers can use this to decide whether to apply Easy Mode formatting.

func IsStderrTerminal

func IsStderrTerminal() bool

IsStderrTerminal reports whether stderr is a TTY. Used when a command wants to draw progress output without polluting a piped stdout — `gk status` prints porcelain to stdout but a fetch spinner to stderr.

func IsTerminal

func IsTerminal() bool

IsTerminal reports whether both stdin and stdout are TTYs.

func MultiSelectPreviewTUI

func MultiSelectPreviewTUI(ctx context.Context, title string, items []MultiSelectItem, preselect map[string]bool, preview func(selected []string) string) ([]string, error)

MultiSelectPreviewTUI is MultiSelectTUI with a live preview pane: preview is called with the currently-selected keys after every toggle and its output is drawn under the list. Used by `gk config setup` to show what a log/status layer combination will actually look like.

func MultiSelectTUI

func MultiSelectTUI(ctx context.Context, title string, items []MultiSelectItem, preselect map[string]bool, extras ...MultiSelectExtraKey) ([]string, error)

MultiSelectTUI presents a checkbox list where the user toggles items with space, confirms with enter, and aborts with esc/ctrl+c. Returns the selected Keys (in original order) or ErrPickerAborted. preselect can pre-check items by Key. extras attach custom keys that can replace the items list on the fly (see MultiSelectExtraKey).

func MultiSelectWith added in v0.151.0

func MultiSelectWith(ctx context.Context, title string, items []MultiSelectItem, preselect map[string]bool, opts MultiSelectOptions) ([]string, error)

MultiSelectWith is MultiSelectTUI with a detail line for the cursor row, a selection preview, and extra keys together.

func PlainProgressBar

func PlainProgressBar(percent float64, width int) string

PlainProgressBar is the no-color counterpart to ProgressBar.

func PlainSummaryTable

func PlainSummaryTable(rows []SummaryRow) string

PlainSummaryTable renders the same layout without style escape codes.

func ProgressBar

func ProgressBar(percent float64, width int) string

ProgressBar renders a static Bubbles progress bar for one-shot CLI output.

func PromptTextTUI

func PromptTextTUI(ctx context.Context, title, placeholder, initial string) (string, error)

PromptTextTUI presents a single-line text input. Returns the trimmed value on enter, ErrPickerAborted on ctrl+c/esc, ErrNonInteractive on non-TTY. Empty input is rejected (enter is a no-op until non-empty).

func RenderNextAction

func RenderNextAction(next, why string, opts SectionOpts) string

RenderNextAction returns the highlighted footer that closes a rich-mode section sequence. The next-command sits in the title row's summary slot so the eye lands on it immediately, and the optional `why` explanation goes in the body — the inverse of the legacy "→ next / why: …" pair which buried the command on the second line.

Bar:

█  NEXT   → gk push
   why: 3 commits ahead of origin/main

Rule:

── NEXT ─────────────────────────
   → gk push
   why: 3 commits ahead of origin/main

`why` may be empty; in that case only the next-command line is emitted.

func RenderSection

func RenderSection(title, summary string, lines []string, opts SectionOpts) string

RenderSection returns a section block titled `title` with an optional `summary` headline and `lines` as the body. Output always ends with a trailing blank line so callers can stack sections without inserting their own separators.

`summary` is the one-line headline that complements the section title — e.g. "5M 2? · 7 files" for a working-tree section. In the bar layout it sits inline with the title (separated by sectionSummaryGap) so the eye gets the headline without descending into the body. In the rule layout it is emitted as the first body line so the rule itself stays clean. Empty summary is a no-op.

Body lines are written verbatim — no padding, no truncation, no per-line border. Wide-character glyphs and embedded ANSI escape sequences cannot misalign the chrome because the chrome never depends on body width.

func RunCommandStreamTUI

func RunCommandStreamTUI(ctx context.Context, title, name string, args ...string) error

RunCommandStreamTUI launches `name` with `args`, streams its combined stdout/stderr into a scrollable viewport in real time, and returns the process's exit error (or ErrPickerAborted on user cancel).

On non-TTY environments the call degrades to a normal exec.Cmd that inherits the parent's stdout/stderr — no TUI is drawn.

func ScrollSelectTUI

func ScrollSelectTUI(ctx context.Context, title, body string, options []ScrollSelectOption) (string, error)

ScrollSelectTUI renders a scrollable body above a fixed list of keystroke-bound actions. Useful when the user needs to read context (a diff, a commit summary) before picking a strategy. Returns the chosen Value, or ErrPickerAborted on esc/ctrl+c.

func SectionColor

func SectionColor(name string) *color.Color

SectionColor returns the canonical chrome colour for a named section. Names are matched case-insensitively and trimmed; unknown names fall back to SectionMuted so a typo never crashes the renderer.

The registry covers the gk-wide section vocabulary so the same name yields the same colour regardless of which command renders it — the "divergence" violet appears in `gk status`, `gk pull`, and `gk merge`, reinforcing the visual association.

func StartBubbleSpinner

func StartBubbleSpinner(msg string) (stop func())

StartBubbleSpinner draws a bubbletea-driven inline spinner on stderr until stop() is called. Non-TTY stderr (pipes, CI, `2>file`) makes it a no-op so piped output streams stay clean. The first frame is delayed by SpinnerStartDelay so sub-150ms ops never paint anything to clear.

Same idempotent-safe contract as StartSpinner: pair with defer for exception-safe cleanup.

func StartBubbleSpinnerLive

func StartBubbleSpinnerLive(label func() string) (stop func())

StartBubbleSpinnerLive is StartBubbleSpinner with a live label: the callback is evaluated on every frame, so elapsed time, token counts, or round numbers can tick while the spinner runs. The callback runs on the bubbletea render goroutine — share state via atomics.

func StartBubbleSpinnerWithBudget

func StartBubbleSpinnerWithBudget(msg string, budget time.Duration) (stop func())

StartBubbleSpinnerWithBudget is StartBubbleSpinner plus a live "elapsed / budget" countdown that colours amber then red as it nears the deadline — for a provider call bounded by a known timeout, so the user sees how close it is to timing out rather than waiting blind. A zero budget degrades to the plain spinner.

func StartSpinner

func StartSpinner(msg string) (stop func())

StartSpinner draws a stderr-bound braille spinner until stop() is called. Non-TTY stderr (pipes, CI, `2>file`) makes it a no-op so piped output streams stay clean. The first frame is delayed so sub- SpinnerStartDelay operations never draw anything to clear.

Usage:

stop := ui.StartSpinner("fetching origin...")
err := longOp()
stop()

The returned stop func is idempotent-safe for single-call usage. Pair with defer at the call site for exception-safe cleanup.

func StripANSI

func StripANSI(s string) string

StripANSI is the exported version of stripANSI for use by other packages.

func SummaryTable

func SummaryTable(rows []SummaryRow) string

SummaryTable renders a quiet, ANSI-aware key/value block. It deliberately avoids borders so verbose output still behaves like normal command output.

func TTYWidth

func TTYWidth() (int, bool)

TTYWidth returns stdout terminal width in columns. Returns (0, false) when stdout is not a TTY or the size cannot be determined.

Types

type AutoPrompter

type AutoPrompter struct {
	Default ConflictChoice
}

AutoPrompter returns a fixed default choice without user interaction. Used in non-TTY environments (CI, piped input).

func (*AutoPrompter) ConflictChoice

func (p *AutoPrompter) ConflictChoice(title, context string, allowed []ConflictChoice) (ConflictChoice, error)

type ConflictChoice

type ConflictChoice string

ConflictChoice represents a conflict resolution action.

const (
	ChoiceContinue ConflictChoice = "continue"
	ChoiceAbort    ConflictChoice = "abort"
	ChoiceSkip     ConflictChoice = "skip"
	ChoiceEdit     ConflictChoice = "edit"
	ChoiceOurs     ConflictChoice = "ours"
	ChoiceTheirs   ConflictChoice = "theirs"
	ChoiceQuit     ConflictChoice = "quit"
)

type EasyFormatter

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

EasyFormatter provides consistent formatting for Easy Mode output. It handles emoji insertion, bold section headers, command boxes, and error formatting while respecting --no-color mode.

func NewEasyFormatter

func NewEasyFormatter(emoji *easy.EmojiMapper, noColor bool) *EasyFormatter

NewEasyFormatter creates an EasyFormatter with the given emoji mapper and noColor setting. When noColor is true, ANSI escape sequences are stripped from all output while preserving emoji and text structure.

func (*EasyFormatter) CommandBox

func (f *EasyFormatter) CommandBox(cmd, description string) string

CommandBox returns a command suggestion formatted as an indented block. Format:

→ {cmd}
  {description}

The description line is omitted when description is empty.

func (*EasyFormatter) FormatError

func (f *EasyFormatter) FormatError(err error, hint string) string

FormatError formats an error with easy language and a resolution hint. Format:

{error emoji} {error message}
{hint emoji} {hint}

The hint line is omitted when hint is empty.

func (*EasyFormatter) SectionHeader

func (f *EasyFormatter) SectionHeader(emojiKey, text string) string

SectionHeader returns a formatted section header with an emoji prefix and bold text. Format: "{emoji} {bold}{text}{reset}". When noColor is true, ANSI codes are removed: "{emoji} {text}".

type FallbackPicker

type FallbackPicker struct {
	In  io.Reader
	Out io.Writer
}

FallbackPicker provides a simple numbered list prompt for non-TTY environments.

func (*FallbackPicker) Pick

func (p *FallbackPicker) Pick(ctx context.Context, title string, items []PickerItem) (PickerItem, error)

type MultiSelectExtraKey

type MultiSelectExtraKey struct {
	Key     string
	Help    string
	OnPress func() (items []MultiSelectItem, preselect map[string]bool, err error)
}

MultiSelectExtraKey binds a custom key to a callback that returns a fresh items list. Use it for actions that change *what's listed* — e.g. an "include remote" toggle. Currently-selected keys survive the reload (re-checked if still present).

type MultiSelectItem

type MultiSelectItem struct {
	Key     string
	Display string
}

MultiSelectItem is one row in a MultiSelectTUI list. Key is returned to the caller for the chosen rows; Display is what's drawn.

type MultiSelectOptions added in v0.151.0

type MultiSelectOptions struct {
	// Detail describes the row under the cursor, in the box under the list.
	Detail func(cursorKey string) string
	// Preview summarises the selection, in the same box under Detail.
	Preview func(selected []string) string
	// BoxTitle labels that box; "미리보기" when empty.
	BoxTitle string
	// Header is a column header drawn right above the rows, aligned with
	// Display after the 5-cell " [x] " prefix.
	Header string
	Extras []MultiSelectExtraKey
}

MultiSelectOptions adds what MultiSelectWith shows besides the checkbox rows. Every field is optional.

type Pager

type Pager struct {
	Kind     PagerKind
	Path     string   // absolute path to the binary, or "" for none
	Args     []string // flags to pass
	Disabled bool
}

Pager encapsulates pager selection + invocation.

func Detect

func Detect() *Pager

Detect returns a Pager chosen by this priority:

  1. $GK_PAGER (explicit; value: "delta", "bat", "less", "none", or a full binary path)
  2. $PAGER
  3. PATH lookup: delta → bat → less

When stdout is not a TTY, returns PagerNone (Disabled=true). Honors NO_COLOR for bat and delta (by not passing color flags).

func (*Pager) Run

func (p *Pager) Run() (io.WriteCloser, func() error, error)

Run executes the pager and returns a pipe writer + wait function. Usage:

w, wait, err := pg.Run()
if err != nil { /* fallback to os.Stdout */ }
defer wait()
fmt.Fprintln(w, "...")

func (*Pager) String

func (p *Pager) String() string

String is a short human summary used for `--verbose` output.

type PagerKind

type PagerKind string

PagerKind identifies which pager binary was selected.

const (
	PagerDelta PagerKind = "delta"
	PagerBat   PagerKind = "bat"
	PagerLess  PagerKind = "less"
	PagerNone  PagerKind = "none"
)

type Picker

type Picker interface {
	Pick(ctx context.Context, title string, items []PickerItem) (PickerItem, error)
}

Picker selects one item from a list.

func NewPicker

func NewPicker() Picker

NewPicker returns the active picker for the current environment. Resolution order:

  1. TablePicker — when stdout/stdin are a TTY (the common case)
  2. FallbackPicker — non-TTY: numbered list on stderr

type PickerItem

type PickerItem struct {
	Display     string
	Preview     string
	Key         string
	Cells       []string
	ExtraAction string
	FilterValue string
}

PickerItem represents one selectable row. Display is what's shown in the list. Preview is optional extra text shown alongside the row (currently rendered only by TablePicker). Key is a stable value returned by the picker (usually equal to Display but may be a hash/ref so the caller can look up richer data). Cells, when non-empty, lets table-style pickers (TablePicker) render the row split into columns. Pickers that don't support columns (FallbackPicker) ignore Cells and fall back to Display. ExtraAction is set by TablePicker when an Extra hotkey with Exit=true fires — it carries the key letter so callers can dispatch on it. The rest of the PickerItem reflects the row under the cursor at exit. FilterValue is set by TablePicker on every non-abort exit — it carries the residual filter query so a caller that re-enters the picker (e.g. after a delete action) can re-seed it via TablePicker.InitialFilter.

type Prompter

type Prompter interface {
	// ConflictChoice asks the user to pick a conflict resolution action.
	// title: prompt title; context: summary text to print before the prompt.
	ConflictChoice(title, context string, allowed []ConflictChoice) (ConflictChoice, error)
}

Prompter is the interface consumed by CLI commands for interactive decisions. Implementations: TermPrompter (huh), AutoPrompter (non-interactive with fixed default).

func NewPrompter

func NewPrompter(def ConflictChoice) Prompter

NewPrompter returns TermPrompter if stdout is a TTY, otherwise AutoPrompter(def).

type ScrollSelectOption

type ScrollSelectOption struct {
	Key       string
	Value     string
	Display   string
	IsDefault bool
}

ScrollSelectOption is one keystroke-bound action attached to a ScrollSelectTUI screen. The Key must be a single character the user can press while the body has focus (e.g. "k", "e", "o"). When IsDefault is true, pressing Enter triggers this option — useful for the "happy path" choice (e.g. "keep" on a commit review).

type SectionLayout

type SectionLayout int

SectionLayout selects how RenderSection draws a titled block.

Both layouts share two properties that the legacy box layout did not: the chrome (bar or rule) is independent of body width, so wide-character content cannot push it out of alignment, and the body is rendered verbatim with a fixed three-space indent — no per-line padding.

const (
	// SectionLayoutBar prefixes the title with a thick coloured block
	// and renders the body indented below it. The block fills one full
	// terminal cell and is followed by two spaces so the title text
	// always lands at column 4, which the body indent matches:
	//
	//   █  TITLE   summary
	//      line1
	//      line2
	SectionLayoutBar SectionLayout = iota

	// SectionLayoutRule places the title between two horizontal rule
	// segments sized to min(64, TTY width). Summary, when provided,
	// is emitted as the first body line under the rule:
	//
	//   ── TITLE ──────────────────────
	//      summary
	//      line1
	//      line2
	SectionLayoutRule
)

func ParseSectionLayout

func ParseSectionLayout(s string) SectionLayout

ParseSectionLayout maps a config string ("bar" / "rule") to a layout value. Empty or unknown input falls back to bar.

type SectionOpts

type SectionOpts struct {
	Layout   SectionLayout
	Color    *color.Color
	Width    int
	KeepCase bool
}

SectionOpts customises RenderSection / RenderNextAction output.

Color paints the chrome (bar glyph or rule segments) and — because the title shares the same colour — the title text. fatih/color honours color.NoColor automatically, so callers that want plain output only need to set color.NoColor=true. When nil, faint cyan is used as a safe default.

Width overrides the rule width for SectionLayoutRule. Zero means "auto" — fall back to min(sectionRuleMax, TTYWidth()). Tests use this to pin a deterministic width.

KeepCase suppresses the default ToUpper applied to the title. The upper-cased label reads as a section name for short tags ("BRANCH", "NEXT") but mangles proper nouns and file paths ("INTERNAL/CLI/STATUS.GO" is unreadable), so callers whose title is content-bearing should set this flag.

type SummaryRow

type SummaryRow struct {
	Key   string
	Value string
	Note  string
}

SummaryRow is a compact key/value row for verbose command output.

type TablePicker

type TablePicker struct {
	Headers     []string
	Height      int // 0 → auto (min(items+headers+1, 12))
	Extras      []TablePickerExtraKey
	Subtitle    string
	FilterItems []PickerItem
	// Legend is a one-line glyph key rendered faintly under the subtitle —
	// for listings whose rows carry markers the user is not expected to
	// have memorised. Callers should list only the markers actually on
	// screen; a key for glyphs that aren't there is noise.
	//
	// LegendCompact is the same key in fewer words, used when the terminal
	// cannot hold Legend. Clipping is the last resort: a key whose final
	// entry reads "○ remot…" has lost the thing it was there to explain,
	// so shortening every entry beats truncating the line.
	Legend        string
	LegendCompact string
	// InitialFilter pre-seeds the filter query so the picker opens with
	// the list already narrowed (in nav mode, not typing mode). Callers
	// that re-enter the picker in a loop use it to restore the residual
	// filter recovered from the previous PickerItem.FilterValue.
	InitialFilter string
	// ColumnPriority assigns each column a keep-weight by its header title:
	// when the terminal is too narrow to show every column, the lowest-
	// weight columns are dropped *whole* (cleanly, never mid-character)
	// until the rest fit. Higher weight = kept longer; headers absent from
	// the map default to 0. At least the highest-weight column always
	// survives. Keying on the title (not the index) keeps priorities correct
	// when an ExtraKey toggle swaps the column layout — e.g. `gk wt`'s
	// global view reorders BRANCH and inserts PROJECT. nil keeps the legacy
	// behaviour — render every column and let the terminal hard-clip the
	// right edge — so callers that don't opt in are unaffected. A faint
	// "+N cols" note reports any drop.
	ColumnPriority map[string]int
	// AltScreen draws the picker on the terminal's alternate screen. Inline
	// rendering repaints by moving the cursor up over the lines it drew last,
	// so a resize that rewraps those lines, or a loop that opens the picker
	// again, leaves old copies in the scrollback. It is opt-in because the
	// alternate screen also hides whatever the caller prints between two
	// Picks until the program exits; such a caller passes it as Notice.
	AltScreen bool
	// Notice is a one-line message rendered under the help line, so a caller
	// that re-opens the picker after an action can report the outcome where
	// the user is looking.
	Notice string
}

TablePicker is the default in-process bubbletea picker — no fzf, no external binary. Items with PickerItem.Cells render as multi-column rows; otherwise the row falls back to PickerItem.Display in a single column. Headers is optional — when shorter than the column count it is right-padded with empties.

Subtitle, when non-empty, is rendered as a faint single line above the filter prompt — used for ambient context like "in worktree: X" that callers want visible while the picker is open.

FilterItems are hidden from the unfiltered list but included when the user types a filter query. They are useful for large secondary groups that should not crowd the initial view but should still be discoverable by name.

func (*TablePicker) Pick

func (p *TablePicker) Pick(ctx context.Context, title string, items []PickerItem) (PickerItem, error)

Pick renders the items as a bubbles/table and returns the selected PickerItem, or ErrPickerAborted on cancel. Output is forced to stderr so callers can capture the chosen value on stdout via the post-Run path.

type TablePickerExtraKey

type TablePickerExtraKey struct {
	Key string
	// FilterKey is an optional second keystroke for the same action that
	// fires *even while the filter prompt is focused*. It must be a
	// modifier combo ("ctrl+r", "alt+r") — a plain rune would be
	// indistinguishable from filter text and become untypable. Both forms
	// work in nav mode, and ExtraAction always reports Key, so callers
	// dispatch on one name regardless of which was pressed.
	//
	// This intentionally shadows any same-combo binding inside the filter
	// textinput (e.g. ctrl+f's cursor-forward): reaching the action beats
	// an emacs editing shortcut on a one-line filter box.
	FilterKey string
	Help      string
	// OnPress loads the replacement data set. It runs in a tea.Cmd, off the
	// UI goroutine, so it must not write state the caller reads elsewhere;
	// such writes belong in the returned Apply. Presses that arrive while a
	// load is still running are ignored.
	OnPress func() (TablePickerReload, error)
	Exit    bool
}

TablePickerExtraKey binds a custom keystroke to a callback that can replace the entire data set on the fly — items + headers. Use it for actions that change *what's listed* (e.g. "g toggle global"). Key is a plain keystroke and only fires while the filter prompt is *not* focused; filter typing always wins over bare letters.

When Exit is true, OnPress is ignored: pressing the key quits the picker and surfaces the cursor row's PickerItem with ExtraAction set to Key. Use this for actions whose handlers need to leave the picker (open a confirm dialog, prompt for input) — the caller dispatches on ExtraAction and re-enters the picker on the next loop iteration.

type TablePickerReload added in v0.147.1

type TablePickerReload struct {
	Items    []PickerItem
	Headers  []string
	Subtitle string
	Apply    func()
}

TablePickerReload is what an OnPress extra loaded. Items and Headers replace the listing (nil Headers keeps the columns), and a non-empty Subtitle replaces the subtitle. Apply, when non-nil, runs once after the new rows are applied, on the goroutine that called Pick, so a caller can commit its own state exactly when the screen changes. A failed load, or a picker that closed before the load finished, never runs it.

type TermPrompter

type TermPrompter struct{}

TermPrompter renders interactive bubbletea prompts on a real TTY.

func (*TermPrompter) ConflictChoice

func (p *TermPrompter) ConflictChoice(promptTitle, promptContext string, allowed []ConflictChoice) (ConflictChoice, error)

Jump to

Keyboard shortcuts

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