mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 22:21:18 +00:00
Add and convert editor to use CodeEdit
This commit is contained in:
parent
d782405bcf
commit
a0b409cb14
12 changed files with 400 additions and 247 deletions
|
|
@ -50,7 +50,7 @@ void TextEditor::set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlight
|
|||
el = el->next();
|
||||
}
|
||||
|
||||
TextEdit *te = code_editor->get_text_edit();
|
||||
CodeEdit *te = code_editor->get_text_editor();
|
||||
te->set_syntax_highlighter(p_highlighter);
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ void TextEditor::_change_syntax_highlighter(int p_idx) {
|
|||
}
|
||||
|
||||
void TextEditor::_load_theme_settings() {
|
||||
TextEdit *text_edit = code_editor->get_text_edit();
|
||||
CodeEdit *text_edit = code_editor->get_text_editor();
|
||||
text_edit->get_syntax_highlighter()->update_cache();
|
||||
|
||||
Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
|
||||
|
|
@ -147,9 +147,9 @@ void TextEditor::set_edited_resource(const RES &p_res) {
|
|||
|
||||
text_file = p_res;
|
||||
|
||||
code_editor->get_text_edit()->set_text(text_file->get_text());
|
||||
code_editor->get_text_edit()->clear_undo_history();
|
||||
code_editor->get_text_edit()->tag_saved_version();
|
||||
code_editor->get_text_editor()->set_text(text_file->get_text());
|
||||
code_editor->get_text_editor()->clear_undo_history();
|
||||
code_editor->get_text_editor()->tag_saved_version();
|
||||
|
||||
emit_signal("name_changed");
|
||||
code_editor->update_line_and_column();
|
||||
|
|
@ -177,7 +177,7 @@ void TextEditor::get_breakpoints(List<int> *p_breakpoints) {
|
|||
void TextEditor::reload_text() {
|
||||
ERR_FAIL_COND(text_file.is_null());
|
||||
|
||||
TextEdit *te = code_editor->get_text_edit();
|
||||
CodeEdit *te = code_editor->get_text_editor();
|
||||
int column = te->cursor_get_column();
|
||||
int row = te->cursor_get_line();
|
||||
int h = te->get_h_scroll();
|
||||
|
|
@ -207,7 +207,7 @@ void TextEditor::_update_bookmark_list() {
|
|||
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
|
||||
bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
|
||||
|
||||
Array bookmark_list = code_editor->get_text_edit()->get_bookmarks_array();
|
||||
Array bookmark_list = code_editor->get_text_editor()->get_bookmarks_array();
|
||||
if (bookmark_list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ void TextEditor::_update_bookmark_list() {
|
|||
bookmarks_menu->add_separator();
|
||||
|
||||
for (int i = 0; i < bookmark_list.size(); i++) {
|
||||
String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).strip_edges();
|
||||
String line = code_editor->get_text_editor()->get_line(bookmark_list[i]).strip_edges();
|
||||
// Limit the size of the line if too big.
|
||||
if (line.length() > 50) {
|
||||
line = line.substr(0, 50);
|
||||
|
|
@ -235,12 +235,12 @@ void TextEditor::_bookmark_item_pressed(int p_idx) {
|
|||
}
|
||||
|
||||
void TextEditor::apply_code() {
|
||||
text_file->set_text(code_editor->get_text_edit()->get_text());
|
||||
text_file->set_text(code_editor->get_text_editor()->get_text());
|
||||
}
|
||||
|
||||
bool TextEditor::is_unsaved() {
|
||||
const bool unsaved =
|
||||
code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version() ||
|
||||
code_editor->get_text_editor()->get_version() != code_editor->get_text_editor()->get_saved_version() ||
|
||||
text_file->get_path().empty(); // In memory.
|
||||
return unsaved;
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ void TextEditor::convert_indent_to_tabs() {
|
|||
}
|
||||
|
||||
void TextEditor::tag_saved_version() {
|
||||
code_editor->get_text_edit()->tag_saved_version();
|
||||
code_editor->get_text_editor()->tag_saved_version();
|
||||
}
|
||||
|
||||
void TextEditor::goto_line(int p_line, bool p_with_error) {
|
||||
|
|
@ -300,7 +300,7 @@ void TextEditor::clear_executing_line() {
|
|||
}
|
||||
|
||||
void TextEditor::ensure_focus() {
|
||||
code_editor->get_text_edit()->grab_focus();
|
||||
code_editor->get_text_editor()->grab_focus();
|
||||
}
|
||||
|
||||
Vector<String> TextEditor::get_functions() {
|
||||
|
|
@ -316,7 +316,7 @@ void TextEditor::update_settings() {
|
|||
}
|
||||
|
||||
void TextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
|
||||
code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
|
||||
code_editor->get_text_editor()->set_tooltip_request_func(p_obj, p_method, this);
|
||||
}
|
||||
|
||||
Control *TextEditor::get_edit_menu() {
|
||||
|
|
@ -328,7 +328,7 @@ void TextEditor::clear_edit_menu() {
|
|||
}
|
||||
|
||||
void TextEditor::_edit_option(int p_op) {
|
||||
TextEdit *tx = code_editor->get_text_edit();
|
||||
CodeEdit *tx = code_editor->get_text_editor();
|
||||
|
||||
switch (p_op) {
|
||||
case EDIT_UNDO: {
|
||||
|
|
@ -416,14 +416,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_edit()->get_selection_text();
|
||||
String selected_text = code_editor->get_text_editor()->get_selection_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("search_in_files_requested", selected_text);
|
||||
} break;
|
||||
case REPLACE_IN_FILES: {
|
||||
String selected_text = code_editor->get_text_edit()->get_selection_text();
|
||||
String selected_text = code_editor->get_text_editor()->get_selection_text();
|
||||
|
||||
emit_signal("replace_in_files_requested", selected_text);
|
||||
} break;
|
||||
|
|
@ -470,7 +470,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
|
|||
if (mb.is_valid()) {
|
||||
if (mb->get_button_index() == BUTTON_RIGHT) {
|
||||
int col, row;
|
||||
TextEdit *tx = code_editor->get_text_edit();
|
||||
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"));
|
||||
|
|
@ -503,7 +503,7 @@ 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) {
|
||||
TextEdit *tx = code_editor->get_text_edit();
|
||||
CodeEdit *tx = code_editor->get_text_editor();
|
||||
int line = tx->cursor_get_line();
|
||||
_make_context_menu(tx->is_selection_active(), tx->can_fold(line), tx->is_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos()));
|
||||
context_menu->grab_focus();
|
||||
|
|
@ -552,8 +552,8 @@ TextEditor::TextEditor() {
|
|||
|
||||
update_settings();
|
||||
|
||||
code_editor->get_text_edit()->set_context_menu_enabled(false);
|
||||
code_editor->get_text_edit()->connect("gui_input", callable_mp(this, &TextEditor::_text_edit_gui_input));
|
||||
code_editor->get_text_editor()->set_context_menu_enabled(false);
|
||||
code_editor->get_text_editor()->connect("gui_input", callable_mp(this, &TextEditor::_text_edit_gui_input));
|
||||
|
||||
context_menu = memnew(PopupMenu);
|
||||
add_child(context_menu);
|
||||
|
|
@ -649,7 +649,7 @@ TextEditor::TextEditor() {
|
|||
goto_line_dialog = memnew(GotoLineDialog);
|
||||
add_child(goto_line_dialog);
|
||||
|
||||
code_editor->get_text_edit()->set_drag_forwarding(this);
|
||||
code_editor->get_text_editor()->set_drag_forwarding(this);
|
||||
}
|
||||
|
||||
TextEditor::~TextEditor() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue