chatinput

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package chatinput renders a single-line chat prompt with a placeholder, cursor, and submit/escape key bindings. It's a thin Bubble Tea model — the consumer owns the code and is expected to extend it (history, multi-line, slash commands, completions) by editing the file directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelMsg

type CancelMsg struct{}

CancelMsg is emitted when the user presses Esc.

type Input

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

Input is a Bubble Tea model for a chat-style single-line text input.

func New

func New(t theme.Theme) Input

New constructs an Input using the given theme. Focused by default.

func (Input) Blur

func (i Input) Blur() Input

Blur disables key input.

func (Input) Focus

func (i Input) Focus() Input

Focus enables key input.

func (Input) Focused

func (i Input) Focused() bool

Focused reports whether the input is currently accepting keys.

func (Input) Init

func (i Input) Init() tea.Cmd

Init implements tea.Model.

func (Input) Reset

func (i Input) Reset() Input

Reset clears the value to "".

func (Input) Update

func (i Input) Update(msg tea.Msg) (Input, tea.Cmd)

Update implements tea.Model.

func (Input) Value

func (i Input) Value() string

Value returns the current text.

func (Input) View

func (i Input) View() string

View renders the input. Safe to call repeatedly.

func (Input) WithPlaceholder

func (i Input) WithPlaceholder(s string) Input

WithPlaceholder sets the placeholder shown when the value is empty.

func (Input) WithPrompt

func (i Input) WithPrompt(s string) Input

WithPrompt sets the prompt prefix (default "> "). Use "" for no prompt.

func (Input) WithValue

func (i Input) WithValue(s string) Input

WithValue presets the value. Useful for restored sessions.

func (Input) WithWidth

func (i Input) WithWidth(w int) Input

WithWidth sets the overall input width in cells. Clamped to >= 8.

type SubmitMsg

type SubmitMsg struct {
	Value string
}

SubmitMsg is emitted when the user presses Enter on a non-empty value.

Jump to

Keyboard shortcuts

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