table

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BG_COLOR     = "#0C0C0C"
	BG_COLOR_ODD = "#1C1C1C"

	RED         = "#cc0000"
	ORANGE      = "#ff7800"
	BLUE        = "#1a7091"
	LIGHT_GREEN = "#008a33"
	GREEN       = "#82cc00"

	//TEXT_COLOR  = "#efefef"
	TEXT_COLOR   = "#fff"
	HEADER_COLOR = "#81858d"
)

#094A25, #0C6B37, #F8B324, #EB442C, #BC2023

View Source
const (
	ARROW_DOWN    = "▼"
	ARROW_UP      = "▲"
	DIAMOND       = "◆"
	SQUARE        = "■"
	MEDIUM_SQUARE = "◼"
	CIRCLE        = "●"
	WHITE_CIRCLE  = "○"
)
View Source
const HeadlessTableTemplate = `` /* 1234-byte string literal not displayed */
View Source
const HeatMapTemplate = `` /* 333-byte string literal not displayed */
View Source
const InlineHeatMapTemplate = `` /* 293-byte string literal not displayed */
View Source
const ReportMailTemplate = `` /* 856-byte string literal not displayed */
View Source
const TableTemplate = `` /* 1423-byte string literal not displayed */

Variables

View Source
var CAT_DESCRIPTORS = [5]string{"Tiny", "Small", "Medium", "Big", "Huge"}
View Source
var DefaultBorder = Border{
	Size:      1,
	H_LINE:    "│",
	V_LINE:    "─",
	TL_CORNER: "┌",
	TR_CORNER: "┐",
	BR_CORNER: "┘",
	BL_CORNER: "└",
	CROSS:     "┼",
	TOP_DEL:   "┬",
	BOT_DEL:   "┴",
	LEFT_DEL:  "├",
	RIGHT_DEL: "┤",
}
View Source
var DoubleBorder = Border{
	Size:      1,
	V_LINE:    "═",
	H_LINE:    "║",
	TL_CORNER: "╔",
	TR_CORNER: "╗",
	BL_CORNER: "╚",
	BR_CORNER: "╝",
	LEFT_DEL:  "╠",
	RIGHT_DEL: "╣",
	CROSS:     "╬",
	TOP_DEL:   "╦",
	BOT_DEL:   "╩",
}
View Source
var HiddenBorder = Border{
	Size:      0,
	H_LINE:    "",
	V_LINE:    "─",
	TL_CORNER: "",
	TR_CORNER: "",
	BR_CORNER: "",
	BL_CORNER: "",
	CROSS:     "",
	TOP_DEL:   "",
	BOT_DEL:   "",
	LEFT_DEL:  "",
	RIGHT_DEL: "",
}
View Source
var RoundedBorder = Border{
	Size:      1,
	V_LINE:    "─",
	H_LINE:    "│",
	TL_CORNER: "╭",
	TR_CORNER: "╮",
	BL_CORNER: "╰",
	BR_CORNER: "╯",
	LEFT_DEL:  "├",
	RIGHT_DEL: "┤",
	CROSS:     "┼",
	TOP_DEL:   "┬",
	BOT_DEL:   "┴",
}
View Source
var ThickBorder = Border{
	Size:      1,
	V_LINE:    "━",
	H_LINE:    "┃",
	TL_CORNER: "┏",
	TR_CORNER: "┓",
	BL_CORNER: "┗",
	BR_CORNER: "┛",
	LEFT_DEL:  "┣",
	RIGHT_DEL: "┫",
	CROSS:     "╋",
	TOP_DEL:   "┳",
	BOT_DEL:   "┻",
}

Functions

func FormatString

func FormatString(txt string, length int, align TextAlign) string

Types

type Border

type Border struct {
	Size      int
	H_LINE    string
	V_LINE    string
	TL_CORNER string
	TR_CORNER string
	BR_CORNER string
	BL_CORNER string
	CROSS     string
	TOP_DEL   string
	BOT_DEL   string
	LEFT_DEL  string
	RIGHT_DEL string
}

type Cell

type Cell struct {
	Text      string
	Value     float64
	Marker    int
	Alignment TextAlign
	Link      string
}

type ConsoleRenderer

type ConsoleRenderer struct {
	Styles Styles
	// contains filtered or unexported fields
}

func NewConsoleRenderer

func NewConsoleRenderer() *ConsoleRenderer

func (*ConsoleRenderer) AddStyle

func (cr *ConsoleRenderer) AddStyle(style term.Style) int

func (*ConsoleRenderer) Append

func (cr *ConsoleRenderer) Append(txt string, style term.Style)

func (*ConsoleRenderer) Marker

func (cr *ConsoleRenderer) Marker(mk int, striped bool) term.Style

func (*ConsoleRenderer) String

func (cr *ConsoleRenderer) String() string

type FilterDef

type FilterDef struct {
	Header     string
	Comparator int
	Value      string
}

func BuildFilterDef

func BuildFilterDef(txt string) FilterDef

type FilterFunc

type FilterFunc func(r *Row) bool

◼■

type FormatterFn

type FormatterFn func(values []float64, index int) (string, int, int)

type Formatters

type Formatters struct {
	Float           FormatterFn
	Int             FormatterFn
	HistoInt        FormatterFn
	MarkedFloat     FormatterFn
	Histo           FormatterFn
	Block           FormatterFn
	HistoBlock      FormatterFn
	ColorBlock      FormatterFn
	Percentage      FormatterFn
	Relation        FormatterFn
	Categorized     FormatterFn
	CategorizedNorm FormatterFn
	BuySell         FormatterFn
}

func DefaultFormatters

func DefaultFormatters() Formatters

type MarkedText

type MarkedText struct {
	Text   string
	Marker int
}

type MarkedTextList

type MarkedTextList struct {
	Items []MarkedText
}

func NewMarkedTextList

func NewMarkedTextList() *MarkedTextList

func (*MarkedTextList) Add

func (m *MarkedTextList) Add(txt string, marker int)

func (*MarkedTextList) AddEmpty

func (m *MarkedTextList) AddEmpty()

type Row

type Row struct {
	Size  int
	Cells []Cell
}

func (*Row) AddAlignedText

func (tr *Row) AddAlignedText(txt string, marker, alignment int) *Row

func (*Row) AddBlock

func (tr *Row) AddBlock(positive bool) *Row

func (*Row) AddCategorizedFloat

func (tr *Row) AddCategorizedFloat(v, l1, l2, l3 float64) *Row

func (*Row) AddCategorizedPercentage

func (tr *Row) AddCategorizedPercentage(v, steps float64) *Row

func (*Row) AddCategoryBlock

func (tr *Row) AddCategoryBlock(c float64) *Row

func (*Row) AddCenteredText

func (tr *Row) AddCenteredText(txt string, marker int) *Row

func (*Row) AddChange

func (tr *Row) AddChange(change, changePercent float64) *Row

func (*Row) AddChangePercent

func (tr *Row) AddChangePercent(v float64) *Row

func (*Row) AddColouredPercentage

func (tr *Row) AddColouredPercentage(v, steps float64) *Row

func (*Row) AddDate

func (tr *Row) AddDate(txt string) *Row

func (*Row) AddDefaultText

func (tr *Row) AddDefaultText(txt string) *Row

func (*Row) AddEmpty

func (tr *Row) AddEmpty() *Row

func (*Row) AddExtendedFloat

func (tr *Row) AddExtendedFloat(v float64, pattern string, marker int) *Row

func (*Row) AddFlaggedFloat

func (tr *Row) AddFlaggedFloat(v float64, flag bool) *Row

func (*Row) AddFloat

func (tr *Row) AddFloat(v float64, marker int) *Row

func (*Row) AddHisto

func (tr *Row) AddHisto(p, c float64) *Row

func (*Row) AddHistoBlock

func (tr *Row) AddHistoBlock(prev, cur float64) *Row

func (*Row) AddInt

func (tr *Row) AddInt(v int, marker int) *Row
func (tr *Row) AddLink(txt, url string) *Row

func (*Row) AddMarkedBlock

func (tr *Row) AddMarkedBlock(marker int) *Row

func (*Row) AddMarkedFloat

func (tr *Row) AddMarkedFloat(v float64) *Row

func (*Row) AddMarkedFloatThreshold

func (tr *Row) AddMarkedFloatThreshold(v, t float64) *Row

func (*Row) AddMarkedInt

func (tr *Row) AddMarkedInt(v int) *Row

func (*Row) AddMarkedPercentage

func (tr *Row) AddMarkedPercentage(v, steps float64) *Row

func (*Row) AddRelation

func (tr *Row) AddRelation(first, second float64) *Row

func (*Row) AddRelationPercentage

func (tr *Row) AddRelationPercentage(first, second float64) *Row

func (*Row) AddText

func (tr *Row) AddText(txt string, marker int) *Row

func (*Row) AddTextRight

func (tr *Row) AddTextRight(txt string, marker int) *Row

func (*Row) AddTime

func (tr *Row) AddTime(txt string) *Row

type Styles

type Styles struct {
	Text                  term.Style
	Header                term.Style
	PositiveMarker        term.Style
	NegativeMarker        term.Style
	ClassAMarker          term.Style
	ClassBMarker          term.Style
	ClassCMarker          term.Style
	ClassDMarker          term.Style
	ClassEMarker          term.Style
	ClassFMarker          term.Style
	HeaderStriped         term.Style
	TextStriped           term.Style
	PositiveMarkerStriped term.Style
	NegativeMarkerStriped term.Style
	ClassAMarkerStriped   term.Style
	ClassBMarkerStriped   term.Style
	ClassCMarkerStriped   term.Style
	ClassDMarkerStriped   term.Style
	ClassEMarkerStriped   term.Style
	ClassFMarkerStriped   term.Style
}

type Table

type Table struct {
	Description  string
	Created      string
	TableHeaders []string
	Rows         []Row
	Count        int
	HeaderSizes  []int
	Limit        int
	Formatters   Formatters
	BorderStyle  Border
	PaddingSize  int
	// contains filtered or unexported fields
}

func New

func New() *Table

func NewTable

func NewTable(name string, headers []string) *Table

func (*Table) AddColumn

func (rt *Table) AddColumn(name string, values []float64, fn FormatterFn)

func (*Table) AddIntColumn

func (rt *Table) AddIntColumn(name string, values []int)

func (*Table) AddMarkedTextColumn

func (rt *Table) AddMarkedTextColumn(name string, values []MarkedText)

func (*Table) AddStringColumn

func (rt *Table) AddStringColumn(name string, values []string)

func (*Table) AddStyle

func (rt *Table) AddStyle(fg, bg string, bold bool) int

func (*Table) AddTableHeader

func (rt *Table) AddTableHeader(name string)

func (*Table) Border

func (rt *Table) Border(border Border) *Table

func (*Table) BuildHeadlessHtml

func (rt *Table) BuildHeadlessHtml() string

func (*Table) BuildHtml

func (rt *Table) BuildHtml() string

func (*Table) BuildPlainHtml

func (rt *Table) BuildPlainHtml() string

func (*Table) CreateRow

func (rt *Table) CreateRow() *Row

func (*Table) DelimiterLine

func (rt *Table) DelimiterLine(txt string) *Row

func (*Table) Filter

func (tr *Table) Filter(f string) *Table

func (*Table) FilterRecent

func (tr *Table) FilterRecent(num int) *Table

func (*Table) FindColumnIndex

func (rt *Table) FindColumnIndex(name string) int

func (*Table) Headers

func (rt *Table) Headers(headers ...string) *Table

func (*Table) JSON

func (rt *Table) JSON(w io.Writer) error

func (*Table) Name

func (rt *Table) Name(name string) *Table

func (*Table) Padding

func (rt *Table) Padding(padding int) *Table

func (*Table) RebuildSizes

func (rt *Table) RebuildSizes()

func (*Table) Recent

func (rt *Table) Recent(count int) *Table

func (*Table) SetText

func (rt *Table) SetText(row, col int, txt string)

func (*Table) Sort

func (rt *Table) Sort(name string)

func (*Table) SortReverse

func (rt *Table) SortReverse(name string)

func (*Table) String

func (rt *Table) String() string

func (*Table) Sub

func (tr *Table) Sub(start, end int) *Table

func (*Table) TableHeader

func (rt *Table) TableHeader(idx int, name string) *Table

func (*Table) Top

func (tr *Table) Top(num int) *Table

func (*Table) Width

func (rt *Table) Width() int

type TableCell

type TableCell struct {
	Value  string `json:"value"`
	Marker int    `json:"marker"`
}

type TableRow

type TableRow struct {
	Cells []TableCell `json:"row"`
}

type TextAlign

type TextAlign int
const (
	// AlignLeft align text within a cell
	AlignLeft TextAlign = iota
	// AlignRight align text within a cell
	AlignRight
	// AlignCenter align
	AlignCenter
)

Jump to

Keyboard shortcuts

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