Documentation
¶
Overview ¶
Package textfmt offers a collection of utils for plain text formatting.
Index ¶
- func RemoveNonPrintableChars(s string) string
- func WordWrap(text string, lineWidth int) string
- func WordWrapWithPrefix(text string, lineWidth int, prefix string) string
- func WordWrapWithPrefixes(text string, lineWidth int, firstPrefix, contPrefix string) string
- type Table
- type TableBatchOp
- type TableOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveNonPrintableChars ¶ added in v0.6.0
RemoveNonPrintableChars removes non-printable characters Uses Go's unicode package to determine if a character is printable
func WordWrapWithPrefix ¶ added in v0.5.0
WordWrapWithPrefix with prefix for each line.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a thread-safe plain text table structure
func NewTable ¶ added in v0.6.0
func NewTable(opts ...TableOption) *Table
NewTable creates a new Table with proper initialization
func (*Table) AddDivider ¶ added in v0.3.0
func (t *Table) AddDivider()
AddDivider adds a divider at the current row position
func (*Table) Batch ¶ added in v0.6.0
func (t *Table) Batch(batch *TableBatchOp)
Batch executes the batch operation on the table
type TableBatchOp ¶ added in v0.6.0
type TableBatchOp struct {
// contains filtered or unexported fields
}
TableBatchOp Batch operations when adding rows to table for better performance
func NewTableBatchOp ¶ added in v0.6.0
func NewTableBatchOp() *TableBatchOp
NewTableBatchOp creates a new table batch operation
func (*TableBatchOp) AddDivider ¶ added in v0.6.0
func (bo *TableBatchOp) AddDivider()
AddDivider adds a divider at the current position
func (*TableBatchOp) AddRow ¶ added in v0.6.0
func (bo *TableBatchOp) AddRow(cols ...string)
AddRow adds a row to the table batch op
type TableOption ¶ added in v0.6.0
type TableOption func(*Table)
func TableSkipEmptyRows ¶ added in v0.6.0
func TableSkipEmptyRows(skip bool) TableOption
TableSkipEmptyRows sets whether to skip empty rows
func TableTitle ¶ added in v0.6.0
func TableTitle(title string) TableOption
TableTitle sets the table title
func TableWithHeader ¶ added in v0.6.0
func TableWithHeader() TableOption
TableWithHeader sets whether the table has a header row