summaryrefslogtreecommitdiff
path: root/editor/plugins/text_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/text_editor.cpp')
-rw-r--r--editor/plugins/text_editor.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index faf287b9bd..cfccf90499 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -132,14 +132,14 @@ void TextEditor::reload_text() {
ERR_FAIL_COND(text_file.is_null());
CodeEdit *te = code_editor->get_text_editor();
- int column = te->cursor_get_column();
- int row = te->cursor_get_line();
+ int column = te->get_caret_column();
+ int row = te->get_caret_line();
int h = te->get_h_scroll();
int v = te->get_v_scroll();
te->set_text(text_file->get_text());
- te->cursor_set_line(row);
- te->cursor_set_column(column);
+ te->set_caret_line(row);
+ te->set_caret_column(column);
te->set_h_scroll(h);
te->set_v_scroll(v);
@@ -332,7 +332,7 @@ void TextEditor::_edit_option(int p_op) {
code_editor->duplicate_selection();
} break;
case EDIT_TOGGLE_FOLD_LINE: {
- tx->toggle_foldable_line(tx->cursor_get_line());
+ tx->toggle_foldable_line(tx->get_caret_line());
tx->update();
} break;
case EDIT_FOLD_ALL_LINES: {
@@ -340,7 +340,7 @@ void TextEditor::_edit_option(int p_op) {
tx->update();
} break;
case EDIT_UNFOLD_ALL_LINES: {
- tx->unhide_all_lines();
+ tx->unfold_all_lines();
tx->update();
} break;
case EDIT_TRIM_TRAILING_WHITESAPCE: {
@@ -374,14 +374,14 @@ void TextEditor::_edit_option(int p_op) {
code_editor->get_find_replace_bar()->popup_replace();
} break;
case SEARCH_IN_FILES: {
- String selected_text = code_editor->get_text_editor()->get_selection_text();
+ String selected_text = code_editor->get_text_editor()->get_selected_text();
// Yep, because it doesn't make sense to instance this dialog for every single script open...
// So this will be delegated to the ScriptEditor.
emit_signal(SNAME("search_in_files_requested"), selected_text);
} break;
case REPLACE_IN_FILES: {
- String selected_text = code_editor->get_text_editor()->get_selection_text();
+ String selected_text = code_editor->get_text_editor()->get_selected_text();
emit_signal(SNAME("replace_in_files_requested"), selected_text);
} break;
@@ -427,16 +427,18 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid()) {
if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
- int col, row;
CodeEdit *tx = code_editor->get_text_editor();
- tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
- tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
+ Point2i pos = tx->get_line_column_at_pos(mb->get_global_position() - tx->get_global_position());
+ int row = pos.y;
+ int col = pos.x;
+
+ tx->set_move_caret_on_right_click_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
bool can_fold = tx->can_fold_line(row);
bool is_folded = tx->is_line_folded(row);
- if (tx->is_right_click_moving_caret()) {
- if (tx->is_selection_active()) {
+ if (tx->is_move_caret_on_right_click_enabled()) {
+ if (tx->has_selection()) {
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
int from_column = tx->get_selection_from_column();
@@ -447,23 +449,24 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
tx->deselect();
}
}
- if (!tx->is_selection_active()) {
- tx->cursor_set_line(row, true, false);
- tx->cursor_set_column(col);
+ if (!tx->has_selection()) {
+ tx->set_caret_line(row, true, false);
+ tx->set_caret_column(col);
}
}
if (!mb->is_pressed()) {
- _make_context_menu(tx->is_selection_active(), can_fold, is_folded, get_local_mouse_position());
+ _make_context_menu(tx->has_selection(), can_fold, is_folded, get_local_mouse_position());
}
}
}
Ref<InputEventKey> k = ev;
- if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_MENU) {
+ if (k.is_valid() && k->is_pressed() && k->is_action("ui_menu", true)) {
CodeEdit *tx = code_editor->get_text_editor();
- int line = tx->cursor_get_line();
- _make_context_menu(tx->is_selection_active(), tx->can_fold_line(line), tx->is_line_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
+ int line = tx->get_caret_line();
+ tx->adjust_viewport_to_caret();
+ _make_context_menu(tx->has_selection(), tx->can_fold_line(line), tx->is_line_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->get_caret_draw_pos()));
context_menu->grab_focus();
}
}