ansiformater

package
v0.0.0-...-fc402b7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnsiColorCode

func AnsiColorCode(color textstyle.NamedColor) int

func Format

func Format(as *attributedtext.AttributedString) string

func Formater

func Formater(attr ...attributedtext.Attribute) func(string) string
Example
package main

import (
	"fmt"

	"github.com/muhqu/go-attributedtext/textstyle"
	"github.com/muhqu/go-attributedtext/textstyle/ansiformater"
)

func main() {

	err := ansiformater.Formater(textstyle.Red.ForegroundColor())
	info := ansiformater.Formater(textstyle.Yellow.ForegroundColor())
	fatal := ansiformater.Formater(textstyle.Red.ForegroundColor(), textstyle.Bold, textstyle.Underline, textstyle.White.BackgroundColor())

	fmt.Printf("%#v\n", err("Hello"))
	fmt.Printf("%#v\n", info("World"))
	fmt.Printf("%#v\n", fatal("Fatal!"))

}
Output:


"\x1b[31mHello\x1b[0m"
"\x1b[33mWorld\x1b[0m"
"\x1b[1;4;31;47mFatal!\x1b[0m"

Types

type AnsiStyle

type AnsiStyle struct {
	ForegroundColorCode int
	BackgroundColorCode int
	Bold                bool
	Italic              bool
	Underline           bool
}

func AnsiStyleFromAttributes

func AnsiStyleFromAttributes(attrs ...attributedtext.Attribute) *AnsiStyle

func (*AnsiStyle) Format

func (a *AnsiStyle) Format(s string) string

Jump to

Keyboard shortcuts

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