ui

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Table styles
	BaseTableStyle = lipgloss.NewStyle().
					BorderStyle(lipgloss.NormalBorder()).
					BorderForeground(lipgloss.Color("240"))

	// Title styles
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("99"))

	// Label/Value styles for detail views
	LabelStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("240"))

	ValueStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("252"))

	// Help text
	HelpStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("241"))

	// Success/Error styles
	SuccessStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("42"))

	ErrorStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("196"))

	// Selection styles
	SelectedItemStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color("170")).
						Bold(true)

	NormalItemStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("252"))

	// Default indicator style (subtle)
	DefaultIndicatorStyle = lipgloss.NewStyle().
							Foreground(lipgloss.Color("42")) // Green color for checkmark

	// Default row highlight style
	DefaultRowStyle = lipgloss.NewStyle().
					Background(lipgloss.Color("228")) // Subtle yellow background
)

Common styles used across the application

Functions

func CalculateColumnWidths

func CalculateColumnWidths(termWidth int, config ColumnWidthConfig) []int

CalculateColumnWidths calculates optimal column widths based on terminal width This is inspired by GitHub CLI's approach to responsive table layouts

func CalculateTableHeight

func CalculateTableHeight(terminalHeight, rowCount int) int

CalculateTableHeight calculates appropriate table height based on terminal and row count

func DefaultTableHeaderStyle

func DefaultTableHeaderStyle() lipgloss.Style

Table header style configuration

func DefaultTableSelectedStyle

func DefaultTableSelectedStyle() lipgloss.Style

Table selected row style configuration

func GetTerminalHeight

func GetTerminalHeight() int

GetTerminalHeight returns the current terminal height with a fallback

func GetTerminalWidth

func GetTerminalWidth() int

GetTerminalWidth returns the current terminal width with a fallback

func HighlightTableRow

func HighlightTableRow(cells []string, widths []int) []string

HighlightTableRow applies the default row highlight style to all cells in a row

func IsTerminal

func IsTerminal(w io.Writer) bool

IsTerminal returns true if the given writer is a terminal

func MeasureStringWidth

func MeasureStringWidth(s string) int

MeasureStringWidth returns the display width of a string, accounting for ANSI codes

func SortByName

func SortByName[T SortableByName](items []T)

SortByName sorts a slice of items alphabetically by name (case-insensitive)

func SortStrings

func SortStrings(items []string)

SortStrings sorts a slice of strings alphabetically (case-insensitive)

func StyleTable

func StyleTable(t table.Model) table.Model

StyleTable applies common styling to a table (for interactive select views)

func StyleTableForDisplay

func StyleTableForDisplay(t table.Model) table.Model

StyleTableForDisplay applies styling for non-interactive display tables

func StyleTableForList

func StyleTableForList(t table.Model) table.Model

StyleTableForList applies styling for list views with subtle default highlighting

func TruncateString

func TruncateString(s string, maxLen int) string

TruncateString truncates a string to fit within maxLen, adding "..." if needed

Types

type ColumnWidthConfig

type ColumnWidthConfig struct {
	// MinWidths defines minimum width for each column
	MinWidths []int
	// MaxWidths defines maximum width for each column (0 = no limit)
	MaxWidths []int
	// PreferredWidths defines preferred width for each column
	PreferredWidths []int
	// FlexColumns marks which columns should expand to fill available space
	FlexColumns []bool
}

ColumnWidthConfig defines how to calculate column widths

type OutputFormat

type OutputFormat string

OutputFormat represents the desired output format

const (
	// OutputFormatTable renders as a human-readable table
	OutputFormatTable OutputFormat = "table"
	// OutputFormatJSON renders as JSON
	OutputFormatJSON OutputFormat = "json"
	// OutputFormatTSV renders as tab-separated values
	OutputFormatTSV OutputFormat = "tsv"
)

func ParseOutputFormat

func ParseOutputFormat(s string) (OutputFormat, error)

ParseOutputFormat parses a string into an OutputFormat

type SortableByName

type SortableByName interface {
	GetName() string
}

SortableByName is an interface for items that can be sorted by name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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