ui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package ui implements the Bubble Tea terminal UI for docker-tui.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyLogEntries

func CopyLogEntries(entries []LogEntry) error

func CopyToClipboard

func CopyToClipboard(text string) error

func RenderRow

func RenderRow(totalWidth int, cells []Cell, rs RowStyle) string

RenderRow paints a full-width row with background-aware cells.

func ResolveLogTargetColor

func ResolveLogTargetColor(colors map[string]string, target LogTarget) string

func RowW

func RowW(termW int) int

func SetVersion

func SetVersion(v string)

SetVersion records the application version for display in the header.

func SortLogEntries

func SortLogEntries(entries []LogEntry)

func TableW

func TableW(termW int) int

Types

type Cell

type Cell struct {
	Text       string
	Width      int // target display width; 0 = natural
	FG         lipgloss.Color
	BG         lipgloss.Color // per-cell background (e.g. container tag); overrides row BG
	Bold       bool
	BarPercent float64 // when Bar is true, render a mini progress bar filling Width
	Bar        bool    // render BarPercent as a bar (including 0%)
}

Cell is one column in a rendered row.

type ColumnSpec added in v0.2.0

type ColumnSpec struct {
	Label    string
	Width    int // fixed display cells; when > 0, Percent and Min are ignored
	Percent  int // share of the flexible width, 0-100
	Min      int // floor below which the column is dropped instead of shrunk
	Priority int // higher drops first; 0 never drops
}

ColumnSpec declares one column's width policy. Views declare specs; the fitter turns them into concrete ListColumns for the available width.

type Command

type Command struct {
	Name        string
	Description string
	Run         func(Model) (Model, tea.Cmd)
}

type Frame

type Frame struct {
	TermW, TermH int
	RowW         int // highlight / row body width (termW - 5)
	TableW       int // column layout width (termW - 7)
	BodyRows     int // scrollable data rows
}

Frame holds measured terminal layout for a view.

type ListColumn

type ListColumn struct {
	Label string
	Width int
}

ListColumn describes one table column header.

func FitColumns added in v0.2.0

func FitColumns(specs []ColumnSpec, availW int) []ListColumn

FitColumns lays specs out into availW display columns, accounting for the single-space gap the row renderer places between columns. Columns are dropped highest-Priority-first when the remainder cannot honour every Min.

Precondition: the combined width of every priority-0 (never-drop) column, plus their gaps, should not exceed availW. If it does — e.g. a fixed-width priority-0 column alongside a flexible priority-0 column, as happens in the events view, the notifications view, and the detail identity line — the returned total can exceed availW. This only occurs at terminal widths far narrower than any real terminal (observed threshold: termW < 16 for the events case), so it is documented here rather than defended against.

FitColumns always returns exactly one ListColumn per surviving spec (never nil when specs is non-empty), even at availW <= 0 — callers may see very small or zero Widths, but RenderRow's fitCells/clampRenderedWidth machinery handles that overflow safely.

type ListRowKind

type ListRowKind int

ListRowKind selects marker and background styling for a list row.

const (
	ListRowNormal ListRowKind = iota
	ListRowCursor
	ListRowSelected
	ListRowCursorSelected
)

type ListScreen added in v0.2.0

type ListScreen struct {
	Title     string
	Count     int    // total objects, before filtering
	Selected  int    // multi-selection count; 0 hides the badge
	Filter    string // active filter text; "" hides the filter bar
	Cols      []ListColumn
	Rows      []ListTableRow
	RowCount  int // total rows when Rows is a scroll window; 0 → len(Rows)
	RowOffset int // index of Rows[0] in the full list
	Cursor    int
	State     ScreenState
	Message   string   // body text for Loading / Empty / NoMatch / Error
	Extra     []string // pre-rendered lines between the title and the table
	Help      string   // pre-rendered help bar content
}

ListScreen describes a list view as data. Views build one of these; the renderer below is the only thing that turns it into text, so every view gets identical chrome in identical order.

type ListTableRow

type ListTableRow struct {
	Cells    []Cell
	Selected bool
}

ListTableRow is one data row in a list-style screen.

type LogEntry

type LogEntry struct {
	ContainerID   string
	ContainerName string
	Timestamp     time.Time
	Message       string
	System        bool
	Sequence      int64
	// contains filtered or unexported fields
}

type LogModalFocus added in v0.2.0

type LogModalFocus int

LogModalFocus is which pane receives j/k-style navigation in split layout.

type LogModalState added in v0.2.0

type LogModalState struct {
	Entries        []LogEntry
	Targets        map[string]LogTarget
	ShowCentralTag bool
	Cursor         int
	ListScroll     int
	BodyScroll     int
	Focus          LogModalFocus
}

LogModalState holds a snapshot of log lines shown in the detail modal.

type LogTarget

type LogTarget struct {
	ID    string
	Name  string
	State string
	Color string
}

func SelectCentralLogTargets

func SelectCentralLogTargets(containers []docker.ContainerInfo, selected map[string]bool, colors map[string]string) []LogTarget

type LogViewerState

type LogViewerState struct {
	Entries          []LogEntry
	Targets          map[string]LogTarget
	Scroll           int
	Follow           bool
	Filter           string
	UseRegex         bool
	SelectedIndex    int
	LogCursor        int
	Focused          int
	Selection        map[int64]bool
	HiddenContainers map[string]bool
	SelectAnchor     int
	ShowLegend       bool
	MaxEntries       int
	// contains filtered or unexported fields
}

func NewLogViewerState

func NewLogViewerState(maxEntries int, targets []LogTarget) LogViewerState

func (*LogViewerState) Append

func (s *LogViewerState) Append(entries ...LogEntry)

func (*LogViewerState) AppendSorted

func (s *LogViewerState) AppendSorted(entries ...LogEntry)

func (*LogViewerState) AppendSortedBatch added in v0.2.0

func (s *LogViewerState) AppendSortedBatch(entries []LogEntry)

func (*LogViewerState) ClearSelection

func (s *LogViewerState) ClearSelection()

func (*LogViewerState) FilteredEntries

func (s *LogViewerState) FilteredEntries() []LogEntry

func (*LogViewerState) FocusedEntry

func (s *LogViewerState) FocusedEntry() (LogEntry, bool)

func (LogViewerState) IsContainerHidden

func (s LogViewerState) IsContainerHidden(id string) bool

func (*LogViewerState) MoveFocus

func (s *LogViewerState) MoveFocus(delta int, height int)

func (*LogViewerState) ScrollBy

func (s *LogViewerState) ScrollBy(delta, height int)

func (*LogViewerState) ScrollEnd

func (s *LogViewerState) ScrollEnd()

func (*LogViewerState) ScrollHome

func (s *LogViewerState) ScrollHome(height int)

func (*LogViewerState) ScrollPage

func (s *LogViewerState) ScrollPage(delta, height int)

func (*LogViewerState) SelectRangeToFocused

func (s *LogViewerState) SelectRangeToFocused()

func (*LogViewerState) SelectedEntries

func (s *LogViewerState) SelectedEntries() []LogEntry

func (*LogViewerState) SetFilter

func (s *LogViewerState) SetFilter(filter string)

func (*LogViewerState) SetUseRegex

func (s *LogViewerState) SetUseRegex(useRegex bool)

func (*LogViewerState) ShowAllContainers

func (s *LogViewerState) ShowAllContainers()

func (*LogViewerState) ToggleContainer

func (s *LogViewerState) ToggleContainer(id string)

func (*LogViewerState) ToggleSelectFocused

func (s *LogViewerState) ToggleSelectFocused()

func (*LogViewerState) VisibleEntries

func (s *LogViewerState) VisibleEntries(height int) []LogEntry

func (*LogViewerState) VisibleWindow

func (s *LogViewerState) VisibleWindow(height int) (int, int, int)

type Model

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

func NewModel

func NewModel(cfg *config.Config) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type Notification

type Notification struct {
	Message   string
	IsError   bool
	Timestamp time.Time
}

type RowStyle

type RowStyle struct {
	BG       lipgloss.Color
	Marker   string
	MarkerFG lipgloss.Color
	Rail     string // left accent glyph; " " when the row has no accent
	RailFG   lipgloss.Color
	MinFG    lipgloss.Color // floor colour for cells too close to BG to read
}

RowStyle controls marker, rail and row-level background.

type ScreenState added in v0.2.0

type ScreenState int

ScreenState selects which body a list screen renders.

const (
	ScreenReady   ScreenState = iota // rows are present
	ScreenLoading                    // data is being fetched
	ScreenEmpty                      // no objects exist
	ScreenNoMatch                    // objects exist but the filter matches none
	ScreenError                      // Message holds the error text
)

Jump to

Keyboard shortcuts

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