ui

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ui provides shared UI styling and components for the TUI application.

Index

Constants

View Source
const (
	ColKeyBranch     = "branch"
	ColKeyChecks     = "checks"
	ColKeyName       = "name"
	ColKeyPR         = "pr"
	ColKeyPass       = "pass"
	ColKeyRuns       = "runs"
	ColKeyTime       = "time"
	ColKeyWorkflow   = "workflow"
	ColTitleBranch   = "Branch"
	ColTitleChecks   = "Checks"
	ColTitleName     = "Name"
	ColTitlePR       = "PR"
	ColTitlePass     = "Pass"
	ColTitleRuns     = "Runs"
	ColTitleTime     = "Time"
	ColTitleWorkflow = "Workflow"
)

Column keys and titles shared by more than one table.

View Source
const (
	ColWidthReq = 3
	ColMinFlag  = 1
	ColMinCount = 4
	ColMinShort = 6
	ColMinLabel = 8
	ColMinName  = 10

	ColMaxFlag   = 1
	ColMaxCount  = 4
	ColMaxSteps  = 5
	ColMaxTime   = 12
	ColMaxStatus = 14
	ColMaxValue  = 24
	ColMaxBranch = 28
	ColMaxName   = 36

	WeightLow  = 1
	WeightMid  = 2
	WeightHigh = 3

	PrioFirstToGo  = 1
	PrioSecondToGo = 2
	PrioThirdToGo  = 3
)

Column sizing vocabulary shared by every table, in display cells. Naming the floors keeps a table readable as a set of tradeoffs rather than a wall of digits. Every column holding a short value is capped, because surplus width spread across them pushes a row's cells so far apart that the eye has to travel between them on a wide terminal.

View Source
const PaneBorderSize = 2

PaneBorderSize is the space a pane's border occupies on each axis, which is what separates the width a pane is given from the width its content gets.

View Source
const RowGutterWidth = 2

RowGutterWidth is the "> " selection gutter and any status glyph that sit left of the first column, which the table itself never sees.

Variables

View Source
var (
	PrimaryColor   color.Color
	SecondaryColor color.Color
	AccentColor    color.Color
	MutedColor     color.Color
	SoftMutedColor color.Color
	TextColor      color.Color
	ModalBgColor   color.Color
	ErrorColor     color.Color
	LinkColor      color.Color
)

Colors used throughout the UI.

View Source
var (
	BorderStyle        lipgloss.Style
	CLIPreviewStyle    lipgloss.Style
	ErrorStyle         lipgloss.Style
	ErrorTitleStyle    lipgloss.Style
	FocusedBorderStyle lipgloss.Style
	HelpStyle          lipgloss.Style
	LinkStyle          lipgloss.Style
	NormalStyle        lipgloss.Style
	SelectedStyle      lipgloss.Style
	SubtitleStyle      lipgloss.Style
	TabActiveStyle     lipgloss.Style
	TabInactiveStyle   lipgloss.Style
	TableDefaultStyle  lipgloss.Style
	TableDimmedStyle   lipgloss.Style
	TableHeaderStyle   lipgloss.Style
	TableItalicStyle   lipgloss.Style
	TableRowStyle      lipgloss.Style
	TableSelectedStyle lipgloss.Style
	TitleStyle         lipgloss.Style
)

Styles for the application (initialized in ApplyTheme).

Functions

func ApplyFuzzyFilter

func ApplyFuzzyFilter(query string, items []string) []string

ApplyFuzzyFilter returns items filtered by query using fuzzy matching. Returns original items if query is empty.

func ApplyTheme

func ApplyTheme()

ApplyTheme updates all colors and styles from the current palette. The three roles beyond theme.Semantic are named here because only this application needs them: a softer muted for defaults, a modal ground, and a link color.

func ConfigColumns added in v1.2.0

func ConfigColumns() []table.Column

ConfigColumns describes the workflow-input table at a width that fits every column. Name is the column a reader scans, so it keeps the most weight.

func ConfigColumnsFor added in v1.10.0

func ConfigColumnsFor(room int) []table.Column

ConfigColumnsFor is the input table narrowed to what a pane room cells wide holds, selection gutter included. Dropping a column by priority is not enough on its own: the header then carries an overflow marker naming what it dropped, and that marker is what wraps a header one cell too wide onto a second line, costing the pane the row its bottom border sits on.

func FitColumns added in v1.2.0

func FitColumns(cols []table.Column, width, gutter int) table.Layout

FitColumns resolves cols against the room a pane leaves for its rows, past the gutter its selection indicator and status glyphs occupy.

func FormatEmptyValue

func FormatEmptyValue(val string) string

FormatEmptyValue returns the display string for a value, showing ("") for empty strings.

func InitTheme

func InitTheme(p theme.Palette)

InitTheme sets the palette and applies colors.

func MarkGlyph added in v1.10.0

func MarkGlyph(marked bool) string

MarkGlyph is the cell a list spends on whether a row is marked.

func PaneBox added in v1.10.0

func PaneBox(width, height int, focused bool, content string) string

PaneBox draws content inside a pane of exactly width by height cells. Content is truncated rather than wrapped, because a wrapped line costs the pane the bottom border MaxHeight then clips in its place.

func RemoveListBackgrounds

func RemoveListBackgrounds(l list.Model) list.Model

RemoveListBackgrounds removes all backgrounds from a list.Model for modal overlay.

func RenderEmptyValue

func RenderEmptyValue(val string) string

RenderEmptyValue returns a styled string for a value, using italic style for empty strings.

func RenderScrollIndicator

func RenderScrollIndicator(hasMore, hasLess bool) string

RenderScrollIndicator renders scroll arrows (^ and v) for lists.

func ScrollWindow added in v1.7.0

func ScrollWindow(selected, total, rows int) (int, int)

ScrollWindow returns the half-open range of rows a pane should draw so that selected stays visible. A negative selected holds the window at the top, which is what a cleared selection wants.

func TableHeader added in v1.2.0

func TableHeader(layout table.Layout, gutter int) string

TableHeader renders a column header indented past the row gutter.

func TableRow added in v1.2.0

func TableRow(layout table.Layout, values map[string]string) string

TableRow pads each value to its resolved column width, skipping the columns collapse hid.

Types

type MarkSet added in v1.10.0

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

MarkSet is the set of rows a verb acts on instead of the cursor: `space` marks a row, and the action menu then offers the verb over the marked set. Keys are whatever the pane names its rows by, so a set outlives a reordering of the list it came from.

func (*MarkSet) Clear added in v1.10.0

func (s *MarkSet) Clear()

Clear drops every mark, which is what finishing a batch verb does: leaving them set would make the next verb act on rows the reader has moved past.

func (MarkSet) Has added in v1.10.0

func (s MarkSet) Has(key string) bool

Has reports whether a row is marked.

func (MarkSet) Keys added in v1.10.0

func (s MarkSet) Keys() []string

Keys are the marked rows, sorted so a batch runs in a stable order.

func (MarkSet) Len added in v1.10.0

func (s MarkSet) Len() int

Len is how many rows are marked.

func (*MarkSet) Toggle added in v1.10.0

func (s *MarkSet) Toggle(key string)

Toggle adds or removes one row.

Directories

Path Synopsis
Package modal provides modal dialogs for user interactions in the TUI application.
Package modal provides modal dialogs for user interactions in the TUI application.
Package panes provides the main UI panes for workflow, history, and configuration views.
Package panes provides the main UI panes for workflow, history, and configuration views.
Package timeline lays out a workflow run as bars on a shared time axis.
Package timeline lays out a workflow run as bars on a shared time axis.

Jump to

Keyboard shortcuts

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