aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-03-24 07:36:29 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-03-24 08:36:29 +0100
commitdd2f1d7551bfd70357ad4f3fb180704194272147 (patch)
tree6a4c338b19d7e7cb628b3458acc855256c82dbd1 /builtin/common
parent072bbba69aa2528c309b76aaec288bdba52e119c (diff)
downloadminetest-dd2f1d7551bfd70357ad4f3fb180704194272147.tar.gz
minetest-dd2f1d7551bfd70357ad4f3fb180704194272147.tar.bz2
minetest-dd2f1d7551bfd70357ad4f3fb180704194272147.zip
Add multiline support to colorize. (#5444)
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/misc_helpers.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index a1417dbd4..2318cea12 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -667,7 +667,14 @@ else
end
function core.colorize(color, message)
- return core.get_color_escape_sequence(color) .. message .. core.get_color_escape_sequence("#ffffff")
+ local lines = message:split("\n", true)
+ local color_code = core.get_color_escape_sequence(color)
+
+ for i, line in ipairs(lines) do
+ lines[i] = colour_code .. line
+ end
+
+ return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff")
end
end