panel

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package panel holds the views that replace the editor at the bottom of the screen until dismissed: permission requests, questions, lists and text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KindLabel

func KindLabel(kind string) string

func Lines

func Lines(lines ...string) func(int) []string

Types

type Ask

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

Ask gives each of several questions a tab, plus a final review tab.

func NewAsk

func NewAsk(qs []interact.Question, reply chan<- interact.Answers) *Ask

func (*Ask) Key

func (a *Ask) Key() any

func (*Ask) Queue

func (q *Ask) Queue(behind int)

func (*Ask) Update

func (a *Ask) Update(msg tea.Msg) (tea.Cmd, bool)

func (*Ask) View

func (a *Ask) View(width, height int) string

type Choice

type Choice struct {
	Label string
	Pick  func(checked app.Surface) tea.Cmd
}

Pick receives the checked items.

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

Consent asks about items that would run as the user. A folder's are checked one by one, the checked agreed to and the rest declined; a plugin's are listed, to be taken or left as a whole.

func NewApproval

func NewApproval(key any, title, lead string, items app.Surface, choices []Choice, esc func() tea.Cmd) *Consent

NewApproval lists items to be taken or left as a whole; the choices receive none.

func NewConsent

func NewConsent(key any, title, lead string, items, checked app.Surface, choices []Choice, esc func() tea.Cmd) *Consent

NewConsent starts with checked items checked. key identifies the request; esc runs when the user dismisses it.

func (*Consent) Key

func (p *Consent) Key() any

func (*Consent) Queue

func (q *Consent) Queue(behind int)

func (*Consent) Update

func (p *Consent) Update(msg tea.Msg) (tea.Cmd, bool)

func (*Consent) View

func (p *Consent) View(width, height int) string

type Initer

type Initer interface {
	Init() tea.Cmd
}

type Item

type Item struct {
	Title  string
	Detail string // shown muted after the title
	// A change of Group starts a new section.
	Group string
	// Current marks the item in use, such as the selected model.
	Current bool
	Value   any
}

type List

type List struct {
	Title  string
	Items  []Item
	Hint   string // replaces the default hint
	Filter bool
	// Select runs on enter, and the list closes.
	Select func(Item) tea.Cmd
	// Keys sees keys first. handled stops the list from processing the key;
	// done closes the list. item is nil when nothing is selected.
	Keys func(k string, item *Item) (cmd tea.Cmd, handled, done bool)
	// Reload, if set, refreshes the items every second while shown.
	Reload func() []Item
	// contains filtered or unexported fields
}

func (*List) Init

func (l *List) Init() tea.Cmd

func (*List) Update

func (l *List) Update(msg tea.Msg) (tea.Cmd, bool)

func (*List) View

func (l *List) View(width, height int) string

type Panel

type Panel interface {
	// Update receives keys and any message the TUI doesn't handle itself.
	Update(msg tea.Msg) (cmd tea.Cmd, done bool)
	View(width, height int) string
}

type Permission

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

func NewPermission

func NewPermission(req interact.Approval, reply chan<- interact.Verdict, acceptEdits func()) *Permission

acceptEdits switches to the accept-edits mode; it is offered for edits.

func (*Permission) Key

func (p *Permission) Key() any

func (*Permission) Queue

func (q *Permission) Queue(behind int)

func (*Permission) Update

func (p *Permission) Update(msg tea.Msg) (tea.Cmd, bool)

func (*Permission) View

func (p *Permission) View(width, height int) string

type Request

type Request interface {
	Panel
	Key() any
	Queue(behind int)
}

A Request answers the agent and may be withdrawn by Key. Requests wait their turn; Queue tells the shown one how many wait behind it.

type Tab

type Tab struct {
	Name string
	Body func(width int) []string
}

type Text

type Text struct {
	Title string
	Tabs  []Tab
	// Load, if set, runs off the TUI goroutine; the panel shows a loading
	// state until it returns.
	Load func() []Tab
	// contains filtered or unexported fields
}

func (*Text) Init

func (t *Text) Init() tea.Cmd

func (*Text) Update

func (t *Text) Update(msg tea.Msg) (tea.Cmd, bool)

func (*Text) View

func (t *Text) View(width, height int) string

Jump to

Keyboard shortcuts

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