feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -33,11 +33,17 @@
|
|||
#include "core/core_globals.h"
|
||||
#include "core/os/os.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
static PrintHandlerList *print_handler_list = nullptr;
|
||||
static thread_local bool is_printing = false;
|
||||
|
||||
static void __print_fallback(const String &p_string, bool p_err) {
|
||||
fprintf(p_err ? stderr : stdout, "While attempting to print a message, another message was printed:\n%s\n", p_string.utf8().get_data());
|
||||
static void __print_fallback(const String &p_string, bool p_err, bool p_reentrance) {
|
||||
if (p_reentrance) {
|
||||
fprintf(p_err ? stderr : stdout, "While attempting to print an error, another error was printed:\n");
|
||||
}
|
||||
|
||||
fprintf(p_err ? stderr : stdout, "%s\n", p_string.utf8().get_data());
|
||||
}
|
||||
|
||||
void add_print_handler(PrintHandlerList *p_handler) {
|
||||
|
|
@ -76,8 +82,13 @@ void __print_line(const String &p_string) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreGlobals::print_ready) {
|
||||
__print_fallback(p_string, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_printing) {
|
||||
__print_fallback(p_string, false);
|
||||
__print_fallback(p_string, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -108,6 +119,7 @@ void __print_line_rich(const String &p_string) {
|
|||
|
||||
String output;
|
||||
int pos = 0;
|
||||
bool in_named_url = false;
|
||||
while (pos <= p_string.length()) {
|
||||
int brk_pos = p_string.find_char('[', pos);
|
||||
|
||||
|
|
@ -156,10 +168,24 @@ void __print_line_rich(const String &p_string) {
|
|||
output += "\u001b[2m";
|
||||
} else if (tag == "/code") {
|
||||
output += "\u001b[22m";
|
||||
} else if (tag.begins_with("url=")) {
|
||||
// Support named URLs using OSC 8 escape codes:
|
||||
// <https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>
|
||||
in_named_url = true;
|
||||
const String url_link = tag.substr(strlen("url="));
|
||||
output += vformat("\u001b]8;;%s\u001b\\", url_link);
|
||||
} else if (tag == "url") {
|
||||
output += "";
|
||||
} else if (tag == "/url") {
|
||||
output += "";
|
||||
if (in_named_url) {
|
||||
output += "\u001b]8;;\u001b\\";
|
||||
in_named_url = false;
|
||||
} else {
|
||||
// While it's legal to close an URL that was never opened using OSC 8 escape codes,
|
||||
// it would result in the code being printed to unsupported terminal emulators
|
||||
// when using unnamed URLs.
|
||||
output += "";
|
||||
}
|
||||
} else if (tag == "center") {
|
||||
output += "\n\t\t\t";
|
||||
} else if (tag == "/center") {
|
||||
|
|
@ -277,8 +303,13 @@ void __print_line_rich(const String &p_string) {
|
|||
}
|
||||
output += "\u001b[0m"; // Reset.
|
||||
|
||||
if (!CoreGlobals::print_ready) {
|
||||
__print_fallback(output, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_printing) {
|
||||
__print_fallback(output, false);
|
||||
__print_fallback(output, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -299,8 +330,13 @@ void __print_line_rich(const String &p_string) {
|
|||
}
|
||||
|
||||
void print_raw(const String &p_string) {
|
||||
if (!CoreGlobals::print_ready) {
|
||||
__print_fallback(p_string, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_printing) {
|
||||
__print_fallback(p_string, true);
|
||||
__print_fallback(p_string, true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -316,8 +352,13 @@ void print_error(const String &p_string) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!CoreGlobals::print_ready) {
|
||||
__print_fallback(p_string, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_printing) {
|
||||
__print_fallback(p_string, true);
|
||||
__print_fallback(p_string, true, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue