input

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package input provides the multi-line text entry component used at the bottom of the chat UI. It wraps the bubbles/textarea widget and adds the following behaviours:

  • Pressing Ctrl+J with non-empty text emits a SubmitMsg and clears the field, leaving the widget focused for the next message. Whitespace-only input is silently discarded.
  • Plain Enter inserts a newline (multi-line composition).
  • The textarea grows automatically up to maxHeight rows as content is added, and shrinks back to 1 row on submit/reset.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model wraps a bubbles/textarea.Model. It is a value type in keeping with Bubble Tea conventions; Focus and Blur take pointer receivers because they mutate the internal widget state that must persist across Update calls.

func New

func New() Model

New returns a blurred input widget. The parent model must explicitly call Focus when transitioning to InsertMode.

func (*Model) Blur

func (m *Model) Blur()

Blur removes keyboard focus from the textarea.

func (*Model) Focus

func (m *Model) Focus() tea.Cmd

Focus gives the textarea keyboard focus. Returns a blink command.

func (Model) Focused

func (m Model) Focused() bool

Focused returns true when the underlying textarea has keyboard focus.

func (Model) Height

func (m Model) Height() int

Height returns the current textarea height in lines.

func (Model) Init

func (m Model) Init() tea.Cmd

Init satisfies tea.Model; returns the cursor-blink command.

func (*Model) SetMaxHeight

func (m *Model) SetMaxHeight(h int)

SetMaxHeight sets the maximum number of rows the textarea may grow to.

func (*Model) SetValue

func (m *Model) SetValue(s string)

SetValue sets the textarea content and recalculates the height.

func (*Model) SetWidth

func (m *Model) SetWidth(w int)

SetWidth constrains the visible typing area. Subtract 2 so the parent-allocated width includes the "> " prompt the textarea owns.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update handles incoming messages. Ctrl+J submits; all other keys are forwarded to the underlying textarea.

func (Model) Value

func (m Model) Value() string

Value returns the current textarea content.

func (Model) View

func (m Model) View() string

View renders the prompt prefix and the textarea.

type SubmitMsg

type SubmitMsg struct {
	Value string
}

SubmitMsg is emitted into the Bubble Tea message bus when the user confirms their text. Value contains the trimmed content; it is guaranteed non-empty.

Source Files

  • input.go

Jump to

Keyboard shortcuts

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