summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp22
-rw-r--r--editor/editor_themes.cpp2
-rw-r--r--editor/plugins/script_text_editor.cpp17
-rw-r--r--editor/plugins/shader_editor_plugin.cpp6
-rw-r--r--editor/plugins/text_editor.cpp6
5 files changed, 29 insertions, 24 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 540ba8c19d..4a3be1d29c 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -142,26 +142,23 @@ void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) {
}
bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) {
- int line, col;
String text = get_search_text();
+ Point2i pos = text_editor->search(text, p_flags, p_from_line, p_from_col);
- bool found = text_editor->search(text, p_flags, p_from_line, p_from_col, line, col);
-
- if (found) {
+ if (pos.x != -1) {
if (!preserve_cursor && !is_selection_only()) {
- text_editor->unfold_line(line);
- text_editor->set_caret_line(line, false);
- text_editor->set_caret_column(col + text.length(), false);
+ text_editor->unfold_line(pos.y);
+ text_editor->set_caret_line(pos.y, false);
+ text_editor->set_caret_column(pos.x + text.length(), false);
text_editor->center_viewport_to_caret();
- text_editor->select(line, col, line, col + text.length());
+ text_editor->select(pos.y, pos.x, pos.y, pos.x + text.length());
}
text_editor->set_search_text(text);
text_editor->set_search_flags(p_flags);
- text_editor->set_current_search_result(line, col);
- result_line = line;
- result_col = col;
+ result_line = pos.y;
+ result_col = pos.x;
_update_results_count();
} else {
@@ -170,12 +167,11 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
result_col = -1;
text_editor->set_search_text("");
text_editor->set_search_flags(p_flags);
- text_editor->set_current_search_result(line, col);
}
_update_matches_label();
- return found;
+ return pos.x != -1;
}
void FindReplaceBar::_replace() {
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 5adce2951d..fe6c081922 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1048,6 +1048,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_readonly_color", "LineEdit", font_readonly_color);
theme->set_color("caret_color", "TextEdit", font_color);
theme->set_color("selection_color", "TextEdit", selection_color);
+ theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE);
// CodeEdit
theme->set_stylebox("normal", "CodeEdit", style_widget);
@@ -1062,6 +1063,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_color", "CodeEdit", font_color);
theme->set_color("caret_color", "CodeEdit", font_color);
theme->set_color("selection_color", "CodeEdit", selection_color);
+ theme->set_constant("line_spacing", "CodeEdit", 4 * EDSCALE);
// H/VSplitContainer
theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 6d2b22c46c..8cd746304c 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -241,7 +241,7 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) {
goto_line_centered(p_line.operator int64_t());
} else if (p_line.get_type() == Variant::DICTIONARY) {
Dictionary meta = p_line.operator Dictionary();
- code_editor->get_text_editor()->insert_at("# warning-ignore:" + meta["code"].operator String(), meta["line"].operator int64_t() - 1);
+ code_editor->get_text_editor()->insert_line_at(meta["line"].operator int64_t() - 1, "# warning-ignore:" + meta["code"].operator String());
_validate_script();
}
}
@@ -884,7 +884,7 @@ void ScriptTextEditor::update_toggle_scripts_button() {
void ScriptTextEditor::_update_connected_methods() {
CodeEdit *text_edit = code_editor->get_text_editor();
- text_edit->set_gutter_width(connection_gutter, text_edit->get_row_height());
+ text_edit->set_gutter_width(connection_gutter, text_edit->get_line_height());
for (int i = 0; i < text_edit->get_line_count(); i++) {
if (text_edit->get_line_gutter_metadata(i, connection_gutter) == "") {
continue;
@@ -1325,7 +1325,7 @@ void ScriptTextEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
- code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_row_height());
+ code_editor->get_text_editor()->set_gutter_width(connection_gutter, code_editor->get_text_editor()->get_line_height());
} break;
default:
break;
@@ -1422,8 +1422,10 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
Dictionary d = p_data;
CodeEdit *te = code_editor->get_text_editor();
- int row, col;
- te->_get_mouse_pos(p_point, row, col);
+
+ Point2i pos = te->get_line_column_at_pos(p_point);
+ int row = pos.y;
+ int col = pos.x;
if (d.has("type") && String(d["type"]) == "resource") {
Ref<Resource> res = d["resource"];
@@ -1512,8 +1514,9 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
}
if (create_menu) {
- int col, row;
- tx->_get_mouse_pos(local_pos, row, col);
+ Point2i pos = tx->get_line_column_at_pos(local_pos);
+ 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"));
if (tx->is_move_caret_on_right_click_enabled()) {
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 00890227cb..29436e32b2 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -550,9 +550,11 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
if (mb.is_valid()) {
if (mb->get_button_index() == MOUSE_BUTTON_RIGHT && mb->is_pressed()) {
- int col, row;
CodeEdit *tx = shader_editor->get_text_editor();
- tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
+
+ 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"));
if (tx->is_move_caret_on_right_click_enabled()) {
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index f38bb6e996..cfccf90499 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -427,9 +427,11 @@ 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);
+
+ 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);