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) *ConfigBuilder
- 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) *ConfigBuilder
- 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) *ConfigBuilder
- 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) 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) *FooterFormattingBuilder
- 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) 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) *HeaderFormattingBuilder
- 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(condition *runewidth.Condition) Option
- func WithConfig(cfg Config) Option
- func WithCounters(counters ...tw.Counter) Option
- func WithDebug(debug bool) Option
- func WithEastAsian(enable bool) 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) Option
- 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) Option
- 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) Option
- func WithRowPaddingPerColumn(padding []tw.Padding) Option
- func WithStreaming(c tw.StreamConfig) Option
- func WithStringer(stringer interface{}) Option
- func WithStringerCache() 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) 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) *RowFormattingBuilder
- 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 ¶ added in v1.0.7
type AlignmentConfigBuilder struct {
// contains filtered or unexported fields
}
AlignmentConfigBuilder configures alignment settings
func (*AlignmentConfigBuilder) Build ¶ added in v1.0.7
func (a *AlignmentConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*AlignmentConfigBuilder) WithGlobal ¶ added in v1.0.7
func (a *AlignmentConfigBuilder) WithGlobal(align tw.Align) *AlignmentConfigBuilder
WithGlobal sets global alignment
func (*AlignmentConfigBuilder) WithPerColumn ¶ added in v1.0.7
func (a *AlignmentConfigBuilder) WithPerColumn(alignments []tw.Align) *AlignmentConfigBuilder
WithPerColumn sets per-column alignments
type Behavior
deprecated
added in
v1.0.1
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 ¶ added in v1.0.7
type BehaviorConfigBuilder struct {
// contains filtered or unexported fields
}
BehaviorConfigBuilder configures behavior settings
func (*BehaviorConfigBuilder) Build ¶ added in v1.0.7
func (bb *BehaviorConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*BehaviorConfigBuilder) WithAutoHeader ¶ added in v1.0.9
func (bb *BehaviorConfigBuilder) WithAutoHeader(state tw.State) *BehaviorConfigBuilder
WithAutoHeader enables/disables automatic header extraction for structs in Bulk.
func (*BehaviorConfigBuilder) WithAutoHide ¶ added in v1.0.7
func (bb *BehaviorConfigBuilder) WithAutoHide(state tw.State) *BehaviorConfigBuilder
WithAutoHide enables/disables auto-hide
func (*BehaviorConfigBuilder) WithCompactMerge ¶ added in v1.0.7
func (bb *BehaviorConfigBuilder) WithCompactMerge(state tw.State) *BehaviorConfigBuilder
WithCompactMerge enables/disables compact width optimization for merged cells
func (*BehaviorConfigBuilder) WithFooterHide ¶ added in v1.0.7
func (bb *BehaviorConfigBuilder) WithFooterHide(state tw.State) *BehaviorConfigBuilder
WithFooterHide enables/disables footer visibility
func (*BehaviorConfigBuilder) WithHeaderHide ¶ added in v1.0.7
func (bb *BehaviorConfigBuilder) WithHeaderHide(state tw.State) *BehaviorConfigBuilder
WithHeaderHide enables/disables header visibility
func (*BehaviorConfigBuilder) WithTrimSpace ¶ added in v1.0.7
func (bb *BehaviorConfigBuilder) WithTrimSpace(state tw.State) *BehaviorConfigBuilder
WithTrimSpace enables/disables trim space
type ColumnConfigBuilder ¶ added in v1.0.0
type ColumnConfigBuilder struct {
// contains filtered or unexported fields
}
ColumnConfigBuilder configures column-specific settings
func (*ColumnConfigBuilder) Build ¶ added in v1.0.0
func (c *ColumnConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*ColumnConfigBuilder) WithAlignment ¶ added in v1.0.0
func (c *ColumnConfigBuilder) WithAlignment(align tw.Align) *ColumnConfigBuilder
WithAlignment sets alignment for the column
func (*ColumnConfigBuilder) WithMaxWidth ¶ added in v1.0.0
func (c *ColumnConfigBuilder) WithMaxWidth(width int) *ColumnConfigBuilder
WithMaxWidth sets max width for the column
type Config ¶ added in v1.0.0
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 ¶ added in v1.0.0
type ConfigBuilder struct {
// contains filtered or unexported fields
}
ConfigBuilder provides a fluent interface for building Config
func NewConfigBuilder ¶ added in v1.0.0
func NewConfigBuilder() *ConfigBuilder
NewConfigBuilder creates a new ConfigBuilder with defaults
func (*ConfigBuilder) Behavior ¶ added in v1.0.7
func (b *ConfigBuilder) Behavior() *BehaviorConfigBuilder
Behavior returns a BehaviorConfigBuilder for behavior configuration
func (*ConfigBuilder) Build ¶ added in v1.0.0
func (b *ConfigBuilder) Build() Config
Build returns the built Config
func (*ConfigBuilder) Footer ¶ added in v1.0.0
func (b *ConfigBuilder) Footer() *FooterConfigBuilder
Footer returns a FooterConfigBuilder for footer configuration
func (*ConfigBuilder) ForColumn ¶ added in v1.0.0
func (b *ConfigBuilder) ForColumn(col int) *ColumnConfigBuilder
ForColumn returns a ColumnConfigBuilder for column-specific configuration
func (*ConfigBuilder) Header ¶ added in v1.0.0
func (b *ConfigBuilder) Header() *HeaderConfigBuilder
Header returns a HeaderConfigBuilder for header configuration
func (*ConfigBuilder) Row ¶ added in v1.0.0
func (b *ConfigBuilder) Row() *RowConfigBuilder
Row returns a RowConfigBuilder for row configuration
func (*ConfigBuilder) WithAutoHide ¶ added in v1.0.1
func (b *ConfigBuilder) WithAutoHide(state tw.State) *ConfigBuilder
WithAutoHide enables or disables automatic hiding of empty columns (ignored in streaming mode).
func (*ConfigBuilder) WithDebug ¶ added in v1.0.0
func (b *ConfigBuilder) WithDebug(debug bool) *ConfigBuilder
WithDebug enables/disables debug logging
func (*ConfigBuilder) WithFooterAlignment ¶ added in v1.0.0
func (b *ConfigBuilder) WithFooterAlignment(align tw.Align) *ConfigBuilder
WithFooterAlignment sets the text alignment for all footer cells. Invalid alignments are ignored.
func (*ConfigBuilder) WithFooterAutoFormat ¶ added in v1.0.0
func (b *ConfigBuilder) WithFooterAutoFormat(autoFormat tw.State) *ConfigBuilder
WithFooterAutoFormat enables or disables automatic formatting (e.g., title case) for footer cells.
func (*ConfigBuilder) WithFooterAutoWrap ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (b *ConfigBuilder) WithFooterGlobalPadding(padding tw.Padding) *ConfigBuilder
WithFooterGlobalPadding sets the global padding for all footer cells.
func (*ConfigBuilder) WithFooterMaxWidth ¶ added in v1.0.0
func (b *ConfigBuilder) WithFooterMaxWidth(maxWidth int) *ConfigBuilder
WithFooterMaxWidth sets the maximum content width for footer cells. Negative values are ignored.
func (*ConfigBuilder) WithFooterMergeMode ¶ added in v1.0.0
func (b *ConfigBuilder) WithFooterMergeMode(mergeMode int) *ConfigBuilder
WithFooterMergeMode sets the merge behavior for footer cells (e.g., horizontal, hierarchical). Invalid merge modes are ignored.
func (*ConfigBuilder) WithHeaderAlignment ¶ added in v1.0.0
func (b *ConfigBuilder) WithHeaderAlignment(align tw.Align) *ConfigBuilder
WithHeaderAlignment sets the text alignment for all header cells. Invalid alignments are ignored.
func (*ConfigBuilder) WithHeaderAutoFormat ¶ added in v1.0.0
func (b *ConfigBuilder) WithHeaderAutoFormat(autoFormat tw.State) *ConfigBuilder
WithHeaderAutoFormat enables or disables automatic formatting (e.g., title case) for header cells.
func (*ConfigBuilder) WithHeaderAutoWrap ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (b *ConfigBuilder) WithHeaderGlobalPadding(padding tw.Padding) *ConfigBuilder
WithHeaderGlobalPadding sets the global padding for all header cells.
func (*ConfigBuilder) WithHeaderMaxWidth ¶ added in v1.0.0
func (b *ConfigBuilder) WithHeaderMaxWidth(maxWidth int) *ConfigBuilder
WithHeaderMaxWidth sets the maximum content width for header cells. Negative values are ignored.
func (*ConfigBuilder) WithHeaderMergeMode ¶ added in v1.0.0
func (b *ConfigBuilder) WithHeaderMergeMode(mergeMode int) *ConfigBuilder
WithHeaderMergeMode sets the merge behavior for header cells (e.g., horizontal, vertical). Invalid merge modes are ignored.
func (*ConfigBuilder) WithMaxWidth ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (b *ConfigBuilder) WithRowAlignment(align tw.Align) *ConfigBuilder
WithRowAlignment sets the text alignment for all row cells. Invalid alignments are ignored.
func (*ConfigBuilder) WithRowAutoFormat ¶ added in v1.0.0
func (b *ConfigBuilder) WithRowAutoFormat(autoFormat tw.State) *ConfigBuilder
WithRowAutoFormat enables or disables automatic formatting for row cells.
func (*ConfigBuilder) WithRowAutoWrap ¶ added in v1.0.0
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 ¶ added in v1.0.0
func (b *ConfigBuilder) WithRowGlobalPadding(padding tw.Padding) *ConfigBuilder
WithRowGlobalPadding sets the global padding for all row cells.
func (*ConfigBuilder) WithRowMaxWidth ¶ added in v1.0.0
func (b *ConfigBuilder) WithRowMaxWidth(maxWidth int) *ConfigBuilder
WithRowMaxWidth sets the maximum content width for row cells. Negative values are ignored.
func (*ConfigBuilder) WithRowMergeMode ¶ added in v1.0.0
func (b *ConfigBuilder) WithRowMergeMode(mergeMode int) *ConfigBuilder
WithRowMergeMode sets the merge behavior for row cells (e.g., horizontal, hierarchical). Invalid merge modes are ignored.
func (*ConfigBuilder) WithTrimSpace ¶ added in v1.0.1
func (b *ConfigBuilder) WithTrimSpace(state tw.State) *ConfigBuilder
WithTrimSpace enables or disables automatic trimming of leading/trailing spaces. Ignored in streaming mode.
type FooterCallbacksBuilder ¶ added in v1.0.7
type FooterCallbacksBuilder struct {
// contains filtered or unexported fields
}
FooterCallbacksBuilder configures footer callbacks
func (*FooterCallbacksBuilder) AddColumnCallback ¶ added in v1.0.7
func (fc *FooterCallbacksBuilder) AddColumnCallback(callback func()) *FooterCallbacksBuilder
AddColumnCallback adds a callback function for a specific column in the footer
func (*FooterCallbacksBuilder) Build ¶ added in v1.0.7
func (fc *FooterCallbacksBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterCallbacksBuilder) WithGlobal ¶ added in v1.0.7
func (fc *FooterCallbacksBuilder) WithGlobal(callback func()) *FooterCallbacksBuilder
WithGlobal sets the global callback function for the footer
func (*FooterCallbacksBuilder) WithPerColumn ¶ added in v1.0.7
func (fc *FooterCallbacksBuilder) WithPerColumn(callbacks []func()) *FooterCallbacksBuilder
WithPerColumn sets per-column callback functions for the footer
type FooterConfigBuilder ¶ added in v1.0.0
type FooterConfigBuilder struct {
// contains filtered or unexported fields
}
FooterConfigBuilder configures footer settings
func (*FooterConfigBuilder) Alignment ¶ added in v1.0.7
func (f *FooterConfigBuilder) Alignment() *AlignmentConfigBuilder
Alignment returns an AlignmentConfigBuilder for footer alignment
func (*FooterConfigBuilder) Build ¶ added in v1.0.0
func (f *FooterConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*FooterConfigBuilder) Callbacks ¶ added in v1.0.7
func (f *FooterConfigBuilder) Callbacks() *FooterCallbacksBuilder
Callbacks returns a FooterCallbacksBuilder for footer callbacks
func (*FooterConfigBuilder) Filter ¶ added in v1.0.7
func (f *FooterConfigBuilder) Filter() *FooterFilterBuilder
Filter returns a FooterFilterBuilder for footer filtering
func (*FooterConfigBuilder) Formatting ¶ added in v1.0.0
func (f *FooterConfigBuilder) Formatting() *FooterFormattingBuilder
Formatting returns a FooterFormattingBuilder for footer formatting
func (*FooterConfigBuilder) Padding ¶ added in v1.0.0
func (f *FooterConfigBuilder) Padding() *FooterPaddingBuilder
Padding returns a FooterPaddingBuilder for footer padding
type FooterFilterBuilder ¶ added in v1.0.7
type FooterFilterBuilder struct {
// contains filtered or unexported fields
}
FooterFilterBuilder configures footer filtering
func (*FooterFilterBuilder) AddColumnFilter ¶ added in v1.0.7
func (ff *FooterFilterBuilder) AddColumnFilter(filter func(string) string) *FooterFilterBuilder
AddColumnFilter adds a filter function for a specific column in the footer
func (*FooterFilterBuilder) Build ¶ added in v1.0.7
func (ff *FooterFilterBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterFilterBuilder) WithGlobal ¶ added in v1.0.7
func (ff *FooterFilterBuilder) WithGlobal(filter func([]string) []string) *FooterFilterBuilder
WithGlobal sets the global filter function for the footer
func (*FooterFilterBuilder) WithPerColumn ¶ added in v1.0.7
func (ff *FooterFilterBuilder) WithPerColumn(filters []func(string) string) *FooterFilterBuilder
WithPerColumn sets per-column filter functions for the footer
type FooterFormattingBuilder ¶ added in v1.0.0
type FooterFormattingBuilder struct {
// contains filtered or unexported fields
}
FooterFormattingBuilder configures footer formatting
func (*FooterFormattingBuilder) Build ¶ added in v1.0.0
func (ff *FooterFormattingBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterFormattingBuilder) WithAlignment
deprecated
added in
v1.0.0
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 ¶ added in v1.0.0
func (ff *FooterFormattingBuilder) WithAutoFormat(autoFormat tw.State) *FooterFormattingBuilder
WithAutoFormat enables/disables auto formatting
func (*FooterFormattingBuilder) WithAutoWrap ¶ added in v1.0.0
func (ff *FooterFormattingBuilder) WithAutoWrap(autoWrap int) *FooterFormattingBuilder
WithAutoWrap sets auto wrap mode
func (*FooterFormattingBuilder) WithMergeMode ¶ added in v1.0.0
func (ff *FooterFormattingBuilder) WithMergeMode(mergeMode int) *FooterFormattingBuilder
WithMergeMode sets merge mode
type FooterPaddingBuilder ¶ added in v1.0.0
type FooterPaddingBuilder struct {
// contains filtered or unexported fields
}
FooterPaddingBuilder configures footer padding
func (*FooterPaddingBuilder) AddColumnPadding ¶ added in v1.0.0
func (fp *FooterPaddingBuilder) AddColumnPadding(padding tw.Padding) *FooterPaddingBuilder
AddColumnPadding adds padding for a specific column in the footer
func (*FooterPaddingBuilder) Build ¶ added in v1.0.0
func (fp *FooterPaddingBuilder) Build() *FooterConfigBuilder
Build returns the parent FooterConfigBuilder
func (*FooterPaddingBuilder) WithGlobal ¶ added in v1.0.0
func (fp *FooterPaddingBuilder) WithGlobal(padding tw.Padding) *FooterPaddingBuilder
WithGlobal sets global padding
func (*FooterPaddingBuilder) WithPerColumn ¶ added in v1.0.0
func (fp *FooterPaddingBuilder) WithPerColumn(padding []tw.Padding) *FooterPaddingBuilder
WithPerColumn sets per-column padding
type HeaderCallbacksBuilder ¶ added in v1.0.7
type HeaderCallbacksBuilder struct {
// contains filtered or unexported fields
}
HeaderCallbacksBuilder configures header callbacks
func (*HeaderCallbacksBuilder) AddColumnCallback ¶ added in v1.0.7
func (hc *HeaderCallbacksBuilder) AddColumnCallback(callback func()) *HeaderCallbacksBuilder
AddColumnCallback adds a callback function for a specific column in the header
func (*HeaderCallbacksBuilder) Build ¶ added in v1.0.7
func (hc *HeaderCallbacksBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderCallbacksBuilder) WithGlobal ¶ added in v1.0.7
func (hc *HeaderCallbacksBuilder) WithGlobal(callback func()) *HeaderCallbacksBuilder
WithGlobal sets the global callback function for the header
func (*HeaderCallbacksBuilder) WithPerColumn ¶ added in v1.0.7
func (hc *HeaderCallbacksBuilder) WithPerColumn(callbacks []func()) *HeaderCallbacksBuilder
WithPerColumn sets per-column callback functions for the header
type HeaderConfigBuilder ¶ added in v1.0.0
type HeaderConfigBuilder struct {
// contains filtered or unexported fields
}
HeaderConfigBuilder configures header settings
func (*HeaderConfigBuilder) Alignment ¶ added in v1.0.7
func (h *HeaderConfigBuilder) Alignment() *AlignmentConfigBuilder
Alignment returns an AlignmentConfigBuilder for header alignment
func (*HeaderConfigBuilder) Build ¶ added in v1.0.0
func (h *HeaderConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*HeaderConfigBuilder) Callbacks ¶ added in v1.0.7
func (h *HeaderConfigBuilder) Callbacks() *HeaderCallbacksBuilder
Callbacks returns a HeaderCallbacksBuilder for header callbacks
func (*HeaderConfigBuilder) Filter ¶ added in v1.0.7
func (h *HeaderConfigBuilder) Filter() *HeaderFilterBuilder
Filter returns a HeaderFilterBuilder for header filtering
func (*HeaderConfigBuilder) Formatting ¶ added in v1.0.0
func (h *HeaderConfigBuilder) Formatting() *HeaderFormattingBuilder
Formatting returns a HeaderFormattingBuilder for header formatting
func (*HeaderConfigBuilder) Padding ¶ added in v1.0.0
func (h *HeaderConfigBuilder) Padding() *HeaderPaddingBuilder
Padding returns a HeaderPaddingBuilder for header padding
type HeaderFilterBuilder ¶ added in v1.0.7
type HeaderFilterBuilder struct {
// contains filtered or unexported fields
}
HeaderFilterBuilder configures header filtering
func (*HeaderFilterBuilder) AddColumnFilter ¶ added in v1.0.7
func (hf *HeaderFilterBuilder) AddColumnFilter(filter func(string) string) *HeaderFilterBuilder
AddColumnFilter adds a filter function for a specific column in the header
func (*HeaderFilterBuilder) Build ¶ added in v1.0.7
func (hf *HeaderFilterBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderFilterBuilder) WithGlobal ¶ added in v1.0.7
func (hf *HeaderFilterBuilder) WithGlobal(filter func([]string) []string) *HeaderFilterBuilder
WithGlobal sets the global filter function for the header
func (*HeaderFilterBuilder) WithPerColumn ¶ added in v1.0.7
func (hf *HeaderFilterBuilder) WithPerColumn(filters []func(string) string) *HeaderFilterBuilder
WithPerColumn sets per-column filter functions for the header
type HeaderFormattingBuilder ¶ added in v1.0.0
type HeaderFormattingBuilder struct {
// contains filtered or unexported fields
}
HeaderFormattingBuilder configures header formatting
func (*HeaderFormattingBuilder) Build ¶ added in v1.0.0
func (hf *HeaderFormattingBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderFormattingBuilder) WithAlignment
deprecated
added in
v1.0.0
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 ¶ added in v1.0.0
func (hf *HeaderFormattingBuilder) WithAutoFormat(autoFormat tw.State) *HeaderFormattingBuilder
WithAutoFormat enables/disables auto formatting
func (*HeaderFormattingBuilder) WithAutoWrap ¶ added in v1.0.0
func (hf *HeaderFormattingBuilder) WithAutoWrap(autoWrap int) *HeaderFormattingBuilder
WithAutoWrap sets auto wrap mode
func (*HeaderFormattingBuilder) WithMergeMode ¶ added in v1.0.0
func (hf *HeaderFormattingBuilder) WithMergeMode(mergeMode int) *HeaderFormattingBuilder
WithMergeMode sets merge mode
type HeaderPaddingBuilder ¶ added in v1.0.0
type HeaderPaddingBuilder struct {
// contains filtered or unexported fields
}
HeaderPaddingBuilder configures header padding
func (*HeaderPaddingBuilder) AddColumnPadding ¶ added in v1.0.0
func (hp *HeaderPaddingBuilder) AddColumnPadding(padding tw.Padding) *HeaderPaddingBuilder
AddColumnPadding adds padding for a specific column in the header
func (*HeaderPaddingBuilder) Build ¶ added in v1.0.0
func (hp *HeaderPaddingBuilder) Build() *HeaderConfigBuilder
Build returns the parent HeaderConfigBuilder
func (*HeaderPaddingBuilder) WithGlobal ¶ added in v1.0.0
func (hp *HeaderPaddingBuilder) WithGlobal(padding tw.Padding) *HeaderPaddingBuilder
WithGlobal sets global padding
func (*HeaderPaddingBuilder) WithPerColumn ¶ added in v1.0.0
func (hp *HeaderPaddingBuilder) WithPerColumn(padding []tw.Padding) *HeaderPaddingBuilder
WithPerColumn sets per-column padding
type Option ¶ added in v1.0.0
type Option func(target *Table)
Option defines a function type for configuring a Table instance.
func WithAlignment ¶ added in v1.0.3
WithAlignment sets the default column alignment for the header, rows, and footer. Logs the change if debugging is enabled.
func WithAutoHide ¶ added in v1.0.1
WithAutoHide enables or disables automatic hiding of columns with empty data rows. Logs the change if debugging is enabled.
func WithBehavior ¶ added in v1.0.7
WithBehavior applies a behavior configuration to the table. Logs the change if debugging is enabled.
func WithBorders
deprecated
added in
v1.0.1
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 ¶ added in v1.0.1
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 ¶ added in v1.0.1
WithColumnWidths sets per-column widths for the table. Negative widths are removed, and the change is logged if debugging is enabled.
func WithCondition ¶ added in v1.0.8
func WithCondition(condition *runewidth.Condition) Option
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 ¶ added in v1.0.0
WithConfig applies a custom configuration to the table by merging it with the default configuration.
func WithCounters ¶ added in v1.1.0
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 ¶ added in v1.0.0
WithDebug enables or disables debug logging and adjusts the logger level accordingly. Logs the change if debugging is enabled.
func WithEastAsian ¶ added in v1.0.8
WithEastAsian configures the global East Asian width calculation setting.
- enable=true: Enables East Asian width calculations. CJK and ambiguous characters are typically measured as double width.
- enable=false: 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 ¶ added in v1.0.0
WithFooter sets the table footers by calling the Footer method.
func WithFooterAlignmentConfig ¶ added in v1.0.7
func WithFooterAlignmentConfig(alignment tw.CellAlignment) Option
WithFooterAlignmentConfig applies a footer alignment configuration to the table. Logs the change if debugging is enabled.
func WithFooterAutoFormat ¶ added in v1.0.7
WithFooterAutoFormat enables or disables automatic formatting for footer cells. Logs the change if debugging is enabled.
func WithFooterAutoWrap ¶ added in v1.0.7
WithFooterAutoWrap sets the wrapping behavior for footer cells. Invalid wrap modes are ignored, and the change is logged if debugging is enabled.
func WithFooterCallbacks ¶ added in v1.0.7
func WithFooterCallbacks(callbacks tw.CellCallbacks) Option
WithFooterCallbacks sets the callback configuration for footer cells. Logs the change if debugging is enabled.
func WithFooterConfig ¶ added in v1.0.0
func WithFooterConfig(config tw.CellConfig) Option
WithFooterConfig applies a full footer configuration to the table. Logs the change if debugging is enabled.
func WithFooterControl ¶ added in v1.0.6
WithFooterControl sets the control behavior for the table footer. Logs the change if debugging is enabled.
func WithFooterFilter ¶ added in v1.0.7
func WithFooterFilter(filter tw.CellFilter) Option
WithFooterFilter sets the filter configuration for footer cells. Logs the change if debugging is enabled.
func WithFooterMaxWidth ¶ added in v1.0.7
WithFooterMaxWidth sets the maximum content width for footer cells. Negative values are ignored, and the change is logged if debugging is enabled.
func WithFooterMergeMode ¶ added in v1.0.0
WithFooterMergeMode sets the merge mode for footer cells. Invalid merge modes are ignored, and the change is logged if debugging is enabled.
func WithFooterPaddingPerColumn ¶ added in v1.0.7
WithFooterPaddingPerColumn sets per-column padding for footer cells. Logs the change if debugging is enabled.
func WithHeader ¶ added in v1.0.0
WithHeader sets the table headers by calling the Header method.
func WithHeaderAlignment ¶ added in v1.0.0
WithHeaderAlignment sets the text alignment for header cells. Invalid alignments are ignored, and the change is logged if debugging is enabled.
func WithHeaderAlignmentConfig ¶ added in v1.0.7
func WithHeaderAlignmentConfig(alignment tw.CellAlignment) Option
WithHeaderAlignmentConfig applies a header alignment configuration to the table. Logs the change if debugging is enabled.
func WithHeaderAutoFormat ¶ added in v1.0.6
WithHeaderAutoFormat enables or disables automatic formatting for header cells. Logs the change if debugging is enabled.
func WithHeaderAutoWrap ¶ added in v1.0.7
WithHeaderAutoWrap sets the wrapping behavior for header cells. Invalid wrap modes are ignored, and the change is logged if debugging is enabled.
func WithHeaderCallbacks ¶ added in v1.0.7
func WithHeaderCallbacks(callbacks tw.CellCallbacks) Option
WithHeaderCallbacks sets the callback configuration for header cells. Logs the change if debugging is enabled.
func WithHeaderConfig ¶ added in v1.0.0
func WithHeaderConfig(config tw.CellConfig) Option
WithHeaderConfig applies a full header configuration to the table. Logs the change if debugging is enabled.
func WithHeaderControl ¶ added in v1.0.6
WithHeaderControl sets the control behavior for the table header. Logs the change if debugging is enabled.
func WithHeaderFilter ¶ added in v1.0.7
func WithHeaderFilter(filter tw.CellFilter) Option
WithHeaderFilter sets the filter configuration for header cells. Logs the change if debugging is enabled.
func WithHeaderMaxWidth ¶ added in v1.0.7
WithHeaderMaxWidth sets the maximum content width for header cells. Negative values are ignored, and the change is logged if debugging is enabled.
func WithHeaderMergeMode ¶ added in v1.0.7
WithHeaderMergeMode sets the merge mode for header cells. Invalid merge modes are ignored, and the change is logged if debugging is enabled.
func WithHeaderPaddingPerColumn ¶ added in v1.0.7
WithHeaderPaddingPerColumn sets per-column padding for header cells. Logs the change if debugging is enabled.
func WithLineCounter ¶ added in v1.1.0
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 ¶ added in v1.0.1
WithLogger sets a custom logger for the table and updates the renderer if present. Logs the change if debugging is enabled.
func WithMaxWidth ¶ added in v1.0.7
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 ¶ added in v1.0.6
WithPadding sets the global padding for the header, rows, and footer. Logs the change if debugging is enabled.
func WithRenderer ¶ added in v1.0.0
WithRenderer sets a custom renderer for the table and attaches the logger if present. Logs the change if debugging is enabled.
func WithRendererSettings
deprecated
added in
v1.0.1
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 ¶ added in v1.0.5
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 ¶ added in v1.0.7
WithRowAlignment sets the text alignment for row cells. Invalid alignments are ignored, and the change is logged if debugging is enabled.
func WithRowAlignmentConfig ¶ added in v1.0.7
func WithRowAlignmentConfig(alignment tw.CellAlignment) Option
WithRowAlignmentConfig applies a row alignment configuration to the table. Logs the change if debugging is enabled.
func WithRowAutoFormat ¶ added in v1.0.7
WithRowAutoFormat enables or disables automatic formatting for row cells. Logs the change if debugging is enabled.
func WithRowAutoWrap ¶ added in v1.0.7
WithRowAutoWrap sets the wrapping behavior for row cells. Invalid wrap modes are ignored, and the change is logged if debugging is enabled.
func WithRowCallbacks ¶ added in v1.0.7
func WithRowCallbacks(callbacks tw.CellCallbacks) Option
WithRowCallbacks sets the callback configuration for row cells. Logs the change if debugging is enabled.
func WithRowConfig ¶ added in v1.0.0
func WithRowConfig(config tw.CellConfig) Option
WithRowConfig applies a full row configuration to the table. Logs the change if debugging is enabled.
func WithRowFilter ¶ added in v1.0.7
func WithRowFilter(filter tw.CellFilter) Option
WithRowFilter sets the filter configuration for row cells. Logs the change if debugging is enabled.
func WithRowMaxWidth ¶ added in v1.0.0
WithRowMaxWidth sets the maximum content width for row cells. Negative values are ignored, and the change is logged if debugging is enabled.
func WithRowMergeMode ¶ added in v1.0.7
WithRowMergeMode sets the merge mode for row cells. Invalid merge modes are ignored, and the change is logged if debugging is enabled.
func WithRowPaddingPerColumn ¶ added in v1.0.7
WithRowPaddingPerColumn sets per-column padding for row cells. Logs the change if debugging is enabled.
func WithStreaming ¶ added in v1.0.1
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 ¶ added in v1.0.0
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 ¶ added in v1.0.1
func WithStringerCache() Option
WithStringerCache enables caching for the stringer function. Logs the change if debugging is enabled.
func WithSymbols ¶ added in v1.0.1
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
added in
v1.0.5
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 ¶ added in v1.1.0
WithTrimLine sets whether empty visual lines within a cell are trimmed. Logs the change if debugging is enabled.
func WithTrimSpace ¶ added in v1.0.1
WithTrimSpace sets whether leading and trailing spaces are automatically trimmed. Logs the change if debugging is enabled.
func WithWidths ¶ added in v1.0.7
WithWidths sets per-column widths for the table. Negative widths are removed, and the change is logged if debugging is enabled.
type RowCallbacksBuilder ¶ added in v1.0.7
type RowCallbacksBuilder struct {
// contains filtered or unexported fields
}
RowCallbacksBuilder configures row callbacks
func (*RowCallbacksBuilder) AddColumnCallback ¶ added in v1.0.7
func (rc *RowCallbacksBuilder) AddColumnCallback(callback func()) *RowCallbacksBuilder
AddColumnCallback adds a callback function for a specific column in the rows
func (*RowCallbacksBuilder) Build ¶ added in v1.0.7
func (rc *RowCallbacksBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowCallbacksBuilder) WithGlobal ¶ added in v1.0.7
func (rc *RowCallbacksBuilder) WithGlobal(callback func()) *RowCallbacksBuilder
WithGlobal sets the global callback function for the rows
func (*RowCallbacksBuilder) WithPerColumn ¶ added in v1.0.7
func (rc *RowCallbacksBuilder) WithPerColumn(callbacks []func()) *RowCallbacksBuilder
WithPerColumn sets per-column callback functions for the rows
type RowConfigBuilder ¶ added in v1.0.0
type RowConfigBuilder struct {
// contains filtered or unexported fields
}
RowConfigBuilder configures row settings
func (*RowConfigBuilder) Alignment ¶ added in v1.0.7
func (r *RowConfigBuilder) Alignment() *AlignmentConfigBuilder
Alignment returns an AlignmentConfigBuilder for row alignment
func (*RowConfigBuilder) Build ¶ added in v1.0.0
func (r *RowConfigBuilder) Build() *ConfigBuilder
Build returns the parent ConfigBuilder
func (*RowConfigBuilder) Callbacks ¶ added in v1.0.7
func (r *RowConfigBuilder) Callbacks() *RowCallbacksBuilder
Callbacks returns a RowCallbacksBuilder for row callbacks
func (*RowConfigBuilder) Filter ¶ added in v1.0.7
func (r *RowConfigBuilder) Filter() *RowFilterBuilder
Filter returns a RowFilterBuilder for row filtering
func (*RowConfigBuilder) Formatting ¶ added in v1.0.0
func (r *RowConfigBuilder) Formatting() *RowFormattingBuilder
Formatting returns a RowFormattingBuilder for row formatting
func (*RowConfigBuilder) Padding ¶ added in v1.0.0
func (r *RowConfigBuilder) Padding() *RowPaddingBuilder
Padding returns a RowPaddingBuilder for row padding
type RowFilterBuilder ¶ added in v1.0.7
type RowFilterBuilder struct {
// contains filtered or unexported fields
}
RowFilterBuilder configures row filtering
func (*RowFilterBuilder) AddColumnFilter ¶ added in v1.0.7
func (rf *RowFilterBuilder) AddColumnFilter(filter func(string) string) *RowFilterBuilder
AddColumnFilter adds a filter function for a specific column in the rows
func (*RowFilterBuilder) Build ¶ added in v1.0.7
func (rf *RowFilterBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowFilterBuilder) WithGlobal ¶ added in v1.0.7
func (rf *RowFilterBuilder) WithGlobal(filter func([]string) []string) *RowFilterBuilder
WithGlobal sets the global filter function for the rows
func (*RowFilterBuilder) WithPerColumn ¶ added in v1.0.7
func (rf *RowFilterBuilder) WithPerColumn(filters []func(string) string) *RowFilterBuilder
WithPerColumn sets per-column filter functions for the rows
type RowFormattingBuilder ¶ added in v1.0.0
type RowFormattingBuilder struct {
// contains filtered or unexported fields
}
RowFormattingBuilder configures row formatting
func (*RowFormattingBuilder) Build ¶ added in v1.0.0
func (rf *RowFormattingBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowFormattingBuilder) WithAlignment
deprecated
added in
v1.0.0
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 ¶ added in v1.0.0
func (rf *RowFormattingBuilder) WithAutoFormat(autoFormat tw.State) *RowFormattingBuilder
WithAutoFormat enables/disables auto formatting
func (*RowFormattingBuilder) WithAutoWrap ¶ added in v1.0.0
func (rf *RowFormattingBuilder) WithAutoWrap(autoWrap int) *RowFormattingBuilder
WithAutoWrap sets auto wrap mode
func (*RowFormattingBuilder) WithMergeMode ¶ added in v1.0.0
func (rf *RowFormattingBuilder) WithMergeMode(mergeMode int) *RowFormattingBuilder
WithMergeMode sets merge mode
type RowPaddingBuilder ¶ added in v1.0.0
type RowPaddingBuilder struct {
// contains filtered or unexported fields
}
RowPaddingBuilder configures row padding
func (*RowPaddingBuilder) AddColumnPadding ¶ added in v1.0.0
func (rp *RowPaddingBuilder) AddColumnPadding(padding tw.Padding) *RowPaddingBuilder
AddColumnPadding adds padding for a specific column in the rows
func (*RowPaddingBuilder) Build ¶ added in v1.0.0
func (rp *RowPaddingBuilder) Build() *RowConfigBuilder
Build returns the parent RowConfigBuilder
func (*RowPaddingBuilder) WithGlobal ¶ added in v1.0.0
func (rp *RowPaddingBuilder) WithGlobal(padding tw.Padding) *RowPaddingBuilder
WithGlobal sets global padding
func (*RowPaddingBuilder) WithPerColumn ¶ added in v1.0.0
func (rp *RowPaddingBuilder) WithPerColumn(padding []tw.Padding) *RowPaddingBuilder
WithPerColumn sets per-column padding
type Settings
deprecated
added in
v1.0.6
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.4
Caption sets the table caption (legacy method). Defaults to BottomCenter alignment, wrapping to table width. Use SetCaptionOptions for more control.
func (*Table) Close ¶ added in v1.0.1
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 ¶ added in v1.0.1
Config returns the current table configuration. No parameters are required. Returns the Config struct with current settings.
func (*Table) Configure ¶ added in v1.0.0
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 ¶ added in v1.1.0
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 ¶ added in v1.0.0
Debug retrieves the accumulated debug trace logs. No parameters are required. Returns a slice of debug messages including renderer logs.
func (*Table) Footer ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.1.0
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 ¶ added in v1.0.1
Logger retrieves the table's logger instance. No parameters are required. Returns the ll.Logger instance used for debug tracing.
func (*Table) Options ¶ added in v1.0.5
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 ¶ added in v1.0.0
Renderer retrieves the current renderer instance used by the table. No parameters are required. Returns the tw.Renderer interface instance.
func (*Table) Reset ¶ added in v1.0.5
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 ¶ added in v1.0.1
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 ¶ added in v1.0.5
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
|
|
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. |