ui

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSpinnerCharsetIndex = 14

DefaultSpinnerCharsetIndex is the charset index used across views.

Variables

View Source
var (
	BorderStyle = lipgloss.NewStyle().
				Border(lipgloss.NormalBorder()).
				BorderForeground(lipgloss.Color("117")).
				Padding(0, 1)

	StatusStyle = lipgloss.NewStyle().
				Padding(0, 1).
				Width(30)

	ListStyle = lipgloss.NewStyle().
				Border(lipgloss.NormalBorder()).
				BorderForeground(lipgloss.Color("117")).
				Margin(1, 0).
				Padding(1)

	HelpStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("#888888")).
				Italic(true).
				Margin(1, 0)
	CursorStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("230")).
				Background(lipgloss.Color("63")).
				Bold(true)

	StatusBarStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("250")).
					Background(lipgloss.Color("237")).
					Padding(0, 1)
)
View Source
var (
	FrameTitleStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("81")).
					Bold(true)

	FrameHeaderStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("15")).
						Bold(true)

	FrameBorderColor = lipgloss.Color("117")

	ListItemStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("117"))

	ListSelectedStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("230")).
						Background(lipgloss.Color("63")).
						Bold(true)
)

Styles (you can override these per-view if desired)

View Source
var Rainbow = []lipgloss.Style{
	lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5F87")),
	lipgloss.NewStyle().Foreground(lipgloss.Color("#FFAF00")),
	lipgloss.NewStyle().Foreground(lipgloss.Color("#FFFF00")),
	lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF87")),
	lipgloss.NewStyle().Foreground(lipgloss.Color("#5FD7FF")),
	lipgloss.NewStyle().Foreground(lipgloss.Color("#AF87FF")),
}

Functions

func DistributeColumns

func DistributeColumns(totalWidth, gapCount, gapWidth int, cols []int, flexIndices []int) []int

DistributeColumns adjusts column widths to fit `totalWidth` after accounting for `gapCount` gaps of `gapWidth` each. `cols` contains preferred/min widths for each column. `flexIndices` are indexes into `cols` that are allowed to absorb remaining space when total cols < available, or to be reduced when cols exceed available. The function returns a new slice with adjusted widths.

func FilterFragment

func FilterFragment(query string) string

FilterFragment renders a trailing " </query>" fragment marking an active `/` filter, mirroring k9s (which appends the filter rather than folding it into the scope). The angle brackets share the label colour while the "/query" reuses the scope colour, so the filter reads as a scope refinement. It returns "" when no filter is active. Like the rest of ScopedTitle the result already carries ANSI styling, so styleFrameTitle passes it through unchanged.

func Frame

func Frame(title, content string, width int) string

func LeftPadContent

func LeftPadContent(content string) string

LeftPadContent prepends a single space to each line of content.

func OverlayCentered

func OverlayCentered(base, overlay string, width, height int) string

func RenderColumnHeader

func RenderColumnHeader(labels []string, colWidths []int) string

RenderColumnHeader builds a single-line header from labels and column widths. `labels` and `colWidths` must have the same length. It applies the FrameHeaderStyle to the resulting line so callers can place it in the framed header slot.

func RenderConfirmDialog

func RenderConfirmDialog(message string) string

RenderConfirmDialog renders a standard confirmation dialog with y/n options

func RenderFileBrowserDialog

func RenderFileBrowserDialog(title, currentPath string, files []string, cursor int) string

RenderFileBrowserDialog renders a file browser dialog with common styling

func RenderFramedBox

func RenderFramedBox(title, header, content, footer string, width int) string

RenderFramedBox draws a bordered frame with title, optional header, and content. If width <= 0, defaults to content width + padding. ANSI sequences in content are preserved.

func RenderFramedBoxHeight

func RenderFramedBoxHeight(title, header, content, footer string, width, frameHeight int) string

RenderFramedBoxHeight renders a framed box constrained to `frameHeight` lines (including borders). If `frameHeight` <= 0 the function falls back to the unconstrained `RenderFramedBox` behavior. This helper pads the content so the resulting framed box occupies exactly `frameHeight` lines when possible.

func RenderViewFrame

func RenderViewFrame(title, header, content, footer string, width, height int, fullscreen bool) string

RenderViewFrame composes a complete framed view from its parts. It computes frame dimensions, trims/pads content to fit, and renders the bordered frame. When fullscreen is true, only a centered title line and raw content are returned (no borders).

func ScopedTitle

func ScopedTitle(label, scope string, count int) string

ScopedTitle renders a frame title of the form "Label(scope)[count]" with the label/separators, scope, and count coloured distinctly. The returned string already carries its own ANSI styling, so RenderFramedBox passes it through unchanged instead of re-applying FrameTitleStyle (see styleFrameTitle).

func ScopedTitleFiltered

func ScopedTitleFiltered(label, scope string, count int, filter string) string

ScopedTitleFiltered renders ScopedTitle and, when filter is non-empty, appends a FilterFragment so the header reflects the active `/` filter, e.g. "Stacks(all)[1] </pos>". The count is expected to be the post-filter row count. See FilterFragment.

func SpinnerCharAt

func SpinnerCharAt(frame int) string

SpinnerCharAt returns the spinner character for the given frame index. Falls back to an ellipsis if spinner charset is not available.

func SpinnerMarker

func SpinnerMarker() string

SpinnerMarker returns the first spinner character (useful as a marker).

func TrimOrPadContentToLines

func TrimOrPadContentToLines(content string, lines int) string

TrimOrPadContentToLines returns content limited to exactly `lines` rows, padding with empty lines when shorter. Useful when framing viewport content to a fixed height.

func TruncateANSI

func TruncateANSI(s string, width int) string

TruncateANSI truncates a string with ANSI codes to a specific visual (cell) width. It is grapheme/display-width aware (wide East-Asian chars and emoji count as 2 cells) and never splits an escape sequence.

func TruncateANSIAfter

func TruncateANSIAfter(s string, skipWidth int) string

TruncateANSIAfter skips skipWidth visual cells and returns the rest, re-emitting the active SGR state at the cut so colors survive. It is grapheme/display-width aware and never splits an escape sequence.

func WrapText

func WrapText(text string, width int) []string

WrapText wraps text to the specified width, breaking on word boundaries.

Types

type FrameSpec

type FrameSpec struct {
	FrameWidth          int
	FrameHeight         int
	DesiredContentLines int
}

FrameSpec captures the calculated dimensions for a framed view.

func ComputeFrameDimensions

func ComputeFrameDimensions(viewportWidth, viewportHeight, fallbackWidth, fallbackHeight int, header, footer string) FrameSpec

ComputeFrameDimensions derives consistent frame sizing across views.

Inputs: - viewportWidth/Height: usable dimensions provided by app/update.go - fallbackWidth/Height: model dimensions to use if the viewport is not ready - header/footer: rendered strings used to count occupied lines

Behavior aligns with stacks view: add 4 columns for frame padding, use the already-adjusted viewport height directly, and compute the inner content lines as frameHeight - vertical padding - header - footer (never negative).

Directories

Path Synopsis
components

Jump to

Keyboard shortcuts

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