format

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASCIICharMap = map[TableCharacter]string{
	HLINE:    "-",
	VLINE:    "|",
	MIDLLINE: "|",
	MIDRLINE: "|",
	TLCORNER: " ",
	TRCORNER: " ",
	BLCORNER: " ",
	BRCORNER: " ",
}
View Source
var PrettyCharMap = map[TableCharacter]string{
	HLINE:    "\u2500",
	VLINE:    "\u2502",
	MIDLLINE: "\u251C",
	MIDRLINE: "\u2524",
	TLCORNER: "\u250C",
	TRCORNER: "\u2510",
	BLCORNER: "\u2514",
	BRCORNER: "\u2518",
}
View Source
var PrettyCharMapRoundedCorners = map[TableCharacter]string{
	HLINE:    PrettyCharMap[HLINE],
	VLINE:    PrettyCharMap[VLINE],
	MIDLLINE: PrettyCharMap[MIDLLINE],
	MIDRLINE: PrettyCharMap[MIDRLINE],
	TLCORNER: "\u256D",
	TRCORNER: "\u256E",
	BLCORNER: "\u2570",
	BRCORNER: "\u256F",
}

Functions

func AlphabeticLess

func AlphabeticLess(a, b string) bool

func NewCatagoricLess

func NewCatagoricLess(categories []string) func(a, b string) bool

func PrettyPrintMap

func PrettyPrintMap[K comparable, V any](m map[K]V) string

func PrettyPrintMapOrdered

func PrettyPrintMapOrdered[K comparable, V any](m map[K]V, orderedKeys []K) string

func Summarize

func Summarize(content string, length int, clip ClipDirection) string

Types

type ClipDirection

type ClipDirection int
const (
	ClipLeft ClipDirection = iota
	ClipRight
	ClipMiddle
)

type Table

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

func NewTable

func NewTable() *Table

func (*Table) AppendRow

func (t *Table) AppendRow(values ...string)

func (*Table) Body

func (t *Table) Body() [][]string

func (*Table) Len

func (t *Table) Len() int

func (*Table) Less

func (t *Table) Less(i, j int) bool

func (*Table) Select

func (t *Table) Select(columnIndex uint)

func (*Table) SetSort

func (t *Table) SetSort(columnIndex uint, lessFunc func(a, b string) bool)

func (*Table) Swap

func (t *Table) Swap(i, j int)

type TableCharacter

type TableCharacter int
const (
	HLINE TableCharacter = iota
	VLINE
	MIDLLINE
	MIDRLINE
	TLCORNER
	TRCORNER
	BLCORNER
	BRCORNER
)

type TableWriter

type TableWriter struct {
	bytes.Buffer
	// contains filtered or unexported fields
}

func NewTableWriter

func NewTableWriter(t *Table) *TableWriter

func (*TableWriter) WithCharMap

func (w *TableWriter) WithCharMap(m map[TableCharacter]string) *TableWriter

func (*TableWriter) WithTable

func (w *TableWriter) WithTable(t *Table) *TableWriter

Jump to

Keyboard shortcuts

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