Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate remaining features into CodeEdit #50122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 154 additions & 12 deletions doc/classes/CodeEdit.xml

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions doc/classes/TextEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
A virtual method that is called whenever backspace is triggered.
</description>
</method>
<method name="_handle_unicode_input" qualifiers="virtual">
<return type="void" />
<argument index="0" name="unicode" type="int" />
<description>
</description>
</method>
<method name="add_gutter">
<return type="void" />
<argument index="0" name="at" type="int" default="-1" />
Expand Down Expand Up @@ -256,6 +262,11 @@
Returns the [TextEdit]'s' tab size.
</description>
</method>
<method name="get_total_gutter_width" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="get_visible_line_count" qualifiers="const">
<return type="int" />
<description>
Expand All @@ -281,6 +292,11 @@
Returns [code]true[/code] if the caret is visible on the screen.
</description>
</method>
<method name="is_dragging_cursor" qualifiers="const">
<return type="bool" />
<description>
</description>
</method>
<method name="is_gutter_clickable" qualifiers="const">
<return type="bool" />
<argument index="0" name="gutter" type="int" />
Expand Down Expand Up @@ -654,18 +670,6 @@
<description>
</description>
</signal>
<signal name="symbol_lookup">
<argument index="0" name="symbol" type="String" />
<argument index="1" name="row" type="int" />
<argument index="2" name="column" type="int" />
<description>
</description>
</signal>
<signal name="symbol_validate">
<argument index="0" name="symbol" type="String" />
<description>
</description>
</signal>
<signal name="text_changed">
<description>
Emitted when the text changes.
Expand Down Expand Up @@ -790,8 +794,6 @@
<theme_item name="background_color" type="Color" default="Color(0, 0, 0, 0)">
Sets the background [Color] of this [TextEdit].
</theme_item>
<theme_item name="brace_mismatch_color" type="Color" default="Color(1, 0.2, 0.2, 1)">
</theme_item>
<theme_item name="caret_background_color" type="Color" default="Color(0, 0, 0, 1)">
</theme_item>
<theme_item name="caret_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)">
Expand Down
25 changes: 12 additions & 13 deletions editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,20 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_line_folding_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/word_wrap"));
text_editor->set_show_line_length_guidelines(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines"));
text_editor->set_line_length_guideline_soft_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column"));
text_editor->set_line_length_guideline_hard_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_hard_column"));
text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
text_editor->set_auto_brace_completion_enabled(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));

if (EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines")) {
TypedArray<int> guideline_cols;
guideline_cols.append(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_hard_column"));
if (EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column") != guideline_cols[0]) {
guideline_cols.append(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column"));
}
text_editor->set_line_length_guidelines(guideline_cols);
}
}

void CodeTextEditor::set_find_replace_bar(FindReplaceBar *p_bar) {
Expand Down Expand Up @@ -1609,16 +1615,9 @@ void CodeTextEditor::_apply_settings_change() {
} break;
}

// Auto brace completion.
text_editor->set_auto_brace_completion(
EDITOR_GET("text_editor/completion/auto_brace_complete"));

code_complete_timer->set_wait_time(
EDITOR_GET("text_editor/completion/code_complete_delay"));

// Call hint settings.
text_editor->set_code_hint_draw_below(EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line"));

code_complete_timer->set_wait_time(EDITOR_GET("text_editor/completion/code_complete_delay"));
idle->set_wait_time(EDITOR_GET("text_editor/completion/idle_parse_delay"));
}

Expand Down Expand Up @@ -1832,7 +1831,7 @@ CodeTextEditor::CodeTextEditor() {
}

text_editor->set_draw_line_numbers(true);
text_editor->set_brace_matching(true);
text_editor->set_highlight_matching_braces_enabled(true);
text_editor->set_auto_indent_enabled(true);

status_bar = memnew(HBoxContainer);
Expand Down
29 changes: 19 additions & 10 deletions editor/plugins/script_text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ void ScriptTextEditor::_set_theme_for_script() {
for (const String &string : strings) {
String beg = string.get_slice(" ", 0);
String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String();
text_edit->add_string_delimiter(beg, end, end == "");
if (!text_edit->has_string_delimiter(beg)) {
text_edit->add_string_delimiter(beg, end, end == "");
}

if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) {
text_edit->add_auto_brace_completion_pair(beg, end);
}
}

List<String> comments;
Expand All @@ -214,6 +220,10 @@ void ScriptTextEditor::_set_theme_for_script() {
String beg = comment.get_slice(" ", 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
text_edit->add_comment_delimiter(beg, end, end == "");

if (!end.is_empty() && !text_edit->has_auto_brace_completion_open_key(beg)) {
text_edit->add_auto_brace_completion_pair(beg, end);
}
}
}

Expand Down Expand Up @@ -742,7 +752,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
EditorNode::get_singleton()->load_resource(p_symbol);
}

} else if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) {
} else if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_symbol_lookup(), p_symbol, script->get_path(), base, result) == OK) {
_goto_line(p_row);

result.class_name = result.class_name.trim_prefix("_");
Expand Down Expand Up @@ -845,18 +855,17 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
}

ScriptLanguage::LookupResult result;
if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK || (ProjectSettings::get_singleton()->has_autoload(p_symbol) && ProjectSettings::get_singleton()->get_autoload(p_symbol).is_singleton)) {
text_edit->set_highlighted_word(p_symbol);
if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_symbol_lookup(), p_symbol, script->get_path(), base, result) == OK || (ProjectSettings::get_singleton()->has_autoload(p_symbol) && ProjectSettings::get_singleton()->get_autoload(p_symbol).is_singleton)) {
text_edit->set_symbol_lookup_word_as_valid(true);
} else if (p_symbol.is_rel_path()) {
String path = _get_absolute_path(p_symbol);
if (FileAccess::exists(path)) {
text_edit->set_highlighted_word(p_symbol);
text_edit->set_symbol_lookup_word_as_valid(true);
} else {
text_edit->set_highlighted_word(String());
text_edit->set_symbol_lookup_word_as_valid(false);
}

} else {
text_edit->set_highlighted_word(String());
text_edit->set_symbol_lookup_word_as_valid(false);
}
}

Expand Down Expand Up @@ -1544,7 +1553,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
base = _find_node_for_script(base, base, script);
}
ScriptLanguage::LookupResult result;
if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_lookup_completion(), word_at_pos, script->get_path(), base, result) == OK) {
if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_symbol_lookup(), word_at_pos, script->get_path(), base, result) == OK) {
open_docs = true;
}
}
Expand Down Expand Up @@ -1829,7 +1838,7 @@ ScriptTextEditor::ScriptTextEditor() {

code_editor->get_text_editor()->set_code_hint_draw_below(EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"));

code_editor->get_text_editor()->set_select_identifiers_on_hover(true);
code_editor->get_text_editor()->set_symbol_lookup_on_click_enabled(true);
code_editor->get_text_editor()->set_context_menu_enabled(false);

context_menu = memnew(PopupMenu);
Expand Down
6 changes: 5 additions & 1 deletion editor/plugins/shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ void ShaderTextEditor::_load_theme_settings() {
text_editor->add_comment_delimiter("/*", "*/", false);
text_editor->add_comment_delimiter("//", "", true);

if (!text_editor->has_auto_brace_completion_open_key("/*")) {
text_editor->add_auto_brace_completion_pair("/*", "*/");
}

if (warnings_panel) {
// Warnings panel
warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts")));
Expand Down Expand Up @@ -659,7 +663,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {

shader_editor->get_text_editor()->set_code_hint_draw_below(EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"));

shader_editor->get_text_editor()->set_select_identifiers_on_hover(true);
shader_editor->get_text_editor()->set_symbol_lookup_on_click_enabled(true);
shader_editor->get_text_editor()->set_context_menu_enabled(false);
shader_editor->get_text_editor()->connect("gui_input", callable_mp(this, &ShaderEditor::_text_edit_gui_input));

Expand Down
4 changes: 4 additions & 0 deletions editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
expression_box->add_comment_delimiter("/*", "*/", false);
expression_box->add_comment_delimiter("//", "", true);

if (!expression_box->has_auto_brace_completion_open_key("/*")) {
expression_box->add_auto_brace_completion_pair("/*", "*/");
}

expression_box->set_text(expression);
expression_box->set_context_menu_enabled(false);
expression_box->set_draw_line_numbers(true);
Expand Down
Loading