summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2021-07-09 12:42:55 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2021-08-12 09:29:56 +0100
commit9ec3e7f3d7ae7f9eaf5a1de29346c5e10b3af6f9 (patch)
tree2953e06268871695e0c49b12f16372ce672bf027 /editor
parent7e70f9e0b9696fab55e2d0570c6bdc8b07c14462 (diff)
Cleanup TextEdit selection methods
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp36
-rw-r--r--editor/plugins/script_text_editor.cpp20
-rw-r--r--editor/plugins/shader_editor_plugin.cpp8
-rw-r--r--editor/plugins/text_editor.cpp12
4 files changed, 38 insertions, 38 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 57c69f5aab..5f6b7e1788 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -179,7 +179,7 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
}
void FindReplaceBar::_replace() {
- bool selection_enabled = text_editor->is_selection_active();
+ bool selection_enabled = text_editor->has_selection();
Point2i selection_begin, selection_end;
if (selection_enabled) {
selection_begin = Point2i(text_editor->get_selection_from_line(), text_editor->get_selection_from_column());
@@ -229,7 +229,7 @@ void FindReplaceBar::_replace_all() {
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();
+ bool selection_enabled = text_editor->has_selection();
Point2i selection_begin, selection_end;
if (selection_enabled) {
selection_begin = Point2i(text_editor->get_selection_from_line(), text_editor->get_selection_from_column());
@@ -316,7 +316,7 @@ void FindReplaceBar::_get_search_from(int &r_line, int &r_col) {
r_line = text_editor->get_caret_line();
r_col = text_editor->get_caret_column();
- if (text_editor->is_selection_active() && is_selection_only()) {
+ if (text_editor->has_selection() && is_selection_only()) {
return;
}
@@ -409,7 +409,7 @@ bool FindReplaceBar::search_prev() {
int line, col;
_get_search_from(line, col);
- if (text_editor->is_selection_active()) {
+ if (text_editor->has_selection()) {
col--; // Skip currently selected word.
}
@@ -487,8 +487,8 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
search_text->call_deferred(SNAME("grab_focus"));
}
- if (text_editor->is_selection_active() && !selection_only->is_pressed()) {
- search_text->set_text(text_editor->get_selection_text());
+ if (text_editor->has_selection() && !selection_only->is_pressed()) {
+ search_text->set_text(text_editor->get_selected_text());
}
if (!get_search_text().is_empty()) {
@@ -521,9 +521,9 @@ void FindReplaceBar::popup_replace() {
hbc_option_replace->show();
}
- selection_only->set_pressed((text_editor->is_selection_active() && text_editor->get_selection_from_line() < text_editor->get_selection_to_line()));
+ selection_only->set_pressed((text_editor->has_selection() && text_editor->get_selection_from_line() < text_editor->get_selection_to_line()));
- _show_search(is_visible() || text_editor->is_selection_active());
+ _show_search(is_visible() || text_editor->has_selection());
}
void FindReplaceBar::_search_options_changed(bool p_pressed) {
@@ -554,7 +554,7 @@ void FindReplaceBar::_search_text_submitted(const String &p_text) {
}
void FindReplaceBar::_replace_text_submitted(const String &p_text) {
- if (selection_only->is_pressed() && text_editor->is_selection_active()) {
+ if (selection_only->is_pressed() && text_editor->has_selection()) {
_replace_all();
_hide_bar();
} else if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
@@ -1125,7 +1125,7 @@ void CodeTextEditor::convert_indent_to_tabs() {
}
void CodeTextEditor::convert_case(CaseStyle p_case) {
- if (!text_editor->is_selection_active()) {
+ if (!text_editor->has_selection()) {
return;
}
@@ -1171,7 +1171,7 @@ void CodeTextEditor::convert_case(CaseStyle p_case) {
void CodeTextEditor::move_lines_up() {
text_editor->begin_complex_operation();
- if (text_editor->is_selection_active()) {
+ if (text_editor->has_selection()) {
int from_line = text_editor->get_selection_from_line();
int from_col = text_editor->get_selection_from_column();
int to_line = text_editor->get_selection_to_line();
@@ -1217,7 +1217,7 @@ void CodeTextEditor::move_lines_up() {
void CodeTextEditor::move_lines_down() {
text_editor->begin_complex_operation();
- if (text_editor->is_selection_active()) {
+ if (text_editor->has_selection()) {
int from_line = text_editor->get_selection_from_line();
int from_col = text_editor->get_selection_from_column();
int to_line = text_editor->get_selection_to_line();
@@ -1276,7 +1276,7 @@ void CodeTextEditor::_delete_line(int p_line) {
void CodeTextEditor::delete_lines() {
text_editor->begin_complex_operation();
- if (text_editor->is_selection_active()) {
+ if (text_editor->has_selection()) {
int to_line = text_editor->get_selection_to_line();
int from_line = text_editor->get_selection_from_line();
int count = Math::abs(to_line - from_line) + 1;
@@ -1304,7 +1304,7 @@ void CodeTextEditor::duplicate_selection() {
bool selection_active = false;
text_editor->set_caret_column(text_editor->get_line(from_line).length());
- if (text_editor->is_selection_active()) {
+ if (text_editor->has_selection()) {
from_column = text_editor->get_selection_from_column();
to_column = text_editor->get_selection_to_column();
@@ -1312,7 +1312,7 @@ void CodeTextEditor::duplicate_selection() {
to_line = text_editor->get_selection_to_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();
+ new_text = text_editor->get_selected_text();
selection_active = true;
text_editor->set_caret_line(to_line);
@@ -1338,7 +1338,7 @@ void CodeTextEditor::duplicate_selection() {
void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
text_editor->begin_complex_operation();
- if (text_editor->is_selection_active()) {
+ if (text_editor->has_selection()) {
int begin = text_editor->get_selection_from_line();
int end = text_editor->get_selection_to_line();
@@ -1447,8 +1447,8 @@ Variant CodeTextEditor::get_edit_state() {
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()) {
+ state["selection"] = get_text_editor()->has_selection();
+ if (get_text_editor()->has_selection()) {
state["selection_from_line"] = text_editor->get_selection_from_line();
state["selection_from_column"] = text_editor->get_selection_from_column();
state["selection_to_line"] = text_editor->get_selection_to_line();
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 2faa56e661..ad25bca9da 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1080,7 +1080,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
tx->begin_complex_operation();
int begin, end;
- if (tx->is_selection_active()) {
+ if (tx->has_selection()) {
begin = tx->get_selection_from_line();
end = tx->get_selection_to_line();
// ignore if the cursor is not past the first column
@@ -1122,7 +1122,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_EVALUATE: {
Expression expression;
- Vector<String> lines = code_editor->get_text_editor()->get_selection_text().split("\n");
+ Vector<String> lines = code_editor->get_text_editor()->get_selected_text().split("\n");
PackedStringArray results;
for (int i = 0; i < lines.size(); i++) {
@@ -1158,14 +1158,14 @@ void ScriptTextEditor::_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;
@@ -1256,7 +1256,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case HELP_CONTEXTUAL: {
- String text = tx->get_selection_text();
+ String text = tx->get_selected_text();
if (text == "") {
text = tx->get_word_under_caret();
}
@@ -1267,7 +1267,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
case LOOKUP_SYMBOL: {
String text = tx->get_word_under_caret();
if (text == "") {
- text = tx->get_selection_text();
+ text = tx->get_selected_text();
}
if (text != "") {
_lookup_symbol(text, tx->get_caret_line(), tx->get_caret_column());
@@ -1517,7 +1517,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
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()) {
+ 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();
@@ -1528,7 +1528,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
tx->deselect();
}
}
- if (!tx->is_selection_active()) {
+ if (!tx->has_selection()) {
tx->set_caret_line(row, false, false);
tx->set_caret_column(col);
}
@@ -1539,7 +1539,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
word_at_pos = tx->get_word_under_caret();
}
if (word_at_pos == "") {
- word_at_pos = tx->get_selection_text();
+ word_at_pos = tx->get_selected_text();
}
bool has_color = (word_at_pos == "Color");
@@ -1591,7 +1591,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
has_color = false;
}
}
- _make_context_menu(tx->is_selection_active(), has_color, foldable, open_docs, goto_definition, local_pos);
+ _make_context_menu(tx->has_selection(), has_color, foldable, open_docs, goto_definition, local_pos);
}
}
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 3190a0d8ef..00890227cb 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -556,7 +556,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
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()) {
+ 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();
@@ -567,12 +567,12 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
tx->deselect();
}
}
- if (!tx->is_selection_active()) {
+ if (!tx->has_selection()) {
tx->set_caret_line(row, true, false);
tx->set_caret_column(col);
}
}
- _make_context_menu(tx->is_selection_active(), get_local_mouse_position());
+ _make_context_menu(tx->has_selection(), get_local_mouse_position());
}
}
@@ -580,7 +580,7 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (k.is_valid() && k->is_pressed() && k->is_action("ui_menu", true)) {
CodeEdit *tx = shader_editor->get_text_editor();
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()));
+ _make_context_menu(tx->has_selection(), (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 6eea8ae227..4e90399433 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -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;
@@ -436,7 +436,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
bool is_folded = tx->is_line_folded(row);
if (tx->is_move_caret_on_right_click_enabled()) {
- if (tx->is_selection_active()) {
+ 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,14 +447,14 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
tx->deselect();
}
}
- if (!tx->is_selection_active()) {
+ 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());
}
}
}
@@ -464,7 +464,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
CodeEdit *tx = code_editor->get_text_editor();
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()));
+ _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();
}
}