Documentation ¶
Overview ¶
Align 内容方位
- 以 AlignLeft, AlignCenter, AlignTopLeft 为例,表示在单元格内容分别是置于左侧,和顶部左侧 = eg. 当单元格高度为4, 实际内容高度为2, 以 AlignLeft 则居左为 [ ] [ align 2 ] [ align 3 ] [ ] = AlignCenter [ ] [ align 2 ] [ align 3 ] [ ] = AlignTopLeft [ align 2 ] [ align 3 ] [ ] [ ]
- Align.Repeat(in string, w int) string 函数 = 仅支持针对left, center, rights三个方位的拓展, in 是输入, w是实际所需长度, 若
Cell 单元格
目前实现了以下几种 Cell, 均基于BaseCell = BaseCell
基本单元格
只有最基本的功能
EmptyCell
空单元格
没有内容的单元格
InterfaceCell
空接口单元格
用于接纳任意类型的单元格
MergeCell
合并单元格
可以跨多行多列的单元格
Index ¶
- Variables
- func DefaultTransformContentByColor(in interface{}) interface{}
- func DefaultTransformContentByTime(in interface{}) interface{}
- func DeleteDefaultColor(in ...interface{})
- func DisEnableDefaultColor()
- func EnableDefaultColor()
- func SetDefaultColor(cor color.Color, in ...interface{})
- type Align
- type BaseCell
- type Cell
- type Contour
- type EmptyCell
- type InterfaceCell
- type MergeCell
- type Option
- type RowCell
- type Table
- func (t *Table) AddBody(in ...interface{}) *Table
- func (t *Table) AddBodyRow(r RowCell) *Table
- func (t *Table) AddHeaders(in ...interface{}) *Table
- func (t *Table) Copy() *Table
- func (t *Table) GetCellAt(p image.Point) (Cell, error)
- func (t *Table) Page(limit, offset int) *Table
- func (t *Table) Search(eq interface{}, str string) (Cell, error)
- func (t *Table) SetBody(idx int, in ...interface{}) *Table
- func (t *Table) SetCellAt(p image.Point, c Cell) error
- func (t *Table) SetHeaders(in ...interface{}) *Table
- func (t *Table) SetHeadersRow(r RowCell) *Table
- func (t *Table) Sort(column int, less func(i, j int) bool) *Table
- func (t *Table) String() (out string)
- type TransformContent
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultContour default /* ┌──────────┬──────┐ | A | B | ├──────────┼──────┤ | 112 | 2 | | 1 | 223 | | 4 | 5 | | 72312312 | 2328 | └──────────┴──────┘ */ DefaultContour = Contour{ T: "─", R: "|", L: "|", D: "─", TL: "┌", TR: "┐", DL: "└", DR: "┘", TI: "┬", DI: "┴", LI: "├", RI: "┤", I: "┼", CH: "|", CV: "─", } // EmptyContour is empty /* A B 112 2 1 223 4 5 72312312 2328 */ EmptyContour = Contour{ T: " ", R: " ", L: " ", D: " ", TL: " ", TR: " ", DL: " ", DR: " ", TI: " ", DI: " ", LI: " ", RI: " ", I: " ", CH: " ", CV: " ", } // MariaDBContour like to mysql /* +----------+------+ | A | B | +----------+------+ | 112 | 2 | | 1 | 223 | | 4 | 5 | | 72312312 | 2328 | +----------+------+ */ MariaDBContour = Contour{ T: "-", R: "|", L: "|", D: "-", TL: "+", TR: "+", DL: "+", DR: "+", TI: "+", DI: "+", LI: "+", RI: "+", I: "+", CH: "|", CV: "-", } )
View Source
var DefaultColorStylesClient = &defaultColorStyles{ Enable: true, defaultColor: nil, typeTo: map[reflect.Kind]color.Color{}, customizeTypeTo: map[string]color.Color{}, }
View Source
var DefaultOption = &Option{ ExpendID: true, Align: AlignCenter, Contour: DefaultContour, }
Functions ¶
func DefaultTransformContentByColor ¶
func DefaultTransformContentByColor(in interface{}) interface{}
DefaultTransformContentByColor 中文: *依据不同类型进行颜色的区分输出,输出最终格式为string* 目前使用的颜色只支持linux和macOs系统, windows系统需要自己参考定义好一个颜色引擎 + 调用优先级: CustomizeTypeTo > typeTo > defaultColor - Enable: 启用与不启用 - typeTo: 是依据对不同的【基础数据类型】进行颜色输出时的处理 - customizeTypeTo: 依据输入的数据结构反射出的结构进行输出颜色 en: *Differentiate the output of colors according to different types, and the final output format is string* The currently used colors only support linux and `macOS` systems, `windows`system needs refer to define a color engine by itself + call priority: CustomizeTypeTo > typeTo > defaultColor - Enable: enable and disable - typeTo: it is based on the processing of color output for different [basic data types] - customizeTypeTo: output color according to the structure reflected from the input data structure func: DisEnableDefaultColor - 禁用 EnableDefaultColor - 启用 SetDefaultColor - 设置该类型数据渲染为该颜色 DeleteDefaultColor - 删除输入同类型的颜色
func DefaultTransformContentByTime ¶
func DefaultTransformContentByTime(in interface{}) interface{}
func DeleteDefaultColor ¶
func DeleteDefaultColor(in ...interface{})
func DisEnableDefaultColor ¶
func DisEnableDefaultColor()
func EnableDefaultColor ¶
func EnableDefaultColor()
func SetDefaultColor ¶
Types ¶
type BaseCell ¶
type BaseCell struct {
// contains filtered or unexported fields
}
func NewBaseCell ¶
type Contour ¶
type Contour struct { // border like standard 8 azimuth // ┌ ─ ┐ '┌' TL '─' T '┐' TR // | | -> '|' L '|' R // └ - ┘ '└ DL '-' D '┘' DR T, R, L, D string TL, TR, DL, DR string // top | down intersection // for example, the two points highlighted above are the intersection points // ┌ '┬' ─ ┐ '┬' TI -> top intersection // | | -> // └ '┴' - ┘ '┴' DI -> down intersection TI, DI string // left | right intersection // for example, the two points highlighted above are the intersection points // ┌ ─ ┐ // '├' | '├' LI -> left intersection // | '┤' '┤' RI -> right intersection // └ - ┘ LI, RI string // intersection location // ┌ ─ ┬ ─ ┬ - ┐ // | - | - |'-'| '-' CV -> center vertical // | '|' | | '|' CH -> center horizontal // ├ -'┼'- ┼ - ┤ '┼' I -> intersection // └ - ┴ - ┴ - ┘ I, CH, CV string }
Contour outlines are required when rendering the table
func (Contour) Intersection ¶
type InterfaceCell ¶
type InterfaceCell struct { *BaseCell AnyVal []interface{} }
func NewInterfaceCell ¶
func NewInterfaceCell(ag Align, data ...interface{}) *InterfaceCell
func (*InterfaceCell) Add ¶
func (c *InterfaceCell) Add(in ...string)
func (*InterfaceCell) ToBaseCell ¶
func (c *InterfaceCell) ToBaseCell() *BaseCell
type MergeCell ¶
func NewMergeCells ¶
type Option ¶
type Option struct { ExpendID bool Align Align Contour Contour TransformContents []TransformContent }
type Table ¶
func DefaultSimpleTable ¶
func DefaultSimpleTable(in interface{}) *Table
func SimpleTable ¶
func (*Table) AddBodyRow ¶
func (*Table) AddHeaders ¶
func (*Table) SetHeaders ¶
func (*Table) SetHeadersRow ¶
type TransformContent ¶
type TransformContent func(in interface{}) interface{}
TransformContent shi cn:
当你不想对原有内容作出改变的时候,返回值为原值
en:
When you do not want to make changes to the original content, should return origin
E.g:
func t(in interface{}) (interface{}, error) { times, ok := in.(time.Time) if !ok { return in <<<<----- } return times.Format(time.RFC822), nil }
Click to show internal directories.
Click to hide internal directories.