Documentation
¶
Overview ¶
Package formview renders terminal form controls shared by TUI overlays.
Index ¶
- Constants
- func Area(area textarea.Model, focused bool, width, rows int, clean func(string) string, ...) []string
- func HuhConfirm(styles *theme.Styles, first, second string, firstSelected bool, width int) string
- func HuhInlineSelect(styles *theme.Styles, choices []string, selected, width int) string
- func HuhNote(styles *theme.Styles, lines []string, width int) string
- func HuhView(field huh.Field) string
- func Input(input textinput.Model, focused bool, width int, clean func(string) string, ...) string
- func Selection(style lipgloss.Style, marked bool) lipgloss.Style
- type FieldModel
- type Mark
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
Types ¶
type FieldModel ¶
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) 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.