textfmt

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package textfmt offers a collection of utils for plain text formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveNonPrintableChars added in v0.6.0

func RemoveNonPrintableChars(s string) string

RemoveNonPrintableChars removes non-printable characters Uses Go's unicode package to determine if a character is printable

func WordWrap added in v0.5.0

func WordWrap(text string, lineWidth int) string

WordWrap returns string wrapped string to a specified line width.

func WordWrapWithPrefix added in v0.5.0

func WordWrapWithPrefix(text string, lineWidth int, prefix string) string

WordWrapWithPrefix with prefix for each line.

func WordWrapWithPrefixes added in v0.5.0

func WordWrapWithPrefixes(text string, lineWidth int, firstPrefix, contPrefix string) string

WordWrapWithPrefixes returns string with different prefix for first line vs continuation lines.

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) AddRow

func (t *Table) AddRow(cols ...string)

AddRow adds a row to the table

func (*Table) AddRows added in v0.6.0

func (t *Table) AddRows(rows [][]string)

AddRows adds multiple rows efficiently

func (*Table) Append added in v0.6.0

func (t *Table) Append(child *Table)

Append adds a child table

func (*Table) Batch added in v0.6.0

func (t *Table) Batch(batch *TableBatchOp)

Batch executes the batch operation on the table

func (*Table) String

func (t *Table) String() string

String returns the string representation of 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

Jump to

Keyboard shortcuts

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