Reuse CodeEditor's SearchBar class for TextEditor.

This commit is contained in:
Relintai 2022-07-16 15:07:48 +02:00
parent 196c136181
commit b70482d246
2 changed files with 11 additions and 0 deletions

View File

@ -14,6 +14,8 @@
#include "scene/gui/text_edit.h"
#include "scene/gui/texture_rect.h"
#include "editor/code_editor.h"
#include "scene/resources/dynamic_font.h"
String TextEditorVanillaEditor::get_current_path() {
@ -177,8 +179,10 @@ void TextEditorVanillaEditor::count_characters() {
}
void TextEditorVanillaEditor::open_search_box() {
_find_replace_bar->popup_search();
}
void TextEditorVanillaEditor::open_replace_box() {
_find_replace_bar->popup_replace();
}
TextEditorVanillaEditor::TextEditorVanillaEditor() {
@ -229,6 +233,10 @@ TextEditorVanillaEditor::TextEditorVanillaEditor() {
text_editor->set("custom_constants/completion_max_width", 20);
text_editor->set("custom_constants/completion_scroll_width", 20);
_find_replace_bar = memnew(FindReplaceBar);
_find_replace_bar->set_text_edit(text_editor);
add_child(_find_replace_bar);
HBoxContainer *file_info = memnew(HBoxContainer);
add_child(file_info);

View File

@ -17,6 +17,7 @@ class CheckBox;
class Button;
class TextureRect;
class Label;
class FindReplaceBar;
class TextEditorVanillaEditor : public VBoxContainer {
GDCLASS(TextEditorVanillaEditor, VBoxContainer);
@ -64,6 +65,8 @@ protected:
Label *file_info_c_counter;
CheckBox *file_info_read_only;
FindReplaceBar *_find_replace_bar;
String current_path;
String current_filename;