tui

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Theme = struct {
	Primary   color.Color
	Secondary color.Color
	Border    color.Color
	Text      color.Color
	Faint     color.Color
	Success   color.Color
	Warning   color.Color
	Error     color.Color
	Gradient  []color.Color
}{
	Primary:   lipgloss.Color("#00d4ff"),
	Secondary: lipgloss.Color("#9d4edd"),
	Border:    lipgloss.Color("#444444"),
	Text:      lipgloss.Color("#e4e4e7"),
	Faint:     lipgloss.Color("#666666"),
	Success:   lipgloss.Color("#10b981"),
	Warning:   lipgloss.Color("#f59e0b"),
	Error:     lipgloss.Color("#ef4444"),
	Gradient: []color.Color{
		lipgloss.Color("#00d4ff"),
		lipgloss.Color("#00bfff"),
		lipgloss.Color("#6366f1"),
		lipgloss.Color("#a855f7"),
		lipgloss.Color("#d946ef"),
		lipgloss.Color("#f43f5e"),
	},
}

Theme holds all color constants for the TUI.

Functions

func DeleteKittyImageCmd added in v1.6.0

func DeleteKittyImageCmd(id uint32) tea.Cmd

DeleteKittyImageCmd returns a tea.Cmd that deletes a Kitty graphics image from terminal memory. Should be called when leaving the detail view or switching to a different image.

func DetectKittySupport added in v1.6.0

func DetectKittySupport() bool

DetectKittySupport checks if the terminal supports Kitty graphics protocol.

func DetectTrueColorSupport

func DetectTrueColorSupport() bool

DetectTrueColorSupport checks if the terminal supports 24-bit color.

func DownloadCoverImage

func DownloadCoverImage(url string) (image.Image, string, error)

DownloadCoverImage downloads an image from a URL and returns both the decoded image and the local cache file path.

func RenderCoverImage

func RenderCoverImage(img image.Image, maxWidth int, protocol Protocol, cachePath string, maxRows int) string

RenderCoverImage renders an image for the terminal, using the best available protocol. For Kitty protocol, returns the placeholder text (transmit seq is sent separately). maxRows limits the image height (0 = use protocol default).

func ResizeImage

func ResizeImage(img image.Image, maxWidth, maxHeight int) image.Image

ResizeImage resizes an image to fit within maxWidth x maxHeight while preserving aspect ratio, using high-quality CatmullRom scaling.

Types

type AniListLoginMsg added in v1.6.0

type AniListLoginMsg struct {
	Err error
}

AniListLoginMsg is sent when the AniList OAuth login flow completes.

type CoverImageLoadedMsg

type CoverImageLoadedMsg struct {
	Rendered         string // Rendered image (SGR half-block or Unicode placeholder text)
	KittyTransmitSeq string // APC sequence for Kitty graphics (empty for non-Kitty)
	KittyImageID     uint32 // Image ID for Kitty graphics cleanup
	Index            int    // Result index this cover belongs to
}

CoverImageLoadedMsg is sent when a cover image has been downloaded and rendered.

type EpisodeMetadataFetchTriggered

type EpisodeMetadataFetchTriggered struct {
	Index int
}

type EpisodeMetadataLoadedMsg

type EpisodeMetadataLoadedMsg struct {
	Metadata   *EpisodeMetadataPanel
	Index      int
	CacheKey   string         `json:"-"`
	RawEpisode *jikan.Episode `json:"-"`
}

type EpisodeMetadataPanel

type EpisodeMetadataPanel struct {
	Title         string
	TitleJapanese string
	Aired         string
	Score         float64
	Filler        bool
	Recap         bool
	Synopsis      string
	Duration      int
}

EpisodeMetadataPanel holds metadata for a single episode

type EpisodeState

type EpisodeState struct {
	AnimeID          string
	Episodes         []string
	EpisodeTitles    []string
	Selected         int
	Loading          bool
	Err              error
	EpisodeMetadata  *EpisodeMetadataPanel
	MetadataLoading  bool
	Playing          bool
	TrackingStatus   string // "CURRENT", "COMPLETED", etc.
	TrackingProgress int
}

EpisodeState holds the state for episode selection

func NewEpisodeState

func NewEpisodeState() *EpisodeState

NewEpisodeState creates a new episode state

type EpisodesLoadedMsg

type EpisodesLoadedMsg struct {
	Episodes      []string
	EpisodeTitles []string
	Error         error
}

type KittyRenderResult added in v1.6.0

type KittyRenderResult struct {
	TransmitSeq string
	Placeholder string
	ImageID     uint32
}

KittyRenderResult holds the output of rendering an image with the Kitty graphics protocol. TransmitSeq is sent via tea.Raw() to transmit the image to terminal memory. Placeholder is text with Unicode placeholders that tells the terminal where to display the stored image. ImageID is used to delete the image from terminal memory when no longer needed.

func RenderCoverImageKitty added in v1.6.0

func RenderCoverImageKitty(img image.Image, maxWidth int, protocol Protocol, cachePath string, maxRows int) KittyRenderResult

RenderCoverImageKitty renders an image using Kitty protocol and returns the full result including the APC transmit sequence. For non-Kitty protocols, the TransmitSeq will be empty.

func RenderKittyCover added in v1.6.0

func RenderKittyCover(img image.Image, cols, rows int) KittyRenderResult

RenderKittyCover renders an image using the Kitty graphics protocol with Unicode placeholders. Returns the APC transmit sequence (for tea.Raw) and the placeholder text (for view.Content).

type MetadataBatchLoadedMsg

type MetadataBatchLoadedMsg struct {
	MetadataMap map[int]*MetadataPanel
}

MetadataBatchLoadedMsg carries all metadata for a search result set.

type MetadataFetchTriggered

type MetadataFetchTriggered struct {
	Index int
}

type MetadataLoadedMsg

type MetadataLoadedMsg struct {
	Metadata *MetadataPanel
	Index    int
}

MetadataLoadedMsg is sent when a single API source returns.

type MetadataPanel

type MetadataPanel struct {
	Title        string
	TitleEnglish string
	TitleNative  string
	Cover        string
	CoverImage   string // Rendered ANSI cover art (half-block), empty if not available
	Year         int
	Type         string
	Status       string
	Episodes     int
	Score        float64
	Rank         int
	Popularity   int
	Genres       []string
	Synopsis     string
	Source       string // "Jikan", "AniList", or "Jikan + AniList"
}

MetadataPanel holds merged metadata to display on the right panel

type PlayStreamMsg

type PlayStreamMsg struct{}

type Protocol

type Protocol int

Protocol represents a terminal image rendering protocol.

const (
	ProtocolNone      Protocol = iota // No image protocol available
	ProtocolKitty                     // Kitty graphics protocol via Unicode placeholders
	ProtocolHalfBlock                 // ANSI half-block characters (SGR, works everywhere)
	ProtocolChafa                     // chafa unicode art (universal fallback)
)

func DetectTerminalProtocol

func DetectTerminalProtocol() Protocol

DetectTerminalProtocol returns the best image protocol for the current terminal.

Kitty graphics uses Unicode placeholders (\U0010EEEE + combining marks) that survive Bubbletea v2's ultraviolet cell buffer. The image data is transmitted via APC sequences using tea.Raw(), which bypasses the renderer entirely.

type SearchErrorMsg

type SearchErrorMsg struct {
	Err error
}

type SearchModel

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

func NewSearchModel

func NewSearchModel() *SearchModel

func (*SearchModel) GetSelectedAnime

func (m *SearchModel) GetSelectedAnime() *source.Anime

func (*SearchModel) Init

func (m *SearchModel) Init() tea.Cmd

func (*SearchModel) Update

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

func (*SearchModel) View

func (m *SearchModel) View() tea.View

type SearchResultsMsg

type SearchResultsMsg struct {
	Results []*source.Anime
}

type SearchState

type SearchState struct {
	Query           string
	Results         []*source.Anime
	Selected        int
	Metadata        *MetadataPanel
	Loading         bool
	MetadataLoading bool
	Err             error
	TranslationType string
}

SearchState holds the state for the anime search TUI

func NewSearchState

func NewSearchState() *SearchState

NewSearchState creates a new search state

type SelectionResult

type SelectionResult struct {
	Anime   *source.Anime
	Episode string
}

SelectionResult holds the selected anime and episode

func RunSearch

func RunSearch() (*SelectionResult, error)

type SettingsState

type SettingsState struct {
	Quality        string // "1080p", "720p", "480p", "360p", "auto"
	AniskipEnabled bool
	Cursor         int    // 0 = quality, 1 = aniskip, 2 = anilist, 3 = update
	UpdateStatus   string // "", "checking", "updated", "error"
	UpdateVersion  string // latest version tag, e.g. "v1.7.0"
	UpdateError    error
}

SettingsState holds the state for the settings popup

type TUIErrorMsg

type TUIErrorMsg struct {
	Err error
}

type TrackingStatusLoadedMsg added in v1.6.0

type TrackingStatusLoadedMsg struct {
	Status   string
	Progress int
}

TrackingStatusLoadedMsg is sent when the current tracking status for an anime is fetched.

type TrackingUpdateMsg added in v1.6.0

type TrackingUpdateMsg struct {
	Status   string
	Progress int
	Err      error
}

TrackingUpdateMsg is sent after a tracking progress update completes.

type UpdateCheckMsg added in v1.6.1

type UpdateCheckMsg struct {
	LatestVersion string
	Err           error
}

UpdateCheckMsg is sent after checking GitHub for the latest release.

type UpdateCompleteMsg added in v1.6.1

type UpdateCompleteMsg struct {
	Err error
}

UpdateCompleteMsg is sent after downloading and installing the update.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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