Documentation
¶
Overview ¶
Package core provides the fundamental interfaces and types for cmdux.
Package core provides rendering utilities.
Index ¶
- func GetTerminalSize() (width, height int)
- func MeasureText(text string) int
- func StripANSI(str string) string
- type Alignment
- type BoxChars
- type Component
- func (c *Component) GetHeight() int
- func (c *Component) GetStyle() *style.Style
- func (c *Component) GetWidth() int
- func (c *Component) Height(h int) *Component
- func (c *Component) Hide() *Component
- func (c *Component) IsHidden() bool
- func (c *Component) SetStyle(s *style.Style) *Component
- func (c *Component) Show() *Component
- func (c *Component) Width(w int) *Component
- type Renderable
- type Renderer
- func (r *Renderer) Box(content string, width, height int, chars BoxChars) string
- func (r *Renderer) CenterText(text string, width int) string
- func (r *Renderer) FormatTable(headers []string, rows [][]string, columnWidths []int) string
- func (r *Renderer) JoinHorizontal(strs []string, separator string) string
- func (r *Renderer) JoinVertical(strs []string, width int, align Alignment) string
- func (r *Renderer) PadText(text string, width int, align Alignment) string
- func (r *Renderer) RepeatChar(char rune, width int) string
- func (r *Renderer) TruncateText(text string, width int) string
- func (r *Renderer) WrapText(text string, width int) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTerminalSize ¶
func GetTerminalSize() (width, height int)
GetTerminalSize attempts to get the terminal size. Returns default values if unable to detect.
func MeasureText ¶
MeasureText measures the display width of text, handling ANSI codes and unicode.
Types ¶
type BoxChars ¶
type BoxChars struct { TopLeft rune TopRight rune BottomLeft rune BottomRight rune Horizontal rune Vertical rune }
BoxChars defines the characters used for drawing boxes.
func ClassicBoxChars ¶
func ClassicBoxChars() BoxChars
ClassicBoxChars returns classic ASCII box drawing characters.
func DefaultBoxChars ¶
func DefaultBoxChars() BoxChars
DefaultBoxChars returns the default box drawing characters.
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component represents a basic UI component with common properties.
type Renderable ¶
type Renderable interface { // Render returns the string representation of the component using the given theme. Render(theme *style.Theme) string }
Renderable represents any component that can be rendered to the terminal.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer provides utilities for rendering text with proper alignment and sizing.
func NewRenderer ¶
NewRenderer creates a new renderer with the specified dimensions.
func (*Renderer) CenterText ¶
CenterText centers text within the specified width.
func (*Renderer) FormatTable ¶
FormatTable formats a table with proper column alignment and spacing.
func (*Renderer) JoinHorizontal ¶
JoinHorizontal joins multiple strings horizontally.
func (*Renderer) JoinVertical ¶
JoinVertical joins multiple strings vertically with proper alignment.
func (*Renderer) RepeatChar ¶
RepeatChar repeats a character to create a string of specified width.
func (*Renderer) TruncateText ¶
TruncateText truncates text to fit within the specified width.