text

package
v3.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: MIT Imports: 6 Imported by: 200

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Align

type Align int

Align denotes how text is to be aligned horizontally.

const (
	AlignDefault Align = iota // same as AlignLeft
	AlignLeft                 // "left        "
	AlignCenter               // "   center   "
	AlignJustify              // "justify   it"
	AlignRight                // "       right"
)

Align enumerations

func (Align) Apply

func (a Align) Apply(text string, maxLength int) string

Apply aligns the text as directed. Examples:

  • AlignDefault.Apply("Jon Snow", 12) returns "Jon Snow "
  • AlignLeft.Apply("Jon Snow", 12) returns "Jon Snow "
  • AlignCenter.Apply("Jon Snow", 12) returns " Jon Snow "
  • AlignJustify.Apply("Jon Snow", 12) returns "Jon Snow"
  • AlignRight.Apply("Jon Snow", 12) returns " Jon Snow"

func (Align) HTMLProperty

func (a Align) HTMLProperty() string

HTMLProperty returns the equivalent HTML horizontal-align tag property.

func (Align) MarkdownProperty

func (a Align) MarkdownProperty() string

MarkdownProperty returns the equivalent Markdown horizontal-align separator.

type Color

type Color int

Color represents a single color to render text with.

const (
	Reset Color = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Base colors -- attributes in reality

const (
	FgBlack Color = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground text colors

const (
	FgHiBlack Color = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

const (
	BgBlack Color = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background text colors

const (
	BgHiBlack Color = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

Background Hi-Intensity text colors

func (Color) GetEscapeSeq

func (c Color) GetEscapeSeq() string

GetEscapeSeq returns the ANSI escape sequence for the color.

func (Color) Sprint

func (c Color) Sprint(a ...interface{}) string

Sprint colorizes and prints the given string(s).

func (Color) Sprintf

func (c Color) Sprintf(format string, a ...interface{}) string

Sprintf formats and colorizes and prints the given string(s).

type Colors

type Colors []Color

Colors represents an array of Color objects to render text with. Example: Colors{FgCyan, BgBlack}

func (Colors) GetEscapeSeq

func (c Colors) GetEscapeSeq() string

GetEscapeSeq returns the ANSI escape sequence for the colors set.

func (Colors) Sprint

func (c Colors) Sprint(a ...interface{}) string

Sprint colorizes and prints the given string(s).

func (Colors) Sprintf

func (c Colors) Sprintf(format string, a ...interface{}) string

Sprintf formats and colorizes and prints the given string(s).

type Format

type Format int

Format denotes the "case" to use for text.

const (
	FormatDefault Format = iota // default_Case
	FormatLower                 // lower
	FormatTitle                 // Title
	FormatUpper                 // UPPER
)

Format enumerations

func (Format) Apply

func (tc Format) Apply(text string) string

Apply converts the text as directed.

type VAlign

type VAlign int

VAlign denotes how text is to be aligned vertically.

const (
	VAlignDefault VAlign = iota // same as VAlignTop
	VAlignTop                   // "top\n\n"
	VAlignMiddle                // "\nmiddle\n"
	VAlignBottom                // "\n\nbottom"
)

VAlign enumerations

func (VAlign) Apply

func (va VAlign) Apply(lines []string, maxLines int) []string

Apply aligns the lines vertically. Examples:

  • VAlignTop.Apply({"Game", "Of", "Thrones"}, 5) returns {"Game", "Of", "Thrones", "", ""}
  • VAlignMiddle.Apply({"Game", "Of", "Thrones"}, 5) returns {"", "Game", "Of", "Thrones", ""}
  • VAlignBottom.Apply({"Game", "Of", "Thrones"}, 5) returns {"", "", "Game", "Of", "Thrones"}

func (VAlign) ApplyStr

func (va VAlign) ApplyStr(text string, maxLines int) []string

ApplyStr aligns the string (of 1 or more lines) vertically. Examples:

  • VAlignTop.ApplyStr("Game\nOf\nThrones", 5) returns {"Game", "Of", "Thrones", "", ""}
  • VAlignMiddle.ApplyStr("Game\nOf\nThrones", 5) returns {"", "Game", "Of", "Thrones", ""}
  • VAlignBottom.ApplyStr("Game\nOf\nThrones", 5) returns {"", "", "Game", "Of", "Thrones"}

func (VAlign) HTMLProperty

func (va VAlign) HTMLProperty() string

HTMLProperty returns the equivalent HTML vertical-align tag property.

Jump to

Keyboard shortcuts

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