tui

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GraphUpdateInterval is the interval at which the speed history is updated (polling rate)
	GraphUpdateInterval = 500 * time.Millisecond

	// GraphHistoryPoints is the number of data points to keep in history
	// 60 points * 0.5s interval = 30 seconds of history
	GraphHistoryPoints = 60
)
View Source
const (
	// === Timeouts and Intervals ===
	TickInterval = 200 * time.Millisecond

	// === Layout Ratios ===
	ListWidthRatio         = 0.6  // Dashboard: List takes 60% width
	SettingsWidthRatio     = 0.72 // Modals: Settings/Category use 72% width
	LogoWidthRatio         = 0.45 // Header: Logo takes 45% of left column
	GraphTargetHeightRatio = 0.4  // Right Column: Graph target 40% height

	// === Thresholds and Minimums ===
	MinTermWidth             = 45
	MinTermHeight            = 12
	ShortTermHeightThreshold = 25 // Switch to compact header below this height

	MinSettingsWidth      = 64
	MaxSettingsWidth      = 130
	MinSettingsHeight     = 12
	DefaultSettingsHeight = 26

	MinRightColumnWidth = 50 // Hide right column if narrow
	MinGraphStatsWidth  = 50 // Show inline graph stats whenever right column is visible
	MinLogoWidth        = 40 // Hide ASCII logo if narrow

	MinGraphHeight      = 9
	MinGraphHeightShort = 5
	MinListHeight       = 10
	MinChunkMapHeight   = 4
	MinChunkMapVisibleH = 18 // Min term height to show chunk map

	// === Component Heights ===
	ModalHeightPadding = 4 // Bottom fallback padding for modals to avoid clipping
	HeaderHeightMax    = 11
	HeaderHeightMin    = 3
	FilePickerHeight   = 12
	CardHeight         = 2 // Compact rows for downloads list

	// === Padding and Offsets ===
	DefaultPaddingX        = 1
	DefaultPaddingY        = 0
	PopupPaddingX          = 2
	PopupPaddingY          = 1
	PopupWidth             = 70 // Consistent width for small popup dialogs
	HeaderWidthOffset      = 2
	ProgressBarWidthOffset = 4

	// === Layout Offsets (Clean Math) ===
	InternalPaddingHeight = 2 // Standard internal vertical padding
	InternalPaddingWidth  = 2 // Standard internal horizontal padding
	FooterHeight          = 1 // Application-wide footer height (keybindings)
	DividerHeight         = 1 // Horizontal/Vertical divider line

	// === Graph Configuration ===
	GraphAxisWidth  = 10
	GraphStatsWidth = 18
	GraphHeadroom   = 1.1 // Scale max speed by 110% for visual headroom

	// === Input Dimensions ===
	InputWidth        = 40
	MinSettingsInputW = 8
	MaxSettingsInputW = 48

	// === Channel Buffers ===
	ProgressChannelBuffer = types.ProgressChannelBuffer

	// === Units ===
	KB = types.KB
	MB = types.MB
	GB = types.GB
)
View Source
const (
	TabQueued = 0
	TabActive = 1
	TabDone   = 2
)

Variables

View Source
var (
	AppStyle          lipgloss.Style
	PaneStyle         lipgloss.Style
	ActivePaneStyle   lipgloss.Style
	LogoStyle         lipgloss.Style
	GraphStyle        lipgloss.Style
	ListStyle         lipgloss.Style
	DetailStyle       lipgloss.Style
	TitleStyle        lipgloss.Style
	PaneTitleStyle    lipgloss.Style
	TabStyle          lipgloss.Style
	ActiveTabStyle    lipgloss.Style
	StatsLabelStyle   lipgloss.Style
	StatsValueStyle   lipgloss.Style
	LogStyleStarted   lipgloss.Style
	LogStyleComplete  lipgloss.Style
	LogStyleError     lipgloss.Style
	LogStylePaused    lipgloss.Style
	WindowStyle       lipgloss.Style
	BoxStyle          lipgloss.Style
	ModalPaddingStyle lipgloss.Style
	LayoutGapStyle    lipgloss.Style
	EmptyMessageStyle lipgloss.Style
)

=== Layout Styles ===

View Source
var Keys = KeyMap{
	Dashboard: DashboardKeyMap{
		TabQueued: key.NewBinding(
			key.WithKeys("q"),
			key.WithHelp("q", "queued tab"),
		),
		TabActive: key.NewBinding(
			key.WithKeys("w"),
			key.WithHelp("w", "active tab"),
		),
		TabDone: key.NewBinding(
			key.WithKeys("e"),
			key.WithHelp("e", "done tab"),
		),
		NextTab: key.NewBinding(
			key.WithKeys("tab"),
			key.WithHelp("tab", "next tab"),
		),
		Add: key.NewBinding(
			key.WithKeys("a"),
			key.WithHelp("a", "add download"),
		),
		BatchImport: key.NewBinding(
			key.WithKeys("b", "B"),
			key.WithHelp("b", "batch import"),
		),
		Search: key.NewBinding(
			key.WithKeys("f"),
			key.WithHelp("f", "search"),
		),
		Pause: key.NewBinding(
			key.WithKeys("p"),
			key.WithHelp("p", "pause/resume"),
		),
		Refresh: key.NewBinding(
			key.WithKeys("r"),
			key.WithHelp("r", "refresh url"),
		),
		Delete: key.NewBinding(
			key.WithKeys("x"),
			key.WithHelp("x", "delete"),
		),
		Settings: key.NewBinding(
			key.WithKeys("s"),
			key.WithHelp("s", "settings"),
		),
		Log: key.NewBinding(
			key.WithKeys("l"),
			key.WithHelp("l", "toggle log"),
		),
		ToggleHelp: key.NewBinding(
			key.WithKeys("h"),
			key.WithHelp("h", "keybindings"),
		),
		ReportBug: key.NewBinding(
			key.WithKeys("?"),
			key.WithHelp("?", "report bug"),
		),
		OpenFile: key.NewBinding(
			key.WithKeys("o"),
			key.WithHelp("o", "open file"),
		),
		Quit: key.NewBinding(
			key.WithKeys("ctrl+c", "ctrl+q"),
			key.WithHelp("ctrl+q", "quit"),
		),
		ForceQuit: key.NewBinding(
			key.WithKeys("ctrl+c"),
			key.WithHelp("ctrl+c", "force quit"),
		),
		CategoryFilter: key.NewBinding(
			key.WithKeys("c"),
			key.WithHelp("c", "category"),
		),
		Up: key.NewBinding(
			key.WithKeys("up", "k"),
			key.WithHelp("\u2191/k", "up"),
		),
		Down: key.NewBinding(
			key.WithKeys("down", "j"),
			key.WithHelp("\u2193/j", "down"),
		),
		LogUp: key.NewBinding(
			key.WithKeys("up", "k"),
			key.WithHelp("\u2191/k", "scroll up"),
		),
		LogDown: key.NewBinding(
			key.WithKeys("down", "j"),
			key.WithHelp("\u2193/j", "scroll down"),
		),
		LogTop: key.NewBinding(
			key.WithKeys("g"),
			key.WithHelp("g", "top"),
		),
		LogBottom: key.NewBinding(
			key.WithKeys("G"),
			key.WithHelp("G", "bottom"),
		),
		LogClose: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "close log"),
		),
	},
	Input: InputKeyMap{
		Tab: key.NewBinding(
			key.WithKeys("tab"),
			key.WithHelp("tab", "browse/next"),
		),
		Enter: key.NewBinding(
			key.WithKeys("enter"),
			key.WithHelp("enter", "confirm/next"),
		),
		Esc: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "cancel"),
		),
		Up: key.NewBinding(
			key.WithKeys("up"),
			key.WithHelp("\u2191", "previous"),
		),
		Down: key.NewBinding(
			key.WithKeys("down"),
			key.WithHelp("\u2193", "next"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "cancel"),
		),
	},
	FilePicker: FilePickerKeyMap{
		UseDir: key.NewBinding(
			key.WithKeys("enter"),
			key.WithHelp("enter", "use current"),
		),
		GotoHome: key.NewBinding(
			key.WithKeys("h", "H"),
			key.WithHelp("h", "home"),
		),
		Back: key.NewBinding(
			key.WithKeys("left"),
			key.WithHelp("\u2190", "back"),
		),
		Forward: key.NewBinding(
			key.WithKeys("right"),
			key.WithHelp("\u2192", "open"),
		),
		Open: key.NewBinding(
			key.WithKeys("."),
			key.WithHelp(".", "select highlighted"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "cancel"),
		),
	},
	Duplicate: DuplicateKeyMap{
		Continue: key.NewBinding(
			key.WithKeys("c", "C"),
			key.WithHelp("c", "continue"),
		),
		Focus: key.NewBinding(
			key.WithKeys("f", "F"),
			key.WithHelp("f", "focus existing"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("x", "X", "esc"),
			key.WithHelp("x", "cancel"),
		),
	},
	Extension: ExtensionKeyMap{
		Confirm: key.NewBinding(
			key.WithKeys("enter"),
			key.WithHelp("enter", "confirm"),
		),
		Browse: key.NewBinding(
			key.WithKeys("tab"),
			key.WithHelp("tab", "browse path"),
		),
		Next: key.NewBinding(
			key.WithKeys("down"),
			key.WithHelp("\u2193", "next field"),
		),
		Prev: key.NewBinding(
			key.WithKeys("up"),
			key.WithHelp("\u2191", "prev field"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "cancel"),
		),
	},
	Settings: SettingsKeyMap{
		Tab1: key.NewBinding(
			key.WithKeys("1"),
			key.WithHelp("1", "general"),
		),
		Tab2: key.NewBinding(
			key.WithKeys("2"),
			key.WithHelp("2", "network"),
		),
		Tab3: key.NewBinding(
			key.WithKeys("3"),
			key.WithHelp("3", "performance"),
		),
		Tab4: key.NewBinding(
			key.WithKeys("4"),
			key.WithHelp("4", "categories"),
		),
		Tab5: key.NewBinding(
			key.WithKeys("5"),
			key.WithHelp("5", "extension"),
		),
		NextTab: key.NewBinding(
			key.WithKeys("right"),
			key.WithHelp("\u2192", "next tab"),
		),
		PrevTab: key.NewBinding(
			key.WithKeys("left"),
			key.WithHelp("\u2190", "prev tab"),
		),
		Browse: key.NewBinding(
			key.WithKeys("tab"),
			key.WithHelp("tab", "browse dir"),
		),
		Edit: key.NewBinding(
			key.WithKeys("enter"),
			key.WithHelp("enter", "edit"),
		),
		Up: key.NewBinding(
			key.WithKeys("up", "k"),
			key.WithHelp("\u2191/k", "up"),
		),
		Down: key.NewBinding(
			key.WithKeys("down", "j"),
			key.WithHelp("\u2193/j", "down"),
		),
		Reset: key.NewBinding(
			key.WithKeys("r", "R"),
			key.WithHelp("r", "reset"),
		),
		Close: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "save & close"),
		),
	},
	SettingsEditor: SettingsEditorKeyMap{
		Confirm: key.NewBinding(
			key.WithKeys("enter"),
			key.WithHelp("enter", "confirm"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "cancel"),
		),
	},
	BatchConfirm: BatchConfirmKeyMap{
		Confirm: key.NewBinding(
			key.WithKeys("y", "Y", "enter"),
			key.WithHelp("y", "confirm"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("n", "N", "esc"),
			key.WithHelp("n", "cancel"),
		),
	},
	Update: UpdateKeyMap{
		OpenGitHub: key.NewBinding(
			key.WithKeys("o", "O", "enter"),
			key.WithHelp("o", "open on github"),
		),
		IgnoreNow: key.NewBinding(
			key.WithKeys("i", "I", "esc"),
			key.WithHelp("i", "ignore for now"),
		),
		NeverRemind: key.NewBinding(
			key.WithKeys("n", "N"),
			key.WithHelp("n", "never remind"),
		),
	},
	BugReport: BugReportKeyMap{
		Core: key.NewBinding(
			key.WithKeys("1", "c", "C"),
			key.WithHelp("1", "core report"),
		),
		Extension: key.NewBinding(
			key.WithKeys("2", "e", "E"),
			key.WithHelp("2", "extension report"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("esc"),
			key.WithHelp("esc", "cancel"),
		),
	},
	CategoryMgr: CategoryManagerKeyMap{
		Up:     key.NewBinding(key.WithKeys("up", "k"), key.WithHelp("\u2191/k", "up")),
		Down:   key.NewBinding(key.WithKeys("down", "j"), key.WithHelp("\u2193/j", "down")),
		Edit:   key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "edit")),
		Add:    key.NewBinding(key.WithKeys("a"), key.WithHelp("a", "add")),
		Delete: key.NewBinding(key.WithKeys("x"), key.WithHelp("x", "delete")),
		Toggle: key.NewBinding(key.WithKeys("t"), key.WithHelp("t", "toggle")),
		Tab:    key.NewBinding(key.WithKeys("tab"), key.WithHelp("tab", "next field")),
		Close:  key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "save & close")),
	},
	QuitConfirm: QuitConfirmKeyMap{
		Left: key.NewBinding(
			key.WithKeys("left", "h"),
		),
		Right: key.NewBinding(
			key.WithKeys("right", "l", "tab"),
		),
		Yes: key.NewBinding(
			key.WithKeys("y", "Y"),
		),
		No: key.NewBinding(
			key.WithKeys("n", "N"),
		),
		Select: key.NewBinding(
			key.WithKeys("enter", "space"),
			key.WithHelp("y/enter", "confirm"),
		),
		Cancel: key.NewBinding(
			key.WithKeys("esc", "ctrl+c", "ctrl+q"),
			key.WithHelp("n/esc", "cancel"),
		),
	},
}

Keys contains all the keybindings for the application

Functions

func ApplyGradient

func ApplyGradient(text string, startColor, endColor color.Color) string

ApplyGradient applies a vertical gradient to a multi-line string

func CalculateTwoColumnWidths added in v0.8.0

func CalculateTwoColumnWidths(modalWidth, preferredLeft, minRight int) (int, int)

CalculateTwoColumnWidths calculates the distribution of widths for a two-column modal layout.

func GetAuthToken added in v0.8.0

func GetAuthToken() string

GetAuthToken returns the cached authentication token.

func GetDynamicModalDimensions added in v0.8.2

func GetDynamicModalDimensions(termW, termH, minW, minH, prefW, contentH int) (int, int)

GetDynamicModalDimensions calculates safe dimensions for a modal based on content and terminal size.

func GetGraphAreaDimensions added in v0.8.0

func GetGraphAreaDimensions(rightWidth int, isStatsHidden bool) (int, int)

GetGraphAreaDimensions calculates dimensions for the graph area

func GetHeaderHeight added in v0.8.0

func GetHeaderHeight(termHeight int) int

GetHeaderHeight returns the appropriate header height based on terminal height

func GetListWidth added in v0.8.0

func GetListWidth(availableWidth int) int

GetListWidth calculates the list width based on available width

func GetMinGraphHeight added in v0.8.0

func GetMinGraphHeight(termHeight int) int

GetMinGraphHeight returns the minimum graph height based on terminal height

func GetSettingsDimensions added in v0.8.0

func GetSettingsDimensions(termWidth, termHeight int) (int, int)

GetSettingsDimensions calculates dimensions for settings/category modals

func InitAuthToken added in v0.8.0

func InitAuthToken()

InitAuthToken reads the authentication token from disk and caches it in memory. This is called once at startup to avoid re-reading from disk on every frame layout.

func InitializeStyles added in v0.8.2

func InitializeStyles()

func InitializeTUI added in v0.8.2

func InitializeTUI()

InitializeTUI prepares global TUI state like styles and component caches. This should be called exactly once before any TUI elements are rendered.

func IsShortTerminal added in v0.8.0

func IsShortTerminal(height int) bool

IsShortTerminal returns true if the terminal height is below the threshold

func NewDownloadList

func NewDownloadList(width, height int) list.Model

NewDownloadList creates a new list.Model configured for downloads

Types

type BatchConfirmKeyMap

type BatchConfirmKeyMap struct {
	Confirm key.Binding
	Cancel  key.Binding
}

BatchConfirmKeyMap defines keybindings for batch import confirmation

func (BatchConfirmKeyMap) FullHelp

func (k BatchConfirmKeyMap) FullHelp() [][]key.Binding

func (BatchConfirmKeyMap) ShortHelp

func (k BatchConfirmKeyMap) ShortHelp() []key.Binding

type BugReportKeyMap added in v0.8.3

type BugReportKeyMap struct {
	Core      key.Binding
	Extension key.Binding
	Cancel    key.Binding
}

BugReportKeyMap defines keybindings for selecting bug report target.

func (BugReportKeyMap) FullHelp added in v0.8.3

func (k BugReportKeyMap) FullHelp() [][]key.Binding

func (BugReportKeyMap) ShortHelp added in v0.8.3

func (k BugReportKeyMap) ShortHelp() []key.Binding

type CategoryManagerKeyMap

type CategoryManagerKeyMap struct {
	Up     key.Binding
	Down   key.Binding
	Edit   key.Binding
	Add    key.Binding
	Delete key.Binding
	Toggle key.Binding // toggle enable/disable
	Tab    key.Binding
	Close  key.Binding
}

CategoryManagerKeyMap defines keybindings for the category manager

func (CategoryManagerKeyMap) FullHelp

func (k CategoryManagerKeyMap) FullHelp() [][]key.Binding

func (CategoryManagerKeyMap) ShortHelp

func (k CategoryManagerKeyMap) ShortHelp() []key.Binding

type DashboardKeyMap

type DashboardKeyMap struct {
	TabQueued      key.Binding
	TabActive      key.Binding
	TabDone        key.Binding
	NextTab        key.Binding
	Add            key.Binding
	BatchImport    key.Binding
	Search         key.Binding
	Pause          key.Binding
	Refresh        key.Binding
	Delete         key.Binding
	Settings       key.Binding
	Log            key.Binding
	ToggleHelp     key.Binding
	ReportBug      key.Binding
	OpenFile       key.Binding
	Quit           key.Binding
	ForceQuit      key.Binding
	CategoryFilter key.Binding
	// Navigation
	Up   key.Binding
	Down key.Binding
	// Log Navigation
	LogUp     key.Binding
	LogDown   key.Binding
	LogTop    key.Binding
	LogBottom key.Binding
	LogClose  key.Binding
}

DashboardKeyMap defines keybindings for the main dashboard

func (DashboardKeyMap) FullHelp

func (k DashboardKeyMap) FullHelp() [][]key.Binding

FullHelp returns keybindings for the expanded help view

func (DashboardKeyMap) ShortHelp

func (k DashboardKeyMap) ShortHelp() []key.Binding

ShortHelp returns keybindings to show in the mini help view

type DashboardLayout added in v0.8.2

type DashboardLayout struct {
	AvailableWidth  int
	AvailableHeight int

	// Columns
	LeftWidth  int
	RightWidth int

	// Header
	LogoWidth    int
	LogWidth     int
	HeaderHeight int

	// Download List
	ListWidth    int
	ListHeight   int
	TabBarHeight int

	// Right Column components
	GraphHeight     int
	MinGraphHeight  int
	DetailHeight    int
	ChunkMapHeight  int
	ShowChunkMap    bool
	HideRightColumn bool
	VerticalLayout  bool
}

DashboardLayout holds all calculated dimensions for the dashboard components.

func CalculateDashboardLayout added in v0.8.2

func CalculateDashboardLayout(termW, termH int) DashboardLayout

CalculateDashboardLayout computes the layout mapping for all dashboard components based on terminal size.

type DownloadItem

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

DownloadItem implements list.Item interface for downloads

func (DownloadItem) Description

func (i DownloadItem) Description() string

func (DownloadItem) FilterValue

func (i DownloadItem) FilterValue() string

func (DownloadItem) Title

func (i DownloadItem) Title() string

type DownloadModel

type DownloadModel struct {
	ID            string
	URL           string
	Filename      string
	FilenameLower string
	Destination   string // Full path to the destination file
	Total         int64
	Downloaded    int64
	Speed         float64
	Connections   int

	StartTime time.Time
	Elapsed   time.Duration
	// contains filtered or unexported fields
}

func NewDownloadModel

func NewDownloadModel(id string, url string, filename string, total int64) *DownloadModel

NewDownloadModel creates a new download model

type DuplicateKeyMap

type DuplicateKeyMap struct {
	Continue key.Binding
	Focus    key.Binding
	Cancel   key.Binding
}

DuplicateKeyMap defines keybindings for duplicate warning

func (DuplicateKeyMap) FullHelp

func (k DuplicateKeyMap) FullHelp() [][]key.Binding

func (DuplicateKeyMap) ShortHelp

func (k DuplicateKeyMap) ShortHelp() []key.Binding

type ExtensionKeyMap

type ExtensionKeyMap struct {
	Confirm key.Binding
	Browse  key.Binding
	Next    key.Binding
	Prev    key.Binding
	Cancel  key.Binding
}

ExtensionKeyMap defines keybindings for extension confirmation

func (ExtensionKeyMap) FullHelp

func (k ExtensionKeyMap) FullHelp() [][]key.Binding

func (ExtensionKeyMap) ShortHelp

func (k ExtensionKeyMap) ShortHelp() []key.Binding

type FilePickerKeyMap

type FilePickerKeyMap struct {
	UseDir   key.Binding
	GotoHome key.Binding
	Back     key.Binding
	Forward  key.Binding
	Open     key.Binding
	Cancel   key.Binding
}

FilePickerKeyMap defines keybindings for the file picker

func (FilePickerKeyMap) FullHelp

func (k FilePickerKeyMap) FullHelp() [][]key.Binding

func (FilePickerKeyMap) ShortHelp

func (k FilePickerKeyMap) ShortHelp() []key.Binding

type FilePickerOrigin added in v0.8.2

type FilePickerOrigin int
const (
	FilePickerOriginNone FilePickerOrigin = iota
	FilePickerOriginAdd
	FilePickerOriginSettings
	FilePickerOriginExtension
	FilePickerOriginCategory
	FilePickerOriginTheme
)

type GraphStats

type GraphStats struct {
	DownloadSpeed float64 // Current download speed in MB/s
	DownloadTop   float64 // Top download speed in MB/s
	DownloadTotal int64   // Total downloaded bytes
}

GraphStats contains the statistics to overlay on the graph

type InputKeyMap

type InputKeyMap struct {
	Tab    key.Binding
	Enter  key.Binding
	Esc    key.Binding
	Up     key.Binding
	Down   key.Binding
	Cancel key.Binding
}

InputKeyMap defines keybindings for the add download input

func (InputKeyMap) FullHelp

func (k InputKeyMap) FullHelp() [][]key.Binding

func (InputKeyMap) ShortHelp

func (k InputKeyMap) ShortHelp() []key.Binding

type KeyMap

type KeyMap struct {
	Dashboard      DashboardKeyMap
	Input          InputKeyMap
	FilePicker     FilePickerKeyMap
	Duplicate      DuplicateKeyMap
	Extension      ExtensionKeyMap
	Settings       SettingsKeyMap
	SettingsEditor SettingsEditorKeyMap
	BatchConfirm   BatchConfirmKeyMap
	Update         UpdateKeyMap
	BugReport      BugReportKeyMap
	CategoryMgr    CategoryManagerKeyMap
	QuitConfirm    QuitConfirmKeyMap
}

KeyMap defines the keybindings for the entire application

type QuitConfirmKeyMap

type QuitConfirmKeyMap struct {
	Left   key.Binding
	Right  key.Binding
	Yes    key.Binding
	No     key.Binding
	Select key.Binding
	Cancel key.Binding
}

QuitConfirmKeyMap defines keybindings for the quit confirmation modal

func (QuitConfirmKeyMap) FullHelp

func (k QuitConfirmKeyMap) FullHelp() [][]key.Binding

func (QuitConfirmKeyMap) ShortHelp

func (k QuitConfirmKeyMap) ShortHelp() []key.Binding

type RootModel

type RootModel struct {

	// Service Interface
	// Core
	Service      core.DownloadService
	Orchestrator *processing.LifecycleManager

	PWD string

	// Graph Data
	SpeedHistory []float64 // Stores the last ~60 ticks of speed data

	// Settings
	Settings            *config.Settings // Application settings
	SettingsBaseline    *config.Settings // Snapshot of settings when entering the settings view
	SettingsActiveTab   int              // Active category tab (0-3)
	SettingsSelectedRow int              // Selected setting within current tab
	SettingsIsEditing   bool             // Whether currently editing a value
	SettingsInput       textinput.Model  // Input for editing string/int values

	ExtensionTokenCopied bool // Flash message for "Token Copied!"

	// Selection persistence
	SelectedDownloadID string // ID of the currently selected download
	ManualTabSwitch    bool   // Whether the last tab switch was manual

	// Server port for display
	ServerPort int
	ServerHost string
	IsRemote   bool

	// Update check
	UpdateInfo     *version.UpdateInfo // Update information (nil if no update available)
	CurrentVersion string              // Current version of Surge
	CurrentCommit  string              // Current commit hash of Surge

	InitialDarkBackground bool // Captured at startup for "System" theme

	RestartRequested bool // Flag to signal process re-exec after TUI shutdown

	ToggleServiceFunc func(bool) error
	// contains filtered or unexported fields
}

func InitialRootModel

func InitialRootModel(serverPort int, currentVersion string, service core.DownloadService, orchestrator *processing.LifecycleManager, noResume bool, currentCommit ...string) RootModel

func (*RootModel) ApplyTheme

func (m *RootModel) ApplyTheme(mode int, path string)

ApplyTheme applies the selected theme mode

func (RootModel) ComputeViewStats

func (m RootModel) ComputeViewStats() ViewStats

func (*RootModel) FindDownloadByID

func (m *RootModel) FindDownloadByID(id string) *DownloadModel

FindDownloadByID finds a download by its ID

func (*RootModel) GetSelectedDownload

func (m *RootModel) GetSelectedDownload() *DownloadModel

GetSelectedDownload returns the currently selected download from the list

func (RootModel) Init

func (m RootModel) Init() tea.Cmd

func (RootModel) Update

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

Update handles messages and updates the model

func (*RootModel) UpdateListItems

func (m *RootModel) UpdateListItems()

UpdateListItems updates the list with filtered downloads based on active tab

func (RootModel) View

func (m RootModel) View() tea.View

func (RootModel) WithEnqueueContext

func (m RootModel) WithEnqueueContext(ctx context.Context, cancel context.CancelFunc) RootModel

WithEnqueueContext lets callers bind model-initiated probes to a process-level shutdown context instead of the model's default standalone context.

type SettingsEditorKeyMap

type SettingsEditorKeyMap struct {
	Confirm key.Binding
	Cancel  key.Binding
}

SettingsEditorKeyMap defines keybindings for editing a setting

func (SettingsEditorKeyMap) FullHelp

func (k SettingsEditorKeyMap) FullHelp() [][]key.Binding

func (SettingsEditorKeyMap) ShortHelp

func (k SettingsEditorKeyMap) ShortHelp() []key.Binding

type SettingsKeyMap

type SettingsKeyMap struct {
	Tab1    key.Binding
	Tab2    key.Binding
	Tab3    key.Binding
	Tab4    key.Binding
	Tab5    key.Binding
	NextTab key.Binding
	PrevTab key.Binding
	Browse  key.Binding
	Edit    key.Binding
	Up      key.Binding
	Down    key.Binding
	Reset   key.Binding
	Close   key.Binding
}

SettingsKeyMap defines keybindings for the settings view

func (SettingsKeyMap) FullHelp

func (k SettingsKeyMap) FullHelp() [][]key.Binding

func (SettingsKeyMap) ShortHelp

func (k SettingsKeyMap) ShortHelp() []key.Binding

type UIState

type UIState int // Defines UIState as int to be used in rootModel
const (
	DashboardState              UIState = iota // DashboardState is 0 increments after each line
	InputState                                 // InputState is 1
	DetailState                                // DetailState is 2
	FilePickerState                            // FilePickerState is 3
	DuplicateWarningState                      // DuplicateWarningState is 4
	SearchState                                // SearchState is 6
	SettingsState                              // SettingsState is 7
	ExtensionConfirmationState                 // ExtensionConfirmationState is 8
	BatchFilePickerState                       // BatchFilePickerState is 9
	BatchConfirmState                          // BatchConfirmState is 10
	UpdateAvailableState                       // UpdateAvailableState is 11
	URLUpdateState                             // URLUpdateState is 12
	CategoryManagerState                       // CategoryManagerState is 13
	QuitConfirmState                           // QuitConfirmState is 14
	RestartConfirmState                        // RestartConfirmState is 15
	HelpModalState                             // HelpModalState is 16
	BugReportTargetState                       // BugReportTargetState is 17
	BugReportSystemDetailsState                // BugReportSystemDetailsState is 18
	BugReportLogPathState                      // BugReportLogPathState is 19
	CategoryResetConfirmState                  // CategoryResetConfirmState is 20
)

type UpdateCheckResultMsg

type UpdateCheckResultMsg struct {
	Info *version.UpdateInfo
}

UpdateCheckResultMsg is sent when the update check is complete

type UpdateKeyMap

type UpdateKeyMap struct {
	OpenGitHub  key.Binding
	IgnoreNow   key.Binding
	NeverRemind key.Binding
}

UpdateKeyMap defines keybindings for update notification

func (UpdateKeyMap) FullHelp

func (k UpdateKeyMap) FullHelp() [][]key.Binding

func (UpdateKeyMap) ShortHelp

func (k UpdateKeyMap) ShortHelp() []key.Binding

type ViewStats

type ViewStats struct {
	ActiveCount     int
	QueuedCount     int
	DownloadedCount int
	TotalDownloaded int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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