Comparison

util/termcolours.lua @ 10423:317bcc4f25f5

util.termcolours: Use explicit number formatting instead of coercion on concatenation
author Kim Alvefur <zash@zash.se>
date Wed, 20 Nov 2019 19:22:55 +0100
parent 8555:4f0f5b49bb03
child 12975:d10957394a3c
comparison
equal deleted inserted replaced
10422:cb6c0a5f9367 10423:317bcc4f25f5
81 end 81 end
82 82
83 setmetatable(stylemap, { __index = function(_, style) 83 setmetatable(stylemap, { __index = function(_, style)
84 if type(style) == "string" and style:find("%x%x%x%x%x%x") == 1 then 84 if type(style) == "string" and style:find("%x%x%x%x%x%x") == 1 then
85 local g = style:sub(7) == " background" and "48;5;" or "38;5;"; 85 local g = style:sub(7) == " background" and "48;5;" or "38;5;";
86 return g .. color(hex2rgb(style)); 86 return format("%s%d", g, color(hex2rgb(style)));
87 end 87 end
88 end } ); 88 end } );
89 89
90 local csscolors = { 90 local csscolors = {
91 red = "ff0000"; fuchsia = "ff00ff"; green = "008000"; white = "ffffff"; 91 red = "ff0000"; fuchsia = "ff00ff"; green = "008000"; white = "ffffff";