formview

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package formview renders terminal form controls shared by TUI overlays.

Index

Constants

View Source
const SelectAllKey = "ctrl+a"

SelectAllKey is the binding, stated once so a surface can name it without spelling the string again.

Variables

This section is empty.

Functions

func Area

func Area(
	area *textarea.Model,
	focused bool,
	width, rows int,
	clean func(string) string,
	cursor func(string, int, int) string,
) []string

Area renders a fixed-height textarea viewport.

func HuhConfirm

func HuhConfirm(styles *theme.Styles, first, second string, firstSelected bool, width int) string

HuhConfirm renders the yes/no core of a confirm prompt. Spec section 5.2 assigns huh's Confirm to the ship and kill prompts. The first choice is the affirmative because huh renders the affirmative on the left, and the buttons must appear in the order kb's frozen tab cycle walks them.

func HuhInlineSelect

func HuhInlineSelect(styles *theme.Styles, choices []string, selected, width int) string

HuhInlineSelect renders one choice as a single row: the current option between the previous and next indicators. Spec section 5.2 assigns Select to the Source, Max stories, Priority and Effort choice fields, all of which are single rows in the frozen v1.0.1 layout with one pointer target each, so the inline form is the only one that fits without moving a hit region.

func HuhNote

func HuhNote(styles *theme.Styles, lines []string, width int) string

HuhNote renders a disclaimer block. Spec section 5.2 assigns huh's Note to the blocks that explain what an action will do.

func HuhView

func HuhView(field huh.Field) string

HuhView is the sub-model adapter: it settles the field - a Select sizes its viewport in Update and renders nothing until it has - and then renders the huh.Model that came back.

func Input

func Input(
	input textinput.Model,
	focused bool,
	width int,
	clean func(string) string,
	cursor func(string, int, int) string,
) string

Input renders one text input within the requested terminal width.

func Selection

func Selection(style lipgloss.Style, marked bool) lipgloss.Style

Selection applies the marked treatment to the style a view paints a field row with. The mark is the theme's pressed token - reverse video - set as an attribute on the row's own style rather than wrapped around it, which is the form widget.Button uses for the same token: a wrapping run is cancelled by the first reset the content emits, and the mark would vanish mid-row.

Views that compose a field value into a line some other style paints use theme.Styles.PressedRun on the value instead; that form carries no reset and so survives composition.

func TerminalTextView added in v1.7.3

func TerminalTextView(snapshot string, offset, width, height int) string

TerminalTextView renders an immutable plain-text snapshot with terminal mouse reporting disabled by the owning root view. The terminal can then own ordinary drag selection and its native copy command.

func UpdateTerminalText added in v1.7.3

func UpdateTerminalText(snapshot string, offset, width, height int, key string) (next int, exit bool)

UpdateTerminalText applies navigation to an immutable snapshot. Exit is true only for Escape; callers retain ownership of their surrounding model.

Types

type FieldModel

type FieldModel interface {
	Value() string
	SetValue(string)
}

FieldModel is the part of a bubbles field model the mark drives. Both *textinput.Model and *textarea.Model satisfy it.

type Mark

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

Mark is the select-all state of one surface. It holds the identifier of the marked field rather than a bare flag, so a mark never leaks onto a sibling field: a key routed for a different field finds no mark and behaves normally.

The zero value is an unmarked surface.

func (*Mark) Active

func (m *Mark) Active(field string) bool

Active reports whether field currently carries the mark.

func (*Mark) Area

func (m *Mark) Area(field string, area *textarea.Model, msg tea.KeyPressMsg) bool

Area is Input for a textarea.

func (*Mark) Drop

func (m *Mark) Drop()

Drop clears the mark. Surfaces call it when focus moves by a route that never reaches the key handler, a pointer click being the one that matters.

func (*Mark) Input

func (m *Mark) Input(field string, input *textinput.Model, msg tea.KeyPressMsg) bool

Input applies the emulation to a focused text input ahead of the field's own key handling. It reports whether the key was consumed; an unconsumed key must still be dispatched, because that is how a typed rune lands in the field the mark just emptied.

Jump to

Keyboard shortcuts

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