tw

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 13 Imported by: 209

Documentation

Overview

Package tw provides utility functions for text formatting, width calculation, and string manipulation specifically tailored for table rendering, including handling ANSI escape codes and Unicode text.

Package tw defines types and constants for table formatting and configuration, including validation logic for various table properties.

Index

Constants

View Source
const (
	NameASCII     = "ascii"
	NameUnicode   = "unicode"
	NameNothing   = "nothing"
	NameMarkdown  = "markdown"
	NameGraphical = "graphical"
	NameMerger    = "merger"
)

Private: Style name constants

View Source
const (
	Fail    = -1 // Operation failed
	Success = 1  // Operation succeeded

	DefaultMinlColumnWidth = 8
)

Operation Status Constants Used to indicate the success or failure of operations

View Source
const (
	Empty   = ""
	Skip    = ""
	Space   = " "
	NewLine = "\n"
)
View Source
const (
	WrapNone     = iota // No wrapping
	WrapNormal          // Standard word wrapping
	WrapTruncate        // Truncate text with ellipsis
	WrapBreak           // Break words to fit
)

Text Wrapping Constants Defines text wrapping behavior in table cells

View Source
const (
	MergeNone         = iota // No merging
	MergeVertical            // Merge cells vertically
	MergeHorizontal          // Merge cells horizontally
	MergeBoth                // Merge both vertically and horizontally
	MergeHierarchical        // Hierarchical merging
)
View Source
const (
	CharEllipsis = "…" // Ellipsis character for truncation
	CharBreak    = "↩" // Break character for wrapping
)

Special Character Constants Defines special characters used in formatting

Variables

View Source
var BorderNone = Border{Left: Off, Right: Off, Top: Off, Bottom: Off}

BorderNone defines a border configuration with all sides disabled.

Functions

func BreakPoint added in v1.0.1

func BreakPoint(s string, limit int) int

BreakPoint finds the rune index where the display width of a string first exceeds the specified limit. It returns the number of runes if the entire string fits, or 0 if nothing fits.

func CompileANSIFilter added in v1.0.1

func CompileANSIFilter() *regexp.Regexp

CompileANSIFilter constructs and compiles a regex for matching ANSI sequences. It supports both control sequences (CSI) and operating system commands (OSC) like hyperlinks.

func DisplayWidth added in v1.0.1

func DisplayWidth(str string) int

DisplayWidth calculates the visual width of a string, excluding ANSI escape sequences. It uses go-runewidth to handle Unicode characters correctly.

func IsIsNumericOrSpace added in v1.0.1

func IsIsNumericOrSpace(r rune) bool

IsIsNumericOrSpace checks if a rune is a digit or space character. Used in formatting logic to determine safe character replacements.

func IsNumeric added in v1.0.1

func IsNumeric(s string) bool

IsNumeric checks if a string represents a valid integer or floating-point number.

func Max added in v1.0.1

func Max(a, b int) int

Max returns the greater of two integers.

func Min added in v1.0.1

func Min(a, b int) int

Min returns the smaller of two integers.

func Or added in v1.0.1

func Or(cond bool, valid, inValid string) string

Or provides a ternary-like operation for strings, returning 'valid' if cond is true, else 'inValid'.

func PadCenter added in v1.0.1

func PadCenter(s, pad string, width int) string

PadCenter centers a string within a specified width using a padding character. Extra padding is split between left and right, with slight preference to left if uneven.

func PadLeft added in v1.0.1

func PadLeft(s, pad string, width int) string

PadLeft right-aligns a string within a specified width, filling remaining space on the left with padding.

func PadRight added in v1.0.1

func PadRight(s, pad string, width int) string

PadRight left-aligns a string within a specified width, filling remaining space on the right with padding.

func SplitCamelCase added in v1.0.1

func SplitCamelCase(src string) (entries []string)

SplitCamelCase splits a camelCase or PascalCase string into separate words. It detects transitions between uppercase, lowercase, digits, and other characters.

func Title added in v1.0.1

func Title(name string) string

Title normalizes and uppercases a label string for use in headers. It replaces underscores and certain dots with spaces and trims whitespace.

func TruncateString added in v1.0.1

func TruncateString(s string, maxWidth int, suffix ...string) string

TruncateString shortens a string to a specified maximum display width while preserving ANSI color codes. An optional suffix (e.g., "...") is appended if truncation occurs.

Types

type Align

type Align string

Align specifies the text alignment within a table cell.

const (
	AlignNone    Align = "none"    // Center-aligned text
	AlignCenter  Align = "center"  // Center-aligned text
	AlignRight   Align = "right"   // Right-aligned text
	AlignLeft    Align = "left"    // Left-aligned text
	AlignDefault       = AlignLeft // Left-aligned text
)

Table Alignment Constants Defines text alignment options for table content

func (Align) Validate added in v1.0.1

func (a Align) Validate() error

Validate checks if the Align is one of the allowed values: None, Center, Left, or Right.

type Alignment added in v1.0.3

type Alignment []Align

func MakeAlign added in v1.0.3

func MakeAlign(l int, align Align) Alignment

func (Alignment) Add added in v1.0.3

func (a Alignment) Add(aligns ...Align) Alignment

func (Alignment) Copy added in v1.0.3

func (a Alignment) Copy() Alignment

Copy creates a new independent copy of the Alignment

func (Alignment) Set added in v1.0.3

func (a Alignment) Set(col int, align Align) Alignment

func (Alignment) String added in v1.0.3

func (a Alignment) String() string

type Border

type Border struct {
	Left   State // Left border visibility
	Right  State // Right border visibility
	Top    State // Top border visibility
	Bottom State // Bottom border visibility
}

Border defines the visibility states of table borders.

type BorderStyle

type BorderStyle int

BorderStyle defines different border styling options

const (
	StyleNone BorderStyle = iota
	StyleASCII
	StyleLight
	StyleHeavy
	StyleDouble
	StyleLightHeavy
	StyleHeavyLight
	StyleLightDouble
	StyleDoubleLight
	StyleRounded
	StyleMarkdown
	StyleGraphical
	StyleMerger
	StyleDefault
)

Border style constants

func (BorderStyle) String

func (s BorderStyle) String() string

String returns the string representation of a border style

type CellCallbacks

type CellCallbacks struct {
	Global    func()   // Global callback applied to all cells
	PerColumn []func() // Column-specific callbacks
}

CellCallbacks holds callback functions for cell processing. Note: These are currently placeholders and not fully implemented.

type CellConfig

type CellConfig struct {
	Formatting   CellFormatting // Cell formatting options
	Padding      CellPadding    // Padding configuration
	Callbacks    CellCallbacks  // Callback functions (unused)
	Filter       CellFilter     // Function to filter cell content (renamed from Filter Filter)
	ColumnAligns []Align        // Per-column alignment overrides
	ColMaxWidths CellWidth      // Per-column maximum width overrides
}

CellConfig combines formatting, padding, and callback settings for a table section.

type CellContext

type CellContext struct {
	Data    string     // Content to be displayed in the cell, provided by the caller
	Align   Align      // Text alignment within the cell (Left, Right, Center, Skip)
	Padding Padding    // Padding characters surrounding the cell content
	Width   int        // Suggested width (often overridden by Row.Widths)
	Merge   MergeState // Details about cell spanning across rows or columns
}

CellContext defines the properties and formatting state of an individual table cell.

type CellFilter

type CellFilter struct {
	Global    func([]string) []string // Processes the entire row
	PerColumn []func(string) string   // Processes individual cells by column
}

CellFilter defines filtering functions for cell content.

type CellFormatting

type CellFormatting struct {
	Alignment  Align // Text alignment within the cell (e.g., Left, Right, Center)
	AutoWrap   int   // Wrapping behavior (e.g., WrapTruncate, WrapNormal)
	AutoFormat bool  // Enables automatic formatting (e.g., title case for headers)
	MaxWidth   int   // Maximum content width for the cell
	MergeMode  int   // Bitmask for merge behavior (e.g., MergeHorizontal, MergeVertical)
}

CellFormatting holds formatting options for table cells.

type CellPadding

type CellPadding struct {
	Global    Padding   // Default padding applied to all cells
	PerColumn []Padding // Column-specific padding overrides
}

CellPadding defines padding settings for table cells.

type CellWidth added in v1.0.1

type CellWidth struct {
	Global    int
	PerColumn Mapper[int, int]
}

type Filter

type Filter func([]string) []string

Filter defines a function type for processing cell content. It takes a slice of strings (representing cell data) and returns a processed slice.

type Formatter

type Formatter interface {
	Format() string // Returns the formatted string representation
}

Formatter defines an interface for types that can format themselves into a string. Used for custom formatting of table cell content.

type Formatting

type Formatting struct {
	Row              RowContext // Detailed configuration for the row and its cells
	Level            Level      // Hierarchical level (Header, Body, Footer) affecting line drawing
	HasFooter        bool       // Indicates if the table includes a footer section
	IsSubRow         bool       // Marks this as a continuation or padding line in multi-line rows
	NormalizedWidths Mapper[int, int]
}

Formatting encapsulates the complete formatting context for a table row. It provides all necessary information to render a row correctly within the table structure.

type KeyValuePair

type KeyValuePair[K comparable, V any] struct {
	Key   K
	Value V
}

KeyValuePair represents a single key-value pair from a Mapper.

type Level

type Level int

Level indicates the vertical position of a line in the table (e.g., header, body, or footer).

const (
	LevelHeader Level = iota // Topmost line position
	LevelBody                // LevelBody line position
	LevelFooter              // LevelFooter line position
)

func (Level) Validate added in v1.0.1

func (l Level) Validate() error

Validate checks if the Level is one of the allowed values: Header, Body, or Footer.

type Lines

type Lines struct {
	ShowTop        State // Top border visibility
	ShowBottom     State // Bottom border visibility
	ShowHeaderLine State // Header separator line visibility
	ShowFooterLine State // Footer separator line visibility
}

Lines manages the visibility of table boundary lines.

type Location

type Location string

Location specifies the horizontal position of a cell or column within a table row.

const (
	LocationFirst  Location = "first"  // Topmost line position
	LocationMiddle Location = "middle" // LevelBody line position
	LocationEnd    Location = "end"    // LevelFooter line position
)

func (Location) Validate added in v1.0.1

func (l Location) Validate() error

Validate checks if the Location is one of the allowed values: First, Middle, or End.

type Mapper

type Mapper[K comparable, V any] map[K]V

Mapper is a generic map type with comparable keys and any value type. It provides type-safe operations on maps with additional convenience methods.

func NewMapper

func NewMapper[K comparable, V any]() Mapper[K, V]

NewMapper creates and returns a new initialized Mapper.

func SlicerToMapper

func SlicerToMapper[K comparable, V any](s Slicer[KeyValuePair[K, V]]) Mapper[K, V]

SlicerToMapper converts a Slicer of KeyValuePair to a Mapper.

func (Mapper[K, V]) Clear added in v1.0.1

func (m Mapper[K, V]) Clear()

func (Mapper[K, V]) Clone

func (m Mapper[K, V]) Clone() Mapper[K, V]

Clone returns a shallow copy of the Mapper.

func (Mapper[K, V]) Delete

func (m Mapper[K, V]) Delete(key K) Mapper[K, V]

Delete removes the specified key from the map. Does nothing if the key doesn't exist or the map is nil.

func (Mapper[K, V]) Each

func (m Mapper[K, V]) Each(fn func(K, V))

Each iterates over each key-value pair in the map and calls the provided function. Does nothing if the map is nil.

func (Mapper[K, V]) Filter

func (m Mapper[K, V]) Filter(fn func(K, V) bool) Mapper[K, V]

Filter returns a new Mapper containing only the key-value pairs that satisfy the predicate.

func (Mapper[K, V]) Get

func (m Mapper[K, V]) Get(key K) V

Get returns the value associated with the key. If the key doesn't exist or the map is nil, it returns the zero value for the value type.

func (Mapper[K, V]) Has

func (m Mapper[K, V]) Has(key K) bool

Has returns true if the key exists in the map, false otherwise.

func (Mapper[K, V]) Keys

func (m Mapper[K, V]) Keys() []K

Keys returns a slice containing all keys in the map. Returns nil if the map is nil or empty.

func (Mapper[K, V]) Len

func (m Mapper[K, V]) Len() int

Len returns the number of elements in the map. Returns 0 if the map is nil.

func (Mapper[K, V]) MapValues

func (m Mapper[K, V]) MapValues(fn func(V) V) Mapper[K, V]

MapValues returns a new Mapper with the same keys but values transformed by the provided function.

func (Mapper[K, V]) OK

func (m Mapper[K, V]) OK(key K) (V, bool)

OK returns the value associated with the key and a boolean indicating whether the key exists.

func (Mapper[K, V]) Set

func (m Mapper[K, V]) Set(key K, value V) Mapper[K, V]

Set sets the value for the specified key. Does nothing if the map is nil.

func (Mapper[K, V]) Slicer

func (m Mapper[K, V]) Slicer() Slicer[KeyValuePair[K, V]]

Slicer converts the Mapper to a Slicer of key-value pairs.

func (Mapper[K, V]) SortedKeys added in v1.0.1

func (m Mapper[K, V]) SortedKeys() []K

func (Mapper[K, V]) Values

func (m Mapper[K, V]) Values() []V

Values returns a slice containing all values in the map. Returns nil if the map is nil or empty.

type MergeState

type MergeState struct {
	Vertical     MergeStateOption // Properties for vertical merging (across rows)
	Horizontal   MergeStateOption // Properties for horizontal merging (across columns)
	Hierarchical MergeStateOption // Properties for nested/hierarchical merging
}

MergeState captures how a cell merges across different directions.

type MergeStateOption

type MergeStateOption struct {
	Present bool // True if this merge direction is active
	Span    int  // Number of cells this merge spans
	Start   bool // True if this cell is the starting point of the merge
	End     bool // True if this cell is the ending point of the merge
}

MergeStateOption represents common attributes for merging in a specific direction.

type Padding

type Padding struct {
	Left   string
	Right  string
	Top    string
	Bottom string
}

Padding defines custom padding characters for a cell

type Position

type Position string

Position defines where formatting applies in the table (e.g., header, footer, or rows).

const (
	Header Position = "header" // Table header section
	Row    Position = "row"    // Table row section
	Footer Position = "footer" // Table footer section
)

func (Position) Validate added in v1.0.1

func (pos Position) Validate() error

Validate checks if the Position is one of the allowed values: Header, Footer, or Row.

type Renderer

type Renderer interface {
	Start(w io.Writer) error
	Header(w io.Writer, headers [][]string, ctx Formatting) // Renders table header
	Row(w io.Writer, row []string, ctx Formatting)          // Renders a single row
	Footer(w io.Writer, footers [][]string, ctx Formatting) // Renders table footer
	Line(w io.Writer, ctx Formatting)                       // Renders separator line
	Config() Rendition                                      // Returns renderer config
	Close(w io.Writer) error
	Logger(logger *ll.Logger) // send logger to renderers
}

Renderer defines the interface for rendering tables to an io.Writer. Implementations must handle headers, rows, footers, and separator lines.

type Rendition added in v1.0.1

type Rendition struct {
	Borders   Border   // Border visibility settings
	Symbols   Symbols  // Symbols used for table drawing
	Settings  Settings // Rendering behavior settings
	Streaming bool
}

Rendition holds the configuration for the default renderer.

type RowContext

type RowContext struct {
	Position     Position            // Section of the table (Header, Row, Footer)
	Location     Location            // Boundary position (First, Middle, End)
	Current      map[int]CellContext // Cells in this row, indexed by column
	Previous     map[int]CellContext // Cells from the row above; nil if none
	Next         map[int]CellContext // Cells from the row below; nil if none
	Widths       Mapper[int, int]    // Computed widths for each column
	ColMaxWidths CellWidth           // Maximum allowed width per column
}

RowContext manages layout properties and relationships for a row and its columns. It maintains state about the current row and its neighbors for proper rendering.

func (RowContext) GetCell added in v1.0.1

func (r RowContext) GetCell(col int) CellContext

type Separators

type Separators struct {
	ShowHeader     State // Controls header separator visibility
	ShowFooter     State // Controls footer separator visibility
	BetweenRows    State // Determines if lines appear between rows
	BetweenColumns State // Determines if separators appear between columns
}

Separators controls the visibility of separators in the table.

type Settings

type Settings struct {
	Separators Separators // Separator visibility settings
	Lines      Lines      // Line visibility settings
	//TrimWhitespace State      // Trims whitespace from cell content if enabled
	CompactMode State // Reserved for future compact rendering (unused)
}

Settings holds configuration preferences for rendering behavior.

type Slicer

type Slicer[T any] []T

Slicer is a generic slice type that provides additional methods for slice manipulation.

func NewSlicer

func NewSlicer[T any]() Slicer[T]

NewSlicer creates and returns a new initialized Slicer.

func (Slicer[T]) Append

func (s Slicer[T]) Append(elements ...T) Slicer[T]

Append appends elements to the slice and returns the new slice.

func (Slicer[T]) Clone

func (s Slicer[T]) Clone() Slicer[T]

Clone returns a shallow copy of the Slicer.

func (Slicer[T]) Contains

func (s Slicer[T]) Contains(fn func(T) bool) bool

Contains returns true if the slice contains an element that satisfies the predicate.

func (Slicer[T]) Each

func (s Slicer[T]) Each(fn func(T))

Each iterates over each element in the slice and calls the provided function. Does nothing if the slice is nil.

func (Slicer[T]) Filter

func (s Slicer[T]) Filter(fn func(T) bool) Slicer[T]

Filter returns a new Slicer containing only elements that satisfy the predicate.

func (Slicer[T]) Find

func (s Slicer[T]) Find(fn func(T) bool) (T, bool)

Find returns the first element that satisfies the predicate, along with a boolean indicating if it was found.

func (Slicer[T]) First

func (s Slicer[T]) First() T

First returns the first element of the slice, or the zero value if empty.

func (Slicer[T]) Get

func (s Slicer[T]) Get(index int) T

Get returns the element at the specified index. Returns the zero value if the index is out of bounds or the slice is nil.

func (Slicer[T]) GetOK

func (s Slicer[T]) GetOK(index int) (T, bool)

GetOK returns the element at the specified index and a boolean indicating whether the index was valid.

func (Slicer[T]) Has

func (s Slicer[T]) Has(index int) bool

Has returns true if the index exists in the slice.

func (Slicer[T]) IsEmpty

func (s Slicer[T]) IsEmpty() bool

IsEmpty returns true if the slice is nil or has zero elements.

func (Slicer[T]) Last

func (s Slicer[T]) Last() T

Last returns the last element of the slice, or the zero value if empty.

func (Slicer[T]) Len

func (s Slicer[T]) Len() int

Len returns the number of elements in the slice. Returns 0 if the slice is nil.

func (Slicer[T]) Map

func (s Slicer[T]) Map(fn func(T) T) Slicer[T]

Map returns a new Slicer with each element transformed by the provided function.

func (Slicer[T]) Prepend

func (s Slicer[T]) Prepend(elements ...T) Slicer[T]

Prepend adds elements to the beginning of the slice and returns the new slice.

type State

type State int

State represents an on/off state

const (
	On  State = Success // Feature is enabled
	Off State = Fail    // Feature is disabled
)

Feature State Constants Represents enabled/disabled states for features

func (State) Cond

func (o State) Cond(c func() bool) bool

Cond executes a condition if the state is enabled

func (State) Disabled

func (o State) Disabled() bool

Disabled checks if the state is off

func (State) Enabled

func (o State) Enabled() bool

Enabled checks if the state is on

func (State) Or

func (o State) Or(c State) State

Or returns this state if enabled, else the provided state

func (State) String

func (o State) String() string

String returns the string representation of the state

func (State) Toggle

func (o State) Toggle() State

Toggle switches the state between on and off

type StreamConfig added in v1.0.1

type StreamConfig struct {
	Enable bool
	Widths CellWidth // Cell/column widths
}

type SymbolASCII

type SymbolASCII struct{}

SymbolASCII provides basic SymbolASCII border symbols

func (*SymbolASCII) BottomLeft

func (s *SymbolASCII) BottomLeft() string

func (*SymbolASCII) BottomMid

func (s *SymbolASCII) BottomMid() string

func (*SymbolASCII) BottomRight

func (s *SymbolASCII) BottomRight() string

func (*SymbolASCII) Center

func (s *SymbolASCII) Center() string

func (*SymbolASCII) Column

func (s *SymbolASCII) Column() string

func (*SymbolASCII) HeaderLeft

func (s *SymbolASCII) HeaderLeft() string

func (*SymbolASCII) HeaderMid

func (s *SymbolASCII) HeaderMid() string

func (*SymbolASCII) HeaderRight

func (s *SymbolASCII) HeaderRight() string

func (*SymbolASCII) MidLeft

func (s *SymbolASCII) MidLeft() string

func (*SymbolASCII) MidRight

func (s *SymbolASCII) MidRight() string

func (*SymbolASCII) Name

func (s *SymbolASCII) Name() string

SymbolASCII symbol methods

func (*SymbolASCII) Row

func (s *SymbolASCII) Row() string

func (*SymbolASCII) TopLeft

func (s *SymbolASCII) TopLeft() string

func (*SymbolASCII) TopMid

func (s *SymbolASCII) TopMid() string

func (*SymbolASCII) TopRight

func (s *SymbolASCII) TopRight() string

type SymbolCustom added in v1.0.1

type SymbolCustom struct {
	// contains filtered or unexported fields
}

SymbolCustom implements the Symbols interface with fully configurable symbols

func NewSymbolCustom added in v1.0.1

func NewSymbolCustom(name string) *SymbolCustom

NewSymbolCustom creates a new customizable border style

func (*SymbolCustom) BottomLeft added in v1.0.1

func (c *SymbolCustom) BottomLeft() string

func (*SymbolCustom) BottomMid added in v1.0.1

func (c *SymbolCustom) BottomMid() string

func (*SymbolCustom) BottomRight added in v1.0.1

func (c *SymbolCustom) BottomRight() string

func (*SymbolCustom) Center added in v1.0.1

func (c *SymbolCustom) Center() string

func (*SymbolCustom) Column added in v1.0.1

func (c *SymbolCustom) Column() string

func (*SymbolCustom) HeaderLeft added in v1.0.1

func (c *SymbolCustom) HeaderLeft() string

func (*SymbolCustom) HeaderMid added in v1.0.1

func (c *SymbolCustom) HeaderMid() string

func (*SymbolCustom) HeaderRight added in v1.0.1

func (c *SymbolCustom) HeaderRight() string

func (*SymbolCustom) MidLeft added in v1.0.1

func (c *SymbolCustom) MidLeft() string

func (*SymbolCustom) MidRight added in v1.0.1

func (c *SymbolCustom) MidRight() string

func (*SymbolCustom) Name added in v1.0.1

func (c *SymbolCustom) Name() string

Implement all Symbols interface methods

func (*SymbolCustom) Row added in v1.0.1

func (c *SymbolCustom) Row() string

func (*SymbolCustom) TopLeft added in v1.0.1

func (c *SymbolCustom) TopLeft() string

func (*SymbolCustom) TopMid added in v1.0.1

func (c *SymbolCustom) TopMid() string

func (*SymbolCustom) TopRight added in v1.0.1

func (c *SymbolCustom) TopRight() string

func (*SymbolCustom) WithBottomLeft added in v1.0.1

func (c *SymbolCustom) WithBottomLeft(s string) *SymbolCustom

func (*SymbolCustom) WithBottomMid added in v1.0.1

func (c *SymbolCustom) WithBottomMid(s string) *SymbolCustom

func (*SymbolCustom) WithBottomRight added in v1.0.1

func (c *SymbolCustom) WithBottomRight(s string) *SymbolCustom

func (*SymbolCustom) WithCenter added in v1.0.1

func (c *SymbolCustom) WithCenter(s string) *SymbolCustom

Builder methods for fluent configuration

func (*SymbolCustom) WithColumn added in v1.0.1

func (c *SymbolCustom) WithColumn(s string) *SymbolCustom

func (*SymbolCustom) WithHeaderLeft added in v1.0.1

func (c *SymbolCustom) WithHeaderLeft(s string) *SymbolCustom

func (*SymbolCustom) WithHeaderMid added in v1.0.1

func (c *SymbolCustom) WithHeaderMid(s string) *SymbolCustom

func (*SymbolCustom) WithHeaderRight added in v1.0.1

func (c *SymbolCustom) WithHeaderRight(s string) *SymbolCustom

func (*SymbolCustom) WithMidLeft added in v1.0.1

func (c *SymbolCustom) WithMidLeft(s string) *SymbolCustom

func (*SymbolCustom) WithMidRight added in v1.0.1

func (c *SymbolCustom) WithMidRight(s string) *SymbolCustom

func (*SymbolCustom) WithRow added in v1.0.1

func (c *SymbolCustom) WithRow(s string) *SymbolCustom

func (*SymbolCustom) WithTopLeft added in v1.0.1

func (c *SymbolCustom) WithTopLeft(s string) *SymbolCustom

func (*SymbolCustom) WithTopMid added in v1.0.1

func (c *SymbolCustom) WithTopMid(s string) *SymbolCustom

func (*SymbolCustom) WithTopRight added in v1.0.1

func (c *SymbolCustom) WithTopRight(s string) *SymbolCustom

type SymbolGraphical

type SymbolGraphical struct{}

SymbolGraphical provides border symbols using emoji/emoticons

func (*SymbolGraphical) BottomLeft

func (s *SymbolGraphical) BottomLeft() string

func (*SymbolGraphical) BottomMid

func (s *SymbolGraphical) BottomMid() string

func (*SymbolGraphical) BottomRight

func (s *SymbolGraphical) BottomRight() string

func (*SymbolGraphical) Center

func (s *SymbolGraphical) Center() string

func (*SymbolGraphical) Column

func (s *SymbolGraphical) Column() string

func (*SymbolGraphical) HeaderLeft

func (s *SymbolGraphical) HeaderLeft() string

func (*SymbolGraphical) HeaderMid

func (s *SymbolGraphical) HeaderMid() string

func (*SymbolGraphical) HeaderRight

func (s *SymbolGraphical) HeaderRight() string

func (*SymbolGraphical) MidLeft

func (s *SymbolGraphical) MidLeft() string

func (*SymbolGraphical) MidRight

func (s *SymbolGraphical) MidRight() string

func (*SymbolGraphical) Name

func (s *SymbolGraphical) Name() string

SymbolGraphical symbol methods

func (*SymbolGraphical) Row

func (s *SymbolGraphical) Row() string

func (*SymbolGraphical) TopLeft

func (s *SymbolGraphical) TopLeft() string

func (*SymbolGraphical) TopMid

func (s *SymbolGraphical) TopMid() string

func (*SymbolGraphical) TopRight

func (s *SymbolGraphical) TopRight() string

type SymbolMarkdown

type SymbolMarkdown struct{}

SymbolMarkdown provides symbols for SymbolMarkdown-style tables

func (*SymbolMarkdown) BottomLeft

func (s *SymbolMarkdown) BottomLeft() string

func (*SymbolMarkdown) BottomMid

func (s *SymbolMarkdown) BottomMid() string

func (*SymbolMarkdown) BottomRight

func (s *SymbolMarkdown) BottomRight() string

func (*SymbolMarkdown) Center

func (s *SymbolMarkdown) Center() string

func (*SymbolMarkdown) Column

func (s *SymbolMarkdown) Column() string

func (*SymbolMarkdown) HeaderLeft

func (s *SymbolMarkdown) HeaderLeft() string

func (*SymbolMarkdown) HeaderMid

func (s *SymbolMarkdown) HeaderMid() string

func (*SymbolMarkdown) HeaderRight

func (s *SymbolMarkdown) HeaderRight() string

func (*SymbolMarkdown) MidLeft

func (s *SymbolMarkdown) MidLeft() string

func (*SymbolMarkdown) MidRight

func (s *SymbolMarkdown) MidRight() string

func (*SymbolMarkdown) Name

func (s *SymbolMarkdown) Name() string

SymbolMarkdown symbol methods

func (*SymbolMarkdown) Row

func (s *SymbolMarkdown) Row() string

func (*SymbolMarkdown) TopLeft

func (s *SymbolMarkdown) TopLeft() string

func (*SymbolMarkdown) TopMid

func (s *SymbolMarkdown) TopMid() string

func (*SymbolMarkdown) TopRight

func (s *SymbolMarkdown) TopRight() string

type SymbolMerger

type SymbolMerger struct {
	// contains filtered or unexported fields
}

SymbolMerger provides custom symbols for merged table rendering

func (*SymbolMerger) BottomLeft

func (s *SymbolMerger) BottomLeft() string

func (*SymbolMerger) BottomMid

func (s *SymbolMerger) BottomMid() string

func (*SymbolMerger) BottomRight

func (s *SymbolMerger) BottomRight() string

func (*SymbolMerger) Center

func (s *SymbolMerger) Center() string

func (*SymbolMerger) Column

func (s *SymbolMerger) Column() string

func (*SymbolMerger) HeaderLeft

func (s *SymbolMerger) HeaderLeft() string

func (*SymbolMerger) HeaderMid

func (s *SymbolMerger) HeaderMid() string

func (*SymbolMerger) HeaderRight

func (s *SymbolMerger) HeaderRight() string

func (*SymbolMerger) MidLeft

func (s *SymbolMerger) MidLeft() string

func (*SymbolMerger) MidRight

func (s *SymbolMerger) MidRight() string

func (*SymbolMerger) Name

func (s *SymbolMerger) Name() string

SymbolMerger symbol methods

func (*SymbolMerger) Row

func (s *SymbolMerger) Row() string

func (*SymbolMerger) TopLeft

func (s *SymbolMerger) TopLeft() string

func (*SymbolMerger) TopMid

func (s *SymbolMerger) TopMid() string

func (*SymbolMerger) TopRight

func (s *SymbolMerger) TopRight() string

type SymbolNothing

type SymbolNothing struct{}

SymbolNothing provides no border symbols (invisible borders)

func (*SymbolNothing) BottomLeft

func (s *SymbolNothing) BottomLeft() string

func (*SymbolNothing) BottomMid

func (s *SymbolNothing) BottomMid() string

func (*SymbolNothing) BottomRight

func (s *SymbolNothing) BottomRight() string

func (*SymbolNothing) Center

func (s *SymbolNothing) Center() string

func (*SymbolNothing) Column

func (s *SymbolNothing) Column() string

func (*SymbolNothing) HeaderLeft

func (s *SymbolNothing) HeaderLeft() string

func (*SymbolNothing) HeaderMid

func (s *SymbolNothing) HeaderMid() string

func (*SymbolNothing) HeaderRight

func (s *SymbolNothing) HeaderRight() string

func (*SymbolNothing) MidLeft

func (s *SymbolNothing) MidLeft() string

func (*SymbolNothing) MidRight

func (s *SymbolNothing) MidRight() string

func (*SymbolNothing) Name

func (s *SymbolNothing) Name() string

SymbolNothing symbol methods

func (*SymbolNothing) Row

func (s *SymbolNothing) Row() string

func (*SymbolNothing) TopLeft

func (s *SymbolNothing) TopLeft() string

func (*SymbolNothing) TopMid

func (s *SymbolNothing) TopMid() string

func (*SymbolNothing) TopRight

func (s *SymbolNothing) TopRight() string

type SymbolUnicode

type SymbolUnicode struct {
	// contains filtered or unexported fields
}

SymbolUnicode provides configurable SymbolUnicode border symbols

func (*SymbolUnicode) BottomLeft

func (s *SymbolUnicode) BottomLeft() string

func (*SymbolUnicode) BottomMid

func (s *SymbolUnicode) BottomMid() string

func (*SymbolUnicode) BottomRight

func (s *SymbolUnicode) BottomRight() string

func (*SymbolUnicode) Center

func (s *SymbolUnicode) Center() string

func (*SymbolUnicode) Column

func (s *SymbolUnicode) Column() string

func (*SymbolUnicode) HeaderLeft

func (s *SymbolUnicode) HeaderLeft() string

func (*SymbolUnicode) HeaderMid

func (s *SymbolUnicode) HeaderMid() string

func (*SymbolUnicode) HeaderRight

func (s *SymbolUnicode) HeaderRight() string

func (*SymbolUnicode) MidLeft

func (s *SymbolUnicode) MidLeft() string

func (*SymbolUnicode) MidRight

func (s *SymbolUnicode) MidRight() string

func (*SymbolUnicode) Name

func (s *SymbolUnicode) Name() string

SymbolUnicode symbol methods

func (*SymbolUnicode) Row

func (s *SymbolUnicode) Row() string

func (*SymbolUnicode) TopLeft

func (s *SymbolUnicode) TopLeft() string

func (*SymbolUnicode) TopMid

func (s *SymbolUnicode) TopMid() string

func (*SymbolUnicode) TopRight

func (s *SymbolUnicode) TopRight() string

type Symbols

type Symbols interface {
	// Name returns the style name
	Name() string

	// Basic component symbols
	Center() string // Junction symbol (where lines cross)
	Row() string    // Horizontal line symbol
	Column() string // Vertical line symbol

	// Corner and junction symbols
	TopLeft() string     // LevelHeader-left corner
	TopMid() string      // LevelHeader junction
	TopRight() string    // LevelHeader-right corner
	MidLeft() string     // Left junction
	MidRight() string    // Right junction
	BottomLeft() string  // LevelFooter-left corner
	BottomMid() string   // LevelFooter junction
	BottomRight() string // LevelFooter-right corner

	// Optional header-specific symbols
	HeaderLeft() string
	HeaderMid() string
	HeaderRight() string
}

Symbols defines the interface for table border symbols

func NewSymbols

func NewSymbols(style BorderStyle) Symbols

NewSymbols creates a new Symbols instance with the specified style

Jump to

Keyboard shortcuts

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