table

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0, MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

table

Overview/docs: GoDoc

from:-

**Firstname**   **Lastname**    **Age**
Jill    Smith   50
Eve Jackson 45

to:-

╭─────────────╥────────────╥───────╮
│**Firstname**║**Lastname**║**Age**│
╞═════════════╬════════════╬═══════╡
│     Eve     ║   Jackson  ║   45  │
│     Jill    ║    Smith   ║   50  │
╰─────────────╨────────────╨───────╯

Notice: markdown tables can be simply converted, find/replace, to tab based sources for this package.

Documentation

Overview

package table prettifies tab/line text tables to aligned/formatted/sorted/rearranged and justified text tables.

Index

Examples

Constants

View Source
const (
	ASCIIStyle                            string = "+-++| ||"
	ASCIIBoxStyle                         string = "+-+++-++| ||+-++"
	MarkdownStyle                         string = "|-||| ||"
	BoxStyle                              string = "┌─┬┐├─┼┤│ ││└─┴┘"
	DoubleBoxStyle                        string = "╔═╦╗╠═╬╣║ ║║╚═╩╝"
	ThickHeaderDivideBoxStyle             string = "┌─┬┐┝━┿┥│ ││└─┴┘"
	DoubleBorderBoxStyle                  string = "╔═╤╗╟─┼╢║ │║╚═╧╝"
	DoubleVerticalBoxStyle                string = "╓─╥╖╟─╫╢║ ║║╙─╨╜"
	DoubleHorizontalBoxStyle              string = "╒═╤╕╞═╪╡│ ││╘═╧╛"
	DoubleSingleHorizontalBoxStyle        string = "╔═╤╗╠═╪╣║ │║╚═╧╝"
	DoubleTopBottomBoxStyle               string = "╒═╤╕├─┼┤│ ││╘═╧╛"
	DoubleSidesBoxStyle                   string = "╓─┬╖╟─┼╢║ │║╙─┴╜"
	DoubleTopBoxStyle                     string = "╒═╤╕├─┼┤│ ││└─┴┘"
	DoubleDivideBoxStyle                  string = "┌─┬┐╞═╪╡│ ││└─┴┘"
	DoubleBottomBoxStyle                  string = "┌─┬┐├─┼┤│ ││╘═╧╛"
	DoubleRightBoxStyle                   string = "┌─┬╖├─┼┤│ ││└─┴╜"
	DoubleLeftBoxStyle                    string = "╓─┬┐╟─┼┤║ ││╙─┴┘"
	DoubleInsideBoxStyle                  string = "┌─╥┐╞═╬╡│ ║│└─╨┘"
	DoubleInsideVerticalBoxStyle          string = "┌─╥┐├─╫┤│ ║│└─╨┘"
	DoubleInsideHorizontalBoxStyle        string = "┌─┬┐╞═╪╡│ ││└─┴┘"
	RoundedBoxStyle                       string = "╭─┬╮├─┼┤│ ││╰─┴╯"
	RoundedDoubleInsideBoxStyle           string = "╭─╥╮╞═╬╡│ ║│╰─╨╯"
	RoundedDoubleInsideHorizontalBoxStyle string = "╭─┬╮╞═╪╡│ ││╰─┴╯"
	RoundedDoubleInsideVerticalBoxStyle   string = "╭─╥╮├─╫┤│ ║│╰─╨╯"
)

built-in Styles

Variables

View Source
var (
	Writer              io.Writer
	HeaderRows          = 1
	Style               = MarkdownStyle
	ColumnMapper        func(int) int // rearrange columns
	SortColumn          int
	NumericNotAlphaSort bool
	DefaultCellPrinter  = Centred
	DividerEvery        int
	FormfeedWithDivider bool
)

global options

Functions

func Centred

func Centred(c string, w int)

centre printer 打印机中心

func Fprint

func Fprint(w io.Writer, tabulated string, cellPrinters ...func(string, int))

set global var 'Writer' then call Print.

func Fprintf

func Fprintf(w io.Writer, s string, tabulated string, cellPrinters ...func(string, int))

set the global var's 'Writer' and 'Style' then call Print.

func LeftJustified

func LeftJustified(c string, w int)

left justifier printer 左对齐打印机

func MakeDoc

func MakeDoc(linesObj []GenInterfaceDoc)

func MinWidth

func MinWidth(form func(string, int), min uint) func(string, int)

modify a cellPrinter to have a minimum width 修改 cellPrinter 以具有最小宽度

func MoveToLeftEdge

func MoveToLeftEdge(column uint) func(int) int

returns a column mapper func, that puts a particular column first, (columns start from 1), otherwise preserves order. 返回一个列映射器函数,它将特定列放在第一位(列从 1 开始),否则保留顺序。

func NumbersBoolJustified

func NumbersBoolJustified(c string, w int)

centre print if a boolean, right justify if a number, default otherwise. 如果是布尔值则居中打印,如果是数字则右对齐,否则默认。

func NumbersRightJustified

func NumbersRightJustified(c string, w int)

right justify if a number 如果一个数字右对齐

func Print

func Print(tabulated string, cellPrinters ...func(string, int))

Write 'tabulated' string as text table, rows coming from lines, columns separated by the tab character. Mono-spaced font required for alignment. cellPrinters - applied to columns: * missing - use default * len=1 - use for all cells * len=n - use n'th for n'th column, use default if column count>n Not thread safe, uses globals for options (see variables), however can be used multiple, fixed count, times by using multiple imports and different aliases. Bytes supporting. 将“制表”字符串写为文本表,行来自行,列由制表符分隔。对齐所需的等距字体。 cellPrinters - 应用于列:缺失 - 使用默认值 len=1 - 用于所有单元格 len=n - 对第 n 列使用 n'th,如果列数>n 则使用默认值 不是线程安全的,使用全局变量作为选项(参见变量),但是可以通过使用多个导入和不同的别名来使用多个固定计数的时间。 Bytes 支持。

Example
Writer = os.Stdout
Style = RoundedDoubleInsideBoxStyle
ColumnMapper = MoveToLeftEdge(3)
SortColumn = 1
Print("**Firstname**\t**Lastname**\t**Age**\nJill\tSmith\t50\nEve\tJackson\t45", RightJustified, Centred)
Output:
╭───────╥─────────────╥────────────╮
│**Age**║**Firstname**║**Lastname**│
╞═══════╬═════════════╬════════════╡
│     45║     Eve     ║   Jackson  │
│     50║     Jill    ║    Smith   │
╰───────╨─────────────╨────────────╯

func PrintStructFieldsInfoTable

func PrintStructFieldsInfoTable(fields []FieldInfo)

func Printf

func Printf(s string, tabulated string, cellPrinters ...func(string, int))

set global var 'Style' then call Print.

func RightJustified

func RightJustified(c string, w int)

right justifier printer 右对齐打印机

func Run

func Run(tabulated string, isDoc bool, cellPrinters ...func(string, int)) string

Types

type FieldInfo

type FieldInfo struct {
	//Index     string
	Number    string
	Deep      string
	Name      string
	Kind      string
	Size      string
	ValueFmt  string //Hex|Decimal Bool String (HexDump Map)
	Value     any
	Stream    string
	Json      string //no
	TableLine *FieldInfo
}

type GenInterfaceDoc

type GenInterfaceDoc struct {
	//index    int    //Centred
	Api      string //LeftJustified
	Function string //LeftJustified
	Note     string //LeftJustified
	Todo     string //LeftJustified 放到尾巴注释,因为无法对齐

}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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