func Color(at, fg, bg int) (string, error) {
	var a, f, b string

	// can't be all NA
	if at == AttrNA && fg == AttrNA && bg == AttrNA {
		return "", ErrInvalidColor
	}

	switch at {
	case AttrNA:
		break
	case AttrBold, AttrUnderline, AttrReverse, AttrReset:
		a = fmt.Sprintf("%v;", at)
	default:
		return "", ErrInvalidAttribute
	}

	switch {
	case fg == AttrNA:
		break
	case fg >= ColorBlack && fg <= ColorWhite:
		f = fmt.Sprintf("%v;", fg+ANSIFg)
	default:
		return "", ErrInvalidForeground
	}

	switch {
	case bg == AttrNA:
		break
	case bg >= ColorBlack && bg <= ColorWhite:
		b = fmt.Sprintf("%v;", bg+ANSIBg)
	default:
		return "", ErrInvalidBackground
	}

	es := fmt.Sprintf("\x1b[%v%v%v", a, f, b)

	// replace last ; with m
	es = es[:len(es)-1] + "m"

	return es, nil
}
func Color(at, fg, bg int) (string, error) {
	var a, f, b string

	
	if at == AttrNA && fg == AttrNA && bg == AttrNA {
		return "", ErrInvalidColor
	}

	switch at {
	case AttrNA:
		break
	case AttrBold, AttrUnderline, AttrReverse, AttrReset:
		a = fmt.Sprintf("%v;", at)
	default:
		return "", ErrInvalidAttribute
	}

	switch {
	case fg == AttrNA:
		break
	case fg >= ColorBlack && fg <= ColorWhite:
		f = fmt.Sprintf("%v;", fg+ANSIFg)
	default:
		return "", ErrInvalidForeground
	}

	switch {
	case bg == AttrNA:
		break
	case bg >= ColorBlack && bg <= ColorWhite:
		b = fmt.Sprintf("%v;", bg+ANSIBg)
	default:
		return "", ErrInvalidBackground
	}

	es := fmt.Sprintf("\x1b[%v%v%v", a, f, b)

	
	es = es[:len(es)-1] + "m"

	return es, nil
}
func Color ( at , fg , bg int ) ( string , error ) { var a , f , b string // can't be all NA if at == AttrNA && fg == AttrNA && bg == AttrNA { return " " , ErrInvalidColor } switch at { case AttrNA : break case AttrBold , AttrUnderline , AttrReverse , AttrReset : a = fmt . Sprintf ( " " , at ) default : return " " , ErrInvalidAttribute } switch { case fg == AttrNA : break case fg >= ColorBlack && fg <= ColorWhite : f = fmt . Sprintf ( " " , fg + ANSIFg ) default : return " " , ErrInvalidForeground } switch { case bg == AttrNA : break case bg >= ColorBlack && bg <= ColorWhite : b = fmt . Sprintf ( " " , bg + ANSIBg ) default : return " " , ErrInvalidBackground } es := fmt . Sprintf ( " \x1b " , a , f , b ) // replace last ; with m es = es [ : len ( es ) - 1 ] + " " return es , nil }
// Color creates an ANSI compatible escape sequence that encodes colors and
// attributes.
Color creates an ANSI compatible escape sequence that encodes colors and attributes .