tui

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg *config.Config, st *state.DB) tea.Model

New creates a new TUI model that implements the tea.Model interface. It orchestrates the MVC components: TUIModel, TUIView, and TUIController.

Types

type TUIController

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

TUIController manages user interaction state and event handling for the TUI.

func NewTUIController

func NewTUIController(model *TUIModel, view *TUIView) *TUIController

NewTUIController creates a new TUIController instance with the given model and view.

func (*TUIController) Init

func (c *TUIController) Init() tea.Cmd

Init initializes the controller by loading download rows and starting the tick command.

func (*TUIController) SetModel

func (c *TUIController) SetModel(m tea.Model)

SetModel sets the reference to the main tea.Model instance for proper orchestration.

func (*TUIController) Update

func (c *TUIController) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles incoming messages and updates the controller state accordingly. (important-comment)

type TUIModel

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

TUIModel manages core data and business logic for the TUI application.

func NewTUIModel

func NewTUIModel(cfg *config.Config, st *state.DB) *TUIModel

NewTUIModel creates a new TUIModel instance with the given configuration and state database.

func (*TUIModel) AddEphemeral

func (m *TUIModel) AddEphemeral(url, dest string, headers map[string]string, sha string)

AddEphemeral adds an ephemeral download state for the given URL and destination.

func (*TUIModel) DestGuess

func (m *TUIModel) DestGuess(url string) string

DestGuess generates a suggested destination path for the given URL.

func (*TUIModel) FilteredRows

func (m *TUIModel) FilteredRows(statuses []string) []state.DownloadRow

FilteredRows returns download rows filtered by the given status list.

func (*TUIModel) GetEphems

func (m *TUIModel) GetEphems() map[string]ephemeral

GetEphems returns the ephemeral download states.

func (*TUIModel) GetPrev

func (m *TUIModel) GetPrev() map[string]obs

GetPrev returns the previous observation states.

func (*TUIModel) GetRows

func (m *TUIModel) GetRows() []state.DownloadRow

GetRows returns the current download rows.

func (*TUIModel) GetRunning

func (m *TUIModel) GetRunning() map[string]context.CancelFunc

GetRunning returns a snapshot of currently running downloads with their cancel functions.

func (*TUIModel) LoadRows

func (m *TUIModel) LoadRows() error

LoadRows loads download rows from the state database.

func (*TUIModel) PreflightForDownload

func (m *TUIModel) PreflightForDownload(url, dest string) error

PreflightForDownload performs preflight checks before starting a download.

func (*TUIModel) ProgressFor

func (m *TUIModel) ProgressFor(url, dest string) (int64, int64, string)

ProgressFor returns the progress information for a specific download.

func (*TUIModel) StartDownload

func (m *TUIModel) StartDownload(ctx context.Context, urlStr, dest, sha string, headers map[string]string) error

StartDownload initiates a new download with URL resolution and authentication.

type TUIView

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

TUIView handles all rendering logic and UI presentation for the TUI.

func NewTUIView

func NewTUIView() *TUIView

NewTUIView creates a new TUIView instance with default styling and progress bar.

func (*TUIView) SetSize

func (v *TUIView) SetSize(width, height int)

SetSize updates the view dimensions for responsive rendering.

func (*TUIView) View

func (v *TUIView) View(model *TUIModel, controller *TUIController) string

View renders the complete TUI interface based on the current model and controller state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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