table

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ComposeIDColumn = 2

ComposeIDColumn is the index of the column holding a deployment's identity (its full working_dir). Model.selectedID() reads it for the compose view — the PROJECT column is first but not unique, so it can't serve as the identity.

Variables

This section is empty.

Functions

func ComposeColumns

func ComposeColumns(w int) []table.Column

func ContainerColumns

func ContainerColumns(w int) []table.Column

func ContainerStatsColumns

func ContainerStatsColumns(w int) []table.Column

ContainerStatsColumns is the alternate container layout (toggled with 's') that mirrors `docker stats`: live CPU/MEM/MEM%/NET I/O/BLOCK I/O. ID stays last so Model.selectedID() keeps working.

func HostColumns

func HostColumns(w int) []table.Column

HostColumns is the unified hosts/dashboard layout: saved-host identity plus the aggregate daemon summary (`docker info`). NAME stays first (identity for selectedID) and STATUS (col 2) is colorized after layout.

func ImageColumns

func ImageColumns(w int) []table.Column

func NetworkColumns

func NetworkColumns(w int) []table.Column

func SortContainers

func SortContainers(containers []docker.Container, stats map[string]docker.ContainerStats, field SortField, desc bool) []docker.Container

SortContainers returns containers reordered by field (stable; the input slice is not mutated). CPU/MEM figures come from stats — a container without a sample sorts as zero. SortNone returns the slice unchanged. Equal rows fall back to NAME ascending regardless of direction, so the order stays stable.

func Summary

func Summary(total, shown int) string

Summary returns a human-readable count string.

func VolumeColumns

func VolumeColumns(w int) []table.Column

Types

type Colorizer

type Colorizer func(plainCell string) (lipgloss.Style, bool)

Colorizer maps a column's plain cell text to the style it should be drawn with. The bool reports whether to apply that style: returning false leaves the cell in the base style (so a colorizer can opt out per row, e.g. the alert marker only colors breaching rows).

func ComposeColorizers

func ComposeColorizers() []Colorizer

ComposeColorizers colors the STATUS column of the compose layout.

func ContainerColorizers

func ContainerColorizers() []Colorizer

ContainerColorizers colors the NAME (alert ⚠ marker), STATUS and HEALTH columns of the default container layout; the column order matches columns().

func ContainerStatsColorizers

func ContainerStatsColorizers() []Colorizer

ContainerStatsColorizers colors the NAME column's alert ⚠ marker in the `docker stats`-style layout (7 columns); the other columns stay base.

func HostColorizers

func HostColorizers() []Colorizer

HostColorizers colors the STATUS column of the hosts layout (col 2).

type Model

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

func New

func New() Model

func (*Model) InnerTable

func (m *Model) InnerTable() *table.Model

func (*Model) RefreshStyles

func (m *Model) RefreshStyles()

RefreshStyles re-applies the package styles to the underlying bubbles table. bubbles captures its Styles once at construction, so a runtime theme switch (styles.Apply) leaves the table's stored Selected/Header/Cell pointing at the previous palette. The selected-row highlight is detected and re-rendered by matching bubbles' Selected-style ANSI prefix (see selectedPrefix/View); once that prefix is stale the cursor row stops being recognised and its highlight vanishes in colorized views. Call this after every styles.Apply.

func (*Model) SelectComposeRow

func (m *Model) SelectComposeRow(id string)

SelectComposeRow moves the cursor to the compose row whose identity column (working_dir) equals id; it's a no-op if no row matches. Used to restore the selection when returning from a drill-down to the deployment list.

func (Model) SelectedID

func (m Model) SelectedID() string

SelectedID returns the last column of the selected row (the resource ID for containers/images/networks, whose last column is a real ID column).

func (Model) SelectedRow

func (m Model) SelectedRow() []string

SelectedRow returns the cells of the currently selected row, or nil.

func (*Model) SetColorizers

func (m *Model) SetColorizers(cs []Colorizer)

SetColorizers installs the per-column colorizers used to color cells after layout. Pass nil for views with no colored columns. The slice is indexed by column; a nil entry leaves that column in the base style.

func (*Model) SetColumns

func (m *Model) SetColumns(cols []table.Column)

SetColumns updates column definitions (called on resize or resource switch). Rows are cleared ONLY when the column count changes to avoid index-out-of-range in renderRow while preserving existing rows on resize.

func (*Model) SetCompose

func (m *Model) SetCompose(projects []docker.ComposeProject, filter string)

func (*Model) SetContainers

func (m *Model) SetContainers(containers []docker.Container, filter string, stats map[string]docker.ContainerStats, statsView bool, selected, alerted map[string]bool)

func (*Model) SetHosts

func (m *Model) SetHosts(hostList []hosts.Host, filter string, summaries map[string]docker.HostSummary)

SetHosts fills the unified hosts/dashboard view; summaries holds per-host daemon snapshots keyed by host URL (absent = probe pending).

func (*Model) SetImages

func (m *Model) SetImages(images []docker.Image, filter string, selected map[string]bool)

func (*Model) SetNetworks

func (m *Model) SetNetworks(networks []docker.Network, filter string)

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets width and height. Caller must call SetColumns separately.

func (*Model) SetSort

func (m *Model) SetSort(field SortField, desc bool)

SetSort selects the column the containers view is ordered by. SortNone keeps the daemon's order. Only the containers view honours it.

func (*Model) SetVolumes

func (m *Model) SetVolumes(volumes []docker.Volume, filter string)

func (Model) Table

func (m Model) Table() table.Model

func (*Model) Update

func (m *Model) Update(msg any)

func (Model) View

func (m Model) View() string

View post-processes bubbles output. bubbles truncates each cell with runewidth, which counts ANSI-escape bytes as visible width — so a pre-colored cell loses its text in a narrow column on truecolor terminals. We therefore keep colored content out of the row values and apply color here.

Two paths:

  • colorized views (containers/compose/hosts): every data row is rebuilt from its plain text so colored columns can be styled after layout, with the selection background preserved under the cursor row.
  • plain views: only the selected line needs fixing — its inner cell resets break the Selected background, so we strip and re-render it uniformly.

type SortField

type SortField int

SortField identifies the column the container list is ordered by. SortNone keeps the daemon's own order (the default).

const (
	SortNone SortField = iota
	SortName
	SortStatus
	SortCPU
	SortMem
)

func (SortField) String

func (f SortField) String() string

String returns a short label for the active sort, shown in the header.

Jump to

Keyboard shortcuts

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