Documentation ¶
Overview ¶
Example ¶
// Don't care about Windows? fmt.Printf("%s\n", lux.Red("Red!")) fmt.Printf("%s\n", lux.Red(lux.BgWhite("Red on White"))) // Oh, you do care about Windows. Good call... Stdout := colorable.NewColorableStdout() fmt.Fprintf(Stdout, "%s\n", lux.Red("Red!")) // *sigh* // Want lux to handle Stdout? Use built-in Print functions (Print, Println, Printf) lux.Printf("%s\n", lux.Red("Red!")) // Hang on to your styles p := lux.New(lux.Red, lux.BgWhite) p.Println("Big Red") // First-Class Prints! bigred := lux.New(lux.Bold, lux.Red).Println bigred("Notice!") // Make Terminals Great Again r := lux.HiRed w := lux.HiWhite b := lux.HiBlue lux.Printf("%s%s%s! %s%s%s!\n", r("U"), w("S"), b("A"), r("U"), w("S"), b("A"))
Output:
Index ¶
- Variables
- func Print(a ...interface{}) (n int, err error)
- func Printf(format string, a ...interface{}) (n int, err error)
- func Println(a ...interface{}) (n int, err error)
- type CodeFn
- type Lux
- func BgBlack(v interface{}) *Lux
- func BgBlue(v interface{}) *Lux
- func BgCyan(v interface{}) *Lux
- func BgGreen(v interface{}) *Lux
- func BgHiBlack(v interface{}) *Lux
- func BgHiBlue(v interface{}) *Lux
- func BgHiCyan(v interface{}) *Lux
- func BgHiGreen(v interface{}) *Lux
- func BgHiMagenta(v interface{}) *Lux
- func BgHiRed(v interface{}) *Lux
- func BgHiWhite(v interface{}) *Lux
- func BgHiYellow(v interface{}) *Lux
- func BgMagenta(v interface{}) *Lux
- func BgRed(v interface{}) *Lux
- func BgWhite(v interface{}) *Lux
- func BgYellow(v interface{}) *Lux
- func Black(v interface{}) *Lux
- func BlinkRapid(v interface{}) *Lux
- func BlinkSlow(v interface{}) *Lux
- func Blue(v interface{}) *Lux
- func Bold(v interface{}) *Lux
- func Conceal(v interface{}) *Lux
- func CrossedOut(v interface{}) *Lux
- func Cyan(v interface{}) *Lux
- func Faint(v interface{}) *Lux
- func Green(v interface{}) *Lux
- func HiBlack(v interface{}) *Lux
- func HiBlue(v interface{}) *Lux
- func HiCyan(v interface{}) *Lux
- func HiGreen(v interface{}) *Lux
- func HiMagenta(v interface{}) *Lux
- func HiRed(v interface{}) *Lux
- func HiWhite(v interface{}) *Lux
- func HiYellow(v interface{}) *Lux
- func Italic(v interface{}) *Lux
- func Magenta(v interface{}) *Lux
- func New(fns ...CodeFn) *Lux
- func Red(v interface{}) *Lux
- func Reset(v interface{}) *Lux
- func ReverseVideo(v interface{}) *Lux
- func Underline(v interface{}) *Lux
- func White(v interface{}) *Lux
- func Yellow(v interface{}) *Lux
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NoColor defines whether to use escape sequences or not. By default, // escape sequences are enabled when running on a TTY. NoColor = !isatty.IsTerminal(os.Stdout.Fd()) )
var Output = colorable.NewColorableStdout()
Output is the io.Writer used by Print, Printf, and Println.
Functions ¶
func Print ¶
Print is a colorable frontend to fmt.Print.
Example ¶
package main import ( "github.com/moorereason/lux" ) func main() { lux.Print(lux.Blue("Skies")) }
Output:
Types ¶
type Lux ¶
type Lux struct {
// contains filtered or unexported fields
}
Lux represents the state of a particular stylized string.
func BgHiBlack ¶
func BgHiBlack(v interface{}) *Lux
BgHiBlack writes the high-intensity, black background code.
func BgHiBlue ¶
func BgHiBlue(v interface{}) *Lux
BgHiBlue writes the high-intensity, blue background code.
func BgHiCyan ¶
func BgHiCyan(v interface{}) *Lux
BgHiCyan writes the high-intensity, cyan background code.
func BgHiGreen ¶
func BgHiGreen(v interface{}) *Lux
BgHiGreen writes the high-intensity, green background code.
func BgHiMagenta ¶
func BgHiMagenta(v interface{}) *Lux
BgHiMagenta writes the high-intensity, magenta background code.
func BgHiRed ¶
func BgHiRed(v interface{}) *Lux
BgHiRed writes the high-intensity, red background code.
func BgHiWhite ¶
func BgHiWhite(v interface{}) *Lux
BgHiWhite writes the high-intensity, white background code.
func BgHiYellow ¶
func BgHiYellow(v interface{}) *Lux
BgHiYellow writes the high-intensity, yellow background code.
func HiBlack ¶
func HiBlack(v interface{}) *Lux
HiBlack writes the high-intensity, black foreground code.
func HiBlue ¶
func HiBlue(v interface{}) *Lux
HiBlue writes the high-intensity, blue foreground code.
func HiCyan ¶
func HiCyan(v interface{}) *Lux
HiCyan writes the high-intensity, cyan foreground code.
func HiGreen ¶
func HiGreen(v interface{}) *Lux
HiGreen writes the high-intensity, green foreground code.
func HiMagenta ¶
func HiMagenta(v interface{}) *Lux
HiMagenta writes the high-intensity, magenta foreground code.
func HiWhite ¶
func HiWhite(v interface{}) *Lux
HiWhite writes the high-intensity, white foreground code.
func HiYellow ¶
func HiYellow(v interface{}) *Lux
HiYellow writes the high-intensity, yellow foreground code.
func ReverseVideo ¶
func ReverseVideo(v interface{}) *Lux
ReverseVideo writes the reverse video code.
func (*Lux) Format ¶
Format implements the fmt.Formatter interface. Not to be used directly. Instead, pass the Lux as a parameter to fmt format functions.
func (*Lux) Print ¶
Print is a colorable frontend to fmt.Print.
Example ¶
package main import ( "github.com/moorereason/lux" ) func main() { c := lux.New(lux.Red) c.Print("ERROR") }
Output: