Browse Source

Handle clickable `[url]` tags in `print_rich()` editor output log

Since this uses `OS.shell_open()`, this allows the use of any standard URL
including `file://` paths, `mailto:`, custom protocols set up by the user, etc.
Hugo Locurcio 1 year ago
parent
commit
4a11d48420
3 changed files with 7 additions and 0 deletions
  1. 1 0
      doc/classes/@GlobalScope.xml
  2. 5 0
      editor/editor_log.cpp
  3. 1 0
      editor/editor_log.h

+ 1 - 0
doc/classes/@GlobalScope.xml

@@ -877,6 +877,7 @@
 				[/codeblocks]
 				[/codeblocks]
 				[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method print_rich]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.
 				[b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method print_rich]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.
 				[b]Note:[/b] On Windows, only Windows 10 and later correctly displays ANSI escape codes in standard output.
 				[b]Note:[/b] On Windows, only Windows 10 and later correctly displays ANSI escape codes in standard output.
+				[b]Note:[/b] Output displayed in the editor supports clickable [code skip-lint][url=address]text[/url][/code] tags. The [code skip-lint][url][/code] tag's [code]address[/code] value is handled by [method OS.shell_open] when clicked.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="print_verbose" qualifiers="vararg">
 		<method name="print_verbose" qualifiers="vararg">

+ 5 - 0
editor/editor_log.cpp

@@ -192,6 +192,10 @@ void EditorLog::_load_state() {
 	is_loading_state = false;
 	is_loading_state = false;
 }
 }
 
 
+void EditorLog::_meta_clicked(const String &p_meta) {
+	OS::get_singleton()->shell_open(p_meta);
+}
+
 void EditorLog::_clear_request() {
 void EditorLog::_clear_request() {
 	log->clear();
 	log->clear();
 	messages.clear();
 	messages.clear();
@@ -407,6 +411,7 @@ EditorLog::EditorLog() {
 	log->set_v_size_flags(SIZE_EXPAND_FILL);
 	log->set_v_size_flags(SIZE_EXPAND_FILL);
 	log->set_h_size_flags(SIZE_EXPAND_FILL);
 	log->set_h_size_flags(SIZE_EXPAND_FILL);
 	log->set_deselect_on_focus_loss_enabled(false);
 	log->set_deselect_on_focus_loss_enabled(false);
+	log->connect("meta_clicked", callable_mp(this, &EditorLog::_meta_clicked));
 	vb_left->add_child(log);
 	vb_left->add_child(log);
 
 
 	// Search box
 	// Search box

+ 1 - 0
editor/editor_log.h

@@ -157,6 +157,7 @@ private:
 	Thread::ID current;
 	Thread::ID current;
 
 
 	//void _dragged(const Point2& p_ofs);
 	//void _dragged(const Point2& p_ofs);
+	void _meta_clicked(const String &p_meta);
 	void _clear_request();
 	void _clear_request();
 	void _copy_request();
 	void _copy_request();
 	static void _undo_redo_cbk(void *p_self, const String &p_name);
 	static void _undo_redo_cbk(void *p_self, const String &p_name);