GithubHelp home page GithubHelp logo

birendra-90 / ansicolor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shiena/ansicolor

0.0 2.0 0.0 34 KB

Ansicolor library provides color console in Windows as ANSICON for Golang.

License: MIT License

Go 100.00%

ansicolor's Introduction

GoDoc

ansicolor

Ansicolor library provides color console in Windows as ANSICON for Golang.

Features

Escape sequence Text attributes
\x1b[0m All attributes off(color at startup)
\x1b[1m Bold on(enable foreground intensity)
\x1b[4m Underline on
\x1b[5m Blink on(enable background intensity)
\x1b[21m Bold off(disable foreground intensity)
\x1b[24m Underline off
\x1b[25m Blink off(disable background intensity)
Escape sequence Foreground colors
\x1b[30m Black
\x1b[31m Red
\x1b[32m Green
\x1b[33m Yellow
\x1b[34m Blue
\x1b[35m Magenta
\x1b[36m Cyan
\x1b[37m White
\x1b[39m Default(foreground color at startup)
\x1b[90m Light Gray
\x1b[91m Light Red
\x1b[92m Light Green
\x1b[93m Light Yellow
\x1b[94m Light Blue
\x1b[95m Light Magenta
\x1b[96m Light Cyan
\x1b[97m Light White
Escape sequence Background colors
\x1b[40m Black
\x1b[41m Red
\x1b[42m Green
\x1b[43m Yellow
\x1b[44m Blue
\x1b[45m Magenta
\x1b[46m Cyan
\x1b[47m White
\x1b[49m Default(background color at startup)
\x1b[100m Light Gray
\x1b[101m Light Red
\x1b[102m Light Green
\x1b[103m Light Yellow
\x1b[104m Light Blue
\x1b[105m Light Magenta
\x1b[106m Light Cyan
\x1b[107m Light White

Example

package main

import (
	"fmt"
	"os"

	"github.com/shiena/ansicolor"
)

func main() {
	w := ansicolor.NewAnsiColorWriter(os.Stdout)
	text := "%sforeground %sbold%s %sbackground%s\n"
	fmt.Fprintf(w, text, "\x1b[31m", "\x1b[1m", "\x1b[21m", "\x1b[41;32m", "\x1b[0m")
	fmt.Fprintf(w, text, "\x1b[32m", "\x1b[1m", "\x1b[21m", "\x1b[42;31m", "\x1b[0m")
	fmt.Fprintf(w, text, "\x1b[33m", "\x1b[1m", "\x1b[21m", "\x1b[43;34m", "\x1b[0m")
	fmt.Fprintf(w, text, "\x1b[34m", "\x1b[1m", "\x1b[21m", "\x1b[44;33m", "\x1b[0m")
	fmt.Fprintf(w, text, "\x1b[35m", "\x1b[1m", "\x1b[21m", "\x1b[45;36m", "\x1b[0m")
	fmt.Fprintf(w, text, "\x1b[36m", "\x1b[1m", "\x1b[21m", "\x1b[46;35m", "\x1b[0m")
	fmt.Fprintf(w, text, "\x1b[37m", "\x1b[1m", "\x1b[21m", "\x1b[47;30m", "\x1b[0m")
}

screenshot

See also:

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

ansicolor's People

Contributors

cxfksword avatar johnschnake avatar parkghost avatar shiena avatar techtonik avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.