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 ¶
- type Model
- func (m *Model) Blur()
- func (m *Model) Focus() tea.Cmd
- func (m Model) Focused() bool
- func (m Model) Height() int
- func (m Model) Init() tea.Cmd
- func (m *Model) SetMaxHeight(h int)
- func (m *Model) SetValue(s string)
- func (m *Model) SetWidth(w int)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) Value() string
- func (m Model) View() string
- type SubmitMsg
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) Focus ¶
Focus gives the textarea keyboard focus. Returns a blink command.
func (Model) Focused ¶
Focused returns true when the underlying textarea has keyboard focus.
func (Model) Height ¶
Height returns the current textarea height in lines.
func (Model) Init ¶
Init satisfies tea.Model; returns the cursor-blink command.
func (*Model) SetMaxHeight ¶
SetMaxHeight sets the maximum number of rows the textarea may grow to.
func (*Model) SetValue ¶
SetValue sets the textarea content and recalculates the height.
func (*Model) SetWidth ¶
SetWidth constrains the visible typing area. We subtract 4 columns to reserve space for the styled "> " prompt prefix and lipgloss padding.
func (Model) Update ¶
Update handles incoming messages. Ctrl+J submits; all other keys are forwarded to the underlying textarea.
Source Files
¶
- input.go