• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

ansicolor/H19-Nov-2015-

.gitignoreH A D19-Nov-2015309

LICENSEH A D19-Nov-20151.1 KiB

README.mdH A D19-Nov-20152.7 KiB

ansicolor.goH A D19-Nov-20151.3 KiB

ansicolor_ansi.goH A D19-Nov-2015360

ansicolor_test.goH A D19-Nov-2015648

ansicolor_windows.goH A D19-Nov-201511.4 KiB

ansicolor_windows_test.goH A D19-Nov-20159.1 KiB

example_test.goH A D19-Nov-2015955

export_test.goH A D19-Nov-2015421

README.md

1[![GoDoc](https://godoc.org/github.com/shiena/ansicolor?status.svg)](https://godoc.org/github.com/shiena/ansicolor)
2
3# ansicolor
4
5Ansicolor library provides color console in Windows as ANSICON for Golang.
6
7## Features
8
9|Escape sequence|Text attributes|
10|---------------|----|
11|\x1b[0m|All attributes off(color at startup)|
12|\x1b[1m|Bold on(enable foreground intensity)|
13|\x1b[4m|Underline on|
14|\x1b[5m|Blink on(enable background intensity)|
15|\x1b[21m|Bold off(disable foreground intensity)|
16|\x1b[24m|Underline off|
17|\x1b[25m|Blink off(disable background intensity)|
18
19|Escape sequence|Foreground colors|
20|---------------|----|
21|\x1b[30m|Black|
22|\x1b[31m|Red|
23|\x1b[32m|Green|
24|\x1b[33m|Yellow|
25|\x1b[34m|Blue|
26|\x1b[35m|Magenta|
27|\x1b[36m|Cyan|
28|\x1b[37m|White|
29|\x1b[39m|Default(foreground color at startup)|
30|\x1b[90m|Light Gray|
31|\x1b[91m|Light Red|
32|\x1b[92m|Light Green|
33|\x1b[93m|Light Yellow|
34|\x1b[94m|Light Blue|
35|\x1b[95m|Light Magenta|
36|\x1b[96m|Light Cyan|
37|\x1b[97m|Light White|
38
39|Escape sequence|Background colors|
40|---------------|----|
41|\x1b[40m|Black|
42|\x1b[41m|Red|
43|\x1b[42m|Green|
44|\x1b[43m|Yellow|
45|\x1b[44m|Blue|
46|\x1b[45m|Magenta|
47|\x1b[46m|Cyan|
48|\x1b[47m|White|
49|\x1b[49m|Default(background color at startup)|
50|\x1b[100m|Light Gray|
51|\x1b[101m|Light Red|
52|\x1b[102m|Light Green|
53|\x1b[103m|Light Yellow|
54|\x1b[104m|Light Blue|
55|\x1b[105m|Light Magenta|
56|\x1b[106m|Light Cyan|
57|\x1b[107m|Light White|
58
59## Example
60
61```go
62package main
63
64import (
65	"fmt"
66	"os"
67
68	"github.com/shiena/ansicolor"
69)
70
71func main() {
72	w := ansicolor.NewAnsiColorWriter(os.Stdout)
73	text := "%sforeground %sbold%s %sbackground%s\n"
74	fmt.Fprintf(w, text, "\x1b[31m", "\x1b[1m", "\x1b[21m", "\x1b[41;32m", "\x1b[0m")
75	fmt.Fprintf(w, text, "\x1b[32m", "\x1b[1m", "\x1b[21m", "\x1b[42;31m", "\x1b[0m")
76	fmt.Fprintf(w, text, "\x1b[33m", "\x1b[1m", "\x1b[21m", "\x1b[43;34m", "\x1b[0m")
77	fmt.Fprintf(w, text, "\x1b[34m", "\x1b[1m", "\x1b[21m", "\x1b[44;33m", "\x1b[0m")
78	fmt.Fprintf(w, text, "\x1b[35m", "\x1b[1m", "\x1b[21m", "\x1b[45;36m", "\x1b[0m")
79	fmt.Fprintf(w, text, "\x1b[36m", "\x1b[1m", "\x1b[21m", "\x1b[46;35m", "\x1b[0m")
80	fmt.Fprintf(w, text, "\x1b[37m", "\x1b[1m", "\x1b[21m", "\x1b[47;30m", "\x1b[0m")
81}
82```
83
84![screenshot](https://gist.githubusercontent.com/shiena/a1bada24b525314a7d5e/raw/c763aa7cda6e4fefaccf831e2617adc40b6151c7/main.png)
85
86## See also:
87
88- https://github.com/daviddengcn/go-colortext
89- https://github.com/adoxa/ansicon
90- https://github.com/aslakhellesoy/wac
91- https://github.com/wsxiaoys/terminal
92- https://github.com/mattn/go-colorable
93
94## Contributing
95
961. Fork it
972. Create your feature branch (`git checkout -b my-new-feature`)
983. Commit your changes (`git commit -am 'Add some feature'`)
994. Push to the branch (`git push origin my-new-feature`)
1005. Create new Pull Request
101
102