table

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: Unlicense Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

Functions

func MapCellSplice

func MapCellSplice(data map[int]TableCellInterface, offset int, replacer TableCellInterface) map[int]TableCellInterface

func MapRowSplice

func MapRowSplice(data map[int]TableRowInterface, offset int, replacer TableRowInterface) map[int]TableRowInterface

func RowMapReplaceRecursive

func RowMapReplaceRecursive(
	base TableData,
	replacement map[int]map[int]TableCellInterface,
) map[int]map[int]TableCellInterface

func SetStyleDefinition

func SetStyleDefinition(name string, style TableStyleInterface)

Types

type PaddingType

type PaddingType int
const (
	PadDefault  PaddingType = 0
	PadToRight  PaddingType = 1
	PadToLeft   PaddingType = 2
	PadToCenter PaddingType = 3
)

type Table

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

func NewTable

func NewTable() *Table

func (*Table) AddHeader

func (t *Table) AddHeader(row TableRowInterface) *Table

func (*Table) AddHeaderFromString

func (t *Table) AddHeaderFromString(row []string) *Table

func (*Table) AddHeaders

func (t *Table) AddHeaders(rows []TableRowInterface) *Table

func (*Table) AddHeadersFromString

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

func (*Table) AddRow

func (t *Table) AddRow(row TableRowInterface) *Table

func (*Table) AddRowFromString

func (t *Table) AddRowFromString(row []string) *Table

func (*Table) AddRows

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

func (*Table) AddRowsFromString

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

func (*Table) AddTableSeparator

func (t *Table) AddTableSeparator() *Table

func (*Table) GetCellsAsList

func (t *Table) GetCellsAsList() []TableCellInterface

func (*Table) GetColumnPadding

func (t *Table) GetColumnPadding(column int) PaddingType

func (*Table) GetColumnsAsList

func (t *Table) GetColumnsAsList() []TableColumnInterface

func (*Table) GetFooterTitle

func (t *Table) GetFooterTitle() string

func (*Table) GetHeaderTitle

func (t *Table) GetHeaderTitle() string

func (*Table) GetHeaders

func (t *Table) GetHeaders() *TableData

func (*Table) GetLinesAsList

func (t *Table) GetLinesAsList() []TableRowInterface

func (*Table) GetRows

func (t *Table) GetRows() *TableData

func (*Table) SetColumnPadding

func (t *Table) SetColumnPadding(column int, padding PaddingType) *Table

func (*Table) SetFooterTitle

func (t *Table) SetFooterTitle(title string) *Table

func (*Table) SetHeaderTitle

func (t *Table) SetHeaderTitle(title string) *Table

func (*Table) SetHeaders

func (t *Table) SetHeaders(data *TableData) *Table

func (*Table) SetHeadersFromString

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

func (*Table) SetRows

func (t *Table) SetRows(data *TableData) *Table

func (*Table) SetRowsFromString

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

type TableCell

type TableCell struct {
	Value   string
	Colspan int
	PadType PaddingType
	// contains filtered or unexported fields
}

func NewTableCell

func NewTableCell(value string) *TableCell

func (*TableCell) GetColspan

func (t *TableCell) GetColspan() int

func (*TableCell) GetPadType

func (t *TableCell) GetPadType() PaddingType

func (*TableCell) GetValue

func (t *TableCell) GetValue() string

func (*TableCell) SetColspan

func (t *TableCell) SetColspan(colspan int) *TableCell

func (*TableCell) SetPadType

func (t *TableCell) SetPadType(pad PaddingType) *TableCell

func (*TableCell) SetValue

func (t *TableCell) SetValue(value string) *TableCell

type TableCellInterface

type TableCellInterface interface {
	GetValue() string
	SetValue(value string) *TableCell

	GetColspan() int
	GetPadType() PaddingType
	// contains filtered or unexported methods
}

type TableColumn

type TableColumn struct {
	Cell TableCellInterface
}

func MakeColumnFromString

func MakeColumnFromString(cell string) *TableColumn

func NewTableColumn

func NewTableColumn() *TableColumn

func (*TableColumn) GetCell

func (t *TableColumn) GetCell() TableCellInterface

func (*TableColumn) SetCell

func (t *TableColumn) SetCell(cell TableCellInterface) *TableColumn

type TableColumnInterface

type TableColumnInterface interface {
	SetCell(cell TableCellInterface) *TableColumn
	GetCell() TableCellInterface
}

type TableData

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

func MakeDataFromStrings

func MakeDataFromStrings(rows [][]string) *TableData

func MergeData

func MergeData(datas ...*TableData) *TableData

func NewTableData

func NewTableData() *TableData

func RowMapFill

func RowMapFill(startIndex int, count int, value TableRowInterface) TableData

func (*TableData) AddRow

func (t *TableData) AddRow(row TableRowInterface) *TableData

func (*TableData) AddRowFromString

func (t *TableData) AddRowFromString(rowData []string) *TableData

func (*TableData) AddRows

func (t *TableData) AddRows(rows []TableRowInterface) *TableData

func (*TableData) AddRowsFromString

func (t *TableData) AddRowsFromString(rows [][]string) *TableData

func (*TableData) GetCellsAsList

func (t *TableData) GetCellsAsList() []TableCellInterface

func (*TableData) GetColumnsAsList

func (t *TableData) GetColumnsAsList() []TableColumnInterface

func (*TableData) GetRow

func (t *TableData) GetRow(index int) TableRowInterface

func (*TableData) GetRows

func (t *TableData) GetRows() map[int]TableRowInterface

func (*TableData) GetRowsAsList

func (t *TableData) GetRowsAsList() []TableRowInterface

func (*TableData) GetRowsSortedKeys

func (t *TableData) GetRowsSortedKeys() []int

func (*TableData) SetRow

func (t *TableData) SetRow(index int, row TableRowInterface) *TableData

func (*TableData) SetRows

func (t *TableData) SetRows(lines map[int]TableRowInterface) *TableData

type TableInterface

type TableInterface interface {
	SetHeaders(data *TableData) *Table
	GetHeaders() *TableData

	SetRows(data *TableData) *Table
	GetRows() *TableData

	SetHeaderTitle(title string) *Table
	GetHeaderTitle() string

	SetFooterTitle(title string) *Table
	GetFooterTitle() string

	GetLinesAsList() []TableRowInterface
	GetColumnsAsList() []TableColumnInterface
	GetCellsAsList() []TableCellInterface
}

type TableRender

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

func NewRender

func NewRender(output output.OutputInterface) *TableRender

Table constructor

func (*TableRender) GetColumnMaxWidth

func (t *TableRender) GetColumnMaxWidth(column int) int

func (*TableRender) GetColumnMinWidth

func (t *TableRender) GetColumnMinWidth(column int) int

func (*TableRender) GetColumnStyle

func (t *TableRender) GetColumnStyle(column int) TableStyleInterface

func (*TableRender) GetContent

func (t *TableRender) GetContent() *Table

func (*TableRender) Render

func (t *TableRender) Render()

func (*TableRender) SetColumnMaxWidth

func (t *TableRender) SetColumnMaxWidth(column int, width int) *TableRender

func (*TableRender) SetColumnMinWidth

func (t *TableRender) SetColumnMinWidth(column int, width int) *TableRender

func (*TableRender) SetColumnStyle

func (t *TableRender) SetColumnStyle(column int, name string) *TableRender

func (*TableRender) SetColumnWidth

func (t *TableRender) SetColumnWidth(column int, width int) *TableRender

func (*TableRender) SetColumnsMaxWidths

func (t *TableRender) SetColumnsMaxWidths(widths map[int]int) *TableRender

func (*TableRender) SetColumnsMinWidths

func (t *TableRender) SetColumnsMinWidths(widths map[int]int) *TableRender

func (*TableRender) SetColumnsWidths

func (t *TableRender) SetColumnsWidths(widths map[int]int) *TableRender

func (*TableRender) SetContent

func (t *TableRender) SetContent(content *Table) *TableRender

func (*TableRender) SetStyle

func (t *TableRender) SetStyle(style TableStyleInterface) *TableRender

func (*TableRender) SetStyleFromName

func (t *TableRender) SetStyleFromName(name string) *TableRender

type TableRow

type TableRow struct {
	Columns map[int]TableColumnInterface
}

func MakeRowFromStrings

func MakeRowFromStrings(column []string) *TableRow

func NewTableRow

func NewTableRow() *TableRow

func (*TableRow) AddColumn

func (t *TableRow) AddColumn(column TableColumnInterface) *TableRow

func (*TableRow) GetCellsAsList

func (t *TableRow) GetCellsAsList() []TableCellInterface

func (*TableRow) GetColumn

func (t *TableRow) GetColumn(column int) TableColumnInterface

func (*TableRow) GetColumns

func (t *TableRow) GetColumns() map[int]TableColumnInterface

func (*TableRow) GetColumnsSortedKeys

func (t *TableRow) GetColumnsSortedKeys() []int

func (*TableRow) SetColumn

func (t *TableRow) SetColumn(index int, column TableColumnInterface) *TableRow

func (*TableRow) SetColumns

func (t *TableRow) SetColumns(columns map[int]TableColumnInterface) *TableRow

type TableRowInterface

type TableRowInterface interface {
	SetColumns(columns map[int]TableColumnInterface) *TableRow
	GetColumns() map[int]TableColumnInterface

	GetColumnsSortedKeys() []int

	SetColumn(index int, cell TableColumnInterface) *TableRow
	GetColumn(column int) TableColumnInterface

	GetCellsAsList() []TableCellInterface
}

type TableSeparator

type TableSeparator struct {
	TableCell
	// contains filtered or unexported fields
}

func NewTableSeparator

func NewTableSeparator() *TableSeparator

TableSeparator constructors

func NewTableSeparatorDouble

func NewTableSeparatorDouble() *TableSeparator

func (*TableSeparator) IsDouble

func (t *TableSeparator) IsDouble() bool

func (*TableSeparator) IsSeparator

func (t *TableSeparator) IsSeparator() bool

type TableSeparatorInterface

type TableSeparatorInterface interface {
	IsSeparator() bool
	IsDouble() bool
}

type TableStyle

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

func NewTableStyle

func NewTableStyle() *TableStyle

func (*TableStyle) GetBorderFormat

func (t *TableStyle) GetBorderFormat() string

func (*TableStyle) GetCellHeaderFormat

func (t *TableStyle) GetCellHeaderFormat() string

func (*TableStyle) GetCellRowContentFormat

func (t *TableStyle) GetCellRowContentFormat() string

func (*TableStyle) GetCellRowFormat

func (t *TableStyle) GetCellRowFormat() string

func (*TableStyle) GetCrossingBottomLeftChar

func (t *TableStyle) GetCrossingBottomLeftChar() string

func (*TableStyle) GetCrossingBottomMidChar

func (t *TableStyle) GetCrossingBottomMidChar() string

func (*TableStyle) GetCrossingBottomRightChar

func (t *TableStyle) GetCrossingBottomRightChar() string

func (*TableStyle) GetCrossingChar

func (t *TableStyle) GetCrossingChar() string

func (*TableStyle) GetCrossingMidLeftChar

func (t *TableStyle) GetCrossingMidLeftChar() string

func (*TableStyle) GetCrossingMidRightChar

func (t *TableStyle) GetCrossingMidRightChar() string

func (*TableStyle) GetCrossingTopLeftBottomChar

func (t *TableStyle) GetCrossingTopLeftBottomChar() string

func (*TableStyle) GetCrossingTopLeftChar

func (t *TableStyle) GetCrossingTopLeftChar() string

func (*TableStyle) GetCrossingTopMidBottomChar

func (t *TableStyle) GetCrossingTopMidBottomChar() string

func (*TableStyle) GetCrossingTopMidChar

func (t *TableStyle) GetCrossingTopMidChar() string

func (*TableStyle) GetCrossingTopRightBottomChar

func (t *TableStyle) GetCrossingTopRightBottomChar() string

func (*TableStyle) GetCrossingTopRightChar

func (t *TableStyle) GetCrossingTopRightChar() string

func (TableStyle) GetFooterTitleFormat

func (t TableStyle) GetFooterTitleFormat() string

func (TableStyle) GetHeaderTitleFormat

func (t TableStyle) GetHeaderTitleFormat() string

func (*TableStyle) GetHorizontalInsideBorderChar

func (t *TableStyle) GetHorizontalInsideBorderChar() string

func (*TableStyle) GetHorizontalOutsideBorderChar

func (t *TableStyle) GetHorizontalOutsideBorderChar() string

func (*TableStyle) GetPadType

func (t *TableStyle) GetPadType() PaddingType

func (*TableStyle) GetPaddingChar

func (t *TableStyle) GetPaddingChar() string

func (*TableStyle) GetVerticalInsideBorderChar

func (t *TableStyle) GetVerticalInsideBorderChar() string

func (*TableStyle) GetVerticalOutsideBorderChar

func (t *TableStyle) GetVerticalOutsideBorderChar() string

func (TableStyle) Pad

func (t TableStyle) Pad(content string, length int, pad string, direction PaddingType) string

custom methods

func (*TableStyle) SetBorderFormat

func (t *TableStyle) SetBorderFormat(borderFormat string) *TableStyle

func (*TableStyle) SetCellHeaderFormat

func (t *TableStyle) SetCellHeaderFormat(cellHeaderFormat string) *TableStyle

func (*TableStyle) SetCellRowContentFormat

func (t *TableStyle) SetCellRowContentFormat(cellRowContentFormat string) *TableStyle

func (*TableStyle) SetCellRowFormat

func (t *TableStyle) SetCellRowFormat(cellRowFormat string) *TableStyle

func (*TableStyle) SetCrossingChar

func (t *TableStyle) SetCrossingChar(crossingChar string) *TableStyle

func (*TableStyle) SetCrossingChars

func (t *TableStyle) SetCrossingChars(
	cross string,
	topLeft string,
	topMid string,
	topRight string,
	midRight string,
	bottomRight string,
	bottomMid string,
	bottomLeft string,
	midLeft string,
	topLeftBottom string,
	topMidBottom string,
	topRightBottom string,

) *TableStyle

func (*TableStyle) SetHorizontalBorderChars

func (t *TableStyle) SetHorizontalBorderChars(borderChar string) *TableStyle

func (*TableStyle) SetHorizontalInsideBorderChar

func (t *TableStyle) SetHorizontalInsideBorderChar(borderChar string) *TableStyle

func (*TableStyle) SetHorizontalOutsideBorderChar

func (t *TableStyle) SetHorizontalOutsideBorderChar(borderChar string) *TableStyle

func (*TableStyle) SetPadType

func (t *TableStyle) SetPadType(padType PaddingType) *TableStyle

func (*TableStyle) SetPaddingChar

func (t *TableStyle) SetPaddingChar(paddingChar string) *TableStyle

func (*TableStyle) SetVerticalBorderChars

func (t *TableStyle) SetVerticalBorderChars(borderChar string) *TableStyle

func (*TableStyle) SetVerticalInsideBorderChar

func (t *TableStyle) SetVerticalInsideBorderChar(borderChar string) *TableStyle

func (*TableStyle) SetVerticalOutsideBorderChar

func (t *TableStyle) SetVerticalOutsideBorderChar(borderChar string) *TableStyle

type TableStyleInterface

type TableStyleInterface interface {
	GetPaddingChar() string

	GetHorizontalOutsideBorderChar() string
	GetHorizontalInsideBorderChar() string

	GetVerticalOutsideBorderChar() string
	GetVerticalInsideBorderChar() string

	GetCrossingChar() string

	GetCrossingTopRightChar() string
	GetCrossingTopMidChar() string
	GetCrossingTopLeftChar() string

	GetCrossingBottomRightChar() string
	GetCrossingBottomMidChar() string
	GetCrossingBottomLeftChar() string

	GetCrossingMidRightChar() string
	GetCrossingMidLeftChar() string

	GetCrossingTopLeftBottomChar() string
	GetCrossingTopMidBottomChar() string
	GetCrossingTopRightBottomChar() string

	GetHeaderTitleFormat() string
	GetFooterTitleFormat() string

	GetCellHeaderFormat() string
	GetCellRowFormat() string
	GetCellRowContentFormat() string
	GetBorderFormat() string
	GetPadType() PaddingType
	Pad(content string, length int, pad string, direction PaddingType) string
}

func GetStyleDefinition

func GetStyleDefinition(name string) TableStyleInterface

Jump to

Keyboard shortcuts

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