diff options
| author | ruki <[email protected]> | 2019-01-03 22:44:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-01-03 10:24:28 +0800 |
| commit | 5e96c7f81c2d20ca081b4c7a854c424b0ff8f56d (patch) | |
| tree | 5aef7a5e127bea83c2ed8f85bc28cede6b85f009 | |
| parent | 2c8d0f142deeb90f8e2d2ae7962abbc8a62790aa (diff) | |
improve to print emoji text
| -rw-r--r-- | xmake/core/base/colors.lua | 28 | ||||
| -rw-r--r-- | xmake/themes/emoji/xmake.lua | 8 |
2 files changed, 21 insertions, 15 deletions
diff --git a/xmake/core/base/colors.lua b/xmake/core/base/colors.lua index ef7f239fa..b78a26b12 100644 --- a/xmake/core/base/colors.lua +++ b/xmake/core/base/colors.lua @@ -335,12 +335,6 @@ function colors.translate(str) end end - -- attempt to translate to emoji - local emoji_str = emoji.translate(word) - if emoji_str then - return emoji_str - end - -- get keys local keys = colors.color256() and colors._keys256 or colors._keys8 if colors.truecolor() then @@ -348,11 +342,13 @@ function colors.translate(str) end -- make color buffer - local buffer = {} + local text_buffer = {} + local color_buffer = {} for _, key in ipairs(word:split("%s+")) do -- get the color code local code = keys[key] + local text = false if not code then if colors.truecolor() and key:find(";", 1, true) then if key:startswith("on;") then @@ -367,16 +363,26 @@ function colors.translate(str) code = key:gsub("#", "38;5;") end else + -- get emoji code + local emoji_code = emoji.translate(key) + if emoji_code then + table.insert(text_buffer, emoji_code) + text = true + end end end - assert(code, "unknown color: " .. key) + assert(code or text, "unknown color: " .. key) -- save this code - table.insert(buffer, code) + table.insert(color_buffer, code) end - -- format the color buffer - return colors._escape:format(table.concat(buffer, ";")) + -- make result + local result = colors._escape:format(table.concat(color_buffer, ";")) + if #text_buffer > 0 then + result = result .. table.concat(text_buffer, "") + end + return result end) -- ok diff --git a/xmake/themes/emoji/xmake.lua b/xmake/themes/emoji/xmake.lua index 223ab467b..b579f742f 100644 --- a/xmake/themes/emoji/xmake.lua +++ b/xmake/themes/emoji/xmake.lua @@ -39,13 +39,13 @@ theme("emoji") -- the error info set_color("error", "exclamation") - set_color("error.dim", "exclamation") - set_color("error.bright", "exclamation") + set_color("error.dim", "dim exclamation") + set_color("error.bright", "bright exclamation") -- the warning info set_color("warning", "warning") - set_color("warning.dim", "warning") - set_color("warning.bright", "warning") + set_color("warning.dim", "dim warning") + set_color("warning.bright", "bright warning") -- the building progress set_text("build.progress_format", "[%3d%%]") |
