styles

package
v0.0.0-...-a977c90 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2014 License: MIT Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MkPainter

func MkPainter(p Painter) func(string, ...interface{}) string

Retuns an anonymous function which formats text with Sprintf

func PaintColors

func PaintColors(fg, bg Color, format string, a ...interface{}) string

Sets the foreground to `fg` and the background to `bg` and formats the text with Sprintf

Types

type Attrib

type Attrib string
const (
	ColorA        Attrib = "\x03"
	Bold          Attrib = "\x02"
	Italic        Attrib = "\x09"
	Reset         Attrib = "\x0F"
	StrikeThrough Attrib = "\x13"
	Underline     Attrib = "\x15"
	Reverse       Attrib = "\x16"
	Underline2    Attrib = "\x1F"
)

func (Attrib) Paint

func (self Attrib) Paint(format string, a ...interface{}) string

Paints the text with `Attrib` and formats the text with Sprintf

type Color

type Color int
const (
	Clear        Color = 0 // Do not change existing colors
	White        Color = 1 // Also color reset in most clients
	Black        Color = 2
	Blue         Color = 3
	Green        Color = 4
	LightRed     Color = 5
	Red          Color = 6
	Magenta      Color = 7
	Orange       Color = 8
	Yellow       Color = 9
	LightGreen   Color = 10
	Cyan         Color = 11
	LightCyan    Color = 12
	LightBlue    Color = 13
	LightMagenta Color = 14
	Gray         Color = 15
	LightGray    Color = 16
)

func (Color) Bg

func (self Color) Bg(format string, a ...interface{}) string

Sets the background to `Color` and formats the text with Sprintf

func (Color) Fg

func (self Color) Fg(format string, a ...interface{}) string

Sets the foreground to `Color` and formats the text with Sprintf

func (Color) Paint

func (self Color) Paint(format string, a ...interface{}) string

Sets the foregroudn and background to `Color` and formats the text with Sprintf

type Painter

type Painter interface {
	// Paint a style with Print-style formatting
	Paint(a ...interface{}) string
	// Paint a style with Printf-style formatting
	Paintf(string, ...interface{}) string
	// Paint a style with Println-style formatting
	Paintln(a ...interface{}) string
}

type Style

type Style struct {
	Fg, Bg     Color
	Attributes []Attrib
}

func (*Style) Paint

func (self *Style) Paint(a ...interface{}) string

Sets the `Style` and formats the text with Sprint

func (*Style) Paintf

func (self *Style) Paintf(format string, a ...interface{}) string

Sets the `Style` and formats the text with Sprintf

func (*Style) Paintln

func (self *Style) Paintln(a ...interface{}) string

Sets the `Style` and formats the text with Sprintln

Jump to

Keyboard shortcuts

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