ansi

package module
v0.0.0-...-7a94ea0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2015 License: MIT Imports: 0 Imported by: 0

README

ansi - ANSI escape sequence library

wercker status Coverage Status GoDoc

ansi is an ANSI escape sequence library for Google Go.

Colored strings

If the output supported ANSI escape codes, you can print colored strings using the utility functions in this library.

fmt.Println(ansi.Red("This string will be red", None))

You can also apply modifiers to the output strings to make the text bold, italic or underlined.

fmt.Println(ansi.Red("This string will be bold red", Bold))
fmt.Println(ansi.Red("This string will be bold and underlined red", Bold|Underline))

License

ansi is licensed under the MIT license.

Documentation

Overview

Package ansi provides utility functions to apply ANSI escape sequences to strings.

Index

Examples

Constants

View Source
const (
	None           = 0
	Light modifier = 1 << iota
	Bold
	Italic
	Underline
	Blink
)

Text modifiers.

Variables

This section is empty.

Functions

func Black

func Black(str string, mod modifier) string

Black returns a string enclosed in the ANSI escape code for black text.

Example
fmt.Println(Black("This text will be black", None))
Output:

Example (Bold)
fmt.Println(Black("This text will be bold and black", Bold))
Output:

Example (Combined)
fmt.Println(Black("This text will be bold, underlined and black", Bold|Underline))
Output:

Example (Italic)
fmt.Println(Black("This text will be italic and black", Italic))
Output:

Example (Light)
fmt.Println(Black("This text will be light black", Light))
Output:

Example (Underline)
fmt.Println(Black("This text will be underlined and black", Underline))
Output:

func Blue

func Blue(str string, mod modifier) string

Blue returns a string enclosed in the ANSI escape code for blue text.

func Cyan

func Cyan(str string, mod modifier) string

Cyan returns a string enclosed in the ANSI escape code for cyan text.

func Disable

func Disable()

Disable disabled the use of ANSI escape sequences in calls to ansi functions. In short, no string manipulations will be done by the ansi functions.

func Enable

func Enable()

Enable enables the use of ANSI escape sequences in calls to ansi functions.

func Green

func Green(str string, mod modifier) string

Green returns a string enclosed in the ANSI escape code for green text.

func Magenta

func Magenta(str string, mod modifier) string

Magenta returns a string enclosed in the ANSI escape code for magenta text.

func Red

func Red(str string, mod modifier) string

Red returns a string enclosed in the ANSI escape code for red text.

func White

func White(str string, mod modifier) string

White returns a string enclosed in the ANSI escape code for white text.

func Yellow

func Yellow(str string, mod modifier) string

Yellow returns a string enclosed in the ANSI escape code for yellow text.

Types

This section is empty.

Jump to

Keyboard shortcuts

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