Documentation
¶
Index ¶
- func CenterRow(row string, width int) string
- func ComposeContent(m ContentModel) string
- func FocusLineOffset(optionFocus bool, optionCursor, optionCount int, hasInput bool) int
- func FocusOptionsCursor(optionCount int, reverse bool) int
- func RenderChoiceGroups(groups []ChoiceGroup, selected []int, activeGroup int, focus bool, ...) string
- func RenderHintLines(lines [][]Hint, gap string, keyStyle, textStyle lg.Style) string
- func RenderScrollable(m ScrollableModel) string
- func StepChoice(current, choiceCount, delta int, wrap bool) int
- type Choice
- type ChoiceGroup
- type ChoiceGroupStyles
- type ContentModel
- type Hint
- type NavDirection
- type NavResult
- type ScrollableModel
- type State
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeContent ¶
func ComposeContent(m ContentModel) string
ComposeContent builds prompt body content from already-rendered parts.
func FocusLineOffset ¶
FocusLineOffset returns the content line offset of the focused element within prompt content laid out by ComposeContent and RenderChoiceGroups.
When optionFocus is true and optionCount > 0, it returns the line of the option at optionCursor. Otherwise, if hasInput is true, it returns the line where the input field begins. Returns -1 when there is nothing to scroll to.
func FocusOptionsCursor ¶
FocusOptionsCursor returns the cursor position to use when entering options.
func RenderChoiceGroups ¶
func RenderChoiceGroups( groups []ChoiceGroup, selected []int, activeGroup int, focus bool, styles ChoiceGroupStyles, ) string
RenderChoiceGroups renders labeled groups of mutually exclusive choices.
func RenderHintLines ¶
RenderHintLines renders one or more lines of key/text hints.
func RenderScrollable ¶
func RenderScrollable(m ScrollableModel) string
RenderScrollable renders content inside a styled box, using a viewport and scrollbar when the content exceeds the available height.
func StepChoice ¶
StepChoice moves or cycles the selected value within a choice group.
Types ¶
type ChoiceGroup ¶
type ChoiceGroupStyles ¶
type ContentModel ¶
type NavResult ¶
type NavResult struct {
}
func NavigateOptions ¶
func NavigateOptions(cursor, optionCount int, hasInput bool, dir NavDirection) NavResult
NavigateOptions computes the next options cursor or whether focus should move from the option list into the input field.
type ScrollableModel ¶
type State ¶
State holds generic interaction state for a prompt with optional choice groups and a yes/no selection. Apps embed this alongside their own app-specific fields (textarea, viewport, action semantics, etc.).
func (*State) EnterOptions ¶
EnterOptions sets focus to the option list and positions the cursor at the first or last option depending on reverse.
func (*State) FocusLine ¶
FocusLine returns the content line offset of the currently focused element, for use with viewport scroll-to-visible. Returns -1 when there is nothing to scroll to.
func (*State) Navigate ¶
func (s *State) Navigate(dir NavDirection, optionCount int, hasInput bool) NavResult
Navigate moves the option cursor in the given direction and returns whether focus should move to the input field. The cursor is updated in-place when the result does not move to input.