Documentation
¶
Index ¶
- type AlignmentConfigBuilder
- type Behaviordeprecated
- type BehaviorConfigBuilder
- func (bb *BehaviorConfigBuilder) Build() *ConfigBuilder
- func (bb *BehaviorConfigBuilder) WithAutoHeader(state tw.State) *BehaviorConfigBuilder
- func (bb *BehaviorConfigBuilder) WithAutoHide(state tw.State) *BehaviorConfigBuilder
- func (bb *BehaviorConfigBuilder) WithCompactMerge(state tw.State) *BehaviorConfigBuilder
- func (bb *BehaviorConfigBuilder) WithFooterHide(state tw.State) *BehaviorConfigBuilder
- func (bb *BehaviorConfigBuilder) WithHeaderHide(state tw.State) *BehaviorConfigBuilder
- func (bb *BehaviorConfigBuilder) WithTrimSpace(state tw.State) *BehaviorConfigBuilder
- type ColumnConfigBuilder
- type Config
- type ConfigBuilder
- func (b *ConfigBuilder) Behavior() *BehaviorConfigBuilder
- func (b *ConfigBuilder) Build() Config
- func (b *ConfigBuilder) Footer() *FooterConfigBuilder
- func (b *ConfigBuilder) ForColumn(col int) *ColumnConfigBuilder
- func (b *ConfigBuilder) Header() *HeaderConfigBuilder
- func (b *ConfigBuilder) Row() *RowConfigBuilder
- func (b *ConfigBuilder) WithAutoHide(state tw.State) *ConfigBuilder
- func (b *ConfigBuilder) WithDebug(debug bool) *ConfigBuilder
- func (b *ConfigBuilder) WithFooterAlignment(align tw.Align) *ConfigBuilder
- func (b *ConfigBuilder) WithFooterAutoFormat(autoFormat tw.State) *ConfigBuilder
- func (b *ConfigBuilder) WithFooterAutoWrap(autoWrap int) *ConfigBuilder
- func (b *ConfigBuilder) WithFooterGlobalPadding(padding tw.Padding) *ConfigBuilder
- func (b *ConfigBuilder) WithFooterMaxWidth(maxWidth int) *ConfigBuilder
- func (b *ConfigBuilder) WithFooterMergeMode(mergeMode int) *ConfigBuilderdeprecated
- func (b *ConfigBuilder) WithHeaderAlignment(align tw.Align) *ConfigBuilder
- func (b *ConfigBuilder) WithHeaderAutoFormat(autoFormat tw.State) *ConfigBuilder
- func (b *ConfigBuilder) WithHeaderAutoWrap(autoWrap int) *ConfigBuilder
- func (b *ConfigBuilder) WithHeaderGlobalPadding(padding tw.Padding) *ConfigBuilder
- func (b *ConfigBuilder) WithHeaderMaxWidth(maxWidth int) *ConfigBuilder
- func (b *ConfigBuilder) WithHeaderMergeMode(mergeMode int) *ConfigBuilderdeprecated
- func (b *ConfigBuilder) WithMaxWidth(width int) *ConfigBuilder
- func (b *ConfigBuilder) WithRowAlignment(align tw.Align) *ConfigBuilder
- func (b *ConfigBuilder) WithRowAutoFormat(autoFormat tw.State) *ConfigBuilder
- func (b *ConfigBuilder) WithRowAutoWrap(autoWrap int) *ConfigBuilder
- func (b *ConfigBuilder) WithRowGlobalPadding(padding tw.Padding) *ConfigBuilder
- func (b *ConfigBuilder) WithRowMaxWidth(maxWidth int) *ConfigBuilder
- func (b *ConfigBuilder) WithRowMergeMode(mergeMode int) *ConfigBuilderdeprecated
- func (b *ConfigBuilder) WithTrimSpace(state tw.State) *ConfigBuilder
- type FooterCallbacksBuilder
- func (fc *FooterCallbacksBuilder) AddColumnCallback(callback func()) *FooterCallbacksBuilder
- func (fc *FooterCallbacksBuilder) Build() *FooterConfigBuilder
- func (fc *FooterCallbacksBuilder) WithGlobal(callback func()) *FooterCallbacksBuilder
- func (fc *FooterCallbacksBuilder) WithPerColumn(callbacks []func()) *FooterCallbacksBuilder
- type FooterConfigBuilder
- func (f *FooterConfigBuilder) Alignment() *AlignmentConfigBuilder
- func (f *FooterConfigBuilder) Build() *ConfigBuilder
- func (f *FooterConfigBuilder) Callbacks() *FooterCallbacksBuilder
- func (f *FooterConfigBuilder) Filter() *FooterFilterBuilder
- func (f *FooterConfigBuilder) Formatting() *FooterFormattingBuilder
- func (f *FooterConfigBuilder) Merging() *FooterMergingBuilder
- func (f *FooterConfigBuilder) Padding() *FooterPaddingBuilder
- type FooterFilterBuilder
- func (ff *FooterFilterBuilder) AddColumnFilter(filter func(string) string) *FooterFilterBuilder
- func (ff *FooterFilterBuilder) Build() *FooterConfigBuilder
- func (ff *FooterFilterBuilder) WithGlobal(filter func([]string) []string) *FooterFilterBuilder
- func (ff *FooterFilterBuilder) WithPerColumn(filters []func(string) string) *FooterFilterBuilder
- type FooterFormattingBuilder
- func (ff *FooterFormattingBuilder) Build() *FooterConfigBuilder
- func (ff *FooterFormattingBuilder) WithAlignment(align tw.Align) *FooterFormattingBuilderdeprecated
- func (ff *FooterFormattingBuilder) WithAutoFormat(autoFormat tw.State) *FooterFormattingBuilder
- func (ff *FooterFormattingBuilder) WithAutoWrap(autoWrap int) *FooterFormattingBuilder
- func (ff *FooterFormattingBuilder) WithMergeMode(mergeMode int) *FooterFormattingBuilderdeprecated
- type FooterMergingBuilder
- type FooterPaddingBuilder
- func (fp *FooterPaddingBuilder) AddColumnPadding(padding tw.Padding) *FooterPaddingBuilder
- func (fp *FooterPaddingBuilder) Build() *FooterConfigBuilder
- func (fp *FooterPaddingBuilder) WithGlobal(padding tw.Padding) *FooterPaddingBuilder
- func (fp *FooterPaddingBuilder) WithPerColumn(padding []tw.Padding) *FooterPaddingBuilder
- type HeaderCallbacksBuilder
- func (hc *HeaderCallbacksBuilder) AddColumnCallback(callback func()) *HeaderCallbacksBuilder
- func (hc *HeaderCallbacksBuilder) Build() *HeaderConfigBuilder
- func (hc *HeaderCallbacksBuilder) WithGlobal(callback func()) *HeaderCallbacksBuilder
- func (hc *HeaderCallbacksBuilder) WithPerColumn(callbacks []func()) *HeaderCallbacksBuilder
- type HeaderConfigBuilder
- func (h *HeaderConfigBuilder) Alignment() *AlignmentConfigBuilder
- func (h *HeaderConfigBuilder) Build() *ConfigBuilder
- func (h *HeaderConfigBuilder) Callbacks() *HeaderCallbacksBuilder
- func (h *HeaderConfigBuilder) Filter() *HeaderFilterBuilder
- func (h *HeaderConfigBuilder) Formatting() *HeaderFormattingBuilder
- func (h *HeaderConfigBuilder) Merging() *HeaderMergingBuilder
- func (h *HeaderConfigBuilder) Padding() *HeaderPaddingBuilder
- type HeaderFilterBuilder
- func (hf *HeaderFilterBuilder) AddColumnFilter(filter func(string) string) *HeaderFilterBuilder
- func (hf *HeaderFilterBuilder) Build() *HeaderConfigBuilder
- func (hf *HeaderFilterBuilder) WithGlobal(filter func([]string) []string) *HeaderFilterBuilder
- func (hf *HeaderFilterBuilder) WithPerColumn(filters []func(string) string) *HeaderFilterBuilder
- type HeaderFormattingBuilder
- func (hf *HeaderFormattingBuilder) Build() *HeaderConfigBuilder
- func (hf *HeaderFormattingBuilder) WithAlignment(align tw.Align) *HeaderFormattingBuilderdeprecated
- func (hf *HeaderFormattingBuilder) WithAutoFormat(autoFormat tw.State) *HeaderFormattingBuilder
- func (hf *HeaderFormattingBuilder) WithAutoWrap(autoWrap int) *HeaderFormattingBuilder
- func (hf *HeaderFormattingBuilder) WithMergeMode(mergeMode int) *HeaderFormattingBuilderdeprecated
- type HeaderMergingBuilder
- type HeaderPaddingBuilder
- func (hp *HeaderPaddingBuilder) AddColumnPadding(padding tw.Padding) *HeaderPaddingBuilder
- func (hp *HeaderPaddingBuilder) Build() *HeaderConfigBuilder
- func (hp *HeaderPaddingBuilder) WithGlobal(padding tw.Padding) *HeaderPaddingBuilder
- func (hp *HeaderPaddingBuilder) WithPerColumn(padding []tw.Padding) *HeaderPaddingBuilder
- type Option
- func WithAlignment(alignment tw.Alignment) Option
- func WithAutoHide(state tw.State) Option
- func WithBehavior(behavior tw.Behavior) Option
- func WithBorders(borders tw.Border) Optiondeprecated
- func WithColumnMax(width int) Option
- func WithColumnWidths(widths tw.Mapper[int, int]) Option
- func WithCondition(cond *runewidth.Condition) Optiondeprecated
- func WithConfig(cfg Config) Option
- func WithCounters(counters ...tw.Counter) Option
- func WithDebug(debug bool) Option
- func WithEastAsian(state tw.State) Option
- func WithFooter(footers []string) Option
- func WithFooterAlignmentConfig(alignment tw.CellAlignment) Option
- func WithFooterAutoFormat(state tw.State) Option
- func WithFooterAutoWrap(wrap int) Option
- func WithFooterCallbacks(callbacks tw.CellCallbacks) Option
- func WithFooterConfig(config tw.CellConfig) Option
- func WithFooterControl(control tw.Control) Option
- func WithFooterFilter(filter tw.CellFilter) Option
- func WithFooterMaxWidth(maxWidth int) Option
- func WithFooterMergeMode(mergeMode int) Optiondeprecated
- func WithFooterPaddingPerColumn(padding []tw.Padding) Option
- func WithHeader(headers []string) Option
- func WithHeaderAlignment(align tw.Align) Option
- func WithHeaderAlignmentConfig(alignment tw.CellAlignment) Option
- func WithHeaderAutoFormat(state tw.State) Option
- func WithHeaderAutoWrap(wrap int) Option
- func WithHeaderCallbacks(callbacks tw.CellCallbacks) Option
- func WithHeaderConfig(config tw.CellConfig) Option
- func WithHeaderControl(control tw.Control) Option
- func WithHeaderFilter(filter tw.CellFilter) Option
- func WithHeaderMaxWidth(maxWidth int) Option
- func WithHeaderMergeMode(mergeMode int) Optiondeprecated
- func WithHeaderPaddingPerColumn(padding []tw.Padding) Option
- func WithLineCounter() Option
- func WithLogger(logger *ll.Logger) Option
- func WithMaxWidth(width int) Option
- func WithPadding(padding tw.Padding) Option
- func WithRenderer(f tw.Renderer) Option
- func WithRendererSettings(settings tw.Settings) Optiondeprecated
- func WithRendition(rendition tw.Rendition) Option
- func WithRowAlignment(align tw.Align) Option
- func WithRowAlignmentConfig(alignment tw.CellAlignment) Option
- func WithRowAutoFormat(state tw.State) Option
- func WithRowAutoWrap(wrap int) Option
- func WithRowCallbacks(callbacks tw.CellCallbacks) Option
- func WithRowConfig(config tw.CellConfig) Option
- func WithRowFilter(filter tw.CellFilter) Option
- func WithRowMaxWidth(maxWidth int) Option
- func WithRowMergeMode(mergeMode int) Optiondeprecated
- func WithRowPaddingPerColumn(padding []tw.Padding) Option
- func WithStreaming(c tw.StreamConfig) Option
- func WithStringer(stringer interface{}) Option
- func WithStringerCache() Option
- func WithStringerCacheCustom(cache twcache.Cache[reflect.Type, reflect.Value]) Option
- func WithSymbols(symbols tw.Symbols) Option
- func WithTableMax(width int) Optiondeprecated
- func WithTrimLine(state tw.State) Option
- func WithTrimSpace(state tw.State) Option
- func WithWidths(width tw.CellWidth) Option
- type RowCallbacksBuilder
- func (rc *RowCallbacksBuilder) AddColumnCallback(callback func()) *RowCallbacksBuilder
- func (rc *RowCallbacksBuilder) Build() *RowConfigBuilder
- func (rc *RowCallbacksBuilder) WithGlobal(callback func()) *RowCallbacksBuilder
- func (rc *RowCallbacksBuilder) WithPerColumn(callbacks []func()) *RowCallbacksBuilder
- type RowConfigBuilder
- func (r *RowConfigBuilder) Alignment() *AlignmentConfigBuilder
- func (r *RowConfigBuilder) Build() *ConfigBuilder
- func (r *RowConfigBuilder) Callbacks() *RowCallbacksBuilder
- func (r *RowConfigBuilder) Filter() *RowFilterBuilder
- func (r *RowConfigBuilder) Formatting() *RowFormattingBuilder
- func (r *RowConfigBuilder) Merging() *RowMergingBuilder
- func (r *RowConfigBuilder) Padding() *RowPaddingBuilder
- type RowFilterBuilder
- func (rf *RowFilterBuilder) AddColumnFilter(filter func(string) string) *RowFilterBuilder
- func (rf *RowFilterBuilder) Build() *RowConfigBuilder
- func (rf *RowFilterBuilder) WithGlobal(filter func([]string) []string) *RowFilterBuilder
- func (rf *RowFilterBuilder) WithPerColumn(filters []func(string) string) *RowFilterBuilder
- type RowFormattingBuilder
- func (rf *RowFormattingBuilder) Build() *RowConfigBuilder
- func (rf *RowFormattingBuilder) WithAlignment(align tw.Align) *RowFormattingBuilderdeprecated
- func (rf *RowFormattingBuilder) WithAutoFormat(autoFormat tw.State) *RowFormattingBuilder
- func (rf *RowFormattingBuilder) WithAutoWrap(autoWrap int) *RowFormattingBuilder
- func (rf *RowFormattingBuilder) WithMergeMode(mergeMode int) *RowFormattingBuilderdeprecated
- type RowMergingBuilder
- type RowPaddingBuilder
- func (rp *RowPaddingBuilder) AddColumnPadding(padding tw.Padding) *RowPaddingBuilder
- func (rp *RowPaddingBuilder) Build() *RowConfigBuilder
- func (rp *RowPaddingBuilder) WithGlobal(padding tw.Padding) *RowPaddingBuilder
- func (rp *RowPaddingBuilder) WithPerColumn(padding []tw.Padding) *RowPaddingBuilder
- type Settingsdeprecated
- type Table
- func (t *Table) Append(rows ...interface{}) error
- func (t *Table) Bulk(rows interface{}) error
- func (t *Table) Caption(caption tw.Caption) *Table
- func (t *Table) Close() error
- func (t *Table) Config() Config
- func (t *Table) Configure(fn func(cfg *Config)) *Table
- func (t *Table) Counters() []tw.Counter
- func (t *Table) Debug() *bytes.Buffer
- func (t *Table) Footer(elements ...any)
- func (t *Table) Header(elements ...any)
- func (t *Table) Lines() int
- func (t *Table) Logger() *ll.Logger
- func (t *Table) Options(opts ...Option) *Table
- func (t *Table) Render() error
- func (t *Table) Renderer() tw.Renderer
- func (t *Table) Reset()
- func (t *Table) Start() error
- func (t *Table) Trimmer(str string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlignmentConfigBuilder ¶
type AlignmentConfigBuilder struct {
// contains filtered or unexported fields
}
AlignmentConfigBuilder configures alignment settings
func (*AlignmentConfigBuilder) Build ¶
func (a *AlignmentConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*AlignmentConfigBuilder) WithGlobal ¶
func (a *AlignmentConfigBuilder) WithGlobal(align tw.Align) *AlignmentConfigBuilder
WithGlobal sets global alignment
func (*AlignmentConfigBuilder) WithPerColumn ¶
func (a *AlignmentConfigBuilder) WithPerColumn(alignments []tw.Align) *AlignmentConfigBuilder
WithPerColumn sets per-column alignments
type Behavior
deprecated
Behavior is an alias for tw.Behavior to configure table behavior settings. This type is deprecated and will be removed in a future version.
Deprecated: Use tw.Behavior directly to configure settings such as auto-hiding empty columns, trimming spaces, or controlling header/footer visibility.
Example migration:
// Old (deprecated)
var b tablewriter.Behavior = tablewriter.Behavior{AutoHide: tw.On}
// New (recommended)
var b tw.Behavior = tw.Behavior{AutoHide: tw.On}
type BehaviorConfigBuilder ¶
type BehaviorConfigBuilder struct {
// contains filtered or unexported fields
}
BehaviorConfigBuilder configures behavior settings
func (*BehaviorConfigBuilder) Build ¶
func (bb *BehaviorConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*BehaviorConfigBuilder) WithAutoHeader ¶
func (bb *BehaviorConfigBuilder) WithAutoHeader(state tw.State) *BehaviorConfigBuilder
WithAutoHeader enables/disables automatic header extraction for structs in Bulk.
func (*BehaviorConfigBuilder) WithAutoHide ¶
func (bb *BehaviorConfigBuilder) WithAutoHide(state tw.State) *BehaviorConfigBuilder
WithAutoHide enables/disables auto-hide
func (*BehaviorConfigBuilder) WithCompactMerge ¶
func (bb *BehaviorConfigBuilder) WithCompactMerge(state tw.State) *BehaviorConfigBuilder
WithCompactMerge enables/disables compact width optimization for merged cells
func (*BehaviorConfigBuilder) WithFooterHide ¶
func (bb *BehaviorConfigBuilder) WithFooterHide(state tw.State) *BehaviorConfigBuilder
WithFooterHide enables/disables footer visibility
func (*BehaviorConfigBuilder) WithHeaderHide ¶
func (bb *BehaviorConfigBuilder) WithHeaderHide(state tw.State) *BehaviorConfigBuilder
WithHeaderHide enables/disables header visibility
func (*BehaviorConfigBuilder) WithTrimSpace ¶
func (bb *BehaviorConfigBuilder) WithTrimSpace(state tw.State) *BehaviorConfigBuilder
WithTrimSpace enables/disables trim space
type ColumnConfigBuilder ¶
type ColumnConfigBuilder struct {
// contains filtered or unexported fields
}
ColumnConfigBuilder configures column-specific settings
func (*ColumnConfigBuilder) Build ¶
func (c *ColumnConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*ColumnConfigBuilder) WithAlignment ¶
func (c *ColumnConfigBuilder) WithAlignment(align tw.Align) *ColumnConfigBuilder
WithAlignment sets alignment for the column
func (*ColumnConfigBuilder) WithMaxWidth ¶
func (c *ColumnConfigBuilder) WithMaxWidth(width int) *ColumnConfigBuilder
WithMaxWidth sets max width for the column
type Config ¶
type Config struct {
MaxWidth int
Header tw.CellConfig
Row tw.CellConfig
Debug bool
Stream tw.StreamConfig
Behavior tw.Behavior
Widths tw.CellWidth
Counter tw.Counter
}
Config represents the table configuration
type ConfigBuilder ¶
type ConfigBuilder struct {
// contains filtered or unexported fields
}
ConfigBuilder provides a fluent interface for building Config
func NewConfigBuilder ¶
func NewConfigBuilder() *ConfigBuilder
NewConfigBuilder creates a new ConfigBuilder with defaults
func (*ConfigBuilder) Behavior ¶
func (b *ConfigBuilder) Behavior() *BehaviorConfigBuilder
Behavior returns a BehaviorConfigBuilder for behavior configuration
func (*ConfigBuilder) Footer ¶
func (b *ConfigBuilder) Footer() *FooterConfigBuilder
Footer returns a FooterConfigBuilder for footer configuration
func (*ConfigBuilder) ForColumn ¶
func (b *ConfigBuilder) ForColumn(col int) *ColumnConfigBuilder
ForColumn returns a ColumnConfigBuilder for column-specific configuration
func (*ConfigBuilder) Header ¶
func (b *ConfigBuilder) Header() *HeaderConfigBuilder
Header returns a HeaderConfigBuilder for header configuration
func (*ConfigBuilder) Row ¶
func (b *ConfigBuilder) Row() *RowConfigBuilder
Row returns a RowConfigBuilder for row configuration
func (*ConfigBuilder) WithAutoHide ¶
func (b *ConfigBuilder) WithAutoHide(state tw.State) *ConfigBuilder
WithAutoHide enables or disables automatic hiding of empty columns (ignored in streaming mode).
func (*ConfigBuilder) WithDebug ¶
func (b *ConfigBuilder) WithDebug(debug bool) *ConfigBuilder
WithDebug enables/disables debug logging
func (*ConfigBuilder) WithFooterAlignment ¶
func (b *ConfigBuilder) WithFooterAlignment(align tw.Align) *ConfigBuilder
WithFooterAlignment sets the text alignment for all footer cells. Invalid alignments are ignored.
func (*ConfigBuilder) WithFooterAutoFormat ¶
func (b *ConfigBuilder) WithFooterAutoFormat(autoFormat tw.State) *ConfigBuilder
WithFooterAutoFormat enables or disables automatic formatting (e.g., title case) for footer cells.
func (*ConfigBuilder) WithFooterAutoWrap ¶
func (b *ConfigBuilder) WithFooterAutoWrap(autoWrap int) *ConfigBuilder
WithFooterAutoWrap sets the wrapping behavior for footer cells (e.g., truncate, normal, break). Invalid wrap modes are ignored.
func (*ConfigBuilder) WithFooterGlobalPadding ¶
func (b *ConfigBuilder) WithFooterGlobalPadding(padding tw.Padding) *ConfigBuilder
WithFooterGlobalPadding sets the global padding for all footer cells.
func (*ConfigBuilder) WithFooterMaxWidth ¶
func (b *ConfigBuilder) WithFooterMaxWidth(maxWidth int) *ConfigBuilder
WithFooterMaxWidth sets the maximum content width for footer cells. Negative values are ignored.
func (*ConfigBuilder) WithFooterMergeMode
deprecated
func (b *ConfigBuilder) WithFooterMergeMode(mergeMode int) *ConfigBuilder
Deprecated: Use .Footer().CellMerging().WithMode(...) instead. This method will be removed in a future version.
func (*ConfigBuilder) WithHeaderAlignment ¶
func (b *ConfigBuilder) WithHeaderAlignment(align tw.Align) *ConfigBuilder
WithHeaderAlignment sets the text alignment for all header cells. Invalid alignments are ignored.
func (*ConfigBuilder) WithHeaderAutoFormat ¶
func (b *ConfigBuilder) WithHeaderAutoFormat(autoFormat tw.State) *ConfigBuilder
WithHeaderAutoFormat enables or disables automatic formatting (e.g., title case) for header cells.
func (*ConfigBuilder) WithHeaderAutoWrap ¶
func (b *ConfigBuilder) WithHeaderAutoWrap(autoWrap int) *ConfigBuilder
WithHeaderAutoWrap sets the wrapping behavior for header cells (e.g., truncate, normal). Invalid wrap modes are ignored.
func (*ConfigBuilder) WithHeaderGlobalPadding ¶
func (b *ConfigBuilder) WithHeaderGlobalPadding(padding tw.Padding) *ConfigBuilder
WithHeaderGlobalPadding sets the global padding for all header cells.
func (*ConfigBuilder) WithHeaderMaxWidth ¶
func (b *ConfigBuilder) WithHeaderMaxWidth(maxWidth int) *ConfigBuilder
WithHeaderMaxWidth sets the maximum content width for header cells. Negative values are ignored.
func (*ConfigBuilder) WithHeaderMergeMode
deprecated
func (b *ConfigBuilder) WithHeaderMergeMode(mergeMode int) *ConfigBuilder
Deprecated: Use .Header().CellMerging().WithMode(...) instead. This method will be removed in a future version.
func (*ConfigBuilder) WithMaxWidth ¶
func (b *ConfigBuilder) WithMaxWidth(width int) *ConfigBuilder
WithMaxWidth sets the maximum width for the entire table (0 means unlimited). Negative values are treated as 0.
func (*ConfigBuilder) WithRowAlignment ¶
func (b *ConfigBuilder) WithRowAlignment(align tw.Align) *ConfigBuilder
WithRowAlignment sets the text alignment for all row cells. Invalid alignments are ignored.
func (*ConfigBuilder) WithRowAutoFormat ¶
func (b *ConfigBuilder) WithRowAutoFormat(autoFormat tw.State) *ConfigBuilder
WithRowAutoFormat enables or disables automatic formatting for row cells.
func (*ConfigBuilder) WithRowAutoWrap ¶
func (b *ConfigBuilder) WithRowAutoWrap(autoWrap int) *ConfigBuilder
WithRowAutoWrap sets the wrapping behavior for row cells (e.g., truncate, normal). Invalid wrap modes are ignored.
func (*ConfigBuilder) WithRowGlobalPadding ¶
func (b *ConfigBuilder) WithRowGlobalPadding(padding tw.Padding) *ConfigBuilder
WithRowGlobalPadding sets the global padding for all row cells.
func (*ConfigBuilder) WithRowMaxWidth ¶
func (b *ConfigBuilder) WithRowMaxWidth(maxWidth int) *ConfigBuilder
WithRowMaxWidth sets the maximum content width for row cells. Negative values are ignored.
func (*ConfigBuilder) WithRowMergeMode
deprecated
func (b *ConfigBuilder) WithRowMergeMode(mergeMode int) *ConfigBuilder
Deprecated: Use .Row().CellMerging().WithMode(...) instead. This method will be removed in a future version.
func (*ConfigBuilder) WithTrimSpace ¶
func (b *ConfigBuilder) WithTrimSpace(state tw.State) *ConfigBuilder
WithTrimSpace enables or disables automatic trimming of leading/trailing spaces. Ignored in streaming mode.
type FooterCallbacksBuilder ¶
type FooterCallbacksBuilder struct {
// contains filtered or unexported fields
}
FooterCallbacksBuilder configures footer callbacks
func (*FooterCallbacksBuilder) AddColumnCallback ¶
func (fc *FooterCallbacksBuilder) AddColumnCallback(callback func()) *FooterCallbacksBuilder
AddColumnCallback adds a callback function for a specific column in the footer
func (*FooterCallbacksBuilder) Build ¶
func (fc *FooterCallbacksBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterCallbacksBuilder) WithGlobal ¶
func (fc *FooterCallbacksBuilder) WithGlobal(callback func()) *FooterCallbacksBuilder
WithGlobal sets the global callback function for the footer
func (*FooterCallbacksBuilder) WithPerColumn ¶
func (fc *FooterCallbacksBuilder) WithPerColumn(callbacks []func()) *FooterCallbacksBuilder
WithPerColumn sets per-column callback functions for the footer
type FooterConfigBuilder ¶
type FooterConfigBuilder struct {
// contains filtered or unexported fields
}
FooterConfigBuilder configures footer settings
func (*FooterConfigBuilder) Alignment ¶
func (f *FooterConfigBuilder) Alignment() *AlignmentConfigBuilder
Alignment returns an AlignmentConfigBuilder for footer alignment
func (*FooterConfigBuilder) Build ¶
func (f *FooterConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*FooterConfigBuilder) Callbacks ¶
func (f *FooterConfigBuilder) Callbacks() *FooterCallbacksBuilder
Callbacks returns a FooterCallbacksBuilder for footer callbacks
func (*FooterConfigBuilder) Filter ¶
func (f *FooterConfigBuilder) Filter() *FooterFilterBuilder
Filter returns a FooterFilterBuilder for footer filtering
func (*FooterConfigBuilder) Formatting ¶
func (f *FooterConfigBuilder) Formatting() *FooterFormattingBuilder
Formatting returns a FooterFormattingBuilder for footer formatting
func (*FooterConfigBuilder) Merging ¶
func (f *FooterConfigBuilder) Merging() *FooterMergingBuilder
Merging returns a FooterMergingBuilder for configuring cell merging.
func (*FooterConfigBuilder) Padding ¶
func (f *FooterConfigBuilder) Padding() *FooterPaddingBuilder
Padding returns a FooterPaddingBuilder for footer padding
type FooterFilterBuilder ¶
type FooterFilterBuilder struct {
// contains filtered or unexported fields
}
FooterFilterBuilder configures footer filtering
func (*FooterFilterBuilder) AddColumnFilter ¶
func (ff *FooterFilterBuilder) AddColumnFilter(filter func(string) string) *FooterFilterBuilder
AddColumnFilter adds a filter function for a specific column in the footer
func (*FooterFilterBuilder) Build ¶
func (ff *FooterFilterBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterFilterBuilder) WithGlobal ¶
func (ff *FooterFilterBuilder) WithGlobal(filter func([]string) []string) *FooterFilterBuilder
WithGlobal sets the global filter function for the footer
func (*FooterFilterBuilder) WithPerColumn ¶
func (ff *FooterFilterBuilder) WithPerColumn(filters []func(string) string) *FooterFilterBuilder
WithPerColumn sets per-column filter functions for the footer
type FooterFormattingBuilder ¶
type FooterFormattingBuilder struct {
// contains filtered or unexported fields
}
FooterFormattingBuilder configures footer formatting
func (*FooterFormattingBuilder) Build ¶
func (ff *FooterFormattingBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterFormattingBuilder) WithAlignment
deprecated
func (ff *FooterFormattingBuilder) WithAlignment(align tw.Align) *FooterFormattingBuilder
WithAlignment sets the text alignment for footer cells within the formatting configuration. This method is deprecated and will be removed in the next version.
Deprecated: Use FooterConfigBuilder.Alignment with AlignmentConfigBuilder.WithGlobal or AlignmentConfigBuilder.WithPerColumn to configure footer alignments. Alternatively, apply a complete tw.CellAlignment configuration using WithFooterAlignmentConfig.
Example migration:
// Old (deprecated)
builder.Footer().Formatting().WithAlignment(tw.AlignRight)
// New (recommended)
builder.Footer().Alignment().WithGlobal(tw.AlignRight)
// Or
table.Options(WithFooterAlignmentConfig(tw.CellAlignment{Global: tw.AlignRight}))
Parameters:
- align: The tw.Align value to set for footer cells. Valid values are tw.AlignLeft, tw.AlignRight, tw.AlignCenter, and tw.AlignNone. Invalid alignments are ignored.
Returns:
The [FooterFormattingBuilder] instance for method chaining.
func (*FooterFormattingBuilder) WithAutoFormat ¶
func (ff *FooterFormattingBuilder) WithAutoFormat(autoFormat tw.State) *FooterFormattingBuilder
WithAutoFormat enables/disables auto formatting
func (*FooterFormattingBuilder) WithAutoWrap ¶
func (ff *FooterFormattingBuilder) WithAutoWrap(autoWrap int) *FooterFormattingBuilder
WithAutoWrap sets auto wrap mode
func (*FooterFormattingBuilder) WithMergeMode
deprecated
func (ff *FooterFormattingBuilder) WithMergeMode(mergeMode int) *FooterFormattingBuilder
Deprecated: Use .CellMerging().WithMode(...) instead. This method will be removed in a future version.
type FooterMergingBuilder ¶
type FooterMergingBuilder struct {
// contains filtered or unexported fields
}
FooterMergingBuilder configures footer cell merging
func (*FooterMergingBuilder) Build ¶
func (fm *FooterMergingBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder.
func (*FooterMergingBuilder) ByColumnIndex ¶
func (fm *FooterMergingBuilder) ByColumnIndex(indices []int) *FooterMergingBuilder
ByColumnIndex sets specific columns to be merged by their index. If not called, merging applies to all columns.
func (*FooterMergingBuilder) WithMode ¶
func (fm *FooterMergingBuilder) WithMode(mode int) *FooterMergingBuilder
WithMode sets the merge mode (e.g., tw.MergeHorizontal).
type FooterPaddingBuilder ¶
type FooterPaddingBuilder struct {
// contains filtered or unexported fields
}
FooterPaddingBuilder configures footer padding
func (*FooterPaddingBuilder) AddColumnPadding ¶
func (fp *FooterPaddingBuilder) AddColumnPadding(padding tw.Padding) *FooterPaddingBuilder
AddColumnPadding adds padding for a specific column in the footer
func (*FooterPaddingBuilder) Build ¶
func (fp *FooterPaddingBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterPaddingBuilder) WithGlobal ¶
func (fp *FooterPaddingBuilder) WithGlobal(padding tw.Padding) *FooterPaddingBuilder
WithGlobal sets global padding
func (*FooterPaddingBuilder) WithPerColumn ¶
func (fp *FooterPaddingBuilder) WithPerColumn(padding []tw.Padding) *FooterPaddingBuilder
WithPerColumn sets per-column padding
type HeaderCallbacksBuilder ¶
type HeaderCallbacksBuilder struct {
// contains filtered or unexported fields
}
HeaderCallbacksBuilder configures header callbacks
func (*HeaderCallbacksBuilder) AddColumnCallback ¶
func (hc *HeaderCallbacksBuilder) AddColumnCallback(callback func()) *HeaderCallbacksBuilder
AddColumnCallback adds a callback function for a specific column in the header
func (*HeaderCallbacksBuilder) Build ¶
func (hc *HeaderCallbacksBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderCallbacksBuilder) WithGlobal ¶
func (hc *HeaderCallbacksBuilder) WithGlobal(callback func()) *HeaderCallbacksBuilder
WithGlobal sets the global callback function for the header
func (*HeaderCallbacksBuilder) WithPerColumn ¶
func (hc *HeaderCallbacksBuilder) WithPerColumn(callbacks []func()) *HeaderCallbacksBuilder
WithPerColumn sets per-column callback functions for the header
type HeaderConfigBuilder ¶
type HeaderConfigBuilder struct {
// contains filtered or unexported fields
}
HeaderConfigBuilder configures header settings
func (*HeaderConfigBuilder) Alignment ¶
func (h *HeaderConfigBuilder) Alignment() *AlignmentConfigBuilder
Alignment returns an AlignmentConfigBuilder for header alignment
func (*HeaderConfigBuilder) Build ¶
func (h *HeaderConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*HeaderConfigBuilder) Callbacks ¶
func (h *HeaderConfigBuilder) Callbacks() *HeaderCallbacksBuilder
Callbacks returns a HeaderCallbacksBuilder for header callbacks
func (*HeaderConfigBuilder) Filter ¶
func (h *HeaderConfigBuilder) Filter() *HeaderFilterBuilder
Filter returns a HeaderFilterBuilder for header filtering
func (*HeaderConfigBuilder) Formatting ¶
func (h *HeaderConfigBuilder) Formatting() *HeaderFormattingBuilder
Formatting returns a HeaderFormattingBuilder for header formatting
func (*HeaderConfigBuilder) Merging ¶
func (h *HeaderConfigBuilder) Merging() *HeaderMergingBuilder
Merging returns a HeaderMergingBuilder for configuring cell merging.
func (*HeaderConfigBuilder) Padding ¶
func (h *HeaderConfigBuilder) Padding() *HeaderPaddingBuilder
Padding returns a HeaderPaddingBuilder for header padding
type HeaderFilterBuilder ¶
type HeaderFilterBuilder struct {
// contains filtered or unexported fields
}
HeaderFilterBuilder configures header filtering
func (*HeaderFilterBuilder) AddColumnFilter ¶
func (hf *HeaderFilterBuilder) AddColumnFilter(filter func(string) string) *HeaderFilterBuilder
AddColumnFilter adds a filter function for a specific column in the header
func (*HeaderFilterBuilder) Build ¶
func (hf *HeaderFilterBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderFilterBuilder) WithGlobal ¶
func (hf *HeaderFilterBuilder) WithGlobal(filter func([]string) []string) *HeaderFilterBuilder
WithGlobal sets the global filter function for the header
func (*HeaderFilterBuilder) WithPerColumn ¶
func (hf *HeaderFilterBuilder) WithPerColumn(filters []func(string) string) *HeaderFilterBuilder
WithPerColumn sets per-column filter functions for the header
type HeaderFormattingBuilder ¶
type HeaderFormattingBuilder struct {
// contains filtered or unexported fields
}
HeaderFormattingBuilder configures header formatting
func (*HeaderFormattingBuilder) Build ¶
func (hf *HeaderFormattingBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderFormattingBuilder) WithAlignment
deprecated
func (hf *HeaderFormattingBuilder) WithAlignment(align tw.Align) *HeaderFormattingBuilder
WithAlignment sets the text alignment for header cells within the formatting configuration. This method is deprecated and will be removed in the next version.
Deprecated: Use HeaderConfigBuilder.Alignment with AlignmentConfigBuilder.WithGlobal or AlignmentConfigBuilder.WithPerColumn to configure header alignments. Alternatively, apply a complete tw.CellAlignment configuration using WithHeaderAlignmentConfig.
Example migration:
// Old (deprecated)
builder.Header().Formatting().WithAlignment(tw.AlignCenter)
// New (recommended)
builder.Header().Alignment().WithGlobal(tw.AlignCenter)
// Or
table.Options(WithHeaderAlignmentConfig(tw.CellAlignment{Global: tw.AlignCenter}))
Parameters:
- align: The tw.Align value to set for header cells. Valid values are tw.AlignLeft, tw.AlignRight, tw.AlignCenter, and tw.AlignNone. Invalid alignments are ignored.
Returns:
The [HeaderFormattingBuilder] instance for method chaining.
func (*HeaderFormattingBuilder) WithAutoFormat ¶
func (hf *HeaderFormattingBuilder) WithAutoFormat(autoFormat tw.State) *HeaderFormattingBuilder
WithAutoFormat enables/disables auto formatting
func (*HeaderFormattingBuilder) WithAutoWrap ¶
func (hf *HeaderFormattingBuilder) WithAutoWrap(autoWrap int) *HeaderFormattingBuilder
WithAutoWrap sets auto wrap mode
func (*HeaderFormattingBuilder) WithMergeMode
deprecated
func (hf *HeaderFormattingBuilder) WithMergeMode(mergeMode int) *HeaderFormattingBuilder
Deprecated: Use .CellMerging().WithMode(...) instead. This method will be removed in a future version.
type HeaderMergingBuilder ¶
type HeaderMergingBuilder struct {
// contains filtered or unexported fields
}
HeaderMergingBuilder configures header cell merging
func (*HeaderMergingBuilder) Build ¶
func (hm *HeaderMergingBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder.
func (*HeaderMergingBuilder) ByColumnIndex ¶
func (hm *HeaderMergingBuilder) ByColumnIndex(indices []int) *HeaderMergingBuilder
ByColumnIndex sets specific columns to be merged by their index. If not called, merging applies to all columns.
func (*HeaderMergingBuilder) WithMode ¶
func (hm *HeaderMergingBuilder) WithMode(mode int) *HeaderMergingBuilder
WithMode sets the merge mode (e.g., tw.MergeHorizontal).
type HeaderPaddingBuilder ¶
type HeaderPaddingBuilder struct {
// contains filtered or unexported fields
}
HeaderPaddingBuilder configures header padding
func (*HeaderPaddingBuilder) AddColumnPadding ¶
func (hp *HeaderPaddingBuilder) AddColumnPadding(padding tw.Padding) *HeaderPaddingBuilder
AddColumnPadding adds padding for a specific column in the header
func (*HeaderPaddingBuilder) Build ¶
func (hp *HeaderPaddingBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderPaddingBuilder) WithGlobal ¶
func (hp *HeaderPaddingBuilder) WithGlobal(padding tw.Padding) *HeaderPaddingBuilder
WithGlobal sets global padding
func (*HeaderPaddingBuilder) WithPerColumn ¶
func (hp *HeaderPaddingBuilder) WithPerColumn(padding []tw.Padding) *HeaderPaddingBuilder
WithPerColumn sets per-column padding
type Option ¶
type Option func(target *Table)
Option defines a function type for configuring a Table instance.
func WithAlignment ¶
WithAlignment sets the default column alignment for the header, rows, and footer. Logs the change if debugging is enabled.
func WithAutoHide ¶
WithAutoHide enables or disables automatic hiding of columns with empty data rows. Logs the change if debugging is enabled.
func WithBehavior ¶
WithBehavior applies a behavior configuration to the table. Logs the change if debugging is enabled.
func WithBorders
deprecated
WithBorders configures the table's border settings by updating the renderer's border configuration. This function is deprecated and will be removed in a future version.
Deprecated: Use WithRendition to configure border settings for renderers that support tw.Renditioning, or update the renderer's tw.RenderConfig directly via its Config() method. This function has no effect if no renderer is set on the table.
Example migration:
// Old (deprecated)
table.Options(WithBorders(tw.Border{Top: true, Bottom: true}))
// New (recommended)
table.Options(WithRendition(tw.Rendition{Borders: tw.Border{Top: true, Bottom: true}}))
Parameters:
- borders: The tw.Border configuration to apply to the renderer's borders.
Returns:
An [Option] that updates the renderer's border settings if a renderer is set. Logs a debug message if debugging is enabled and a renderer is present.
func WithColumnMax ¶
WithColumnMax sets a global maximum column width for the table in streaming mode. Negative values are ignored, and the change is logged if debugging is enabled.
func WithColumnWidths ¶
WithColumnWidths sets per-column widths for the table. Negative widths are removed, and the change is logged if debugging is enabled.
func WithCondition
deprecated
Deprecated: use WithEastAsian instead. WithCondition provides a way to set a custom global runewidth.Condition that will be used for all subsequent display width calculations by the twwidth (twdw) package.
The runewidth.Condition object allows for more fine-grained control over how rune widths are determined, beyond just toggling EastAsianWidth. This could include settings for ambiguous width characters or other future properties of runewidth.Condition.
func WithConfig ¶
WithConfig applies a custom configuration to the table by merging it with the default configuration.
func WithCounters ¶
WithCounters enables line counting by wrapping the table's writer. If a custom counter (that implements tw.Counter) is provided, it will be used. If the provided counter is nil, a default tw.LineCounter will be used. The final count can be retrieved via the table.Lines() method after Render() is called.
func WithDebug ¶
WithDebug enables or disables debug logging and adjusts the logger level accordingly. Logs the change if debugging is enabled.
func WithEastAsian ¶
WithEastAsian configures the global East Asian width calculation setting.
- state=tw.On: Enables East Asian width calculations. CJK and ambiguous characters are typically measured as double width.
- state=tw.Off: Disables East Asian width calculations. Characters are generally measured as single width, subject to Unicode standards.
This setting affects all subsequent display width calculations using the twdw package.
func WithFooter ¶
WithFooter sets the table footers by calling the Footer method.
func WithFooterAlignmentConfig ¶
func WithFooterAlignmentConfig(alignment tw.CellAlignment) Option
WithFooterAlignmentConfig applies a footer alignment configuration to the table. Logs the change if debugging is enabled.
func WithFooterAutoFormat ¶
WithFooterAutoFormat enables or disables automatic formatting for footer cells. Logs the change if debugging is enabled.
func WithFooterAutoWrap ¶
WithFooterAutoWrap sets the wrapping behavior for footer cells. Invalid wrap modes are ignored, and the change is logged if debugging is enabled.
func WithFooterCallbacks ¶
func WithFooterCallbacks(callbacks tw.CellCallbacks) Option
WithFooterCallbacks sets the callback configuration for footer cells. Logs the change if debugging is enabled.
func WithFooterConfig ¶
func WithFooterConfig(config tw.CellConfig) Option
WithFooterConfig applies a full footer configuration to the table. Logs the change if debugging is enabled.
func WithFooterControl ¶
WithFooterControl sets the control behavior for the table footer. Logs the change if debugging is enabled.
func WithFooterFilter ¶
func WithFooterFilter(filter tw.CellFilter) Option
WithFooterFilter sets the filter configuration for footer cells. Logs the change if debugging is enabled.
func WithFooterMaxWidth ¶
WithFooterMaxWidth sets the maximum content width for footer cells. Negative values are ignored, and the change is logged if debugging is enabled.
func WithFooterMergeMode
deprecated
func WithFooterPaddingPerColumn ¶
WithFooterPaddingPerColumn sets per-column padding for footer cells. Logs the change if debugging is enabled.
func WithHeader ¶
WithHeader sets the table headers by calling the Header method.
func WithHeaderAlignment ¶
WithHeaderAlignment sets the text alignment for header cells. Invalid alignments are ignored, and the change is logged if debugging is enabled.
func WithHeaderAlignmentConfig ¶
func WithHeaderAlignmentConfig(alignment tw.CellAlignment) Option
WithHeaderAlignmentConfig applies a header alignment configuration to the table. Logs the change if debugging is enabled.
func WithHeaderAutoFormat ¶
WithHeaderAutoFormat enables or disables automatic formatting for header cells. Logs the change if debugging is enabled.
func WithHeaderAutoWrap ¶
WithHeaderAutoWrap sets the wrapping behavior for header cells. Invalid wrap modes are ignored, and the change is logged if debugging is enabled.
func WithHeaderCallbacks ¶
func WithHeaderCallbacks(callbacks tw.CellCallbacks) Option
WithHeaderCallbacks sets the callback configuration for header cells. Logs the change if debugging is enabled.
func WithHeaderConfig ¶
func WithHeaderConfig(config tw.CellConfig) Option
WithHeaderConfig applies a full header configuration to the table. Logs the change if debugging is enabled.
func WithHeaderControl ¶
WithHeaderControl sets the control behavior for the table header. Logs the change if debugging is enabled.
func WithHeaderFilter ¶
func WithHeaderFilter(filter tw.CellFilter) Option
WithHeaderFilter sets the filter configuration for header cells. Logs the change if debugging is enabled.
func WithHeaderMaxWidth ¶
WithHeaderMaxWidth sets the maximum content width for header cells. Negative values are ignored, and the change is logged if debugging is enabled.
func WithHeaderMergeMode
deprecated
func WithHeaderPaddingPerColumn ¶
WithHeaderPaddingPerColumn sets per-column padding for header cells. Logs the change if debugging is enabled.
func WithLineCounter ¶
func WithLineCounter() Option
WithLineCounter enables the default line counter. A new instance of tw.LineCounter is added to the table's list of counters. The total count can be retrieved via the table.Lines() method after Render() is called.
func WithLogger ¶
WithLogger sets a custom logger for the table and updates the renderer if present. Logs the change if debugging is enabled.
func WithMaxWidth ¶
WithMaxWidth sets a global maximum table width for the table. Negative values are ignored, and the change is logged if debugging is enabled.
func WithPadding ¶
WithPadding sets the global padding for the header, rows, and footer. Logs the change if debugging is enabled.
func WithRenderer ¶
WithRenderer sets a custom renderer for the table and attaches the logger if present. Logs the change if debugging is enabled.
func WithRendererSettings
deprecated
WithRendererSettings updates the renderer's settings, such as separators and line styles. This function is deprecated and will be removed in a future version.
Deprecated: Use WithRendition to update renderer settings for renderers that implement tw.Renditioning, or configure the renderer's tw.Settings directly via its tw.Renderer.Config method. This function has no effect if no renderer is set.
Example migration:
// Old (deprecated)
table.Options(WithRendererSettings(tw.Settings{Separator: "|"}))
// New (recommended)
table.Options(WithRendition(tw.Rendition{Settings: tw.Settings{Separator: "|"}}))
Parameters:
- settings: The tw.Settings configuration to apply to the renderer.
Returns:
An [Option] that updates the renderer's settings if a renderer is set. Logs a debug message if debugging is enabled and a renderer is present.
func WithRendition ¶
WithRendition allows updating the active renderer's rendition configuration by merging the provided rendition. If the renderer does not implement tw.Renditioning, a warning is logged. Logs the change if debugging is enabled.
func WithRowAlignment ¶
WithRowAlignment sets the text alignment for row cells. Invalid alignments are ignored, and the change is logged if debugging is enabled.
func WithRowAlignmentConfig ¶
func WithRowAlignmentConfig(alignment tw.CellAlignment) Option
WithRowAlignmentConfig applies a row alignment configuration to the table. Logs the change if debugging is enabled.
func WithRowAutoFormat ¶
WithRowAutoFormat enables or disables automatic formatting for row cells. Logs the change if debugging is enabled.
func WithRowAutoWrap ¶
WithRowAutoWrap sets the wrapping behavior for row cells. Invalid wrap modes are ignored, and the change is logged if debugging is enabled.
func WithRowCallbacks ¶
func WithRowCallbacks(callbacks tw.CellCallbacks) Option
WithRowCallbacks sets the callback configuration for row cells. Logs the change if debugging is enabled.
func WithRowConfig ¶
func WithRowConfig(config tw.CellConfig) Option
WithRowConfig applies a full row configuration to the table. Logs the change if debugging is enabled.
func WithRowFilter ¶
func WithRowFilter(filter tw.CellFilter) Option
WithRowFilter sets the filter configuration for row cells. Logs the change if debugging is enabled.
func WithRowMaxWidth ¶
WithRowMaxWidth sets the maximum content width for row cells. Negative values are ignored, and the change is logged if debugging is enabled.
func WithRowMergeMode
deprecated
func WithRowPaddingPerColumn ¶
WithRowPaddingPerColumn sets per-column padding for row cells. Logs the change if debugging is enabled.
func WithStreaming ¶
func WithStreaming(c tw.StreamConfig) Option
WithStreaming applies a streaming configuration to the table by merging it with the existing configuration. Logs the change if debugging is enabled.
func WithStringer ¶
func WithStringer(stringer interface{}) Option
WithStringer sets a custom stringer function for converting row data and clears the stringer cache. Logs the change if debugging is enabled.
func WithStringerCache ¶
func WithStringerCache() Option
WithStringerCache enables the default LRU caching for the stringer function. It initializes the cache with a default capacity if one does not already exist.
func WithStringerCacheCustom ¶
WithStringerCacheCustom enables caching for the stringer function using a specific implementation. Passing nil disables caching entirely.
func WithSymbols ¶
WithSymbols sets the symbols used for drawing table borders and separators. The symbols are applied to the table's renderer configuration, if a renderer is set. If no renderer is set (target.renderer is nil), this option has no effect. .
func WithTableMax
deprecated
WithTableMax sets the maximum width of the entire table in characters. Negative values are ignored, and the change is logged if debugging is enabled. The width constrains the table's rendering, potentially causing text wrapping or truncation based on the configuration's wrapping settings (e.g., tw.WrapTruncate). If debug logging is enabled via WithDebug(true), the applied width is logged.
Deprecated: Use WithMaxWidth instead, which provides the same functionality with a clearer name and consistent naming across the package. For example:
tablewriter.NewTable(os.Stdout, tablewriter.WithMaxWidth(80))
func WithTrimLine ¶
WithTrimLine sets whether empty visual lines within a cell are trimmed. Logs the change if debugging is enabled.
func WithTrimSpace ¶
WithTrimSpace sets whether leading and trailing spaces are automatically trimmed. Logs the change if debugging is enabled.
func WithWidths ¶
WithWidths sets per-column widths for the table. Negative widths are removed, and the change is logged if debugging is enabled.
type RowCallbacksBuilder ¶
type RowCallbacksBuilder struct {
// contains filtered or unexported fields
}
RowCallbacksBuilder configures row callbacks
func (*RowCallbacksBuilder) AddColumnCallback ¶
func (rc *RowCallbacksBuilder) AddColumnCallback(callback func()) *RowCallbacksBuilder
AddColumnCallback adds a callback function for a specific column in the rows
func (*RowCallbacksBuilder) Build ¶
func (rc *RowCallbacksBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowCallbacksBuilder) WithGlobal ¶
func (rc *RowCallbacksBuilder) WithGlobal(callback func()) *RowCallbacksBuilder
WithGlobal sets the global callback function for the rows
func (*RowCallbacksBuilder) WithPerColumn ¶
func (rc *RowCallbacksBuilder) WithPerColumn(callbacks []func()) *RowCallbacksBuilder
WithPerColumn sets per-column callback functions for the rows
type RowConfigBuilder ¶
type RowConfigBuilder struct {
// contains filtered or unexported fields
}
RowConfigBuilder configures row settings
func (*RowConfigBuilder) Alignment ¶
func (r *RowConfigBuilder) Alignment() *AlignmentConfigBuilder
Alignment returns an AlignmentConfigBuilder for row alignment
func (*RowConfigBuilder) Build ¶
func (r *RowConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*RowConfigBuilder) Callbacks ¶
func (r *RowConfigBuilder) Callbacks() *RowCallbacksBuilder
Callbacks returns a RowCallbacksBuilder for row callbacks
func (*RowConfigBuilder) Filter ¶
func (r *RowConfigBuilder) Filter() *RowFilterBuilder
Filter returns a RowFilterBuilder for row filtering
func (*RowConfigBuilder) Formatting ¶
func (r *RowConfigBuilder) Formatting() *RowFormattingBuilder
Formatting returns a RowFormattingBuilder for row formatting
func (*RowConfigBuilder) Merging ¶
func (r *RowConfigBuilder) Merging() *RowMergingBuilder
Merging returns a RowMergingBuilder for configuring cell merging.
func (*RowConfigBuilder) Padding ¶
func (r *RowConfigBuilder) Padding() *RowPaddingBuilder
Padding returns a RowPaddingBuilder for row padding
type RowFilterBuilder ¶
type RowFilterBuilder struct {
// contains filtered or unexported fields
}
RowFilterBuilder configures row filtering
func (*RowFilterBuilder) AddColumnFilter ¶
func (rf *RowFilterBuilder) AddColumnFilter(filter func(string) string) *RowFilterBuilder
AddColumnFilter adds a filter function for a specific column in the rows
func (*RowFilterBuilder) Build ¶
func (rf *RowFilterBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowFilterBuilder) WithGlobal ¶
func (rf *RowFilterBuilder) WithGlobal(filter func([]string) []string) *RowFilterBuilder
WithGlobal sets the global filter function for the rows
func (*RowFilterBuilder) WithPerColumn ¶
func (rf *RowFilterBuilder) WithPerColumn(filters []func(string) string) *RowFilterBuilder
WithPerColumn sets per-column filter functions for the rows
type RowFormattingBuilder ¶
type RowFormattingBuilder struct {
// contains filtered or unexported fields
}
RowFormattingBuilder configures row formatting
func (*RowFormattingBuilder) Build ¶
func (rf *RowFormattingBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowFormattingBuilder) WithAlignment
deprecated
func (rf *RowFormattingBuilder) WithAlignment(align tw.Align) *RowFormattingBuilder
WithAlignment sets the text alignment for row cells within the formatting configuration. This method is deprecated and will be removed in the next version.
Deprecated: Use RowConfigBuilder.Alignment with AlignmentConfigBuilder.WithGlobal or AlignmentConfigBuilder.WithPerColumn to configure row alignments. Alternatively, apply a complete tw.CellAlignment configuration using WithRowAlignmentConfig.
Example migration:
// Old (deprecated)
builder.Row().Formatting().WithAlignment(tw.AlignLeft)
// New (recommended)
builder.Row().Alignment().WithGlobal(tw.AlignLeft)
// Or
table.Options(WithRowAlignmentConfig(tw.CellAlignment{Global: tw.AlignLeft}))
Parameters:
- align: The tw.Align value to set for row cells. Valid values are tw.AlignLeft, tw.AlignRight, tw.AlignCenter, and tw.AlignNone. Invalid alignments are ignored.
Returns:
The [RowFormattingBuilder] instance for method chaining.
func (*RowFormattingBuilder) WithAutoFormat ¶
func (rf *RowFormattingBuilder) WithAutoFormat(autoFormat tw.State) *RowFormattingBuilder
WithAutoFormat enables/disables auto formatting
func (*RowFormattingBuilder) WithAutoWrap ¶
func (rf *RowFormattingBuilder) WithAutoWrap(autoWrap int) *RowFormattingBuilder
WithAutoWrap sets auto wrap mode
func (*RowFormattingBuilder) WithMergeMode
deprecated
func (rf *RowFormattingBuilder) WithMergeMode(mergeMode int) *RowFormattingBuilder
Deprecated: Use .CellMerging().WithMode(...) instead. This method will be removed in a future version.
type RowMergingBuilder ¶
type RowMergingBuilder struct {
// contains filtered or unexported fields
}
RowMergingBuilder configures row cell merging
func (*RowMergingBuilder) Build ¶
func (rm *RowMergingBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder.
func (*RowMergingBuilder) ByColumnIndex ¶
func (rm *RowMergingBuilder) ByColumnIndex(indices []int) *RowMergingBuilder
ByColumnIndex sets specific columns to be merged by their index. If not called, merging applies to all columns.
func (*RowMergingBuilder) WithMode ¶
func (rm *RowMergingBuilder) WithMode(mode int) *RowMergingBuilder
WithMode sets the merge mode (e.g., tw.MergeVertical, tw.MergeHierarchical).
type RowPaddingBuilder ¶
type RowPaddingBuilder struct {
// contains filtered or unexported fields
}
RowPaddingBuilder configures row padding
func (*RowPaddingBuilder) AddColumnPadding ¶
func (rp *RowPaddingBuilder) AddColumnPadding(padding tw.Padding) *RowPaddingBuilder
AddColumnPadding adds padding for a specific column in the rows
func (*RowPaddingBuilder) Build ¶
func (rp *RowPaddingBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowPaddingBuilder) WithGlobal ¶
func (rp *RowPaddingBuilder) WithGlobal(padding tw.Padding) *RowPaddingBuilder
WithGlobal sets global padding
func (*RowPaddingBuilder) WithPerColumn ¶
func (rp *RowPaddingBuilder) WithPerColumn(padding []tw.Padding) *RowPaddingBuilder
WithPerColumn sets per-column padding
type Settings
deprecated
Settings is an alias for tw.Settings to configure renderer settings. This type is deprecated and will be removed in a future version.
Deprecated: Use tw.Settings directly to configure renderer settings, such as separators and line styles.
Example migration:
// Old (deprecated)
var s tablewriter.Settings = tablewriter.Settings{Separator: "|"}
// New (recommended)
var s tw.Settings = tw.Settings{Separator: "|"}
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a table instance with content and rendering capabilities.
func NewCSV ¶
NewCSV Start A new table by importing from a CSV file Takes io.Writer and csv File name
func NewCSVReader ¶
func NewCSVReader(writer io.Writer, csvReader *csv.Reader, hasHeader bool, opts ...Option) (*Table, error)
NewCSVReader Start a New Table Writer with csv.Reader This enables customisation such as reader.Comma = ';' See http://golang.org/src/pkg/encoding/csv/reader.go?s=3213:3671#L94
func NewTable ¶
NewTable creates a new table instance with specified writer and options. Parameters include writer for output and optional configuration options. Returns a pointer to the initialized Table instance.
func NewWriter ¶
NewWriter creates a new table with default settings for backward compatibility. It logs the creation if debugging is enabled.
func (*Table) Append ¶
Append adds data to the current row being built for the table. This method always contributes to a single logical row in the table. To add multiple distinct rows, call Append multiple times (once for each row's data) or use the Bulk() method if providing a slice where each element is a row.
func (*Table) Bulk ¶
Bulk adds multiple rows from a slice to the table. If Behavior.AutoHeader is enabled, no headers set, and rows is a slice of structs, automatically extracts/sets headers from the first struct.
func (*Table) Caption ¶
Caption sets the table caption (legacy method). Defaults to BottomCenter alignment, wrapping to table width. Use SetCaptionOptions for more control.
func (*Table) Close ¶
Close finalizes the table stream. It requires the stream to be started (by calling NewStreamTable). It calls the renderer's Close method to render final elements (like the bottom border) and close the stream.
func (*Table) Config ¶
Config returns the current table configuration. No parameters are required. Returns the Config struct with current settings.
func (*Table) Configure ¶
Configure updates the table's configuration using a provided function. Parameter fn is a function that modifies the Config struct. Returns the Table instance for method chaining.
func (*Table) Counters ¶
Counters returns the slice of all active counter instances. This is useful when multiple counters are enabled. It must be called *after* Render().
func (*Table) Debug ¶
Debug retrieves the accumulated debug trace logs. No parameters are required. Returns a slice of debug messages including renderer logs.
func (*Table) Footer ¶
Footer sets the table's footer content, padding to match column count. Parameter footers is a slice of strings for footer content. No return value. Footer sets the table's footer content. Parameter footers is a slice of strings for footer content. In streaming mode, this processes and stores the footer for rendering by Close().
func (*Table) Header ¶
Header sets the table's header content, padding to match column count. Parameter elements is a slice of strings for header content. No return value. In streaming mode, this processes and renders the header immediately.
func (*Table) Lines ¶
Lines returns the total number of lines rendered. This method is only effective if the WithLineCounter() option was used during table initialization and must be called *after* Render(). It actively searches for the default tw.LineCounter among all active counters. It returns -1 if the line counter was not enabled.
func (*Table) Logger ¶
Logger retrieves the table's logger instance. No parameters are required. Returns the ll.Logger instance used for debug tracing.
func (*Table) Options ¶
Options updates the table's Options using a provided function. Parameter opts is a function that modifies the Table struct. Returns the Table instance for method chaining.
func (*Table) Render ¶
Render triggers the table rendering process to the configured writer. No parameters are required. Returns an error if rendering fails.
func (*Table) Renderer ¶
Renderer retrieves the current renderer instance used by the table. No parameters are required. Returns the tw.Renderer interface instance.
func (*Table) Reset ¶
func (t *Table) Reset()
Reset clears all data (headers, rows, footers, caption) and rendering state from the table, allowing the Table instance to be reused for a new table with the same configuration and writer. It does NOT reset the configuration itself (set by NewTable options or Configure) or the underlying io.Writer.
func (*Table) Start ¶
Start initializes the table stream. In this streaming model, renderer.Start() is primarily called in NewStreamTable. This method serves as a safeguard or point for adding pre-rendering logic. Start initializes the table stream. It is the entry point for streaming mode. Requires t.config.Stream.Enable to be true. Returns an error if streaming is disabled or the renderer does not support streaming, or if called multiple times on the same stream.
func (*Table) Trimmer ¶
Trimmer trims whitespace from a string based on the Table’s configuration. It conditionally applies strings.TrimSpace to the input string if the TrimSpace behavior is enabled in t.config.Behavior, otherwise returning the string unchanged. This method is used in the logging library to format strings for tabular output, ensuring consistent display in log messages. Thread-safe as it only reads configuration and operates on the input string.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_example
|
|
|
filetable
command
|
|
|
symbols
command
|
|
|
cmd
|
|
|
csv2table
command
|
|
|
pkg
|
|
|
twwidth
Package twwidth provides intelligent East Asian width detection.
|
Package twwidth provides intelligent East Asian width detection. |
|
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 provides utility functions for text formatting, width calculation, and string manipulation specifically tailored for table rendering, including handling ANSI escape codes and Unicode text. |
