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 Imports: 6 Imported by: 0

Documentation

Overview

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

Index

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 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 支持。

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 右对齐打印机

Types

This section is empty.

Jump to

Keyboard shortcuts

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