summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp170
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/plugins/script_text_editor.cpp87
-rw-r--r--editor/plugins/shader_editor_plugin.cpp23
-rw-r--r--editor/plugins/text_editor.cpp25
5 files changed, 156 insertions, 152 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index eeb99b3677..0aab0463c4 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -44,7 +44,7 @@
void GotoLineDialog::popup_find_line(CodeEdit *p_edit) {
text_editor = p_edit;
- line->set_text(itos(text_editor->cursor_get_line()));
+ line->set_text(itos(text_editor->get_caret_line()));
line->select_all();
popup_centered(Size2(180, 80) * EDSCALE);
line->grab_focus();
@@ -59,7 +59,7 @@ void GotoLineDialog::ok_pressed() {
return;
}
text_editor->unfold_line(get_line() - 1);
- text_editor->cursor_set_line(get_line() - 1);
+ text_editor->set_caret_line(get_line() - 1);
hide();
}
@@ -150,9 +150,9 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
if (found) {
if (!preserve_cursor && !is_selection_only()) {
text_editor->unfold_line(line);
- text_editor->cursor_set_line(line, false);
- text_editor->cursor_set_column(col + text.length(), false);
- text_editor->center_viewport_to_cursor();
+ text_editor->set_caret_line(line, false);
+ text_editor->set_caret_column(col + text.length(), false);
+ text_editor->center_viewport_to_caret();
text_editor->select(line, col, line, col + text.length());
}
@@ -191,8 +191,8 @@ void FindReplaceBar::_replace() {
text_editor->begin_complex_operation();
if (selection_enabled && is_selection_only()) { // To restrict search_current() to selected region
- text_editor->cursor_set_line(selection_begin.width);
- text_editor->cursor_set_column(selection_begin.height);
+ text_editor->set_caret_line(selection_begin.width);
+ text_editor->set_caret_column(selection_begin.height);
}
if (search_current()) {
@@ -203,13 +203,13 @@ void FindReplaceBar::_replace() {
Point2i match_from(result_line, result_col);
Point2i match_to(result_line, result_col + search_text_len);
if (!(match_from < selection_begin || match_to > selection_end)) {
- text_editor->insert_text_at_cursor(replace_text);
+ text_editor->insert_text_at_caret(replace_text);
if (match_to.x == selection_end.x) { // Adjust selection bounds if necessary
selection_end.y += replace_text.length() - search_text_len;
}
}
} else {
- text_editor->insert_text_at_cursor(replace_text);
+ text_editor->insert_text_at_caret(replace_text);
}
}
text_editor->end_complex_operation();
@@ -226,7 +226,7 @@ void FindReplaceBar::_replace() {
void FindReplaceBar::_replace_all() {
text_editor->disconnect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed));
// Line as x so it gets priority in comparison, column as y.
- Point2i orig_cursor(text_editor->cursor_get_line(), text_editor->cursor_get_column());
+ Point2i orig_cursor(text_editor->get_caret_line(), text_editor->get_caret_column());
Point2i prev_match = Point2(-1, -1);
bool selection_enabled = text_editor->is_selection_active();
@@ -238,8 +238,8 @@ void FindReplaceBar::_replace_all() {
int vsval = text_editor->get_v_scroll();
- text_editor->cursor_set_line(0);
- text_editor->cursor_set_column(0);
+ text_editor->set_caret_line(0);
+ text_editor->set_caret_column(0);
String replace_text = get_replace_text();
int search_text_len = get_search_text().length();
@@ -251,8 +251,8 @@ void FindReplaceBar::_replace_all() {
text_editor->begin_complex_operation();
if (selection_enabled && is_selection_only()) {
- text_editor->cursor_set_line(selection_begin.width);
- text_editor->cursor_set_column(selection_begin.height);
+ text_editor->set_caret_line(selection_begin.width);
+ text_editor->set_caret_column(selection_begin.height);
}
if (search_current()) {
do {
@@ -275,14 +275,14 @@ void FindReplaceBar::_replace_all() {
}
// Replace but adjust selection bounds.
- text_editor->insert_text_at_cursor(replace_text);
+ text_editor->insert_text_at_caret(replace_text);
if (match_to.x == selection_end.x) {
selection_end.y += replace_text.length() - search_text_len;
}
} else {
// Just replace.
- text_editor->insert_text_at_cursor(replace_text);
+ text_editor->insert_text_at_caret(replace_text);
}
rc++;
@@ -294,8 +294,8 @@ void FindReplaceBar::_replace_all() {
replace_all_mode = false;
// Restore editor state (selection, cursor, scroll).
- text_editor->cursor_set_line(orig_cursor.x);
- text_editor->cursor_set_column(orig_cursor.y);
+ text_editor->set_caret_line(orig_cursor.x);
+ text_editor->set_caret_column(orig_cursor.y);
if (selection_enabled && is_selection_only()) {
// Reselect.
@@ -313,8 +313,8 @@ void FindReplaceBar::_replace_all() {
}
void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
- r_line = text_editor->cursor_get_line();
- r_col = text_editor->cursor_get_column();
+ r_line = text_editor->get_caret_line();
+ r_col = text_editor->get_caret_column();
if (text_editor->is_selection_active() && is_selection_only()) {
return;
@@ -807,10 +807,10 @@ void CodeTextEditor::_reset_zoom() {
}
void CodeTextEditor::_line_col_changed() {
- String line = text_editor->get_line(text_editor->cursor_get_line());
+ String line = text_editor->get_line(text_editor->get_caret_line());
int positional_column = 0;
- for (int i = 0; i < text_editor->cursor_get_column(); i++) {
+ for (int i = 0; i < text_editor->get_caret_column(); i++) {
if (line[i] == '\t') {
positional_column += text_editor->get_indent_size(); //tab size
} else {
@@ -820,7 +820,7 @@ void CodeTextEditor::_line_col_changed() {
StringBuilder sb;
sb.append("(");
- sb.append(itos(text_editor->cursor_get_line() + 1).lpad(3));
+ sb.append(itos(text_editor->get_caret_line() + 1).lpad(3));
sb.append(",");
sb.append(itos(positional_column + 1).lpad(3));
sb.append(")");
@@ -952,9 +952,9 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/word_wrap"));
text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
- text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
- text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
- text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
+ text_editor->set_caret_type((TextEdit::CaretType)EditorSettings::get_singleton()->get("text_editor/cursor/type").operator int());
+ text_editor->set_caret_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
+ text_editor->set_caret_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
text_editor->set_auto_brace_completion_enabled(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
if (EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guidelines")) {
@@ -1039,8 +1039,8 @@ void CodeTextEditor::convert_indent_to_spaces() {
indent += " ";
}
- int cursor_line = text_editor->cursor_get_line();
- int cursor_column = text_editor->cursor_get_column();
+ int cursor_line = text_editor->get_caret_line();
+ int cursor_column = text_editor->get_caret_column();
bool changed_indentation = false;
for (int i = 0; i < text_editor->get_line_count(); i++) {
@@ -1069,7 +1069,7 @@ void CodeTextEditor::convert_indent_to_spaces() {
}
}
if (changed_indentation) {
- text_editor->cursor_set_column(cursor_column);
+ text_editor->set_caret_column(cursor_column);
text_editor->end_complex_operation();
text_editor->update();
}
@@ -1079,8 +1079,8 @@ void CodeTextEditor::convert_indent_to_tabs() {
int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
indent_size -= 1;
- int cursor_line = text_editor->cursor_get_line();
- int cursor_column = text_editor->cursor_get_column();
+ int cursor_line = text_editor->get_caret_line();
+ int cursor_column = text_editor->get_caret_column();
bool changed_indentation = false;
for (int i = 0; i < text_editor->get_line_count(); i++) {
@@ -1118,7 +1118,7 @@ void CodeTextEditor::convert_indent_to_tabs() {
}
}
if (changed_indentation) {
- text_editor->cursor_set_column(cursor_column);
+ text_editor->set_caret_column(cursor_column);
text_editor->end_complex_operation();
text_editor->update();
}
@@ -1176,7 +1176,7 @@ void CodeTextEditor::move_lines_up() {
int from_col = text_editor->get_selection_from_column();
int to_line = text_editor->get_selection_to_line();
int to_column = text_editor->get_selection_to_column();
- int cursor_line = text_editor->cursor_get_line();
+ int cursor_line = text_editor->get_caret_line();
for (int i = from_line; i <= to_line; i++) {
int line_id = i;
@@ -1190,15 +1190,15 @@ void CodeTextEditor::move_lines_up() {
text_editor->unfold_line(next_id);
text_editor->swap_lines(line_id, next_id);
- text_editor->cursor_set_line(next_id);
+ text_editor->set_caret_line(next_id);
}
int from_line_up = from_line > 0 ? from_line - 1 : from_line;
int to_line_up = to_line > 0 ? to_line - 1 : to_line;
int cursor_line_up = cursor_line > 0 ? cursor_line - 1 : cursor_line;
text_editor->select(from_line_up, from_col, to_line_up, to_column);
- text_editor->cursor_set_line(cursor_line_up);
+ text_editor->set_caret_line(cursor_line_up);
} else {
- int line_id = text_editor->cursor_get_line();
+ int line_id = text_editor->get_caret_line();
int next_id = line_id - 1;
if (line_id == 0 || next_id < 0) {
@@ -1209,7 +1209,7 @@ void CodeTextEditor::move_lines_up() {
text_editor->unfold_line(next_id);
text_editor->swap_lines(line_id, next_id);
- text_editor->cursor_set_line(next_id);
+ text_editor->set_caret_line(next_id);
}
text_editor->end_complex_operation();
text_editor->update();
@@ -1222,7 +1222,7 @@ void CodeTextEditor::move_lines_down() {
int from_col = text_editor->get_selection_from_column();
int to_line = text_editor->get_selection_to_line();
int to_column = text_editor->get_selection_to_column();
- int cursor_line = text_editor->cursor_get_line();
+ int cursor_line = text_editor->get_caret_line();
for (int i = to_line; i >= from_line; i--) {
int line_id = i;
@@ -1236,15 +1236,15 @@ void CodeTextEditor::move_lines_down() {
text_editor->unfold_line(next_id);
text_editor->swap_lines(line_id, next_id);
- text_editor->cursor_set_line(next_id);
+ text_editor->set_caret_line(next_id);
}
int from_line_down = from_line < text_editor->get_line_count() ? from_line + 1 : from_line;
int to_line_down = to_line < text_editor->get_line_count() ? to_line + 1 : to_line;
int cursor_line_down = cursor_line < text_editor->get_line_count() ? cursor_line + 1 : cursor_line;
text_editor->select(from_line_down, from_col, to_line_down, to_column);
- text_editor->cursor_set_line(cursor_line_down);
+ text_editor->set_caret_line(cursor_line_down);
} else {
- int line_id = text_editor->cursor_get_line();
+ int line_id = text_editor->get_caret_line();
int next_id = line_id + 1;
if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count()) {
@@ -1255,7 +1255,7 @@ void CodeTextEditor::move_lines_down() {
text_editor->unfold_line(next_id);
text_editor->swap_lines(line_id, next_id);
- text_editor->cursor_set_line(next_id);
+ text_editor->set_caret_line(next_id);
}
text_editor->end_complex_operation();
text_editor->update();
@@ -1266,12 +1266,12 @@ void CodeTextEditor::_delete_line(int p_line) {
// so `begin_complex_operation` is omitted here
text_editor->set_line(p_line, "");
if (p_line == 0 && text_editor->get_line_count() > 1) {
- text_editor->cursor_set_line(1);
- text_editor->cursor_set_column(0);
+ text_editor->set_caret_line(1);
+ text_editor->set_caret_column(0);
}
text_editor->backspace();
text_editor->unfold_line(p_line);
- text_editor->cursor_set_line(p_line);
+ text_editor->set_caret_line(p_line);
}
void CodeTextEditor::delete_lines() {
@@ -1281,42 +1281,42 @@ void CodeTextEditor::delete_lines() {
int from_line = text_editor->get_selection_from_line();
int count = Math::abs(to_line - from_line) + 1;
- text_editor->cursor_set_line(from_line, false);
+ text_editor->set_caret_line(from_line, false);
for (int i = 0; i < count; i++) {
_delete_line(from_line);
}
text_editor->deselect();
} else {
- _delete_line(text_editor->cursor_get_line());
+ _delete_line(text_editor->get_caret_line());
}
text_editor->end_complex_operation();
}
void CodeTextEditor::duplicate_selection() {
- const int cursor_column = text_editor->cursor_get_column();
- int from_line = text_editor->cursor_get_line();
- int to_line = text_editor->cursor_get_line();
+ const int cursor_column = text_editor->get_caret_column();
+ int from_line = text_editor->get_caret_line();
+ int to_line = text_editor->get_caret_line();
int from_column = 0;
int to_column = 0;
int cursor_new_line = to_line + 1;
- int cursor_new_column = text_editor->cursor_get_column();
+ int cursor_new_column = text_editor->get_caret_column();
String new_text = "\n" + text_editor->get_line(from_line);
bool selection_active = false;
- text_editor->cursor_set_column(text_editor->get_line(from_line).length());
+ text_editor->set_caret_column(text_editor->get_line(from_line).length());
if (text_editor->is_selection_active()) {
from_column = text_editor->get_selection_from_column();
to_column = text_editor->get_selection_to_column();
from_line = text_editor->get_selection_from_line();
to_line = text_editor->get_selection_to_line();
- cursor_new_line = to_line + text_editor->cursor_get_line() - from_line;
+ cursor_new_line = to_line + text_editor->get_caret_line() - from_line;
cursor_new_column = to_column == cursor_column ? 2 * to_column - from_column : to_column;
new_text = text_editor->get_selection_text();
selection_active = true;
- text_editor->cursor_set_line(to_line);
- text_editor->cursor_set_column(to_column);
+ text_editor->set_caret_line(to_line);
+ text_editor->set_caret_column(to_column);
}
text_editor->begin_complex_operation();
@@ -1325,9 +1325,9 @@ void CodeTextEditor::duplicate_selection() {
text_editor->unfold_line(i);
}
text_editor->deselect();
- text_editor->insert_text_at_cursor(new_text);
- text_editor->cursor_set_line(cursor_new_line);
- text_editor->cursor_set_column(cursor_new_column);
+ text_editor->insert_text_at_caret(new_text);
+ text_editor->set_caret_line(cursor_new_line);
+ text_editor->set_caret_column(cursor_new_column);
if (selection_active) {
text_editor->select(to_line, to_column, 2 * to_line - from_line, to_line == from_line ? 2 * to_column - from_column : to_column);
}
@@ -1348,7 +1348,7 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
}
int col_to = text_editor->get_selection_to_column();
- int cursor_pos = text_editor->cursor_get_column();
+ int cursor_pos = text_editor->get_caret_column();
// Check if all lines in the selected block are commented.
bool is_commented = true;
@@ -1377,7 +1377,7 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
int offset = (is_commented ? -1 : 1) * delimiter.length();
int col_from = text_editor->get_selection_from_column() > 0 ? text_editor->get_selection_from_column() + offset : 0;
- if (is_commented && text_editor->cursor_get_column() == text_editor->get_line(text_editor->cursor_get_line()).length() + 1) {
+ if (is_commented && text_editor->get_caret_column() == text_editor->get_line(text_editor->get_caret_line()).length() + 1) {
cursor_pos += 1;
}
@@ -1385,19 +1385,19 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
col_to += offset;
}
- if (text_editor->cursor_get_column() != 0) {
+ if (text_editor->get_caret_column() != 0) {
cursor_pos += offset;
}
text_editor->select(begin, col_from, text_editor->get_selection_to_line(), col_to);
- text_editor->cursor_set_column(cursor_pos);
+ text_editor->set_caret_column(cursor_pos);
} else {
- int begin = text_editor->cursor_get_line();
+ int begin = text_editor->get_caret_line();
String line_text = text_editor->get_line(begin);
int delimiter_length = delimiter.length();
- int col = text_editor->cursor_get_column();
+ int col = text_editor->get_caret_column();
if (line_text.begins_with(delimiter)) {
line_text = line_text.substr(delimiter_length, line_text.length());
col -= delimiter_length;
@@ -1407,7 +1407,7 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
}
text_editor->set_line(begin, line_text);
- text_editor->cursor_set_column(col);
+ text_editor->set_caret_column(col);
}
text_editor->end_complex_operation();
text_editor->update();
@@ -1428,7 +1428,7 @@ void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
void CodeTextEditor::goto_line_centered(int p_line) {
goto_line(p_line);
- text_editor->call_deferred(SNAME("center_viewport_to_cursor"));
+ text_editor->call_deferred(SNAME("center_viewport_to_caret"));
}
void CodeTextEditor::set_executing_line(int p_line) {
@@ -1444,8 +1444,8 @@ Variant CodeTextEditor::get_edit_state() {
state["scroll_position"] = text_editor->get_v_scroll();
state["h_scroll_position"] = text_editor->get_h_scroll();
- state["column"] = text_editor->cursor_get_column();
- state["row"] = text_editor->cursor_get_line();
+ state["column"] = text_editor->get_caret_column();
+ state["row"] = text_editor->get_caret_line();
state["selection"] = get_text_editor()->is_selection_active();
if (get_text_editor()->is_selection_active()) {
@@ -1469,8 +1469,8 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
Dictionary state = p_state;
/* update the row first as it sets the column to 0 */
- text_editor->cursor_set_line(state["row"]);
- text_editor->cursor_set_column(state["column"]);
+ text_editor->set_caret_line(state["row"]);
+ text_editor->set_caret_column(state["column"]);
text_editor->set_v_scroll(state["scroll_position"]);
text_editor->set_h_scroll(state["h_scroll_position"]);
@@ -1517,9 +1517,9 @@ void CodeTextEditor::set_error_pos(int p_line, int p_column) {
void CodeTextEditor::goto_error() {
if (error->get_text() != "") {
text_editor->unfold_line(error_line);
- text_editor->cursor_set_line(error_line);
- text_editor->cursor_set_column(error_column);
- text_editor->center_viewport_to_cursor();
+ text_editor->set_caret_line(error_line);
+ text_editor->set_caret_column(error_column);
+ text_editor->center_viewport_to_caret();
}
}
@@ -1712,7 +1712,7 @@ void CodeTextEditor::set_warning_count(int p_warning_count) {
}
void CodeTextEditor::toggle_bookmark() {
- int line = text_editor->cursor_get_line();
+ int line = text_editor->get_caret_line();
text_editor->set_line_as_bookmarked(line, !text_editor->is_line_bookmarked(line));
}
@@ -1722,18 +1722,18 @@ void CodeTextEditor::goto_next_bookmark() {
return;
}
- int line = text_editor->cursor_get_line();
+ int line = text_editor->get_caret_line();
if (line >= (int)bmarks[bmarks.size() - 1]) {
text_editor->unfold_line(bmarks[0]);
- text_editor->cursor_set_line(bmarks[0]);
- text_editor->center_viewport_to_cursor();
+ text_editor->set_caret_line(bmarks[0]);
+ text_editor->center_viewport_to_caret();
} else {
for (int i = 0; i < bmarks.size(); i++) {
int bmark_line = bmarks[i];
if (bmark_line > line) {
text_editor->unfold_line(bmark_line);
- text_editor->cursor_set_line(bmark_line);
- text_editor->center_viewport_to_cursor();
+ text_editor->set_caret_line(bmark_line);
+ text_editor->center_viewport_to_caret();
return;
}
}
@@ -1746,18 +1746,18 @@ void CodeTextEditor::goto_prev_bookmark() {
return;
}
- int line = text_editor->cursor_get_line();
+ int line = text_editor->get_caret_line();
if (line <= (int)bmarks[0]) {
text_editor->unfold_line(bmarks[bmarks.size() - 1]);
- text_editor->cursor_set_line(bmarks[bmarks.size() - 1]);
- text_editor->center_viewport_to_cursor();
+ text_editor->set_caret_line(bmarks[bmarks.size() - 1]);
+ text_editor->center_viewport_to_caret();
} else {
for (int i = bmarks.size(); i >= 0; i--) {
int bmark_line = bmarks[i];
if (bmark_line < line) {
text_editor->unfold_line(bmark_line);
- text_editor->cursor_set_line(bmark_line);
- text_editor->center_viewport_to_cursor();
+ text_editor->set_caret_line(bmark_line);
+ text_editor->center_viewport_to_caret();
return;
}
}
@@ -1913,7 +1913,7 @@ CodeTextEditor::CodeTextEditor() {
line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP);
text_editor->connect("gui_input", callable_mp(this, &CodeTextEditor::_text_editor_gui_input));
- text_editor->connect("cursor_changed", callable_mp(this, &CodeTextEditor::_line_col_changed));
+ text_editor->connect("caret_changed", callable_mp(this, &CodeTextEditor::_line_col_changed));
text_editor->connect("text_changed", callable_mp(this, &CodeTextEditor::_text_changed));
text_editor->connect("request_code_completion", callable_mp(this, &CodeTextEditor::_complete_request));
TypedArray<String> cs;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 16c2a0f028..65d75968f6 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -546,7 +546,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Cursor
_initial_set("text_editor/cursor/scroll_past_end_of_file", false);
- _initial_set("text_editor/cursor/block_caret", false);
+ _initial_set("text_editor/cursor/type", 0);
+ hints["text_editor/cursor/type"] = PropertyInfo(Variant::INT, "text_editor/cursor/type", PROPERTY_HINT_ENUM, "Line,Block");
_initial_set("text_editor/cursor/caret_blink", true);
_initial_set("text_editor/cursor/caret_blink_speed", 0.5);
hints["text_editor/cursor/caret_blink_speed"] = PropertyInfo(Variant::FLOAT, "text_editor/cursor/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1, 10, 0.01");
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 64381c0d9e..2faa56e661 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -248,7 +248,7 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) {
void ScriptTextEditor::_error_clicked(Variant p_line) {
if (p_line.get_type() == Variant::INT) {
- code_editor->get_text_editor()->cursor_set_line(p_line.operator int64_t());
+ code_editor->get_text_editor()->set_caret_line(p_line.operator int64_t());
}
}
@@ -256,14 +256,14 @@ void ScriptTextEditor::reload_text() {
ERR_FAIL_COND(script.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(script->get_source_code());
- 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);
@@ -281,12 +281,12 @@ void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray
pos = code_editor->get_text_editor()->get_line_count() + 2;
String func = script->get_language()->make_function("", p_function, p_args);
//code=code+func;
- code_editor->get_text_editor()->cursor_set_line(pos + 1);
- code_editor->get_text_editor()->cursor_set_column(1000000); //none shall be that big
- code_editor->get_text_editor()->insert_text_at_cursor("\n\n" + func);
+ code_editor->get_text_editor()->set_caret_line(pos + 1);
+ code_editor->get_text_editor()->set_caret_column(1000000); //none shall be that big
+ code_editor->get_text_editor()->insert_text_at_caret("\n\n" + func);
}
- code_editor->get_text_editor()->cursor_set_line(pos);
- code_editor->get_text_editor()->cursor_set_column(1);
+ code_editor->get_text_editor()->set_caret_line(pos);
+ code_editor->get_text_editor()->set_caret_column(1);
}
bool ScriptTextEditor::show_members_overview() {
@@ -726,7 +726,7 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
_edit_option(breakpoints_menu->get_item_id(p_idx));
} else {
code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx));
- code_editor->get_text_editor()->call_deferred(SNAME("center_viewport_to_cursor")); //Need to be deferred, because goto uses call_deferred().
+ code_editor->get_text_editor()->call_deferred(SNAME("center_viewport_to_caret")); //Need to be deferred, because goto uses call_deferred().
}
}
@@ -1054,7 +1054,7 @@ void ScriptTextEditor::_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: {
@@ -1142,7 +1142,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
}
code_editor->get_text_editor()->begin_complex_operation(); //prevents creating a two-step undo
- code_editor->get_text_editor()->insert_text_at_cursor(String("\n").join(results));
+ code_editor->get_text_editor()->insert_text_at_caret(String("\n").join(results));
code_editor->get_text_editor()->end_complex_operation();
} break;
case SEARCH_FIND: {
@@ -1189,7 +1189,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
code_editor->remove_all_bookmarks();
} break;
case DEBUG_TOGGLE_BREAKPOINT: {
- int line = tx->cursor_get_line();
+ int line = tx->get_caret_line();
bool dobreak = !tx->is_line_breakpointed(line);
tx->set_line_as_breakpoint(line, dobreak);
EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak);
@@ -1210,20 +1210,20 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
- int line = tx->cursor_get_line();
+ int line = tx->get_caret_line();
// wrap around
if (line >= (int)bpoints[bpoints.size() - 1]) {
tx->unfold_line(bpoints[0]);
- tx->cursor_set_line(bpoints[0]);
- tx->center_viewport_to_cursor();
+ tx->set_caret_line(bpoints[0]);
+ tx->center_viewport_to_caret();
} else {
for (int i = 0; i < bpoints.size(); i++) {
int bline = bpoints[i];
if (bline > line) {
tx->unfold_line(bline);
- tx->cursor_set_line(bline);
- tx->center_viewport_to_cursor();
+ tx->set_caret_line(bline);
+ tx->center_viewport_to_caret();
return;
}
}
@@ -1236,19 +1236,19 @@ void ScriptTextEditor::_edit_option(int p_op) {
return;
}
- int line = tx->cursor_get_line();
+ int line = tx->get_caret_line();
// wrap around
if (line <= (int)bpoints[0]) {
tx->unfold_line(bpoints[bpoints.size() - 1]);
- tx->cursor_set_line(bpoints[bpoints.size() - 1]);
- tx->center_viewport_to_cursor();
+ tx->set_caret_line(bpoints[bpoints.size() - 1]);
+ tx->center_viewport_to_caret();
} else {
for (int i = bpoints.size(); i >= 0; i--) {
int bline = bpoints[i];
if (bline < line) {
tx->unfold_line(bline);
- tx->cursor_set_line(bline);
- tx->center_viewport_to_cursor();
+ tx->set_caret_line(bline);
+ tx->center_viewport_to_caret();
return;
}
}
@@ -1258,19 +1258,19 @@ void ScriptTextEditor::_edit_option(int p_op) {
case HELP_CONTEXTUAL: {
String text = tx->get_selection_text();
if (text == "") {
- text = tx->get_word_under_cursor();
+ text = tx->get_word_under_caret();
}
if (text != "") {
emit_signal(SNAME("request_help"), text);
}
} break;
case LOOKUP_SYMBOL: {
- String text = tx->get_word_under_cursor();
+ String text = tx->get_word_under_caret();
if (text == "") {
text = tx->get_selection_text();
}
if (text != "") {
- _lookup_symbol(text, tx->cursor_get_line(), tx->cursor_get_column());
+ _lookup_symbol(text, tx->get_caret_line(), tx->get_caret_column());
}
} break;
}
@@ -1436,9 +1436,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
return;
}
- te->cursor_set_line(row);
- te->cursor_set_column(col);
- te->insert_text_at_cursor(res->get_path());
+ te->set_caret_line(row);
+ te->set_caret_column(col);
+ te->insert_text_at_caret(res->get_path());
}
if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) {
@@ -1459,9 +1459,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
}
- te->cursor_set_line(row);
- te->cursor_set_column(col);
- te->insert_text_at_cursor(text_to_drop);
+ te->set_caret_line(row);
+ te->set_caret_column(col);
+ te->insert_text_at_caret(text_to_drop);
}
if (d.has("type") && String(d["type"]) == "nodes") {
@@ -1489,9 +1489,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
text_to_drop += "\"" + path.c_escape() + "\"";
}
- te->cursor_set_line(row);
- te->cursor_set_column(col);
- te->insert_text_at_cursor(text_to_drop);
+ te->set_caret_line(row);
+ te->set_caret_column(col);
+ te->insert_text_at_caret(text_to_drop);
}
}
@@ -1505,8 +1505,9 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid() && mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed()) {
local_pos = mb->get_global_position() - tx->get_global_position();
create_menu = true;
- } else if (k.is_valid() && k->get_keycode() == KEY_MENU) {
- local_pos = tx->_get_cursor_pixel_pos();
+ } else if (k.is_valid() && k->is_action("ui_menu", true)) {
+ tx->adjust_viewport_to_caret();
+ local_pos = tx->get_caret_draw_pos();
create_menu = true;
}
@@ -1514,8 +1515,8 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
int col, row;
tx->_get_mouse_pos(local_pos, row, col);
- tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
- if (tx->is_right_click_moving_caret()) {
+ tx->set_move_caret_on_right_click_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_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();
@@ -1528,14 +1529,14 @@ void ScriptTextEditor::_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, false, false);
+ tx->set_caret_column(col);
}
}
String word_at_pos = tx->get_word_at_pos(local_pos);
if (word_at_pos == "") {
- word_at_pos = tx->get_word_under_cursor();
+ word_at_pos = tx->get_word_under_caret();
}
if (word_at_pos == "") {
word_at_pos = tx->get_selection_text();
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 95973f9dfd..3190a0d8ef 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -74,14 +74,14 @@ void ShaderTextEditor::reload_text() {
ERR_FAIL_COND(shader.is_null());
CodeEdit *te = 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(shader->get_code());
- 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);
@@ -408,7 +408,7 @@ void ShaderEditor::_show_warnings_panel(bool p_show) {
void ShaderEditor::_warning_clicked(Variant p_line) {
if (p_line.get_type() == Variant::INT) {
- shader_editor->get_text_editor()->cursor_set_line(p_line.operator int64_t());
+ shader_editor->get_text_editor()->set_caret_line(p_line.operator int64_t());
}
}
@@ -553,9 +553,9 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
int col, row;
CodeEdit *tx = shader_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"));
- 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();
@@ -568,8 +568,8 @@ void ShaderEditor::_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);
}
}
_make_context_menu(tx->is_selection_active(), get_local_mouse_position());
@@ -577,9 +577,10 @@ void ShaderEditor::_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 = shader_editor->get_text_editor();
- _make_context_menu(tx->is_selection_active(), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
+ tx->adjust_viewport_to_caret();
+ _make_context_menu(tx->is_selection_active(), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->get_caret_draw_pos()));
context_menu->grab_focus();
}
}
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();
}
}