Documentation
¶
Index ¶
- Constants
- Variables
- func DistributeColumns(totalWidth, gapCount, gapWidth int, cols []int, flexIndices []int) []int
- func FilterFragment(query string) string
- func Frame(title, content string, width int) string
- func LeftPadContent(content string) string
- func OverlayCentered(base, overlay string, width, height int) string
- func RenderColumnHeader(labels []string, colWidths []int) string
- func RenderConfirmDialog(message string) string
- func RenderFileBrowserDialog(title, currentPath string, files []string, cursor int) string
- func RenderFramedBox(title, header, content, footer string, width int) string
- func RenderFramedBoxHeight(title, header, content, footer string, width, frameHeight int) string
- func RenderViewFrame(title, header, content, footer string, width, height int, fullscreen bool) string
- func ScopedTitle(label, scope string, count int) string
- func ScopedTitleFiltered(label, scope string, count int, filter string) string
- func SpinnerCharAt(frame int) string
- func SpinnerMarker() string
- func TrimOrPadContentToLines(content string, lines int) string
- func TruncateANSI(s string, width int) string
- func TruncateANSIAfter(s string, skipWidth int) string
- func WrapText(text string, width int) []string
- type FrameSpec
Constants ¶
const DefaultSpinnerCharsetIndex = 14
DefaultSpinnerCharsetIndex is the charset index used across views.
Variables ¶
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) )
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)
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 ¶
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 ¶
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 LeftPadContent ¶
LeftPadContent prepends a single space to each line of content.
func OverlayCentered ¶
func RenderColumnHeader ¶
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 ¶
RenderConfirmDialog renders a standard confirmation dialog with y/n options
func RenderFileBrowserDialog ¶
RenderFileBrowserDialog renders a file browser dialog with common styling
func RenderFramedBox ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
Types ¶
type FrameSpec ¶
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).