Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/randrews/color
An ANSI color library for Lua
https://github.com/randrews/color
Last synced: 8 days ago
JSON representation
An ANSI color library for Lua
- Host: GitHub
- URL: https://github.com/randrews/color
- Owner: randrews
- Created: 2012-04-25T23:53:07.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-06T23:54:51.000Z (over 7 years ago)
- Last Synced: 2024-08-02T14:08:39.447Z (3 months ago)
- Language: Lua
- Size: 4.88 KB
- Stars: 34
- Watchers: 7
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: readme.markdown
Awesome Lists containing this project
README
Color.lua - ANSI control library for Lua
========================================A super-simple way to make colored text output in Lua.
To use, simply print out things from this module, then print out some text.Examples:
----------```lua
print(color.bg.green .. color.fg.RED .. "This is bright red on green")print(color.invert .. "This is inverted..." .. color.reset .. " And this isn't.")
print(color.fg(0xDE) .. color.bg(0xEE) ..
"You can use xterm-256 colors too!" ..
color.reset)print("And also " .. color.bold .. "BOLD" .. color.normal .. " if you want.")
print(color.bold .. color.fg.BLUE .. color.bg.blue ..
"Miss your " .. color.fg.RED .. "C-64" ..
color.fg.BLUE .. "?" .. color.reset)
```You can see all these examples in action by calling `color.test()`
Can't pick a good color scheme? Look at a handy chart:
```lua
print(color.chart())
```Extending:
----------I figured out most of how to write this from the excellent [Wikipedia page on ANSI control codes](http://en.wikipedia.org/wiki/ANSI_escape_code). If you want to extend it, that would be a good place to start. And send me a pull request!
Portability:
-----------This doesn't work on Windows at all, and it would be a really nontrivial effort to port it.
License:
----------Copyright 2012 by Ross Andrews, released under the [GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.txt).