tui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeys = KeyMap{
	Up: key.NewBinding(
		key.WithKeys("up"),
		key.WithHelp("↑", "up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down"),
		key.WithHelp("↓", "down"),
	),
	Tab: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "next / apply suggestion"),
	),
	ShiftTab: key.NewBinding(
		key.WithKeys("shift+tab"),
		key.WithHelp("shift+tab", "previous"),
	),
	Enter: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "confirm / apply suggestion"),
	),
	Quit: key.NewBinding(
		key.WithKeys("ctrl+c", "esc"),
		key.WithHelp("esc", "quit"),
	),
	NextSuggestion: key.NewBinding(
		key.WithKeys("ctrl+n"),
		key.WithHelp("ctrl+n", "next suggestion"),
	),
	PrevSuggestion: key.NewBinding(
		key.WithKeys("ctrl+b"),
		key.WithHelp("ctrl+b", "previous suggestion"),
	),
	Space: key.NewBinding(
		key.WithKeys(" "),
		key.WithHelp("space", "toggle selection"),
	),
	Search: key.NewBinding(
		key.WithKeys("/"),
		key.WithHelp("/", "search"),
	),
	SelectAll: key.NewBinding(
		key.WithKeys("ctrl+a"),
		key.WithHelp("ctrl+a", "select all"),
	),
	DeselectAll: key.NewBinding(
		key.WithKeys("ctrl+d"),
		key.WithHelp("ctrl+d", "deselect all"),
	),
}

DefaultKeys is the default key map used by all TUI forms.

Functions

This section is empty.

Types

type FormNavigator

type FormNavigator struct {
	FocusIndex int // Index of the currently focused element
	// contains filtered or unexported fields
}

FormNavigator manages focus and navigation between elements in a TUI form.

func NewNavigator

func NewNavigator(elementCount int) *FormNavigator

NewNavigator creates a new FormNavigator for a form with the given number of elements.

func (*FormNavigator) GetElementCount

func (n *FormNavigator) GetElementCount() int

GetElementCount returns the total number of navigable elements.

func (*FormNavigator) GetFocusIndex

func (n *FormNavigator) GetFocusIndex() int

GetFocusIndex returns the current focus index.

func (*FormNavigator) HandleNavigation

func (n *FormNavigator) HandleNavigation(key string)

HandleNavigation updates the focus index according to the received navigation key.

func (*FormNavigator) SetFocusIndex

func (n *FormNavigator) SetFocusIndex(index int) bool

SetFocusIndex sets the focus index to a specific value if within bounds.

type KeyMap

type KeyMap struct {
	Up             key.Binding
	Down           key.Binding
	Tab            key.Binding
	ShiftTab       key.Binding
	Enter          key.Binding
	Quit           key.Binding
	NextSuggestion key.Binding
	PrevSuggestion key.Binding
	Space          key.Binding
	Search         key.Binding
	SelectAll      key.Binding
	DeselectAll    key.Binding
}

KeyMap holds all key bindings used across task and workspace forms.

type NavigationKeys string

NavigationKeys represents the supported navigation keys.

const (
	KeyUp       NavigationKeys = "up"        // Navigate up
	KeyDown     NavigationKeys = "down"      // Navigate down
	KeyTab      NavigationKeys = "tab"       // Navigate to the next element
	KeyShiftTab NavigationKeys = "shift+tab" // Navigate to the previous element
)

Directories

Path Synopsis
Package suggestions provides autocomplete functionality for TUI forms.
Package suggestions provides autocomplete functionality for TUI forms.

Jump to

Keyboard shortcuts

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