Terminal string styling. Put some color in your console! Support for Fennel, Lua, and Shell.
fortune | cowsay | supernova
- Flavors:
- Installing
- Principles
- Room for Improvement
- Contributing
- Acknowledgments
- References
- Screenshots
"Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system." fennel-lang.org
(local supernova (require :supernova))
(print (supernova.italic.yellow "WARNING: Intense color found."))
(print (supernova.underline.color "Beautiful pink." "#e317e0"))
(print (supernova.gradient
"Reflection, refraction and dispersion."
["#FF0000" "#FFFF00" "#00FF00" "#0FF0FE" "#233CFE"]))
Check the installation instructions.
Check the complete documentation for the Fennel library.
local supernova = require 'supernova'
print(supernova.italic.yellow('WARNING: Intense color found.'))
print(supernova.underline.color('Beautiful pink.', '#e317e0'))
print(supernova.gradient(
'Reflection, refraction and dispersion.',
{ '#FF0000', '#FFFF00', '#00FF00', '#0FF0FE', '#233CFE' }
))
Check the complete documentation for the Lua library.
supernova inspect '#eb4934'
echo WARNING: Intense color found. | supernova italic.yellow
echo Beautiful pink. | supernova underline.color '#e317e0'
echo Reflection, refraction and dispersion. | \
supernova gradient \
'#FF0000' '#FFFF00' '#00FF00' '#0FF0FE' '#233CFE'
Check the complete documentation for the Shell CLI.
Ensure that you have Lua and LuaRocks installed.
Installation through LuaRocks:
Installing for the user (recommended):
luarocks install supernova --local
Installing for the system:
sudo luarocks install supernova
To install through fnx, add to your .fnx.fnl
:
:supernova {:lua/rock ">= 0.0.2"}
; Example:
{:name "my-project"
:version "0.0.1"
:dependencies {
:supernova {:lua/rock ">= 0.0.2"}}}
This project is a spark towards a higher purpose. There are principles to ensure that we are on track. These principles should help with discussions and decision making:
There must be no external dependencies other than Lua. There must be no need to use LuaJIT or any special implementation than the standard Lua. The code must work on any platform where it is possible to run Lua.
Maintainers' priority in the pursuit of this principle:
- Free Software and Free Hardware
- Open Source Software and Open Source Hardware
- Proprietary Software and Proprietary Hardware
The current strategy with metatables has its flaws. You can explore the problem by analyzing these samples of code:
The math for the distance between two colors ain't flawless. We can do better. Current code:
local distance = (
((rgb_color[1] - cadidate_color.rgb[1]) ^ 2) +
((rgb_color[2] - cadidate_color.rgb[2]) ^ 2) +
((rgb_color[3] - cadidate_color.rgb[3]) ^ 2)
)
We have a naive approach for gradient generation. Other algorithms could produce better results: Color gradient algorithm
Current code:
local color = {
math.floor((from_rgb[1] * (1 - mix)) + (to_rgb[1] * mix)),
math.floor((from_rgb[2] * (1 - mix)) + (to_rgb[2] * mix)),
math.floor((from_rgb[3] * (1 - mix)) + (to_rgb[3] * mix))
}
The current 256 VGA color representation may not be accurate enough. Some references that are worth exploring:
We currently only have luarocks packages. We have some experiments with standalone binaries and AUR packages that could be released.
We ensure that Luacheck is valid for any Pull Request or commit.
Also, we follow the Olivine Labs' Lua Style Guide. The LuaRocks' Lua Style Guide is a great reference as well. If their suggestions conflict with each other, the Olivine Labs' Guide prevails.
The names for the colors come from the color-names project.