From 4ce4dce93de7d5c77464f283dea10db1e421af1f Mon Sep 17 00:00:00 2001
From: bruvzg <7645683+bruvzg@users.noreply.github.com>
Date: Tue, 3 Sep 2024 09:54:09 +0300
Subject: [PATCH] [TextEdit] Add support for using SyntaxHighligther for BiDi
override and font override.
---
doc/classes/CodeHighlighter.xml | 209 ++++++++--
doc/classes/EditorSettings.xml | 45 +++
doc/classes/SyntaxHighlighter.xml | 10 +
doc/classes/TextEdit.xml | 42 ++
editor/code_editor.cpp | 4 +
...editor_native_shader_source_visualizer.cpp | 30 +-
editor/editor_settings.cpp | 25 ++
editor/plugins/script_editor_plugin.cpp | 93 +++--
editor/plugins/text_shader_editor.cpp | 46 ++-
.../plugins/visual_shader_editor_plugin.cpp | 43 ++-
editor/themes/editor_fonts.cpp | 13 +
editor/themes/editor_theme_manager.cpp | 18 +
.../4.3-stable.expected | 9 +
.../gdscript/editor/gdscript_highlighter.cpp | 293 +++++++++-----
.../gdscript/editor/gdscript_highlighter.h | 29 +-
scene/gui/text_edit.cpp | 293 ++++++++++++--
scene/gui/text_edit.h | 45 ++-
scene/resources/syntax_highlighter.cpp | 358 ++++++++++++++++--
scene/resources/syntax_highlighter.h | 78 +++-
scene/theme/default_theme.cpp | 4 +
20 files changed, 1403 insertions(+), 284 deletions(-)
diff --git a/doc/classes/CodeHighlighter.xml b/doc/classes/CodeHighlighter.xml
index ca2caf6be50a..f1459ec9c837 100644
--- a/doc/classes/CodeHighlighter.xml
+++ b/doc/classes/CodeHighlighter.xml
@@ -4,12 +4,12 @@
A syntax highlighter intended for code.
- By adjusting various properties of this resource, you can change the colors of strings, comments, numbers, and other text patterns inside a [TextEdit] control.
+ By adjusting various properties of this resource, you can change the colors and font style of strings, comments, numbers, and other text patterns inside a [TextEdit] control.
-
+
@@ -20,43 +20,99 @@
If [param line_only] is [code]true[/code] or [param end_key] is an empty [String], the region does not carry over to the next line.
-
+
+
+
+
+
+
+ Sets the color and font style applied to the given keyword.
+ [param keyword] cannot contain any symbols except [code]_[/code].
+
+
+
Sets the color for a keyword.
- The keyword cannot contain any symbols except '_'.
+ [param keyword] cannot contain any symbols except [code]_[/code].
-
+
+
+
+ Sets the color and font style applied to the given member keyword. Unlike, [method add_keyword], it will not be highlighted if preceded by [code].[/code].
+ [param member_keyword] cannot contain any symbols except [code]_[/code].
+
+
+
+
+
+
+
+ Sets the color applied to the given member keyword. Unlike, [method add_keyword], it will not be highlighted if preceded by [code].[/code].
+ [param member_keyword] cannot contain any symbols except [code]_[/code].
+
+
+
+
+
+
+
+
+
+
- Sets the color for a member keyword.
- The member keyword cannot contain any symbols except '_'.
- It will not be highlighted if preceded by a '.'.
+ Adds a color and font style region (such as for comments or strings) from [param start_key] to [param end_key]. Both keys should be symbols, and [param start_key] must not be shared with other delimiters.
+ If [param line_only] is [code]true[/code] or [param end_key] is an empty [String], the region does not carry over to the next line.
-
+
Removes all color regions.
-
+
Removes all keywords.
-
+
+
+
+ Removes all keywords.
+
+
+
+
+
+ Removes all member keywords.
+
+
+
Removes all member keywords.
+
+
+
+ Removes all color and font style regions.
+
+
+
+
+
+ Returns all color regions, as a dictionary.
+
+
@@ -64,6 +120,19 @@
Returns the color for a keyword.
+
+
+
+ Returns the colors applied to all keywords, as a dictionary.
+
+
+
+
+
+
+ Returns the font style used for a keyword.
+
+
@@ -71,70 +140,158 @@
Returns the color for a member keyword.
-
+
+
+
+ Returns the colors applied to all member keywords, as a dictionary.
+
+
+
+
+
+
+ Returns the font style used for the given member keyword.
+
+
+
Returns [code]true[/code] if the start key exists, else [code]false[/code].
-
+
+
+
+
+ Returns [code]true[/code] if the keyword exists, else [code]false[/code].
+
+
+
Returns [code]true[/code] if the keyword exists, else [code]false[/code].
-
+
Returns [code]true[/code] if the member keyword exists, else [code]false[/code].
-
+
+
+
+
+ Returns [code]true[/code] if the member keyword exists, else [code]false[/code].
+
+
+
+
+
+
+ Returns [code]true[/code] if the start key exists, else [code]false[/code].
+
+
+
Removes the color region that uses that start key.
-
+
Removes the keyword.
-
+
+
+
+
+ Removes the keyword.
+
+
+
+
+
+
+ Removes the member keyword.
+
+
+
Removes the member keyword.
+
+
+
+
+ Removes the color or font style region that uses the given start key.
+
+
+
+
+
+
+ Sets color regions.
+
+
+
+
+
+
+ Sets colors for keywords.
+
+
+
+
+
+
+ Sets colors for member keywords.
+
+
-
- Sets the color regions. All existing regions will be removed. The [Dictionary] key is the region start and end key, separated by a space. The value is the region color.
-
- Sets color for functions. A function is a non-keyword string followed by a '('.
+ Sets color for functions. A function is a non-keyword string followed by a [code]([/code].
+
+
+ Sets the font style for functions. A function is a non-keyword string followed by [code]([/code].
-
- Sets the keyword colors. All existing keywords will be removed. The [Dictionary] key is the keyword. The value is the keyword color.
+
+ Color and font style for keywords, as a [Dictionary] where each key is a keyword [String] and each value is a nested [Dictionary] with the following keys: [code]"color"[/code], [code]"style"[/code].
-
- Sets the member keyword colors. All existing member keyword will be removed. The [Dictionary] key is the member keyword. The value is the member keyword color.
+
+ Color and font style for member keywords, as a [Dictionary] where each key is a keyword [String] and each value is a nested [Dictionary] with the following keys: [code]"color"[/code], [code]"style"[/code].
- Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a '.'.
+ Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a [code].[/code].
+
+
+ Sets the font style for member variables. A member variable is non-keyword, non-function string proceeded with a [code].[/code].
Sets the color for numbers.
+
+ Sets the font style for numbers.
+
+
+ Color and font style regions, [Dictionary] keys are [code]"start_key end_key"[/code] string, values are [Dictionary] with the following keys: [code]"color"[/code], [code]"style"[/code], and [code]text_segment[/code].
+
Sets the color for symbols.
+
+ Sets the font style for symbols.
+
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 550933ce6473..0a296e41c720 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -1353,6 +1353,12 @@
Specifies sorting used for Script Editor's open script list.
+
+ If [code]true[/code], if the syntax highlighter can change the text's font style.
+
+
+ If [code]true[/code], the syntax highlighter is used to tokenize the text for BiDi override.
+
The syntax theme to use in the script editor.
You can save your own syntax theme from your current settings by using [b]File > Theme > Save As...[/b] at the top of the script editor. The syntax theme will then be available locally in the list of color themes.
@@ -1364,6 +1370,9 @@
The script editor's base type color (used for types like [Vector2], [Vector3], [Color], ...).
+
+ The script editor's base type font style (used for types like [Vector2], [Vector3], [Color], ...).
+
The script editor's bookmark icon color (displayed in the gutter).
@@ -1387,6 +1396,9 @@
The script editor's comment color.
[b]Note:[/b] In GDScript, unlike Python, multiline strings are not considered to be comments, and will use the string highlighting color instead.
+
+ The script editor's comment font style.
+
The script editor's autocompletion box background color.
@@ -1408,28 +1420,46 @@
The script editor's control flow keyword color (used for keywords like [code]if[/code], [code]for[/code], [code]return[/code], ...).
+
+ The script editor's control flow keyword font style (used for keywords like [code]if[/code], [code]for[/code], [code]return[/code], ...).
+
The script editor's background color for the line the caret is currently on. This should be set to a translucent color so that it can display on top of other line color modifiers such as [member text_editor/theme/highlighting/mark_color].
The script editor's documentation comment color. In GDScript, this is used for comments starting with [code]##[/code]. In C#, this is used for comments starting with [code]///[/code] or [code]/**[/code].
+
+ The script editor's documentation comment font style. In GDScript, this is used for comments starting with [code]##[/code]. In C#, this is used for comments starting with [code]///[/code] or [code]/**[/code].
+
The script editor's engine type color ([Object], [Mesh], [Node], ...).
+
+ The script editor's engine type font style ([Vector2], [Vector3], [Color], ...).
+
The script editor's color for the debugger's executing line icon (displayed in the gutter).
The script editor's background line highlighting color for folded code region.
+
+ The script editor's background line highlighting font style for folded code region.
+
The script editor's function call color.
[b]Note:[/b] When using the GDScript syntax highlighter, this is replaced by the function definition color configured in the syntax theme for function definitions (e.g. [code]func _ready():[/code]).
+
+ The script editor's function call font style.
+
The script editor's non-control flow keyword color (used for keywords like [code]var[/code], [code]func[/code], [code]extends[/code], ...).
+
+ The script editor's non-control flow keyword font style (used for keywords like [code]var[/code], [code]func[/code], [code]extends[/code], ...).
+
The script editor's color for the line length guideline. The "hard" line length guideline will be drawn with this color, whereas the "soft" line length guideline will be drawn with half of its opacity.
@@ -1443,9 +1473,15 @@
The script editor's color for member variables on objects (e.g. [code]self.some_property[/code]).
[b]Note:[/b] This color is not used for local variable declaration and access.
+
+ The script editor's font style for member variables on objects (e.g. [code]self.some_property[/code]).
+
The script editor's color for numbers (integer and floating-point).
+
+ The script editor's font style for numbers (integer and floating-point).
+
The script editor's color for type-safe line numbers. See also [member text_editor/theme/highlighting/line_number_color].
[b]Note:[/b] Only displayed if [member text_editor/appearance/gutters/highlight_type_safe_lines] is [code]true[/code].
@@ -1462,9 +1498,15 @@
The script editor's color for strings (single-line and multi-line).
+
+ The script editor's font style for strings (single-line and multi-line).
+
The script editor's color for operators ([code]( ) [ ] { } + - * /[/code], ...).
+
+ The script editor's font style for operators ([code]( ) [ ] { } + - * /[/code], ...).
+
The script editor's color for text not highlighted by any syntax highlighting rule.
@@ -1474,6 +1516,9 @@
The script editor's color for user-defined types (using [code]class_name[/code]).
+
+ The script editor's font style for user-defined types (using [code]class_name[/code]).
+
The script editor's color for words highlighted by selecting them. Only visible if [member text_editor/appearance/caret/highlight_all_occurrences] is [code]true[/code].
diff --git a/doc/classes/SyntaxHighlighter.xml b/doc/classes/SyntaxHighlighter.xml
index 22d20d24e5ff..66adc356e3a6 100644
--- a/doc/classes/SyntaxHighlighter.xml
+++ b/doc/classes/SyntaxHighlighter.xml
@@ -70,4 +70,14 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index b884fa595863..c953e72534ad 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -416,6 +416,13 @@
Returns the width in pixels of the [param wrap_index] on [param line].
+
+
+
+
+ Returns line text as it is currently displayed, including IME preedit string.
+
+
@@ -658,6 +665,18 @@
Returns the total number of lines in the text. This includes wrapped lines and excludes folded lines. If [member wrap_mode] is set to [constant LINE_WRAPPING_NONE] and no lines are folded (see [method CodeEdit.is_line_folded]) then this is equivalent to [method get_line_count]. See [method get_visible_line_count_in_range] for a limited range of lines.
+
+
+
+ Returns [code]true[/code] if the syntax highlighter can change the text's font style.
+
+
+
+
+
+ Returns [code]true[/code] if the syntax highlighter is used to tokenize the text for BiDi override.
+
+
@@ -1212,6 +1231,20 @@
Provide custom tooltip text. The callback method must take the following args: [code]hovered_word: String[/code].
+
+
+
+
+ If set to [code]true[/code], syntax highlighter can change text font style.
+
+
+
+
+
+
+ If set to [code]true[/code], syntax highlighter is used to tokenize text for BiDi override.
+
+
@@ -1630,9 +1663,18 @@
The size of the text outline.
[b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
+
+ Sets the default bold [Font]. Used by syntax highlighter.
+
+
+ Sets the default bold italic [Font]. Used by syntax highlighter.
+
Sets the default [Font].
+
+ Sets the default italic [Font]. Used by syntax highlighter.
+
Sets default font size.
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 0c3f91fd1b45..7e1ff0d18af7 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1069,6 +1069,8 @@ void CodeTextEditor::update_editor_settings() {
completion_node_path_color = EDITOR_GET("text_editor/theme/highlighting/gdscript/node_path_color");
completion_comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
completion_doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
+ text_editor->set_use_syntax_highlighter_for_bidi_override(EDITOR_GET("text_editor/syntax_highlighter_for_bidi_override"));
+ text_editor->set_use_syntax_highlighter_font_change(EDITOR_GET("text_editor/syntax_highlighter_can_change_font"));
// Appearance: Caret
text_editor->set_caret_type((TextEdit::CaretType)EDITOR_GET("text_editor/appearance/caret/type").operator int());
@@ -1786,6 +1788,8 @@ CodeTextEditor::CodeTextEditor() {
add_child(text_editor);
text_editor->set_v_size_flags(SIZE_EXPAND_FILL);
text_editor->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_GDSCRIPT);
+ text_editor->set_use_syntax_highlighter_for_bidi_override(EDITOR_GET("text_editor/syntax_highlighter_for_bidi_override"));
+ text_editor->set_use_syntax_highlighter_font_change(EDITOR_GET("text_editor/syntax_highlighter_can_change_font"));
text_editor->set_draw_bookmarks_gutter(true);
text_editor->set_draw_line_numbers(true);
diff --git a/editor/editor_native_shader_source_visualizer.cpp b/editor/editor_native_shader_source_visualizer.cpp
index 9ebf7d680e81..f22a97f7f7a9 100644
--- a/editor/editor_native_shader_source_visualizer.cpp
+++ b/editor/editor_native_shader_source_visualizer.cpp
@@ -39,34 +39,42 @@
void EditorNativeShaderSourceVisualizer::_load_theme_settings() {
syntax_highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/number_color"));
+ syntax_highlighter->set_number_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/number_style"));
syntax_highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/symbol_color"));
+ syntax_highlighter->set_symbol_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/symbol_style"));
syntax_highlighter->set_function_color(EDITOR_GET("text_editor/theme/highlighting/function_color"));
+ syntax_highlighter->set_function_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style"));
syntax_highlighter->set_member_variable_color(EDITOR_GET("text_editor/theme/highlighting/member_variable_color"));
+ syntax_highlighter->set_member_variable_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style"));
- syntax_highlighter->clear_keyword_colors();
+ syntax_highlighter->clear_keywords();
List keywords;
ShaderLanguage::get_keyword_list(&keywords);
- const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
- const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
+ Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle control_flow_keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_style");
for (const String &keyword : keywords) {
if (ShaderLanguage::is_control_flow_keyword(keyword)) {
- syntax_highlighter->add_keyword_color(keyword, control_flow_keyword_color);
+ syntax_highlighter->add_keyword(keyword, control_flow_keyword_color, control_flow_keyword_style);
} else {
- syntax_highlighter->add_keyword_color(keyword, keyword_color);
+ syntax_highlighter->add_keyword(keyword, keyword_color, keyword_style);
}
}
// Colorize comments.
- const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
- syntax_highlighter->clear_color_regions();
- syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
- syntax_highlighter->add_color_region("//", "", comment_color, true);
+ Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
+ syntax_highlighter->clear_regions();
+ syntax_highlighter->add_region("/*", "*/", comment_color, comment_style, false, true);
+ syntax_highlighter->add_region("//", "", comment_color, comment_style, true, true);
// Colorize preprocessor statements.
- const Color user_type_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
- syntax_highlighter->add_color_region("#", "", user_type_color, true);
+ Color user_type_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ SyntaxHighlighter::SyntaxFontStyle user_type_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/user_type_style");
+ syntax_highlighter->add_region("#", "", user_type_color, user_type_style, true);
syntax_highlighter->set_uint_suffix_enabled(true);
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 153cb74b74df..387b27a33f59 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -54,6 +54,7 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/window.h"
+#include "scene/resources/syntax_highlighter.h"
// PRIVATE METHODS
@@ -734,6 +735,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
_initial_set("text_editor/completion/add_node_path_literals", false, true);
_initial_set("text_editor/completion/use_single_quotes", false, true);
_initial_set("text_editor/completion/colorize_suggestions", true);
+ _initial_set("text_editor/syntax_highlighter_for_bidi_override", true);
+ _initial_set("text_editor/syntax_highlighter_can_change_font", true);
// External editor (ScriptEditorPlugin)
_initial_set("text_editor/external/use_external_editor", false, true);
@@ -1030,15 +1033,28 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
void EditorSettings::_load_godot2_text_editor_theme() {
// Godot 2 is only a dark theme; it doesn't have a light theme counterpart.
+#define EDITOR_SETTING(m_type, m_property_hint, m_name, m_default_value, m_hint_string) \
+ _initial_set(m_name, m_default_value); \
+ hints[m_name] = PropertyInfo(m_type, m_name, m_property_hint, m_hint_string);
+
_initial_set("text_editor/theme/highlighting/symbol_color", Color(0.73, 0.87, 1.0), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/symbol_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/keyword_color", Color(1.0, 1.0, 0.7), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/keyword_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/control_flow_keyword_color", Color(1.0, 0.85, 0.7), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/control_flow_keyword_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/base_type_color", Color(0.64, 1.0, 0.83), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/base_type_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/engine_type_color", Color(0.51, 0.83, 1.0), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/engine_type_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/user_type_color", Color(0.42, 0.67, 0.93), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/user_type_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/comment_color", Color(0.4, 0.4, 0.4), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/comment_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/doc_comment_color", Color(0.5, 0.6, 0.7), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/doc_comment_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/string_color", Color(0.94, 0.43, 0.75), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/string_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/background_color", Color(0.13, 0.12, 0.15), true);
_initial_set("text_editor/theme/highlighting/completion_background_color", Color(0.17, 0.16, 0.2));
_initial_set("text_editor/theme/highlighting/completion_selected_color", Color(0.26, 0.26, 0.27));
@@ -1058,16 +1074,21 @@ void EditorSettings::_load_godot2_text_editor_theme() {
_initial_set("text_editor/theme/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), true);
_initial_set("text_editor/theme/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), true);
_initial_set("text_editor/theme/highlighting/number_color", Color(0.92, 0.58, 0.2), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/number_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/function_color", Color(0.4, 0.64, 0.81), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/function_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/member_variable_color", Color(0.9, 0.31, 0.35), true);
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/member_variable_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), true);
_initial_set("text_editor/theme/highlighting/bookmark_color", Color(0.08, 0.49, 0.98));
_initial_set("text_editor/theme/highlighting/breakpoint_color", Color(0.9, 0.29, 0.3));
_initial_set("text_editor/theme/highlighting/executing_line_color", Color(0.98, 0.89, 0.27));
_initial_set("text_editor/theme/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8));
_initial_set("text_editor/theme/highlighting/folded_code_region_color", Color(0.68, 0.46, 0.77, 0.2));
+ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/theme/highlighting/folded_code_region_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, "Regular,Bold,Italic,Bold Italic");
_initial_set("text_editor/theme/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1));
_initial_set("text_editor/theme/highlighting/search_result_border_color", Color(0.41, 0.61, 0.91, 0.38));
+#undef EDITOR_SETTING
}
void EditorSettings::_load_default_visual_shader_editor_theme() {
@@ -1109,6 +1130,8 @@ bool EditorSettings::_save_text_editor_theme(const String &p_file) {
for (const String &key : keys) {
if (key.begins_with("text_editor/theme/highlighting/") && key.contains("color")) {
cf->set_value(theme_section, key.replace("text_editor/theme/highlighting/", ""), ((Color)props[key].variant).to_html());
+ } else if (key.begins_with("text_editor/theme/highlighting/") && key.contains("style")) {
+ cf->set_value(theme_section, key.replace("text_editor/theme/highlighting/", ""), ((int)props[key].variant));
}
}
@@ -1649,6 +1672,8 @@ void EditorSettings::load_text_editor_theme() {
// make sure it is actually a color
if (val.is_valid_html_color() && key.contains("color")) {
props["text_editor/theme/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam
+ } else if (val.is_valid_html_color() && key.contains("style")) {
+ props["text_editor/theme/highlighting/" + key].variant = val;
}
}
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 2896f9989f8f..0a6df2968b60 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -106,29 +106,35 @@ void EditorSyntaxHighlighter::_bind_methods() {
void EditorStandardSyntaxHighlighter::_update_cache() {
highlighter->set_text_edit(text_edit);
- highlighter->clear_keyword_colors();
- highlighter->clear_member_keyword_colors();
- highlighter->clear_color_regions();
+ highlighter->clear_keywords();
+ highlighter->clear_member_keywords();
+ highlighter->clear_regions();
highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/symbol_color"));
+ highlighter->set_symbol_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/symbol_style"));
highlighter->set_function_color(EDITOR_GET("text_editor/theme/highlighting/function_color"));
+ highlighter->set_function_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style"));
highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/number_color"));
+ highlighter->set_number_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/number_style"));
highlighter->set_member_variable_color(EDITOR_GET("text_editor/theme/highlighting/member_variable_color"));
+ highlighter->set_member_variable_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style"));
/* Engine types. */
- const Color type_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
+ Color type_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
+ SyntaxHighlighter::SyntaxFontStyle type_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/engine_type_style");
List types;
ClassDB::get_class_list(&types);
for (const StringName &E : types) {
- highlighter->add_keyword_color(E, type_color);
+ highlighter->add_keyword(E, type_color, type_style);
}
/* User types. */
- const Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ SyntaxHighlighter::SyntaxFontStyle usertype_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/user_type_style");
List global_classes;
ScriptServer::get_global_class_list(&global_classes);
for (const StringName &E : global_classes) {
- highlighter->add_keyword_color(E, usertype_color);
+ highlighter->add_keyword(E, usertype_color, usertype_style);
}
/* Autoloads. */
@@ -136,7 +142,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
for (const KeyValue &E : autoloads) {
const ProjectSettings::AutoloadInfo &info = E.value;
if (info.is_singleton) {
- highlighter->add_keyword_color(info.name, usertype_color);
+ highlighter->add_keyword(info.name, usertype_color, usertype_style);
}
}
@@ -153,28 +159,32 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
if (scr_lang != nullptr) {
/* Core types. */
- const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
+ Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
+ SyntaxHighlighter::SyntaxFontStyle basetype_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/base_type_style");
List core_types;
scr_lang->get_core_type_words(&core_types);
for (const String &E : core_types) {
- highlighter->add_keyword_color(E, basetype_color);
+ highlighter->add_keyword(E, basetype_color, basetype_style);
}
/* Reserved words. */
- const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
- const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
+ Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle control_flow_keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_style");
List keywords;
scr_lang->get_reserved_words(&keywords);
for (const String &E : keywords) {
if (scr_lang->is_control_flow_keyword(E)) {
- highlighter->add_keyword_color(E, control_flow_keyword_color);
+ highlighter->add_keyword(E, control_flow_keyword_color, control_flow_keyword_style);
} else {
- highlighter->add_keyword_color(E, keyword_color);
+ highlighter->add_keyword(E, keyword_color, keyword_style);
}
}
/* Member types. */
- const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
+ Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
+ SyntaxHighlighter::SyntaxFontStyle member_variable_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style");
if (instance_base != StringName()) {
List plist;
ClassDB::get_property_list(instance_base, &plist);
@@ -186,44 +196,47 @@ void EditorStandardSyntaxHighlighter::_update_cache() {
if (prop_name.contains("/")) {
continue;
}
- highlighter->add_member_keyword_color(prop_name, member_variable_color);
+ highlighter->add_member_keyword(prop_name, member_variable_color, member_variable_style);
}
List clist;
ClassDB::get_integer_constant_list(instance_base, &clist);
for (const String &E : clist) {
- highlighter->add_member_keyword_color(E, member_variable_color);
+ highlighter->add_member_keyword(E, member_variable_color, member_variable_style);
}
}
/* Comments */
- const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
List comments;
scr_lang->get_comment_delimiters(&comments);
for (const String &comment : comments) {
String beg = comment.get_slice(" ", 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
- highlighter->add_color_region(beg, end, comment_color, end.is_empty());
+ highlighter->add_region(beg, end, comment_color, comment_style, end.is_empty(), true);
}
/* Doc comments */
- const Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
+ Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
+ SyntaxHighlighter::SyntaxFontStyle doc_comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/doc_comment_style");
List doc_comments;
scr_lang->get_doc_comment_delimiters(&doc_comments);
for (const String &doc_comment : doc_comments) {
String beg = doc_comment.get_slice(" ", 0);
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slice(" ", 1) : String();
- highlighter->add_color_region(beg, end, doc_comment_color, end.is_empty());
+ highlighter->add_region(beg, end, doc_comment_color, doc_comment_style, end.is_empty(), true);
}
/* Strings */
- const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ SyntaxHighlighter::SyntaxFontStyle string_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/string_style");
List strings;
scr_lang->get_string_delimiters(&strings);
for (const String &string : strings) {
String beg = string.get_slice(" ", 0);
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
- highlighter->add_color_region(beg, end, string_color, end.is_empty());
+ highlighter->add_region(beg, end, string_color, string_style, end.is_empty(), true);
}
}
}
@@ -246,15 +259,16 @@ Ref EditorPlainTextSyntaxHighlighter::_create() const {
void EditorJSONSyntaxHighlighter::_update_cache() {
highlighter->set_text_edit(text_edit);
- highlighter->clear_keyword_colors();
- highlighter->clear_member_keyword_colors();
- highlighter->clear_color_regions();
+ highlighter->clear_keywords();
+ highlighter->clear_member_keywords();
+ highlighter->clear_regions();
highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/symbol_color"));
highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/number_color"));
- const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
- highlighter->add_color_region("\"", "\"", string_color);
+ Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ SyntaxHighlighter::SyntaxFontStyle string_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/string_style");
+ highlighter->add_region("\"", "\"", string_color, string_style, true);
}
Ref EditorJSONSyntaxHighlighter::_create() const {
@@ -267,9 +281,9 @@ Ref EditorJSONSyntaxHighlighter::_create() const {
void EditorMarkdownSyntaxHighlighter::_update_cache() {
highlighter->set_text_edit(text_edit);
- highlighter->clear_keyword_colors();
- highlighter->clear_member_keyword_colors();
- highlighter->clear_color_regions();
+ highlighter->clear_keywords();
+ highlighter->clear_member_keywords();
+ highlighter->clear_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"));
@@ -279,28 +293,33 @@ void EditorMarkdownSyntaxHighlighter::_update_cache() {
// Headings (any level).
const Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
- highlighter->add_color_region("#", "", function_color);
+ SyntaxHighlighter::SyntaxFontStyle function_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style");
+ highlighter->add_region("#", "", function_color, function_style);
// Bold.
- highlighter->add_color_region("**", "**", function_color);
+ highlighter->add_region("**", "**", function_color, function_style);
// `__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);
+ SyntaxHighlighter::SyntaxFontStyle type_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/engine_type_style");
+ highlighter->add_region("`", "`", code_color, type_style);
// 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);
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
+ highlighter->add_region("[", "]", link_color, keyword_style);
// Quote.
const Color quote_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
- highlighter->add_color_region(">", "", quote_color, true);
+ SyntaxHighlighter::SyntaxFontStyle string_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/string_style");
+ highlighter->add_region(">", "", quote_color, string_style, 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);
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
+ highlighter->add_region("", comment_color, comment_style);
}
Ref EditorMarkdownSyntaxHighlighter::_create() const {
diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp
index 0ff7aaa3fe46..74f84437914a 100644
--- a/editor/plugins/text_shader_editor.cpp
+++ b/editor/plugins/text_shader_editor.cpp
@@ -228,23 +228,29 @@ void ShaderTextEditor::_load_theme_settings() {
}
syntax_highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/number_color"));
+ syntax_highlighter->set_number_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/number_style"));
syntax_highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/symbol_color"));
+ syntax_highlighter->set_symbol_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/symbol_style"));
syntax_highlighter->set_function_color(EDITOR_GET("text_editor/theme/highlighting/function_color"));
+ syntax_highlighter->set_function_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style"));
syntax_highlighter->set_member_variable_color(EDITOR_GET("text_editor/theme/highlighting/member_variable_color"));
+ syntax_highlighter->set_member_variable_style((SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style"));
- syntax_highlighter->clear_keyword_colors();
+ syntax_highlighter->clear_keywords();
- const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
- const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
+ Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle control_flow_keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_style");
List keywords;
ShaderLanguage::get_keyword_list(&keywords);
for (const String &E : keywords) {
if (ShaderLanguage::is_control_flow_keyword(E)) {
- syntax_highlighter->add_keyword_color(E, control_flow_keyword_color);
+ syntax_highlighter->add_keyword(E, control_flow_keyword_color, control_flow_keyword_style);
} else {
- syntax_highlighter->add_keyword_color(E, keyword_color);
+ syntax_highlighter->add_keyword(E, keyword_color, keyword_style);
}
}
@@ -252,7 +258,7 @@ void ShaderTextEditor::_load_theme_settings() {
ShaderPreprocessor::get_keyword_list(&pp_keywords, false);
for (const String &E : pp_keywords) {
- syntax_highlighter->add_keyword_color(E, control_flow_keyword_color);
+ syntax_highlighter->add_keyword(E, control_flow_keyword_color, control_flow_keyword_style);
}
// Colorize built-ins like `COLOR` differently to make them easier
@@ -304,22 +310,25 @@ void ShaderTextEditor::_load_theme_settings() {
}
}
- const Color user_type_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ Color user_type_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ SyntaxHighlighter::SyntaxFontStyle user_type_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/user_type_style");
for (const String &E : built_ins) {
- syntax_highlighter->add_keyword_color(E, user_type_color);
+ syntax_highlighter->add_keyword(E, user_type_color, user_type_style);
}
// Colorize comments.
- const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
- syntax_highlighter->clear_color_regions();
- syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
- syntax_highlighter->add_color_region("//", "", comment_color, true);
-
- const Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
- syntax_highlighter->add_color_region("/**", "*/", doc_comment_color, false);
+ Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
+ syntax_highlighter->clear_regions();
+ syntax_highlighter->add_region("/*", "*/", comment_color, comment_style, false, true);
+ syntax_highlighter->add_region("//", "", comment_color, comment_style, true, true);
+
+ Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
+ SyntaxHighlighter::SyntaxFontStyle doc_comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/doc_comment_style");
+ syntax_highlighter->add_region("/**", "*/", doc_comment_color, doc_comment_style, false, true);
// "/**/" will be treated as the start of the "/**" region, this line is guaranteed to end the color_region.
- syntax_highlighter->add_color_region("/**/", "", comment_color, true);
+ syntax_highlighter->add_region("/**/", "", comment_color, comment_style, true, true);
// Disabled preprocessor branches use translucent text color to be easier to distinguish from comments.
syntax_highlighter->set_disabled_branch_color(Color(EDITOR_GET("text_editor/theme/highlighting/text_color")) * Color(1, 1, 1, 0.5));
@@ -333,8 +342,9 @@ void ShaderTextEditor::_load_theme_settings() {
}
// Colorize preprocessor include strings.
- const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
- syntax_highlighter->add_color_region("\"", "\"", string_color, false);
+ Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
+ SyntaxHighlighter::SyntaxFontStyle string_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/string_style");
+ syntax_highlighter->add_region("\"", "\"", string_color, string_style, false);
if (warnings_panel) {
// Warnings panel.
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 9e1ffaed92ae..e582d846c150 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1383,22 +1383,30 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color");
Color text_color = EDITOR_GET("text_editor/theme/highlighting/text_color");
+
Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle control_flow_keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_style");
Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
Color symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color");
+ SyntaxHighlighter::SyntaxFontStyle symbol_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/symbol_style");
Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
+ SyntaxHighlighter::SyntaxFontStyle function_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style");
Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color");
+ SyntaxHighlighter::SyntaxFontStyle number_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/number_style");
Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
+ SyntaxHighlighter::SyntaxFontStyle members_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style");
expression_box->set_syntax_highlighter(expression_syntax_highlighter);
expression_box->add_theme_color_override("background_color", background_color);
for (const String &E : editor->keyword_list) {
if (ShaderLanguage::is_control_flow_keyword(E)) {
- expression_syntax_highlighter->add_keyword_color(E, control_flow_keyword_color);
+ expression_syntax_highlighter->add_keyword(E, control_flow_keyword_color, control_flow_keyword_style);
} else {
- expression_syntax_highlighter->add_keyword_color(E, keyword_color);
+ expression_syntax_highlighter->add_keyword(E, keyword_color, keyword_style);
}
}
@@ -1409,11 +1417,15 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool
expression_box->end_bulk_theme_override();
expression_syntax_highlighter->set_number_color(number_color);
+ expression_syntax_highlighter->set_number_style(number_style);
expression_syntax_highlighter->set_symbol_color(symbol_color);
+ expression_syntax_highlighter->set_symbol_style(symbol_style);
expression_syntax_highlighter->set_function_color(function_color);
+ expression_syntax_highlighter->set_function_style(function_style);
expression_syntax_highlighter->set_member_variable_color(members_color);
- expression_syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
- expression_syntax_highlighter->add_color_region("//", "", comment_color, true);
+ expression_syntax_highlighter->set_member_variable_style(members_style);
+ expression_syntax_highlighter->add_region("/*", "*/", comment_color, comment_style, false, true);
+ expression_syntax_highlighter->add_region("//", "", comment_color, comment_style, true, true);
expression_box->clear_comment_delimiters();
expression_box->add_comment_delimiter("/*", "*/", false);
@@ -5203,13 +5215,22 @@ void VisualShaderEditor::_notification(int p_what) {
{
Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color");
Color text_color = EDITOR_GET("text_editor/theme/highlighting/text_color");
+
Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle control_flow_keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_style");
Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
Color symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color");
+ SyntaxHighlighter::SyntaxFontStyle symbol_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/symbol_style");
Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
+ SyntaxHighlighter::SyntaxFontStyle function_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style");
Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color");
+ SyntaxHighlighter::SyntaxFontStyle number_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/number_style");
Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
+ SyntaxHighlighter::SyntaxFontStyle members_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style");
+
Color error_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor));
preview_text->add_theme_color_override("background_color", background_color);
@@ -5217,9 +5238,9 @@ void VisualShaderEditor::_notification(int p_what) {
for (const String &E : keyword_list) {
if (ShaderLanguage::is_control_flow_keyword(E)) {
- syntax_highlighter->add_keyword_color(E, control_flow_keyword_color);
+ syntax_highlighter->add_keyword(E, control_flow_keyword_color, control_flow_keyword_style);
} else {
- syntax_highlighter->add_keyword_color(E, keyword_color);
+ syntax_highlighter->add_keyword(E, keyword_color, keyword_style);
}
}
@@ -5230,12 +5251,16 @@ void VisualShaderEditor::_notification(int p_what) {
preview_text->end_bulk_theme_override();
syntax_highlighter->set_number_color(number_color);
+ syntax_highlighter->set_number_style(number_style);
syntax_highlighter->set_symbol_color(symbol_color);
+ syntax_highlighter->set_symbol_style(symbol_style);
syntax_highlighter->set_function_color(function_color);
+ syntax_highlighter->set_function_style(function_style);
syntax_highlighter->set_member_variable_color(members_color);
- syntax_highlighter->clear_color_regions();
- syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
- syntax_highlighter->add_color_region("//", "", comment_color, true);
+ syntax_highlighter->set_member_variable_style(members_style);
+ syntax_highlighter->clear_regions();
+ syntax_highlighter->add_region("/*", "*/", comment_color, comment_style, false, true);
+ syntax_highlighter->add_region("//", "", comment_color, comment_style, true, true);
preview_text->clear_comment_delimiters();
preview_text->add_comment_delimiter("/*", "*/", false);
diff --git a/editor/themes/editor_fonts.cpp b/editor/themes/editor_fonts.cpp
index da35ed332ee8..d44f052b5af6 100644
--- a/editor/themes/editor_fonts.cpp
+++ b/editor/themes/editor_fonts.cpp
@@ -366,6 +366,16 @@ void editor_register_fonts(const Ref &p_theme) {
} break;
}
+ Ref mono_fc_bold = mono_fc->duplicate();
+ mono_fc_bold->set_variation_embolden(0.8);
+
+ Ref mono_fc_italic = mono_fc->duplicate();
+ mono_fc_italic->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
+
+ Ref mono_fc_bold_italic = mono_fc->duplicate();
+ mono_fc_bold_italic->set_variation_embolden(0.8);
+ mono_fc_bold_italic->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0));
+
{
// Disable contextual alternates (coding ligatures).
Dictionary ftrs;
@@ -468,6 +478,9 @@ void editor_register_fonts(const Ref &p_theme) {
// Code font
p_theme->set_font_size("source_size", EditorStringName(EditorFonts), int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE);
p_theme->set_font("source", EditorStringName(EditorFonts), mono_fc);
+ p_theme->set_font("source_bold", EditorStringName(EditorFonts), mono_fc_bold);
+ p_theme->set_font("source_italics", EditorStringName(EditorFonts), mono_fc_italic);
+ p_theme->set_font("source_bold_italics", EditorStringName(EditorFonts), mono_fc_bold_italic);
p_theme->set_font_size("expression_size", EditorStringName(EditorFonts), (int(EDITOR_GET("interface/editor/code_font_size")) - 1) * EDSCALE);
p_theme->set_font("expression", EditorStringName(EditorFonts), mono_other_fc);
diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp
index 7f3adbc1b608..ef764af9cdd6 100644
--- a/editor/themes/editor_theme_manager.cpp
+++ b/editor/themes/editor_theme_manager.cpp
@@ -44,6 +44,7 @@
#include "scene/resources/style_box_flat.h"
#include "scene/resources/style_box_line.h"
#include "scene/resources/style_box_texture.h"
+#include "scene/resources/syntax_highlighter.h"
#include "scene/resources/texture.h"
// Theme configuration.
@@ -2591,14 +2592,23 @@ void EditorThemeManager::_generate_text_editor_defaults(ThemeConfiguration &p_co
/* clang-format off */
setting->set_initial_value("text_editor/theme/highlighting/symbol_color", symbol_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/symbol_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/keyword_color", keyword_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/keyword_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/control_flow_keyword_color", control_flow_keyword_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/control_flow_keyword_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/base_type_color", base_type_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/base_type_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/engine_type_color", engine_type_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/engine_type_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/user_type_color", user_type_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/user_type_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/comment_color", comment_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/comment_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/doc_comment_color", doc_comment_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/doc_comment_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/string_color", string_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/string_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/background_color", te_background_color, true);
setting->set_initial_value("text_editor/theme/highlighting/completion_background_color", completion_background_color, true);
setting->set_initial_value("text_editor/theme/highlighting/completion_selected_color", completion_selected_color, true);
@@ -2618,14 +2628,18 @@ void EditorThemeManager::_generate_text_editor_defaults(ThemeConfiguration &p_co
setting->set_initial_value("text_editor/theme/highlighting/line_length_guideline_color", line_length_guideline_color, true);
setting->set_initial_value("text_editor/theme/highlighting/word_highlighted_color", word_highlighted_color, true);
setting->set_initial_value("text_editor/theme/highlighting/number_color", number_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/number_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/function_color", function_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/function_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/member_variable_color", member_variable_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/member_variable_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/mark_color", mark_color, true);
setting->set_initial_value("text_editor/theme/highlighting/bookmark_color", bookmark_color, true);
setting->set_initial_value("text_editor/theme/highlighting/breakpoint_color", breakpoint_color, true);
setting->set_initial_value("text_editor/theme/highlighting/executing_line_color", executing_line_color, true);
setting->set_initial_value("text_editor/theme/highlighting/code_folding_color", code_folding_color, true);
setting->set_initial_value("text_editor/theme/highlighting/folded_code_region_color", folded_code_region_color, true);
+ setting->set_initial_value("text_editor/theme/highlighting/folded_code_region_style", SyntaxHighlighter::SYNTAX_STYLE_REGULAR, true);
setting->set_initial_value("text_editor/theme/highlighting/search_result_color", search_result_color, true);
setting->set_initial_value("text_editor/theme/highlighting/search_result_border_color", search_result_border_color, true);
/* clang-format on */
@@ -2643,6 +2657,10 @@ void EditorThemeManager::_populate_text_editor_styles(const Ref &p_
p_theme->set_font(SceneStringName(font), "CodeEdit", p_theme->get_font(SNAME("source"), EditorStringName(EditorFonts)));
p_theme->set_font_size(SceneStringName(font_size), "CodeEdit", p_theme->get_font_size(SNAME("source_size"), EditorStringName(EditorFonts)));
+ p_theme->set_font("bold_font", "CodeEdit", p_theme->get_font(SNAME("source_bold"), EditorStringName(EditorFonts)));
+ p_theme->set_font("italics_font", "CodeEdit", p_theme->get_font(SNAME("source_italics"), EditorStringName(EditorFonts)));
+ p_theme->set_font("bold_italics_font", "CodeEdit", p_theme->get_font(SNAME("source_bold_italics"), EditorStringName(EditorFonts)));
+
/* clang-format off */
p_theme->set_icon("tab", "CodeEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));
p_theme->set_icon("space", "CodeEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));
diff --git a/misc/extension_api_validation/4.3-stable.expected b/misc/extension_api_validation/4.3-stable.expected
index c2b54b1e6897..8a998628ecf8 100644
--- a/misc/extension_api_validation/4.3-stable.expected
+++ b/misc/extension_api_validation/4.3-stable.expected
@@ -205,3 +205,12 @@ GH-99481
Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/push_meta/arguments': size changed value in new API, from 2 to 3.
Optional argument added to set tooltip. Compatibility method registered.
+
+
+GH-96588
+--------
+Validate extension JSON: API was removed: classes/CodeHighlighter/properties/color_regions
+Validate extension JSON: API was removed: classes/CodeHighlighter/properties/keyword_colors
+Validate extension JSON: API was removed: classes/CodeHighlighter/properties/member_keyword_colors
+
+Properties replaced with new 'regions', 'keywords', and 'member_keywords'. Compatibility getters/setters for old properties preserved.
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index 629581bd6c34..0c5ddcd77b03 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -76,6 +76,9 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
Color keyword_color;
Color color;
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = SyntaxHighlighter::SYNTAX_STYLE_REGULAR;
+ SyntaxHighlighter::SyntaxFontStyle style = SyntaxHighlighter::SYNTAX_STYLE_REGULAR;
+ bool text_segment = false;
color_region_cache[p_line] = -1;
int in_region = -1;
@@ -93,9 +96,11 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
in_region = color_region_cache[p_line - 1];
}
- const String &str = text_edit->get_line(p_line);
+ const String &str = text_edit->get_line_with_ime(p_line);
const int line_length = str.length();
Color prev_color;
+ SyntaxHighlighter::SyntaxFontStyle prev_style = font_style;
+ bool prev_text_segment = false;
if (in_region != -1 && line_length == 0) {
color_region_cache[p_line] = in_region;
@@ -103,7 +108,9 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
for (int j = 0; j < line_length; j++) {
Dictionary highlighter_info;
+ text_segment = false;
color = font_color;
+ style = font_style;
bool is_char = !is_symbol(str[j]);
bool is_a_symbol = is_symbol(str[j]);
bool is_a_digit = is_digit(str[j]);
@@ -168,7 +175,11 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
}
}
prev_color = color_regions[in_region].color;
+ prev_style = color_regions[in_region].style;
+ prev_text_segment = color_regions[in_region].is_string || color_regions[in_region].is_comment;
highlighter_info["color"] = color_regions[c].color;
+ highlighter_info["style"] = color_regions[c].style;
+ highlighter_info["text_segment"] = color_regions[c].is_string || color_regions[c].is_comment;
color_map[j] = highlighter_info;
j = line_length;
@@ -188,18 +199,30 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
// If we are in one, find the end key.
if (in_region != -1) {
Color region_color = color_regions[in_region].color;
+ SyntaxHighlighter::SyntaxFontStyle region_style = color_regions[in_region].style;
+ bool region_text_segment = color_regions[in_region].is_string || color_regions[in_region].is_comment;
if (in_node_path && color_regions[in_region].type == ColorRegion::TYPE_STRING) {
region_color = node_path_color;
+ region_style = node_path_style;
+ region_text_segment = false;
}
if (in_node_ref && color_regions[in_region].type == ColorRegion::TYPE_STRING) {
region_color = node_ref_color;
+ region_style = node_ref_style;
+ region_text_segment = false;
}
if (in_string_name && color_regions[in_region].type == ColorRegion::TYPE_STRING) {
region_color = string_name_color;
+ region_style = string_name_style;
+ region_text_segment = false;
}
prev_color = region_color;
+ prev_style = region_style;
+ prev_text_segment = region_text_segment;
highlighter_info["color"] = region_color;
+ highlighter_info["style"] = region_style;
+ highlighter_info["text_segment"] = region_text_segment;
color_map[j] = highlighter_info;
if (color_regions[in_region].is_comment) {
@@ -213,11 +236,15 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
HashMap::ConstIterator E = comment_markers.find(str.substr(marker_start_pos, marker_len));
if (E) {
Dictionary marker_highlighter_info;
- marker_highlighter_info["color"] = comment_marker_colors[E->value];
+ marker_highlighter_info["color"] = comment_marker_colors[E->value].color;
+ marker_highlighter_info["style"] = comment_marker_colors[E->value].style;
+ marker_highlighter_info["text_segment"] = true;
color_map[marker_start_pos] = marker_highlighter_info;
Dictionary marker_continue_highlighter_info;
marker_continue_highlighter_info["color"] = region_color;
+ marker_continue_highlighter_info["style"] = region_style;
+ marker_continue_highlighter_info["text_segment"] = region_text_segment;
color_map[from] = marker_continue_highlighter_info;
}
}
@@ -249,6 +276,8 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
if (!color_regions[in_region].r_prefix) {
Dictionary escape_char_highlighter_info;
escape_char_highlighter_info["color"] = symbol_color;
+ escape_char_highlighter_info["style"] = symbol_style;
+ escape_char_highlighter_info["text_segment"] = true;
color_map[from] = escape_char_highlighter_info;
}
@@ -270,6 +299,8 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
Dictionary region_continue_highlighter_info;
region_continue_highlighter_info["color"] = region_color;
+ region_continue_highlighter_info["style"] = region_style;
+ region_continue_highlighter_info["text_segment"] = region_text_segment;
color_map[from + 1] = region_continue_highlighter_info;
}
@@ -397,10 +428,12 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
String word = str.substr(j, to - j);
Color col;
+ SyntaxHighlighter::SyntaxFontStyle sty = SyntaxHighlighter::SYNTAX_STYLE_REGULAR;
if (global_functions.has(word)) {
// "assert" and "preload" are reserved, so highlight even if not followed by a bracket.
if (word == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::ASSERT) || word == GDScriptTokenizer::get_token_name(GDScriptTokenizer::Token::PRELOAD)) {
col = global_function_color;
+ sty = global_function_style;
} else {
// For other global functions, check if followed by bracket.
int k = to;
@@ -410,16 +443,20 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
if (str[k] == '(') {
col = global_function_color;
+ sty = global_function_style;
}
}
} else if (class_names.has(word)) {
- col = class_names[word];
+ col = class_names[word].color;
+ sty = class_names[word].style;
} else if (reserved_keywords.has(word)) {
- col = reserved_keywords[word];
+ col = reserved_keywords[word].color;
+ sty = reserved_keywords[word].style;
// Don't highlight `list` as a type in `for elem: Type in list`.
expect_type = false;
} else if (member_keywords.has(word)) {
- col = member_keywords[word];
+ col = member_keywords[word].color;
+ sty = member_keywords[word].style;
}
if (col != Color()) {
@@ -435,6 +472,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
if (col != Color()) {
in_keyword = true;
keyword_color = col;
+ keyword_style = sty;
}
}
}
@@ -595,43 +633,68 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
if (in_raw_string_prefix) {
color = string_color;
+ style = string_style;
+ text_segment = true;
} else if (in_node_ref) {
next_type = NODE_REF;
color = node_ref_color;
+ style = node_ref_style;
+ text_segment = false;
} else if (in_annotation) {
next_type = ANNOTATION;
color = annotation_color;
+ style = annotation_style;
+ text_segment = false;
} else if (in_string_name) {
next_type = STRING_NAME;
color = string_name_color;
+ style = string_name_style;
+ text_segment = false;
} else if (in_node_path) {
next_type = NODE_PATH;
color = node_path_color;
+ style = node_path_style;
+ text_segment = false;
} else if (in_keyword) {
next_type = KEYWORD;
color = keyword_color;
+ style = keyword_style;
+ text_segment = false;
} else if (in_signal_declaration) {
next_type = SIGNAL;
color = member_color;
+ style = member_style;
+ text_segment = false;
} else if (in_function_name) {
next_type = FUNCTION;
if (!in_lambda && in_function_declaration) {
color = function_definition_color;
+ style = function_definition_style;
} else {
color = function_color;
+ style = function_style;
}
+ text_segment = false;
} else if (in_number) {
next_type = NUMBER;
color = number_color;
+ style = number_style;
+ text_segment = false;
} else if (is_a_symbol) {
next_type = SYMBOL;
color = symbol_color;
+ style = symbol_style;
+ text_segment = false;
} else if (expect_type) {
next_type = TYPE;
color = type_color;
+ style = type_style;
+ text_segment = false;
} else if (in_member_variable) {
next_type = MEMBER;
color = member_color;
+ style = member_style;
+ text_segment = false;
} else {
next_type = IDENTIFIER;
}
@@ -663,9 +726,13 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l
prev_is_digit = is_a_digit;
prev_is_binary_op = is_binary_op;
- if (color != prev_color) {
+ if (color != prev_color || style != prev_style || text_segment != prev_text_segment) {
prev_color = color;
+ prev_style = style;
+ prev_text_segment = text_segment;
highlighter_info["color"] = color;
+ highlighter_info["style"] = style;
+ highlighter_info["text_segment"] = text_segment;
color_map[j] = highlighter_info;
}
}
@@ -692,68 +759,96 @@ void GDScriptSyntaxHighlighter::_update_cache() {
font_color = text_edit->get_theme_color(SceneStringName(font_color));
symbol_color = EDITOR_GET("text_editor/theme/highlighting/symbol_color");
+ symbol_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/symbol_style");
function_color = EDITOR_GET("text_editor/theme/highlighting/function_color");
+ function_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/function_style");
+
number_color = EDITOR_GET("text_editor/theme/highlighting/number_color");
+ number_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/number_style");
member_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color");
+ member_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/member_variable_style");
/* Engine types. */
- const Color types_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
+ Color types_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
+ SyntaxHighlighter::SyntaxFontStyle types_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/engine_type_style");
List types;
ClassDB::get_class_list(&types);
for (const StringName &E : types) {
if (ClassDB::is_class_exposed(E)) {
- class_names[E] = types_color;
+ class_names[E].color = types_color;
+ class_names[E].style = types_style;
}
}
/* User types. */
- const Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
+ SyntaxHighlighter::SyntaxFontStyle usertype_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/user_type_style");
List global_classes;
ScriptServer::get_global_class_list(&global_classes);
for (const StringName &E : global_classes) {
- class_names[E] = usertype_color;
+ class_names[E].color = usertype_color;
+ class_names[E].style = usertype_style;
}
/* Autoloads. */
for (const KeyValue &E : ProjectSettings::get_singleton()->get_autoload_list()) {
const ProjectSettings::AutoloadInfo &info = E.value;
if (info.is_singleton) {
- class_names[info.name] = usertype_color;
+ class_names[info.name].color = usertype_color;
+ class_names[info.name].style = usertype_style;
}
}
const GDScriptLanguage *gdscript = GDScriptLanguage::get_singleton();
/* Core types. */
- const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
+ Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color");
+ SyntaxHighlighter::SyntaxFontStyle basetype_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/base_type_style");
List core_types;
gdscript->get_core_type_words(&core_types);
for (const String &E : core_types) {
- class_names[StringName(E)] = basetype_color;
+ class_names[StringName(E)].color = basetype_color;
+ class_names[StringName(E)].style = basetype_style;
}
- class_names[SNAME("Variant")] = basetype_color;
- class_names[SNAME("void")] = basetype_color;
+ class_names[SNAME("Variant")].color = basetype_color;
+ class_names[SNAME("Variant")].style = basetype_style;
+
+ class_names[SNAME("void")].color = basetype_color;
+ class_names[SNAME("void")].style = basetype_style;
+
// `get_core_type_words()` doesn't return primitive types.
- class_names[SNAME("bool")] = basetype_color;
- class_names[SNAME("int")] = basetype_color;
- class_names[SNAME("float")] = basetype_color;
+ class_names[SNAME("bool")].color = basetype_color;
+ class_names[SNAME("bool")].style = basetype_style;
+
+ class_names[SNAME("int")].color = basetype_color;
+ class_names[SNAME("int")].style = basetype_style;
+
+ class_names[SNAME("float")].color = basetype_color;
+ class_names[SNAME("float")].style = basetype_style;
/* Reserved words. */
- const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
- const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/keyword_style");
+ Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
+ SyntaxHighlighter::SyntaxFontStyle control_flow_keyword_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_style");
List keyword_list;
gdscript->get_reserved_words(&keyword_list);
for (const String &E : keyword_list) {
if (gdscript->is_control_flow_keyword(E)) {
- reserved_keywords[StringName(E)] = control_flow_keyword_color;
+ reserved_keywords[StringName(E)].color = control_flow_keyword_color;
+ reserved_keywords[StringName(E)].style = control_flow_keyword_style;
} else {
- reserved_keywords[StringName(E)] = keyword_color;
+ reserved_keywords[StringName(E)].color = keyword_color;
+ reserved_keywords[StringName(E)].style = keyword_style;
}
}
// Highlight `set` and `get` as "keywords" with the function color to avoid conflicts with method calls.
- reserved_keywords[SNAME("set")] = function_color;
- reserved_keywords[SNAME("get")] = function_color;
+ reserved_keywords[SNAME("set")].color = function_color;
+ reserved_keywords[SNAME("set")].style = function_style;
+
+ reserved_keywords[SNAME("get")].color = function_color;
+ reserved_keywords[SNAME("get")].style = function_style;
/* Global functions. */
List global_function_list;
@@ -767,45 +862,48 @@ void GDScriptSyntaxHighlighter::_update_cache() {
}
/* Comments */
- const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
+ SyntaxHighlighter::SyntaxFontStyle comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/comment_style");
List comments;
gdscript->get_comment_delimiters(&comments);
for (const String &comment : comments) {
String beg = comment.get_slice(" ", 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
- add_color_region(ColorRegion::TYPE_COMMENT, beg, end, comment_color, end.is_empty());
+ add_color_region(ColorRegion::TYPE_COMMENT, beg, end, comment_color, comment_style, end.is_empty());
}
/* Doc comments */
- const Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
+ Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color");
+ SyntaxHighlighter::SyntaxFontStyle doc_comment_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/doc_comment_style");
List doc_comments;
gdscript->get_doc_comment_delimiters(&doc_comments);
for (const String &doc_comment : doc_comments) {
String beg = doc_comment.get_slice(" ", 0);
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slice(" ", 1) : String();
- add_color_region(ColorRegion::TYPE_COMMENT, beg, end, doc_comment_color, end.is_empty());
+ add_color_region(ColorRegion::TYPE_COMMENT, beg, end, doc_comment_color, doc_comment_style, end.is_empty());
}
/* Code regions */
- const Color code_region_color = Color(EDITOR_GET("text_editor/theme/highlighting/folded_code_region_color").operator Color(), 1.0);
- add_color_region(ColorRegion::TYPE_CODE_REGION, "#region", "", code_region_color, true);
- add_color_region(ColorRegion::TYPE_CODE_REGION, "#endregion", "", code_region_color, true);
+ Color code_region_color = Color(EDITOR_GET("text_editor/theme/highlighting/folded_code_region_color").operator Color(), 1.0);
+ SyntaxHighlighter::SyntaxFontStyle code_region_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/folded_code_region_style");
+ add_color_region(ColorRegion::TYPE_CODE_REGION, "#region", "", code_region_color, code_region_style, true);
+ add_color_region(ColorRegion::TYPE_CODE_REGION, "#endregion", "", code_region_color, code_region_style, true);
/* Strings */
string_color = EDITOR_GET("text_editor/theme/highlighting/string_color");
- add_color_region(ColorRegion::TYPE_STRING, "\"", "\"", string_color);
- add_color_region(ColorRegion::TYPE_STRING, "'", "'", string_color);
- add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "\"\"\"", "\"\"\"", string_color);
- add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "'''", "'''", string_color);
- add_color_region(ColorRegion::TYPE_STRING, "\"", "\"", string_color, false, true);
- add_color_region(ColorRegion::TYPE_STRING, "'", "'", string_color, false, true);
- add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "\"\"\"", "\"\"\"", string_color, false, true);
- add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "'''", "'''", string_color, false, true);
+ string_style = (SyntaxHighlighter::SyntaxFontStyle)(int)EDITOR_GET("text_editor/theme/highlighting/string_style");
+ add_color_region(ColorRegion::TYPE_STRING, "\"", "\"", string_color, string_style);
+ add_color_region(ColorRegion::TYPE_STRING, "'", "'", string_color, string_style);
+ add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "\"\"\"", "\"\"\"", string_color, string_style);
+ add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "'''", "'''", string_color, string_style);
+ add_color_region(ColorRegion::TYPE_STRING, "\"", "\"", string_color, string_style, false, true);
+ add_color_region(ColorRegion::TYPE_STRING, "'", "'", string_color, string_style, false, true);
+ add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "\"\"\"", "\"\"\"", string_color, string_style, false, true);
+ add_color_region(ColorRegion::TYPE_MULTILINE_STRING, "'''", "'''", string_color, string_style, false, true);
const Ref