https://github.com/alecthomas/colour
Quake-style colour formatting for Unix terminals
https://github.com/alecthomas/colour
Last synced: 5 months ago
JSON representation
Quake-style colour formatting for Unix terminals
- Host: GitHub
- URL: https://github.com/alecthomas/colour
- Owner: alecthomas
- License: mit
- Created: 2014-08-21T04:04:02.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-12-02T01:32:02.000Z (over 2 years ago)
- Last Synced: 2025-04-02T08:35:57.134Z (over 1 year ago)
- Language: Go
- Size: 8.79 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Colour terminal text for Go (Golang) [](http://godoc.org/github.com/alecthomas/colour) [](https://travis-ci.org/alecthomas/colour)
Package colour provides [Quake-style colour formatting][2] for Unix terminals.
The package level functions can be used to write to stdout (or strings or
other files). If stdout is not a terminal, colour formatting will be
stripped.
eg.
colour.Printf("^0black ^1red ^2green ^3yellow ^4blue ^5magenta ^6cyan ^7white^R\n")
For more control a Printer object can be created with various helper
functions. This can be used to do useful things such as strip formatting,
write to strings, and so on.
The following sequences are converted to their equivalent ANSI colours:
| Sequence | Effect |
| -------- | ------ |
| ^0 | Black |
| ^1 | Red |
| ^2 | Green |
| ^3 | Yellow |
| ^4 | Blue |
| ^5 | Cyan (light blue) |
| ^6 | Magenta (purple) |
| ^7 | White |
| ^8 | Black Background |
| ^9 | Red Background |
| ^a | Green Background |
| ^b | Yellow Background |
| ^c | Blue Background |
| ^d | Cyan (light blue) Background |
| ^e | Magenta (purple) Background |
| ^f | White Background |
| ^R | Reset |
| ^U | Underline |
| ^D | Dim |
| ^B | Bold |
| ^S | Strikethrough |
[1]: http://godoc.org/github.com/alecthomas/colour
[2]: http://www.holysh1t.net/quake-live-colors-nickname/