tui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tui implements the interactive terminal user interface using Bubble Tea.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Ctx                 context.Context        `json:"-"` // Context for git commands (ignore in JSON if ever needed)
	DryRun              bool                   `json:"dryRun"`
	AllAnalyzedBranches []types.AnalyzedBranch `json:"-"` // Full list (ignore in JSON)
	KeyBranches         []types.AnalyzedBranch `json:"-"` // Protected (ignore in JSON)
	SuggestedBranches   []types.AnalyzedBranch `json:"-"` // Candidates (ignore in JSON)
	OtherActiveBranches []types.AnalyzedBranch `json:"-"` // Active (ignore in JSON)
	ListOrder           []int                  `json:"-"` // Maps display index to original index (ignore in JSON)
	Cursor              int                    `json:"cursor"`
	SelectedLocal       map[int]bool           `json:"selectedLocal"`  // Map using original index
	SelectedRemote      map[int]bool           `json:"selectedRemote"` // Map using original index
	ViewState           ViewState              `json:"viewState"`      // Renamed from viewState
	Results             []types.DeleteResult   `json:"results"`
	Spinner             spinner.Model          `json:"-"` // Spinner model (ignore in JSON)
	Width               int                    `json:"width"`
	Height              int                    `json:"height"`
}

Model represents the state of the TUI application.

func InitialModel

func InitialModel(
	ctx context.Context,
	analyzedBranches []types.AnalyzedBranch,
	dryRun bool,
) Model

InitialModel creates the starting model for the TUI, separating branches into three groups.

func (Model) GetBranchesToDelete

func (m Model) GetBranchesToDelete() []gitcmd.BranchToDelete

GetBranchesToDelete builds the list of actions based on current selections using original indices. Kept internal as it's only called by View and Update.

func (Model) Init

func (m Model) Init() tea.Cmd

Init is the first command that runs when the Bubble Tea program starts.

func (Model) Update

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

Update handles messages and updates the model accordingly.

func (Model) View

func (m Model) View() string

View renders the UI based on the model's state.

type ViewState added in v0.3.0

type ViewState int // Renamed from viewState

ViewState represents the different views the TUI can be in.

const (
	// StateSelecting is the initial state for branch selection.
	StateSelecting ViewState = iota // Renamed from stateSelecting
	// StateConfirming is the state for confirming deletions.
	StateConfirming // Renamed from stateConfirming
	// StateDeleting is the state shown while deletions are in progress.
	StateDeleting // Renamed from stateDeleting
	// StateResults is the state showing the outcome of deletions.
	StateResults // Renamed from stateResults

)

Jump to

Keyboard shortcuts

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