Documentation ¶
Overview ¶
Package elign align the string with east asian character set.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Left ¶
Left padding whitespace to the right of string if cw wider than the string size.
cw is column width.
Types ¶
type Elign ¶
type Elign struct { // WidthFn offer an algorithm can retrive the width of a string. WidthFn WidthFn // ColumnWidth offer the filed size of align operations. ColumnWidth int }
Elign is using for align text with east character set.
Example ¶
data := []string{ "世界上", "只有 10 種人", "懂二進位和不懂二進位的", } e := Default(0).AdjustWidth(data...) for _, d := range data { fmt.Printf("|%v|\n", e.Right(d)) }
Output: | 世界上| | 只有 10 種人| |懂二進位和不懂二進位的|
func Default ¶
Default return a default Elign instance (using Width as WidthFn). This function only for convenient.
cw is initial column width.
func (*Elign) AdjustWidth ¶
AdjustWidth enlarge the ColumnWidth if it's smaller than input string.
It will return itself for chaining call.
Click to show internal directories.
Click to hide internal directories.