ansicolor

package module
v0.0.0-...-fa6507c Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 2 Imported by: 1

README

ansicolor

ANSI color string colorizer for Golang.

Badges

License CircleCI Status Coverage Report Go Report Card CII Best Practices GoDoc

Install

go get github.com/goombaio/ansicolor

You can also update an already installed version:

go get -u github.com/goombaio/ansicolor

Example of use

package main

import (
    "github.com/goombaio/ansicolor"
)

func main() {
    str := "This is an string"

    result := str
    fmt.Println(result)

    result = ansicolor.Color8Colors(str, 31, 40)
    fmt.Println(result)

    result = ansicolor.Color16Colors(str, 93, 100)
    fmt.Println(result)

    result = ansicolor.Color256Colors(str, 4, 238)
    fmt.Println(result)

    result = ansicolor.ColorTrueColors(str, 76, 168, 67, 55, 55, 55)
    fmt.Println(result)
}

License

Copyright (c) 2018 Goomba project Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Overview

Package ansicolor ...

Index

Constants

This section is empty.

Variables

View Source
var (
	// Colorifier ...
	Colorifier = &colorifier{
		Escape:      "\x1b",
		ResetAll:    0,
		ResetColors: "39;49",
	}
)

Functions

func Color16Colors

func Color16Colors(str string, foreground int, background int) string

Color16Colors or Select Graphic Rendition) ...

Also check: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

func Color256Colors

func Color256Colors(str string, foreground int, background int) string

Color256Colors or Select Graphic Rendition) ...

ESC[ … 38;5;<n> … m Select foreground color ESC[ … 48;5;<n> … m Select background color

 0-  7:  standard colors (as in ESC [ 30–37 m)
 8- 15:  high intensity colors (as in ESC [ 90–97 m)
16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)

232-255: grayscale from black to white in 24 steps

Also check: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

func Color8Colors

func Color8Colors(str string, foreground int, background int) string

Color8Colors or Select Graphic Rendition) ...

Also check: https://en.wikipedia.org/wiki/ANSI_escape_code#Colorss

func ColorTrueColors

func ColorTrueColors(str string, fr int, fg int, fb int, br int, bg int, bb int) string

ColorTrueColors or Select Graphic Rendition) ...

Also check: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

Types

This section is empty.

Jump to

Keyboard shortcuts

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