textutil

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: MIT Imports: 5 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tpl

func Tpl(text string, data map[string]string) string

func WriteTable

func WriteTable(w io.Writer, table Table, style TableStyler)

WriteTable formats table to writer with specified style

Types

type ColorWriter

type ColorWriter struct {
	*color.Color
	// contains filtered or unexported fields
}

ColorWriter

func (*ColorWriter) Write

func (cw *ColorWriter) Write(b []byte) (int, error)

type DefaultStyle

type DefaultStyle struct{}

DefaultStyle ...

func (DefaultStyle) BorderRender

func (style DefaultStyle) BorderRender(border string, w *ColorWriter)

func (DefaultStyle) CellRender

func (style DefaultStyle) CellRender(row, col int, cell string, w *ColorWriter)

type StringMatrix

type StringMatrix [][]string

2-Array string

func (StringMatrix) ColCount

func (m StringMatrix) ColCount() int

func (StringMatrix) Get

func (m StringMatrix) Get(i, j int) string

func (StringMatrix) RowCount

func (m StringMatrix) RowCount() int

type Table

type Table interface {
	RowCount() int
	ColCount() int
	Get(i, j int) string
}

Table represents a string-matrix

func AddTableHeader

func AddTableHeader(table Table, header []string) Table

func ClipTable

func ClipTable(table Table, i, j, m, n int) Table

ClipTable creates a view of table

type TableStyler

type TableStyler interface {
	CellRender(row, col int, cell string, w *ColorWriter)
	BorderRender(border string, w *ColorWriter)
}

TableStyler represents s render style for Table

type TableView

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

TableView represents a view of table, it implements Table interface, too

func (TableView) ColCount

func (tv TableView) ColCount() int

func (TableView) Get

func (tv TableView) Get(i, j int) string

func (TableView) RowCount

func (tv TableView) RowCount() int

type TableWithHeader

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

TableWithHeader add header for table

func (TableWithHeader) ColCount

func (twh TableWithHeader) ColCount() int

func (TableWithHeader) Get

func (twh TableWithHeader) Get(i, j int) string

func (TableWithHeader) RowCount

func (twh TableWithHeader) RowCount() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳