util.termcolours: Add some CSS color names
authorKim Alvefur <zash@zash.se>
Sat, 27 Feb 2016 16:56:34 +0100
changeset 7207 ab2b7496a617
parent 7206 be8b88ad35a3
child 7208 a6c4530c1bc0
util.termcolours: Add some CSS color names
util/termcolours.lua
--- a/util/termcolours.lua	Sat Feb 27 16:47:12 2016 +0100
+++ b/util/termcolours.lua	Sat Feb 27 16:56:34 2016 +0100
@@ -80,6 +80,18 @@
 	return g .. color(hex2rgb(style));
 end } );
 
+local csscolors = {
+	red = "ff0000"; fuchsia = "ff00ff"; green = "008000"; white = "ffffff";
+	lime = "00ff00"; yellow = "ffff00"; purple = "800080"; blue = "0000ff";
+	aqua = "00ffff"; olive  = "808000"; black  = "000000"; navy = "000080";
+	teal = "008080"; silver = "c0c0c0"; maroon = "800000"; gray = "808080";
+}
+for color, rgb in pairs(csscolors) do
+	stylemap[color] = stylemap[color] or stylemap[rgb];
+	color, rgb = color .. " background", rgb .. " background"
+	stylemap[color] = stylemap[color] or stylemap[rgb];
+end
+
 local function getstyle(...)
 	local styles, result = { ... }, {};
 	for i, style in ipairs(styles) do