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.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 7bf82fbd1b..c024c909a3 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -127,7 +127,7 @@ void FindReplaceBar::unhandled_input(const Ref<InputEvent> &p_event) {
bool accepted = true;
switch (k->get_keycode()) {
- case KEY_ESCAPE: {
+ case Key::ESCAPE: {
_hide_bar();
} break;
default: {
@@ -542,7 +542,7 @@ void FindReplaceBar::_search_text_changed(const String &p_text) {
}
void FindReplaceBar::_search_text_submitted(const String &p_text) {
- if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
search_prev();
} else {
search_next();
@@ -553,7 +553,7 @@ void FindReplaceBar::_replace_text_submitted(const String &p_text) {
if (selection_only->is_pressed() && text_editor->has_selection()) {
_replace_all();
_hide_bar();
- } else if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ } else if (Input::get_singleton()->is_key_pressed(Key::SHIFT)) {
_replace();
search_prev();
} else {
@@ -624,7 +624,7 @@ FindReplaceBar::FindReplaceBar() {
vbc_lineedit = memnew(VBoxContainer);
add_child(vbc_lineedit);
- vbc_lineedit->set_alignment(ALIGN_CENTER);
+ vbc_lineedit->set_alignment(BoxContainer::ALIGNMENT_CENTER);
vbc_lineedit->set_h_size_flags(SIZE_EXPAND_FILL);
VBoxContainer *vbc_button = memnew(VBoxContainer);
add_child(vbc_button);
@@ -633,10 +633,10 @@ FindReplaceBar::FindReplaceBar() {
HBoxContainer *hbc_button_search = memnew(HBoxContainer);
vbc_button->add_child(hbc_button_search);
- hbc_button_search->set_alignment(ALIGN_END);
+ hbc_button_search->set_alignment(BoxContainer::ALIGNMENT_END);
hbc_button_replace = memnew(HBoxContainer);
vbc_button->add_child(hbc_button_replace);
- hbc_button_replace->set_alignment(ALIGN_END);
+ hbc_button_replace->set_alignment(BoxContainer::ALIGNMENT_END);
HBoxContainer *hbc_option_search = memnew(HBoxContainer);
vbc_option->add_child(hbc_option_search);
@@ -766,9 +766,9 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid()) {
if (mb->is_pressed() && mb->is_command_pressed()) {
- if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) {
+ if (mb->get_button_index() == MouseButton::WHEEL_UP) {
_zoom_in();
- } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) {
+ } else if (mb->get_button_index() == MouseButton::WHEEL_DOWN) {
_zoom_out();
}
}
@@ -1314,10 +1314,10 @@ void CodeTextEditor::delete_lines() {
int count = Math::abs(to_line - from_line) + 1;
text_editor->set_caret_line(from_line, false);
+ text_editor->deselect();
for (int i = 0; i < count; i++) {
_delete_line(from_line);
}
- text_editor->deselect();
} else {
_delete_line(text_editor->get_caret_line());
}
@@ -1534,7 +1534,7 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
void CodeTextEditor::set_error(const String &p_error) {
error->set_text(p_error);
- if (p_error != "") {
+ if (!p_error.is_empty()) {
error->set_default_cursor_shape(CURSOR_POINTING_HAND);
} else {
error->set_default_cursor_shape(CURSOR_ARROW);
@@ -1547,7 +1547,7 @@ void CodeTextEditor::set_error_pos(int p_line, int p_column) {
}
void CodeTextEditor::goto_error() {
- if (error->get_text() != "") {
+ if (!error->get_text().is_empty()) {
text_editor->unfold_line(error_line);
text_editor->set_caret_line(error_line);
text_editor->set_caret_column(error_column);
@@ -1654,7 +1654,7 @@ void CodeTextEditor::_toggle_scripts_pressed() {
void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) {
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
goto_error();
}
}
@@ -1788,9 +1788,9 @@ void CodeTextEditor::update_toggle_scripts_button() {
CodeTextEditor::CodeTextEditor() {
code_complete_func = nullptr;
- ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL);
- ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS);
- ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD | KEY_0);
+ ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KeyModifierMask::CMD | Key::EQUAL);
+ ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KeyModifierMask::CMD | Key::MINUS);
+ ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KeyModifierMask::CMD | Key::KEY_0);
text_editor = memnew(CodeEdit);
add_child(text_editor);
@@ -1824,6 +1824,7 @@ CodeTextEditor::CodeTextEditor() {
text_editor->set_draw_line_numbers(true);
text_editor->set_highlight_matching_braces_enabled(true);
text_editor->set_auto_indent_enabled(true);
+ text_editor->set_deselect_on_focus_loss_enabled(false);
status_bar = memnew(HBoxContainer);
add_child(status_bar);
@@ -1853,7 +1854,7 @@ CodeTextEditor::CodeTextEditor() {
ScrollContainer *scroll = memnew(ScrollContainer);
scroll->set_h_size_flags(SIZE_EXPAND_FILL);
scroll->set_v_size_flags(SIZE_EXPAND_FILL);
- scroll->set_enable_v_scroll(false);
+ scroll->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED);
status_bar->add_child(scroll);
error = memnew(Label);