Documentation
¶
Index ¶
- Constants
- type AccoladesStyle
- type BoxPattern
- type BoxSettings
- type BoxStyle
- type LabelAlign
- type Paragraph
- func (linesIn Paragraph) Accolades(style AccoladesStyle) (linesOut Paragraph)
- func (linesIn Paragraph) Append(linesToAppend Paragraph) Paragraph
- func (linesIn Paragraph) AutoAccolades(style AccoladesStyle) (linesOut Paragraph)
- func (linesIn Paragraph) AutoBox(settings BoxSettings, pattern BoxPattern) Paragraph
- func (linesIn Paragraph) Box(settings BoxSettings, pattern BoxPattern) (linesOut Paragraph)
- func (linesIn Paragraph) Cut(maxWidth int) (linesOut Paragraph)
- func (linesIn Paragraph) Limit(maxWidth int) (linesOut Paragraph)
- func (linesIn Paragraph) Mustache(m map[string]interface{}) (linesOut Paragraph, err error)
- func (linesIn Paragraph) MustacheNoErr(m map[string]interface{}) (linesOut Paragraph)
- func (linesIn Paragraph) PadRight(fillPattern string, width int) (linesOut Paragraph)
- func (linesIn Paragraph) Sort() Paragraph
- func (lines Paragraph) String() string
- func (linesIn Paragraph) Surround(left string, right string) (linesOut Paragraph)
- func (lines Paragraph) ToString(linesSeparator string) (result string)
- func (lines Paragraph) Width() (width int)
- func (lines Paragraph) WriteToFile(fileName string) (err error)
Examples ¶
Constants ¶
const ( AccoladesStyleCount = 3 AccoladesStyleMaxIndex = int(AccoladesStyleUnicode) AccoladesStyleLastValue = AccoladesStyleUnicode )
const ( BoxStyleCount = 21 BoxStyleMaxIndex = int(BoxStyleFantasy4) BoxStyleLastValue = BoxStyleFantasy4 )
const ( LabelAlignCount = 3 LabelAlignMaxIndex = int(LabelAlignRight) LabelAlignLastValue = LabelAlignRight )
const MultiStringsMaxWidth = 1000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccoladesStyle ¶
type AccoladesStyle int
Example ¶
for i := 0; i < 3; i++ {
fmt.Println(AccoladesStyle(i))
}
Output: AccoladesStyleNone AccoladesStyleAscii AccoladesStyleUnicode
const ( AccoladesStyleNone AccoladesStyle = iota AccoladesStyleAscii AccoladesStyleUnicode )
func AccoladesStyleFromString ¶
func AccoladesStyleFromString(s string) (AccoladesStyle, error)
func (AccoladesStyle) String ¶
func (v AccoladesStyle) String() string
type BoxPattern ¶
type BoxPattern struct {
TopLeftCorner string
TopBorder string
TopRightCorner string
LeftBorder string
RightBorder string
BottomLeftCorner string
BottomBorder string
BottomRightCorner string
}
func GetBoxPattern ¶
func GetBoxPattern(style BoxStyle) BoxPattern
type BoxSettings ¶
type BoxSettings struct {
Width int
TopLabel string
TopLabelAlign LabelAlign
BottomLabel string
BottomLabelAlign LabelAlign
}
BoxSettings{30, "", Left, "", Left}
type BoxStyle ¶
type BoxStyle int
Example ¶
for i := 2; i <= BoxStyleMaxIndex; i++ {
fmt.Println(NewFromString(BoxStyle(i).String()).PadRight(" ", 38).Surround(" ", " ").AutoBox(BoxSettings{40, "", LabelAlignLeft, "", LabelAlignLeft}, GetBoxPattern(BoxStyle(i))))
}
Output: ┌────────────────────────────────────────┐ │ BoxStyleSingleLine │ └────────────────────────────────────────┘ ╭────────────────────────────────────────╮ │ BoxStyleSingleLineRounded │ ╰────────────────────────────────────────╯ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ BoxStyleBold ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ╒════════════════════════════════════════╕ │ BoxStyleSingleVDoubleH │ ╘════════════════════════════════════════╛ ╓────────────────────────────────────────╖ ║ BoxStyleSingleHDoubleV ║ ╙────────────────────────────────────────╜ ╔════════════════════════════════════════╗ ║ BoxStyleDoubleLine ║ ╚════════════════════════════════════════╝ ▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜ ▌ BoxStyleExtraBold ▐ ▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟ ▞▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚ ▌ BoxStyleExtraBoldRounded ▐ ▚▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▞ █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ █ BoxStyleMaxBold █ █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░ BoxStyleBlocksLightShade ░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒ BoxStyleBlocksMediumShade ▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓ BoxStyleBlocksDarkShade ▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ██████████████████████████████████████████ █ BoxStyleBlocks █ ██████████████████████████████████████████ .......................................... : BoxStyleDots : :........................................: ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆ ◆ BoxStyleDiamonds ◆ ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆ ╭╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╮ ╽ BoxStyleFantasy1 ╿ ╰╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╾╯ ╱▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔╲ │ BoxStyleFantasy2 │ ╲▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁╱ ▁▂▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▂▁ ▌ BoxStyleFantasy3 ▐ ▜▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▛ ▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂ █ BoxStyleFantasy4 █ █▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂▃▂▁▂█
const ( BoxStyleNone BoxStyle = iota BoxStyleSpaceChar BoxStyleSingleLine BoxStyleSingleLineRounded BoxStyleBold BoxStyleSingleVDoubleH BoxStyleSingleHDoubleV BoxStyleDoubleLine BoxStyleExtraBold BoxStyleExtraBoldRounded BoxStyleMaxBold BoxStyleBlocksLightShade BoxStyleBlocksMediumShade BoxStyleBlocksDarkShade BoxStyleBlocks BoxStyleDots BoxStyleDiamonds BoxStyleFantasy1 BoxStyleFantasy2 BoxStyleFantasy3 BoxStyleFantasy4 )
func BoxStyleFromString ¶
type LabelAlign ¶
type LabelAlign int
const ( LabelAlignLeft LabelAlign = iota LabelAlignCenter LabelAlignRight )
func LabelAlignFromString ¶
func LabelAlignFromString(s string) (LabelAlign, error)
func (LabelAlign) String ¶
func (v LabelAlign) String() string
type Paragraph ¶
type Paragraph []string
func New ¶
New creates and returns a new Paragraph slice with a given capacity. - cap is an integer representing the desired capacity of the slice.
func NewFromString ¶
NewFromString creates and returns a new Paragraph slice from a string. The given string is split into separate substrings at each occurrence of a newline character. - s is a string from which to create the new Paragraph slice.
func NewFromStringSlice ¶
NewFromStringSlice creates and returns a new Paragraph slice from a string slice. - s is a slice of strings from which to create the new Paragraph slice.
func NewWithGivenLen ¶
NewWithGivenLen creates and returns a new Paragraph slice with a given length. - l is the desired length of the slice.
func NewWithPresetContent ¶
NewWithPresetContent creates and returns a new Paragraph slice with a preset line count and content. - line is a string representing the content to be added to each line of the new slice. - count is the desired number of lines in the new slice.
func (Paragraph) Accolades ¶
func (linesIn Paragraph) Accolades(style AccoladesStyle) (linesOut Paragraph)
func (Paragraph) Append ¶
Append appends the strings from another Paragraph slice to the end of the current one.
func (Paragraph) AutoAccolades ¶
func (linesIn Paragraph) AutoAccolades(style AccoladesStyle) (linesOut Paragraph)
func (Paragraph) AutoBox ¶
func (linesIn Paragraph) AutoBox(settings BoxSettings, pattern BoxPattern) Paragraph
func (Paragraph) Box ¶
func (linesIn Paragraph) Box(settings BoxSettings, pattern BoxPattern) (linesOut Paragraph)
func (Paragraph) Cut ¶
Cut truncates the Paragraph slice to a given maximum width by cutting strings that exceed it. - maxWidth is the maximum width to which to truncate the strings.
func (Paragraph) Limit ¶
Limit truncates the Paragraph slice to a given maximum width by splitting strings that exceed it. - maxWidth is the maximum width to which to truncate the strings.
func (Paragraph) MustacheNoErr ¶
func (Paragraph) PadRight ¶
PadRight pads the Paragraph slice on the right side with a given fill pattern to a given width. - fillPattern represents the pattern to use for padding. - width is the desired width of each line after padding.
func (Paragraph) Sort ¶
Sort sorts the Paragraph slice in lexicographic order and returns the sorted slice.
func (Paragraph) Surround ¶
Surround surrounds each line of the Paragraph slice with a given left and right string. - left is the left-side surround for each line. - right is the right-side surround.
func (Paragraph) ToString ¶
ToString concatenates the Paragraph slice into a string with a given line separator. - linesSeparator is a string representing the separator to use between each line.
func (Paragraph) Width ¶
Width returns the width of the Paragraph slice, which is the length of the longest string in the slice.
func (Paragraph) WriteToFile ¶
WriteToFile writes the Paragraph slice to a file with a given filename. - fileName is the name of the file to which to write the slice.