Documentation
¶
Overview ¶
Package tui is the terminal frontend.
It is a frontend on the same internal API the CLI uses, not a place where logic lives: every behaviour here is reachable headless. Two rules keep it honest, both from the spec:
- No blocking I/O in Update. Every device call and every disk scan returns a tea.Cmd, so the display never stalls behind a slow Wi-Fi link.
- Nothing writes to stdout or stderr. Those belong to the renderer; logs go to a file under XDG_STATE_HOME.
Index ¶
Constants ¶
const ( GlyphSynced = "●" // on the device and up to date GlyphPending = "◐" // needs upload or re-upload GlyphAbsent = "○" // not on the device GlyphOrphan = "✕" // on the device but not placed by shelf GlyphUnknown = "·" // no device selected, or status not yet known )
Sync-state glyphs for the per-device column in the library table.
Single characters chosen to be legible in a monospace column and to survive terminals with poor emoji support -- a book list is not the place to discover that your font lacks a glyph.
Variables ¶
This section is empty.
Functions ¶
func OpenLog ¶
OpenLog opens the TUI log file, creating its directory as needed.
The returned closer must be called on exit. If the file cannot be opened, logging is directed to io.Discard rather than failing: an unwritable log directory is not a reason to refuse to run.
func RenderCover ¶
func RenderCover(img image.Image, mode GraphicsMode, cols, rows int) string
RenderCover renders an image into a block of terminal text.
cols and rows are character cells. The image is scaled to fit while keeping its aspect ratio, assuming a cell is roughly twice as tall as it is wide.
Types ¶
type GraphicsMode ¶
type GraphicsMode string
GraphicsMode selects a rendering backend.
const ( GraphicsNone GraphicsMode = "none" GraphicsBlocks GraphicsMode = "ascii" GraphicsSixel GraphicsMode = "sixel" GraphicsKitty GraphicsMode = "kitty" )
func DetectGraphics ¶
func DetectGraphics(pref string) GraphicsMode
DetectGraphics chooses a backend.
pref comes from config ui.graphics and wins unless it is "auto". Detection is by environment only: querying the terminal means writing an escape sequence and reading the reply, which fights with Bubble Tea for the same file descriptor and can hang on a terminal that never answers.
type KeyMap ¶
type KeyMap struct {
// Navigation
Up key.Binding
Down key.Binding
Top key.Binding
Bottom key.Binding
PageUp key.Binding
PageDown key.Binding
// Screens
NextScreen key.Binding
PrevScreen key.Binding
Library key.Binding
Devices key.Binding
SyncScreen key.Binding
// Selection
Select key.Binding
VisualSel key.Binding
SelectAll key.Binding
ClearSel key.Binding
// Detail panel
Detail key.Binding
DetailUp key.Binding
DetailDown key.Binding
// Actions
Filter key.Binding
Sync key.Binding
SyncAll key.Binding
Refresh key.Binding
Confirm key.Binding
Cancel key.Binding
// Meta
Help key.Binding
Quit key.Binding
}
KeyMap is the global keymap. Vim-first, discoverable through bubbles/help.
Bindings live in one place rather than scattered across screens so the help view cannot drift out of sync with what the keys actually do.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the root tea.Model.
type Styles ¶
type Styles struct {
App lipgloss.Style
Title lipgloss.Style
TabActive lipgloss.Style
TabIdle lipgloss.Style
TabBar lipgloss.Style
Header lipgloss.Style
Row lipgloss.Style
RowAlt lipgloss.Style
Selected lipgloss.Style
Cursor lipgloss.Style
Status lipgloss.Style
Success lipgloss.Style
Warning lipgloss.Style
Error lipgloss.Style
Subtle lipgloss.Style
Accent lipgloss.Style
// Header
Rule lipgloss.Style
StatValue lipgloss.Style
StatLabel lipgloss.Style
// Detail panel
Panel lipgloss.Style
DetailTitle lipgloss.Style
DetailAuthor lipgloss.Style
Chip lipgloss.Style
Box lipgloss.Style
Progress lipgloss.Style
Help lipgloss.Style
}
Styles holds every lipgloss style the TUI uses.
Colors are given as adaptive pairs so the same build reads correctly on a light and a dark terminal; lipgloss picks per background at runtime.