Cleanup and bind remaing methods in TextEdit
This commit is contained in:
parent
0a32a6907b
commit
ae4dcb8918
9 changed files with 2570 additions and 2477 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue