ui

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompactDensityVal  = "compact"
	SpaciousDensityVal = "spacious"
)

Density configuration values

View Source
const (
	PaginatorDots   = "dots"
	PaginatorArabic = "arabic"
)

Variables

View Source
var (
	ErrCannotPreview = errors.New("cannot preview")
	ErrInputCanceled = errors.New("input is canceled")
)

Common errors

Functions

func Confirm

func Confirm(prompt string) bool

func ConfirmYes added in v1.6.0

func ConfirmYes(prompt string) bool

func InputFilename

func InputFilename(file *trash.File) (string, error)

func Render added in v1.5.0

func Render(manager *trash.Manager, files []*trash.File, cfg *config.Config) ([]*trash.File, error)

Render displays the file selection interface and returns the selected files

Types

type ConfirmState added in v1.6.0

type ConfirmState string

ConfirmState represents the confirmation dialog state

const (
	ConfirmStateYesNo   ConfirmState = "yn"
	ConfirmStateTypeYES ConfirmState = "yes"
)

type DateFormat added in v1.5.0

type DateFormat string

DateFormat represents the date display format

const (
	DateFormatRelative DateFormat = "relative"
	DateFormatAbsolute DateFormat = "absolute"
)

type File

type File struct {
	*trash.File
	// contains filtered or unexported fields
}

func (File) Browse

func (f File) Browse() (string, error)

func (File) Description

func (f File) Description() string

func (File) FilterValue

func (f File) FilterValue() string

func (File) Size

func (f File) Size() string

func (File) Title

func (f File) Title() string

type FileListLoadedMsg added in v1.5.0

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

FileListLoadedMsg indicates the initial file list has been loaded

type FileListUpdatedMsg added in v1.5.0

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

FileListUpdatedMsg represents an update to the existing file list

type ListDensityType

type ListDensityType uint8

ListDensityType represents the density of the list view

const (
	// Compact shows items without descriptions
	Compact ListDensityType = iota
	// Spacious shows items with descriptions
	Spacious
)

type Model

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

Model represents the main UI model following the Bubble Tea pattern

func NewModel added in v1.5.0

func NewModel(manager *trash.Manager, files []*trash.File, cfg *config.Config) Model

NewModel creates a new UI model instance

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model

func (Model) Update

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

Update handles all UI state updates based on incoming messages

func (Model) View

func (m Model) View() string

View returns the string representation of the current UI state

type RestoreDelegate

type RestoreDelegate struct {
	Styles        RestoreItemStyles
	UpdateFunc    func(tea.Msg, *list.Model) tea.Cmd
	ShortHelpFunc func() []key.Binding
	FullHelpFunc  func() [][]key.Binding
	// contains filtered or unexported fields
}

func NewRestoreDelegate

func NewRestoreDelegate(cfg config.UI, files []File) RestoreDelegate

NewRestoreDelegate creates a new delegate with Restore styles.

func (RestoreDelegate) FullHelp

func (d RestoreDelegate) FullHelp() [][]key.Binding

func (RestoreDelegate) Height

func (d RestoreDelegate) Height() int

func (RestoreDelegate) Render

func (d RestoreDelegate) Render(w io.Writer, m list.Model, index int, item list.Item)

func (RestoreDelegate) ShortHelp

func (d RestoreDelegate) ShortHelp() []key.Binding

func (RestoreDelegate) Spacing

func (d RestoreDelegate) Spacing() int

func (RestoreDelegate) Update

func (d RestoreDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd

type RestoreItem

type RestoreItem interface {
	list.Item
	Title() string
	Description() string
}

RestoreItem describes an item designed to work with RestoreDelegate.

type RestoreItemStyles

type RestoreItemStyles struct {
	NormalTitle lipgloss.Style
	NormalDesc  lipgloss.Style

	CursorTitle lipgloss.Style
	CursorDesc  lipgloss.Style

	SelectedTitle lipgloss.Style
	SelectedDesc  lipgloss.Style

	SelectedCursorTitle lipgloss.Style
	SelectedCursorDesc  lipgloss.Style

	DimmedTitle lipgloss.Style
	DimmedDesc  lipgloss.Style

	FilterMatch  lipgloss.Style
	FilterPrompt lipgloss.Style
}

func NewRestoreItemStyles

func NewRestoreItemStyles(cfg config.UI) (s RestoreItemStyles)

type SelectionManager

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

func (*SelectionManager) Add

func (r *SelectionManager) Add(item File)

func (*SelectionManager) Contains

func (r *SelectionManager) Contains(item File) bool

func (*SelectionManager) IndexOf

func (r *SelectionManager) IndexOf(item File) int

func (*SelectionManager) Remove

func (r *SelectionManager) Remove(item File)

type ShowDetailMsg added in v1.5.0

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

ShowDetailMsg represents a request to switch to detail view

type ViewState added in v1.5.0

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

func NewViewState added in v1.5.0

func NewViewState() *ViewState

NewViewState creates a new ViewState with default values

func (*ViewState) BackspaceYesInput added in v1.6.0

func (v *ViewState) BackspaceYesInput()

BackspaceYesInput removes the last character from YES input

func (*ViewState) ClearYesInput added in v1.6.0

func (v *ViewState) ClearYesInput()

ClearYesInput clears the YES input

func (*ViewState) FormatDate added in v1.5.0

func (v *ViewState) FormatDate(t time.Time) string

FormatDate formats the given time according to the current date format

func (*ViewState) IsYesComplete added in v1.6.0

func (v *ViewState) IsYesComplete() bool

IsYesComplete checks if the complete "YES" has been entered

func (*ViewState) SetConfirmState added in v1.6.0

func (v *ViewState) SetConfirmState(state ConfirmState, files []File)

SetConfirmState sets the confirmation dialog state

func (*ViewState) SetView added in v1.5.0

func (v *ViewState) SetView(newView ViewType)

SetView changes the current view and updates the previous view

func (*ViewState) ToggleDateFormat added in v1.5.0

func (v *ViewState) ToggleDateFormat()

ToggleDateFormat switches between relative and absolute date formats

func (*ViewState) ToggleOriginPath added in v1.5.0

func (v *ViewState) ToggleOriginPath()

ToggleOriginPath switches between showing origin and trash paths

func (*ViewState) UpdateYesInput added in v1.6.0

func (v *ViewState) UpdateYesInput(char string)

UpdateYesInput updates the YES input state

type ViewType

type ViewType uint8

ViewType represents the current view state

const (
	ListView ViewType = iota
	DetailView
	ConfirmView
	Quitting
)

func (ViewType) String added in v1.5.0

func (v ViewType) String() string

Directories

Path Synopsis
components

Jump to

Keyboard shortcuts

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