tui

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package tui provides a text-based user interface for the application.

Index

Constants

This section is empty.

Variables

View Source
var (
	ChoiceStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFFFFF"))
	CursorStyle   = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF00"))
	HintStyle     = lipgloss.NewStyle().Foreground(lipgloss.Color("#767676"))
	InputStyle    = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF00"))
	QuestionStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF06B7")).Bold(true)
)

Style definitions.

Functions

func CommitMessageTextArea

func CommitMessageTextArea() (string, error)

CommitMessageTextArea is an entry function to interact with the text area model.

func IsInteractive added in v0.2.0

func IsInteractive() bool

IsInteractive reports whether the process is attached to a terminal on both ends, which is what Bubble Tea needs: one to render to and one to read keystrokes from. Bubble Tea falls back to the controlling terminal when stdin is redirected, so that counts too. When it returns false the spinner degrades to plain status lines and the interactive prompts cannot run.

func MustPromptForInputTea

func MustPromptForInputTea(prompt string) string

MustPromptForInputTea prompts the user for input using the BubbleTea framework. This function encapsulates the process of setting up, running, and managing the life cycle of the prompt.

func MustPromptWithChoices

func MustPromptWithChoices(question string, choices []string) string

MustPromptWithChoices prompts the user with multiple choices using Tea. Returns the selected choice as a string.

func MustPromptYesNoTea

func MustPromptYesNoTea(question string, defaultChoice bool) bool

MustPromptYesNoTea prompts a yes/no question using Tea. Returns true for 'Yes' and false for 'No'.

func SpinnerStart added in v0.1.0

func SpinnerStart(text string)

SpinnerStart starts the spinner with the given text. Without a terminal (a git hook, a CI job, redirected stdin or stdout) it prints the text as a plain line instead, since Bubble Tea cannot run there.

func SpinnerStop added in v0.1.0

func SpinnerStop()

SpinnerStop stops the running spinner.

Types

type ChoiceModel

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

ChoiceModel holds the state for multiple-choice prompts. It manages the current selection, the list of choices, and the specific question being asked.

func (ChoiceModel) Init

func (m ChoiceModel) Init() tea.Cmd

Init initializes the model. Returns a command but does nothing initially.

func (ChoiceModel) Update

func (m ChoiceModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update processes incoming messages and updates the model based on user input. Handles key presses to navigate and select from the choices.

func (ChoiceModel) View

func (m ChoiceModel) View() string

View renders the UI components, showing the question and the list of choices.

type InputModel

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

InputModel holds the state for text input prompts. It manages the text input field, any potential error state, the prompt message, and the final user input.

func (InputModel) Init

func (m InputModel) Init() tea.Cmd

Init initializes the input model for the Tea framework. Here, it sets up the text input blinking for user interaction.

func (InputModel) Update

func (m InputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update serves as the state update function for the Tea framework. It processes incoming messages, which often stem from user input.

func (InputModel) View

func (m InputModel) View() string

View returns the string that represents the current View of the program. It provides the prompt, the user input area, and a hint for submission.

type SpinnerModel

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

SpinnerModel contains the state and behavior of the spinner.

func (SpinnerModel) Init

func (m SpinnerModel) Init() tea.Cmd

Init initializes the spinner, returning its initial command for starting the tick loop.

func (SpinnerModel) Update

func (m SpinnerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for spinner updates and potential quit requests.

func (SpinnerModel) View

func (m SpinnerModel) View() string

View renders the spinner and associated text to be displayed.

type TextAreaModel added in v0.1.0

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

Define a model for managing the state of the text area.

func (TextAreaModel) Init added in v0.1.0

func (m TextAreaModel) Init() tea.Cmd

Init initializes the text area model for the Tea framework.

func (TextAreaModel) Update added in v0.1.0

func (m TextAreaModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for updating the text area model.

func (TextAreaModel) View added in v0.1.0

func (m TextAreaModel) View() string

View method renders the current state of the model into a viewable string format.

Jump to

Keyboard shortcuts

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