summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp88
1 files changed, 67 insertions, 21 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 54730ec674..8c3979918d 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -261,6 +261,52 @@ Ref<EditorSyntaxHighlighter> EditorJSONSyntaxHighlighter::_create() const {
return syntax_highlighter;
}
+////
+
+void EditorMarkdownSyntaxHighlighter::_update_cache() {
+ highlighter->set_text_edit(text_edit);
+ highlighter->clear_keyword_colors();
+ highlighter->clear_member_keyword_colors();
+ highlighter->clear_color_regions();
+
+ // Disable automatic symbolic highlights, as these don't make sense for prose.
+ highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ highlighter->set_member_variable_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+ highlighter->set_function_color(EDITOR_GET("text_editor/theme/highlighting/text_color"));
+
+ // Headings (any level).
+ const Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
+ highlighter->add_color_region("#", "", function_color);
+
+ // Bold.
+ highlighter->add_color_region("**", "**", function_color);
+ // `__bold__` syntax is not supported as color regions must begin with a symbol,
+ // not a character that is valid in an identifier.
+
+ // Code (both inline code and triple-backticks code blocks).
+ const Color code_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
+ highlighter->add_color_region("`", "`", code_color);
+
+ // Link (both references and inline links with URLs). The URL is not highlighted.
+ const Color link_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ highlighter->add_color_region("[", "]", link_color);
+
+ // Quote.
+ const Color quote_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ highlighter->add_color_region(">", "", quote_color, true);
+
+ // HTML comment, which is also supported in Markdown.
+ const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ highlighter->add_color_region("<!--", "-->", comment_color);
+}
+
+Ref<EditorSyntaxHighlighter> EditorMarkdownSyntaxHighlighter::_create() const {
+ Ref<EditorMarkdownSyntaxHighlighter> syntax_highlighter;
+ syntax_highlighter.instantiate();
+ return syntax_highlighter;
+}
+
////////////////////////////////////////////////////////////////////////////////
/*** SCRIPT EDITOR ****/
@@ -1734,18 +1780,18 @@ void ScriptEditor::_notification(int p_what) {
case NOTIFICATION_THEME_CHANGED: {
tab_container->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("ScriptEditor"), EditorStringName(EditorStyles)));
- help_search->set_icon(get_editor_theme_icon(SNAME("HelpSearch")));
- site_search->set_icon(get_editor_theme_icon(SNAME("ExternalLink")));
+ help_search->set_button_icon(get_editor_theme_icon(SNAME("HelpSearch")));
+ site_search->set_button_icon(get_editor_theme_icon(SNAME("ExternalLink")));
if (is_layout_rtl()) {
- script_forward->set_icon(get_editor_theme_icon(SNAME("Back")));
- script_back->set_icon(get_editor_theme_icon(SNAME("Forward")));
+ script_forward->set_button_icon(get_editor_theme_icon(SNAME("Back")));
+ script_back->set_button_icon(get_editor_theme_icon(SNAME("Forward")));
} else {
- script_forward->set_icon(get_editor_theme_icon(SNAME("Forward")));
- script_back->set_icon(get_editor_theme_icon(SNAME("Back")));
+ script_forward->set_button_icon(get_editor_theme_icon(SNAME("Forward")));
+ script_back->set_button_icon(get_editor_theme_icon(SNAME("Back")));
}
- members_overview_alphabeta_sort_button->set_icon(get_editor_theme_icon(SNAME("Sort")));
+ members_overview_alphabeta_sort_button->set_button_icon(get_editor_theme_icon(SNAME("Sort")));
filter_scripts->set_right_icon(get_editor_theme_icon(SNAME("Search")));
filter_methods->set_right_icon(get_editor_theme_icon(SNAME("Search")));
@@ -2139,8 +2185,6 @@ void ScriptEditor::_update_script_colors() {
continue;
}
- script_list->set_item_custom_bg_color(i, Color(0, 0, 0, 0));
-
if (script_temperature_enabled) {
int pass = n->get_meta("__editor_pass", -1);
if (pass < 0) {
@@ -2166,7 +2210,7 @@ void ScriptEditor::_update_script_names() {
HashSet<Ref<Script>> used;
Node *edited = EditorNode::get_singleton()->get_edited_scene();
- if (edited) {
+ if (edited && EDITOR_GET("text_editor/script_list/highlight_scene_scripts")) {
_find_scripts(edited, edited, used);
}
@@ -2336,7 +2380,7 @@ void ScriptEditor::_update_script_names() {
script_list->set_item_tooltip(index, sedata_filtered[i].tooltip);
script_list->set_item_metadata(index, sedata_filtered[i].index); /* Saving as metadata the script's index in the tab container and not the filtered one */
if (sedata_filtered[i].used) {
- script_list->set_item_custom_bg_color(index, Color(88 / 255.0, 88 / 255.0, 60 / 255.0));
+ script_list->set_item_custom_bg_color(index, Color(.5, .5, .5, .125));
}
if (tab_container->get_current_tab() == sedata_filtered[i].index) {
script_list->select(index);
@@ -2798,6 +2842,8 @@ void ScriptEditor::_reload_scripts(bool p_refresh_only) {
scr->set_source_code(rel_scr->get_source_code());
scr->set_last_modified_time(rel_scr->get_last_modified_time());
scr->reload(true);
+
+ update_docs_from_script(scr);
}
Ref<JSON> json = edited_res;
@@ -3644,11 +3690,9 @@ void ScriptEditor::update_doc(const String &p_name) {
void ScriptEditor::clear_docs_from_script(const Ref<Script> &p_script) {
ERR_FAIL_COND(p_script.is_null());
- Vector<DocData::ClassDoc> documentations = p_script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- if (EditorHelp::get_doc_data()->has_doc(doc.name)) {
- EditorHelp::get_doc_data()->remove_doc(doc.name);
+ for (const DocData::ClassDoc &cd : p_script->get_documentation()) {
+ if (EditorHelp::get_doc_data()->has_doc(cd.name)) {
+ EditorHelp::get_doc_data()->remove_doc(cd.name);
}
}
}
@@ -3656,11 +3700,9 @@ void ScriptEditor::clear_docs_from_script(const Ref<Script> &p_script) {
void ScriptEditor::update_docs_from_script(const Ref<Script> &p_script) {
ERR_FAIL_COND(p_script.is_null());
- Vector<DocData::ClassDoc> documentations = p_script->get_documentation();
- for (int j = 0; j < documentations.size(); j++) {
- const DocData::ClassDoc &doc = documentations.get(j);
- EditorHelp::get_doc_data()->add_doc(doc);
- update_doc(doc.name);
+ for (const DocData::ClassDoc &cd : p_script->get_documentation()) {
+ EditorHelp::get_doc_data()->add_doc(cd);
+ update_doc(cd.name);
}
}
@@ -4416,6 +4458,10 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
json_syntax_highlighter.instantiate();
register_syntax_highlighter(json_syntax_highlighter);
+ Ref<EditorMarkdownSyntaxHighlighter> markdown_syntax_highlighter;
+ markdown_syntax_highlighter.instantiate();
+ register_syntax_highlighter(markdown_syntax_highlighter);
+
_update_online_doc();
}