Documentation
¶
Index ¶
- Variables
- type ANSIRenderer
- func (r *ANSIRenderer) ClearScreen() string
- func (r *ANSIRenderer) EnterAltScreen() string
- func (r *ANSIRenderer) ExitAltScreen() string
- func (r *ANSIRenderer) HideCursor() string
- func (r *ANSIRenderer) MoveCursor(x, y int) string
- func (r *ANSIRenderer) RenderStyle(s *Style) string
- func (r *ANSIRenderer) Reset() string
- func (r *ANSIRenderer) ShowCursor() string
- type BorderChars
- type BorderStyle
- type Cell
- type ColorMode
- type Screen
- type Style
- func (s *Style) WithBackground(c *color.Color) *Style
- func (s *Style) WithBold(bold bool) *Style
- func (s *Style) WithBorder(chars BorderChars) *Style
- func (s *Style) WithBorderColor(c *color.Color) *Style
- func (s *Style) WithForeground(c *color.Color) *Style
- func (s *Style) WithItalic(italic bool) *Style
- func (s *Style) WithTextOverflow(overflow TextOverflow) *Style
- func (s *Style) WithUnderline(underline bool) *Style
- type StyledNode
- type TerminalCapabilities
- type TerminalDimensions
- type TextAlign
- type TextOverflow
- type TextWrap
Constants ¶
This section is empty.
Variables ¶
var ( RoundedBorder = BorderChars{ TopLeft: '╭', TopRight: '╮', BottomLeft: '╰', BottomRight: '╯', Horizontal: '─', Vertical: '│', } DoubleBorder = BorderChars{ TopLeft: '╔', TopRight: '╗', BottomLeft: '╚', BottomRight: '╝', Horizontal: '═', Vertical: '║', } ThickBorder = BorderChars{ TopLeft: '┏', TopRight: '┓', BottomLeft: '┗', BottomRight: '┛', Horizontal: '━', Vertical: '┃', } NormalBorder = BorderChars{ TopLeft: '┌', TopRight: '┐', BottomLeft: '└', BottomRight: '┘', Horizontal: '─', Vertical: '│', } )
Predefined border styles
Functions ¶
This section is empty.
Types ¶
type ANSIRenderer ¶
type ANSIRenderer struct {
ColorMode ColorMode
}
ANSIRenderer converts styles to ANSI escape codes
func NewANSIRenderer ¶
func NewANSIRenderer() *ANSIRenderer
NewANSIRenderer creates a new ANSI renderer with detected capabilities
func NewANSIRendererWithMode ¶
func NewANSIRendererWithMode(mode ColorMode) *ANSIRenderer
NewANSIRendererWithMode creates a new ANSI renderer with specified color mode
func (*ANSIRenderer) ClearScreen ¶
func (r *ANSIRenderer) ClearScreen() string
ClearScreen clears the entire screen
func (*ANSIRenderer) EnterAltScreen ¶
func (r *ANSIRenderer) EnterAltScreen() string
EnterAltScreen enters the alternate screen buffer
func (*ANSIRenderer) ExitAltScreen ¶
func (r *ANSIRenderer) ExitAltScreen() string
ExitAltScreen exits the alternate screen buffer
func (*ANSIRenderer) HideCursor ¶
func (r *ANSIRenderer) HideCursor() string
HideCursor hides the cursor
func (*ANSIRenderer) MoveCursor ¶
func (r *ANSIRenderer) MoveCursor(x, y int) string
MoveCursor moves the cursor to the specified position (1-indexed)
func (*ANSIRenderer) RenderStyle ¶
func (r *ANSIRenderer) RenderStyle(s *Style) string
RenderStyle converts a style to ANSI escape codes
func (*ANSIRenderer) Reset ¶
func (r *ANSIRenderer) Reset() string
Reset returns the ANSI reset sequence
func (*ANSIRenderer) ShowCursor ¶
func (r *ANSIRenderer) ShowCursor() string
ShowCursor shows the cursor
type BorderChars ¶
type BorderChars struct {
TopLeft rune
TopRight rune
BottomLeft rune
BottomRight rune
Horizontal rune
Vertical rune
}
BorderChars defines the characters used for borders
type BorderStyle ¶
type BorderStyle struct {
Top bool
Right bool
Bottom bool
Left bool
// Border characters
Chars BorderChars
}
BorderStyle defines which borders to render
type Cell ¶
type Cell struct {
// Content can be a single rune or a complete grapheme cluster (emoji sequence, etc.)
Content string
Style *Style
}
Cell represents a single character cell in the terminal
type Screen ¶
type Screen struct {
Width int
Height int
Cells [][]Cell
Previous [][]Cell
// contains filtered or unexported fields
}
Screen represents the terminal screen buffer
func (*Screen) Render ¶
func (s *Screen) Render(node *StyledNode)
Render renders a styled node to the screen buffer
func (*Screen) SetCell ¶
SetCell sets a single cell with content (can be a rune or grapheme cluster)
func (*Screen) SetColorMode ¶
SetColorMode sets the color mode for rendering
type Style ¶
type Style struct {
// Colors
Foreground *color.Color
Background *color.Color
// Text attributes
Bold bool
Italic bool
Underline bool
Strikethrough bool
Dim bool
Blink bool
Reverse bool
// Text layout
TextWrap TextWrap // How text should wrap
TextAlign TextAlign // Horizontal alignment
TextOverflow TextOverflow // Overflow handling
// Borders
Border *BorderStyle
BorderColor *color.Color
}
Style defines visual attributes without sizing properties. Sizing and layout are handled by the layout engine.
func (*Style) WithBackground ¶
WithBackground sets the background color
func (*Style) WithBorder ¶
func (s *Style) WithBorder(chars BorderChars) *Style
WithBorder sets a border with all sides enabled
func (*Style) WithBorderColor ¶
WithBorderColor sets the border color
func (*Style) WithForeground ¶
WithForeground sets the foreground color
func (*Style) WithItalic ¶
WithItalic sets italic text
func (*Style) WithTextOverflow ¶
func (s *Style) WithTextOverflow(overflow TextOverflow) *Style
WithTextOverflow sets the text overflow behavior
func (*Style) WithUnderline ¶
WithUnderline sets underlined text
type StyledNode ¶
type StyledNode struct {
*layout.Node
Style *Style
Content string
Children []*StyledNode
}
StyledNode wraps a layout.Node with visual styling
func NewStyledNode ¶
func NewStyledNode(node *layout.Node, style *Style) *StyledNode
NewStyledNode creates a new styled node
func (*StyledNode) AddChild ¶
func (n *StyledNode) AddChild(child *StyledNode)
AddChild adds a child node
type TerminalCapabilities ¶
type TerminalCapabilities struct {
ColorMode ColorMode
IsTTY bool
SupportsAlt bool // Alternate screen buffer
}
TerminalCapabilities holds information about terminal capabilities
func DetectCapabilities ¶
func DetectCapabilities() *TerminalCapabilities
DetectCapabilities detects the terminal's capabilities
type TerminalDimensions ¶
type TerminalDimensions struct {
Columns int // Character columns (e.g., 80)
Rows int // Character rows (e.g., 24)
PixelWidth int // Total width in pixels (0 if unsupported)
PixelHeight int // Total height in pixels (0 if unsupported)
CellWidth float64 // Width of one character in pixels
CellHeight float64 // Height of one character in pixels
HasPixelSupport bool // Whether terminal supports pixel queries
}
TerminalDimensions represents the complete dimensions of the terminal
func QueryTerminalDimensions ¶
func QueryTerminalDimensions(columns, rows int) TerminalDimensions
QueryTerminalDimensions gets comprehensive terminal dimensions including pixel sizes
func (TerminalDimensions) String ¶
func (d TerminalDimensions) String() string
String returns a human-readable representation of dimensions
type TextOverflow ¶
type TextOverflow int
TextOverflow defines how text should be handled when it overflows
const ( TextOverflowClip TextOverflow = iota // Clip text at boundary TextOverflowEllipsis // Show ellipsis (…) at end for overflow TextOverflowEllipsisStart // Show ellipsis (…) at start for overflow TextOverflowEllipsisMiddle // Show ellipsis (…) in middle for overflow )