summaryrefslogtreecommitdiff
path: root/core/variant
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-06-28 23:35:53 +0200
committerGitHub <noreply@github.com>2022-06-28 23:35:53 +0200
commitb730d2ee09a8fdc4eaa44efe9afc083d907f80c3 (patch)
tree0ed1a5563e639656ccc63749a2f53add1733965d /core/variant
parent0cd049e4112ab8d4ee2ebd6869d114bdf754c3bb (diff)
parentc6291bcd8a49055ce2158f88759a487de5b8d1bd (diff)
Merge pull request #60675 from voylin/Add-BBCode-support-for-printing-output
Adding print_rich() for printing with BBCode
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/variant_utility.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index d1b5e285d2..2bca5f8284 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -560,6 +560,22 @@ struct VariantUtilityFunctions {
r_error.error = Callable::CallError::CALL_OK;
}
+ static inline void print_rich(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
+ String s;
+ for (int i = 0; i < p_arg_count; i++) {
+ String os = p_args[i]->operator String();
+
+ if (i == 0) {
+ s = os;
+ } else {
+ s += os;
+ }
+ }
+
+ print_line_rich(s);
+ r_error.error = Callable::CallError::CALL_OK;
+ }
+
static inline void print_verbose(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
if (OS::get_singleton()->is_stdout_verbose()) {
String s;
@@ -1306,6 +1322,7 @@ void Variant::_register_variant_utility_functions() {
FUNCBINDVARARGS(str, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDR(error_string, sarray("error"), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDVARARGV(print, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL);
+ FUNCBINDVARARGV(print_rich, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDVARARGV(printerr, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDVARARGV(printt, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDVARARGV(prints, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL);