textprompt

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package textprompt provides a single-line text-input overlay for the tui/app shell — the third of the overlay kits next to prompt (buttons) and picker (filterable list).

The overlay closes itself and emits a ResultMsg; the hosting Content matches on Key to tell prompts apart:

case textprompt.ResultMsg:
    if field, ok := msg.Key.(configField); ok { ... }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Key is echoed in ResultMsg so apps with several prompts can tell
	// results apart.
	Key   any
	Title string
	// Help is dimmed explanatory text under the title.
	Help string
	// Value pre-fills the input.
	Value string
	// Placeholder defaults to Title.
	Placeholder string
	// Secret masks the typed value (password-style echo).
	Secret bool
	// CharLimit bounds the input length (default 128).
	CharLimit int
	// MaxWidth bounds the modal (default 70).
	MaxWidth int
}

Options configure New.

type Overlay

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

Overlay is a centered single-line text-input modal.

func New

func New(opts Options) *Overlay

New creates a text prompt overlay. Push it with Host.PushOverlay.

func (*Overlay) ID

func (o *Overlay) ID() string

ID implements app.Overlay.

func (*Overlay) Init

func (o *Overlay) Init() tea.Cmd

Init implements app.Overlay.

func (*Overlay) Update

func (o *Overlay) Update(msg tea.Msg) (app.Overlay, tea.Cmd)

Update implements app.Overlay.

func (*Overlay) Value

func (o *Overlay) Value() string

Value returns the current input value.

func (*Overlay) View

func (o *Overlay) View(width, height int) string

View implements app.Overlay.

type ResultMsg

type ResultMsg struct {
	// Key identifies which prompt resolved (Options.Key, may be nil).
	Key       any
	Cancelled bool
	Value     string
}

ResultMsg is emitted when the prompt closes.

Jump to

Keyboard shortcuts

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