summaryrefslogtreecommitdiffstats
path: root/editor/plugins/text_editor.cpp
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2021-07-08 18:35:56 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2021-08-12 09:29:13 +0100
commitd5dcaee4c5b41faca64f02888b152f7f05c4a20b (patch)
tree9357d0d289d3cd1089fa298accc7933b97979e5d /editor/plugins/text_editor.cpp
parente60900a35395f0aa97d01383e2095c4e50faa500 (diff)
downloadredot-engine-d5dcaee4c5b41faca64f02888b152f7f05c4a20b.tar.gz
Cleanup and rename caret operations
Diffstat (limited to 'editor/plugins/text_editor.cpp')
-rw-r--r--editor/plugins/text_editor.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index faf287b9bd..6eea8ae227 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: {
@@ -431,11 +431,11 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
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"));
+ 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_move_caret_on_right_click_enabled()) {
if (tx->is_selection_active()) {
int from_line = tx->get_selection_from_line();
int to_line = tx->get_selection_to_line();
@@ -448,8 +448,8 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
}
if (!tx->is_selection_active()) {
- tx->cursor_set_line(row, true, false);
- tx->cursor_set_column(col);
+ tx->set_caret_line(row, true, false);
+ tx->set_caret_column(col);
}
}
@@ -460,10 +460,11 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
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->is_selection_active(), 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();
}
}