summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/code_editor.cpp5
-rw-r--r--editor/editor_settings.cpp8
-rw-r--r--editor/plugins/shader_editor_plugin.cpp5
-rw-r--r--scene/gui/text_edit.cpp34
-rw-r--r--scene/gui/text_edit.h10
5 files changed, 41 insertions, 21 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index e898bc54dd..8e44c6c244 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -915,8 +915,9 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_hiding_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_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline"));
- text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column"));
+ 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"));
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index d81b9bbb82..ea93c0fff0 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -456,9 +456,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/appearance/show_info_gutter", true);
_initial_set("text_editor/appearance/code_folding", true);
_initial_set("text_editor/appearance/word_wrap", false);
- _initial_set("text_editor/appearance/show_line_length_guideline", true);
- _initial_set("text_editor/appearance/line_length_guideline_column", 80);
- hints["text_editor/appearance/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 1");
+ _initial_set("text_editor/appearance/show_line_length_guidelines", true);
+ _initial_set("text_editor/appearance/line_length_guideline_soft_column", 80);
+ hints["text_editor/appearance/line_length_guideline_soft_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_soft_column", PROPERTY_HINT_RANGE, "20, 160, 1");
+ _initial_set("text_editor/appearance/line_length_guideline_hard_column", 100);
+ hints["text_editor/appearance/line_length_guideline_hard_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_hard_column", PROPERTY_HINT_RANGE, "20, 160, 1");
// Script list
_initial_set("text_editor/script_list/show_members_overview", true);
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index a19f0b4975..0210bfff70 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -382,8 +382,9 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
shader_editor->get_text_edit()->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap"));
shader_editor->get_text_edit()->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE);
- shader_editor->get_text_edit()->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline"));
- shader_editor->get_text_edit()->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column"));
+ shader_editor->get_text_edit()->set_show_line_length_guidelines(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines"));
+ shader_editor->get_text_edit()->set_line_length_guideline_soft_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_soft_column"));
+ shader_editor->get_text_edit()->set_line_length_guideline_hard_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_hard_column"));
shader_editor->get_text_edit()->set_breakpoint_gutter_enabled(false);
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index a5c316848e..92da21af84 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -753,10 +753,18 @@ void TextEdit::_notification(int p_what) {
}
}
- if (line_length_guideline) {
- int x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs;
- if (x > xmargin_beg && x < xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, size.height), cache.line_length_guideline_color);
+ if (line_length_guidelines) {
+ const int hard_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_hard_col - cursor.x_ofs;
+ if (hard_x > xmargin_beg && hard_x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color);
+ }
+
+ // Draw a "Soft" line length guideline, less visible than the hard line length guideline.
+ // It's usually set to a lower column compared to the hard line length guideline.
+ // Only drawn if its column differs from the hard line length guideline.
+ const int soft_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_soft_col - cursor.x_ofs;
+ if (hard_x != soft_x && soft_x > xmargin_beg && soft_x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5));
}
}
@@ -6798,13 +6806,18 @@ bool TextEdit::is_show_line_numbers_enabled() const {
return line_numbers;
}
-void TextEdit::set_show_line_length_guideline(bool p_show) {
- line_length_guideline = p_show;
+void TextEdit::set_show_line_length_guidelines(bool p_show) {
+ line_length_guidelines = p_show;
+ update();
+}
+
+void TextEdit::set_line_length_guideline_soft_column(int p_column) {
+ line_length_guideline_soft_col = p_column;
update();
}
-void TextEdit::set_line_length_guideline_column(int p_column) {
- line_length_guideline_col = p_column;
+void TextEdit::set_line_length_guideline_hard_column(int p_column) {
+ line_length_guideline_hard_col = p_column;
update();
}
@@ -7273,8 +7286,9 @@ TextEdit::TextEdit() {
tooltip_obj = NULL;
line_numbers = false;
line_numbers_zero_padded = false;
- line_length_guideline = false;
- line_length_guideline_col = 80;
+ line_length_guidelines = false;
+ line_length_guideline_soft_col = 80;
+ line_length_guideline_hard_col = 100;
draw_bookmark_gutter = false;
draw_breakpoint_gutter = false;
draw_fold_gutter = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index a849f62bc5..4a4ac3392e 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -369,8 +369,9 @@ private:
bool undo_enabled;
bool line_numbers;
bool line_numbers_zero_padded;
- bool line_length_guideline;
- int line_length_guideline_col;
+ bool line_length_guidelines;
+ int line_length_guideline_soft_col;
+ int line_length_guideline_hard_col;
bool draw_bookmark_gutter;
bool draw_breakpoint_gutter;
int breakpoint_gutter_width;
@@ -765,8 +766,9 @@ public:
void set_line_numbers_zero_padded(bool p_zero_padded);
- void set_show_line_length_guideline(bool p_show);
- void set_line_length_guideline_column(int p_column);
+ void set_show_line_length_guidelines(bool p_show);
+ void set_line_length_guideline_soft_column(int p_column);
+ void set_line_length_guideline_hard_column(int p_column);
void set_bookmark_gutter_enabled(bool p_draw);
bool is_bookmark_gutter_enabled() const;