aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/misc_helpers.lua
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-06-09 20:39:25 +0100
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-06-09 21:39:25 +0200
commit740b4bec07b0a43943c9d4a20a2dc1abf4c90db9 (patch)
treed6ca194ce2dac6e59d62df59d86efded876f3eca /builtin/common/misc_helpers.lua
parent44495ea719b98aca341b9082521d0d4ee51405c8 (diff)
downloadminetest-740b4bec07b0a43943c9d4a20a2dc1abf4c90db9.tar.gz
minetest-740b4bec07b0a43943c9d4a20a2dc1abf4c90db9.tar.bz2
minetest-740b4bec07b0a43943c9d4a20a2dc1abf4c90db9.zip
Fix sending color codes to clients that don't support them. (#5950)
Also remove `disable_escape_sequences` since it's not needed anymore.
Diffstat (limited to 'builtin/common/misc_helpers.lua')
-rw-r--r--builtin/common/misc_helpers.lua44
1 files changed, 13 insertions, 31 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index d162bc0a2..f9b572d9f 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -642,44 +642,26 @@ end
local ESCAPE_CHAR = string.char(0x1b)
--- Client-side mods don't have access to settings
-if core.settings and core.settings:get_bool("disable_escape_sequences") then
-
- function core.get_color_escape_sequence(color)
- return ""
- end
-
- function core.get_background_escape_sequence(color)
- return ""
- end
-
- function core.colorize(color, message)
- return message
- end
-
-else
-
- function core.get_color_escape_sequence(color)
- return ESCAPE_CHAR .. "(c@" .. color .. ")"
- end
-
- function core.get_background_escape_sequence(color)
- return ESCAPE_CHAR .. "(b@" .. color .. ")"
- end
+function core.get_color_escape_sequence(color)
+ return ESCAPE_CHAR .. "(c@" .. color .. ")"
+end
- function core.colorize(color, message)
- local lines = tostring(message):split("\n", true)
- local color_code = core.get_color_escape_sequence(color)
+function core.get_background_escape_sequence(color)
+ return ESCAPE_CHAR .. "(b@" .. color .. ")"
+end
- for i, line in ipairs(lines) do
- lines[i] = color_code .. line
- end
+function core.colorize(color, message)
+ local lines = tostring(message):split("\n", true)
+ local color_code = core.get_color_escape_sequence(color)
- return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff")
+ for i, line in ipairs(lines) do
+ lines[i] = color_code .. line
end
+ return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff")
end
+
function core.strip_foreground_colors(str)
return (str:gsub(ESCAPE_CHAR .. "%(c@[^)]+%)", ""))
end