github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/ui/color.go (about)

     1  package ui
     2  
     3  import (
     4  	"github.com/mitchellh/colorstring"
     5  )
     6  
     7  var colorstringDisable = colorstring.Colorize{
     8  	Colors:  colorstring.DefaultColors,
     9  	Disable: true,
    10  	Reset:   false,
    11  }
    12  
    13  // Colorize is a helper to colorize the string according to the colorstring
    14  // library defaults.
    15  func Colorize(t string) string {
    16  	return colorstring.Color("[reset]" + t)
    17  }
    18  
    19  // StripColors is a helper to strip all the color tags from the text.
    20  func StripColors(t string) string {
    21  	return colorstringDisable.Color(t)
    22  }