From da356eca0f386c94ba38677a63c6215bf0b4f590 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Mon, 7 Mar 2016 02:32:51 +0000 Subject: [PATCH] Enabled scrolling past end of file (cherry picked from commit f19eea2f2d01cdfd671f16436eb639b46908b150) --- scene/gui/text_edit.cpp | 6 +++++- scene/gui/text_edit.h | 5 +++++ tools/editor/editor_settings.cpp | 2 ++ tools/editor/plugins/script_editor_plugin.cpp | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 5d7436517f7..bb15659e704 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -290,7 +290,10 @@ void TextEdit::_update_scrollbars() { int hscroll_rows = ((hmin.height-1)/get_row_height())+1; int visible_rows = get_visible_rows(); int total_rows = text.size(); - + if (scroll_past_end_of_file_enabled) { + total_rows += get_visible_rows() - 1; + } + int vscroll_pixels = v_scroll->get_combined_minimum_size().width; int visible_width = size.width - cache.style_normal->get_minimum_size().width; int total_width = text.get_max_width() + vmin.x; @@ -3969,6 +3972,7 @@ TextEdit::TextEdit() { tooltip_obj=NULL; line_numbers=false; next_operation_is_complex=false; + scroll_past_end_of_file_enabled=false; auto_brace_completion_enabled=false; brace_matching_enabled=false; auto_indent=false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 44e780aaf3e..8d0efc406a0 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -211,6 +211,7 @@ class TextEdit : public Control { bool undo_enabled; bool line_numbers; + bool scroll_past_end_of_file_enabled; bool auto_brace_completion_enabled; bool brace_matching_enabled; bool auto_indent; @@ -322,6 +323,10 @@ public: void set_line(int line, String new_text); void backspace_at_cursor(); + inline void set_scroll_pass_end_of_file(bool p_enabled) { + scroll_past_end_of_file_enabled = p_enabled; + update(); + } inline void set_auto_brace_completion(bool p_enabled) { auto_brace_completion_enabled = p_enabled; } diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index f8a4ecc8d9f..e70a50788f6 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -482,6 +482,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { set("text_editor/brace_mismatch_color",Color(1,0.2,0.2)); set("text_editor/current_line_color",Color(0.3,0.5,0.8,0.15)); + set("text_editor/scroll_past_end_of_file", false); + set("text_editor/idle_parse_delay",2); set("text_editor/create_signal_callbacks",true); set("text_editor/autosave_interval_secs",0); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index e3dce0b36a3..4be8b3f95ce 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1927,6 +1927,7 @@ void ScriptEditor::edit(const Ref