summaryrefslogtreecommitdiff
path: root/editor/code_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r--editor/code_editor.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 4c7f2f53cc..665ce7658f 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -373,7 +373,6 @@ void FindReplaceBar::_hide_bar() {
void FindReplaceBar::_show_search() {
- hide(); // to update size correctly
show();
search_text->grab_focus();
@@ -481,7 +480,7 @@ void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) {
void FindReplaceBar::_update_size() {
- container->set_custom_minimum_size(Size2(0, hbc->get_size().height));
+ container->set_size(Size2(hbc->get_size().width, 1));
}
void FindReplaceBar::_bind_methods() {
@@ -507,7 +506,8 @@ void FindReplaceBar::_bind_methods() {
FindReplaceBar::FindReplaceBar() {
- container = memnew(Control);
+ container = memnew(MarginContainer);
+ container->add_constant_override("margin_bottom", 5 * EDSCALE);
add_child(container);
container->set_clip_contents(true);
container->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -592,8 +592,7 @@ FindReplaceBar::FindReplaceBar() {
add_child(hide_button);
hide_button->set_focus_mode(FOCUS_NONE);
hide_button->connect("pressed", this, "_hide_pressed");
- hide_button->set_expand(true);
- hide_button->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
+ hide_button->set_v_size_flags(SIZE_SHRINK_CENTER);
}
/*** CODE EDITOR ****/
@@ -650,12 +649,12 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
}
void CodeTextEditor::_zoom_in() {
- font_resize_val += EDSCALE;
+ font_resize_val += MAX(EDSCALE, 1.0f);
_zoom_changed();
}
void CodeTextEditor::_zoom_out() {
- font_resize_val -= EDSCALE;
+ font_resize_val -= MAX(EDSCALE, 1.0f);
_zoom_changed();
}
@@ -677,7 +676,20 @@ void CodeTextEditor::_reset_zoom() {
void CodeTextEditor::_line_col_changed() {
line_nb->set_text(itos(text_editor->cursor_get_line() + 1));
- col_nb->set_text(itos(text_editor->cursor_get_column() + 1));
+
+ String line = text_editor->get_line(text_editor->cursor_get_line());
+
+ int positional_column = 0;
+
+ for (int i = 0; i < text_editor->cursor_get_column(); i++) {
+ if (line[i] == '\t') {
+ positional_column += text_editor->get_indent_size(); //tab size
+ } else {
+ positional_column += 1;
+ }
+ }
+
+ col_nb->set_text(itos(positional_column + 1));
}
void CodeTextEditor::_text_changed() {
@@ -766,6 +778,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
+ text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/word_wrap"));
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));