tables

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 5 Imported by: 0

README

tabula-rasa

Print tables from Go

Documentation

Index

Constants

View Source
const (
	Left = 1 << iota
	Center
	Right
	Top
	Header
	Bottom
	Horizontal
	Left2
	Center2
	Right2
	Top2
	Header2
	Bottom2
	Horizontal2
)

Variables

View Source
var (
	// DefaultPadding specifies the number of spaces around content in columns.
	DefaultPadding = 1

	// DefaultWriter specifies the output io.Writer for the Table.Print method.
	DefaultWriter io.Writer = os.Stdout

	// DefaultWidthFunc specifies the default WidthFunc for calculating column widths
	DefaultWidthFunc WidthFunc = utf8.RuneCountInString
)

Functions

func GetAlignment

func GetAlignment(align int) (label string)

Types

type Cell

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

func FormCell

func FormCell(color func(a ...any) string, contents string) Cell

type Row

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

type Table

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

func NewTable

func NewTable(colNames ...string) (tbl *Table)

func (*Table) AddCells

func (tbl *Table) AddCells(color func(a ...any) string, cells ...Cell) (err error)

func (*Table) AddRow

func (tbl *Table) AddRow(color func(a ...any) string, cells ...string) (err error)

func (*Table) Align

func (tbl *Table) Align(colName string, alignment int, includeHeader bool)

func (*Table) CalcWidth

func (tbl *Table) CalcWidth(column string, pad bool, verbose bool) (calcWidth int, debug debugCol)

func (*Table) CharWidth

func (tbl *Table) CharWidth(column string) int

func (*Table) ColumnCount

func (tbl *Table) ColumnCount() int

func (*Table) FillWidths

func (tbl *Table) FillWidths()

func (*Table) GetBorder

func (tbl *Table) GetBorder(border int) (bool, bool)

func (*Table) Padding

func (tbl *Table) Padding(before bool, colIndex int) int

func (*Table) Print

func (tbl *Table) Print()

func (*Table) SetBorder

func (tbl *Table) SetBorder(border int, display bool, style bool)

type WidthFunc

type WidthFunc func(string) int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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