summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-14 16:57:27 +0100
committerGitHub <noreply@github.com>2018-01-14 16:57:27 +0100
commit515da5b08ba56440800cb9f5793230fd5c930eed (patch)
tree5574e74751de1fffab284c91915f04d427a75d96
parentf96f11c850827a16c9a498a059ad9bdf8666cf1f (diff)
parentc318cdad662f98e81f9dc5a3829059f6c784c7b6 (diff)
Merge pull request #15706 from groud/remove_unused_class
Remove the unused FindReplaceDialog class
-rw-r--r--editor/code_editor.cpp385
-rw-r--r--editor/code_editor.h56
2 files changed, 0 insertions, 441 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 3e079cb3ca..061f6ccc33 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -577,391 +577,6 @@ FindReplaceBar::FindReplaceBar() {
selection_only->connect("toggled", this, "_search_options_changed");
}
-void FindReplaceDialog::popup_search() {
-
- set_title(TTR("Search"));
- replace_mc->hide();
- replace_label->hide();
- replace_vb->hide();
- skip->hide();
- popup_centered(Point2(300, 190));
- get_ok()->set_text(TTR("Find"));
- search_text->grab_focus();
- if (text_edit->is_selection_active() && (text_edit->get_selection_from_line() == text_edit->get_selection_to_line())) {
-
- search_text->set_text(text_edit->get_selection_text());
- }
- search_text->select_all();
-
- error_label->set_text("");
-}
-
-void FindReplaceDialog::popup_replace() {
-
- set_title(TTR("Replace"));
- bool do_selection = (text_edit->is_selection_active() && text_edit->get_selection_from_line() < text_edit->get_selection_to_line());
-
- set_replace_selection_only(do_selection);
-
- if (!do_selection && text_edit->is_selection_active()) {
- search_text->set_text(text_edit->get_selection_text());
- }
-
- replace_mc->show();
- replace_label->show();
- replace_vb->show();
- popup_centered(Point2(300, 300));
- if (search_text->get_text() != "" && replace_text->get_text() == "") {
- search_text->select(0, 0);
- replace_text->grab_focus();
- } else {
- search_text->grab_focus();
- search_text->select_all();
- }
- error_label->set_text("");
-
- if (prompt->is_pressed()) {
- skip->show();
- get_ok()->set_text(TTR("Next"));
- selection_only->set_disabled(true);
-
- } else {
- skip->hide();
- get_ok()->set_text(TTR("Replace"));
- selection_only->set_disabled(false);
- }
-}
-
-void FindReplaceDialog::_search_callback() {
-
- if (is_replace_mode())
- _replace();
- else
- _search();
-}
-
-void FindReplaceDialog::_replace_skip_callback() {
-
- _search();
-}
-
-void FindReplaceDialog::_replace() {
-
- text_edit->begin_complex_operation();
- if (is_replace_all_mode()) {
-
- //line as x so it gets priority in comparison, column as y
- Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column());
- Point2i prev_match = Point2(-1, -1);
-
- bool selection_enabled = text_edit->is_selection_active();
- Point2i selection_begin, selection_end;
- if (selection_enabled) {
- selection_begin = Point2i(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
- selection_end = Point2i(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());
- }
- int vsval = text_edit->get_v_scroll();
- //int hsval = text_edit->get_h_scroll();
-
- text_edit->cursor_set_line(0);
- text_edit->cursor_set_column(0);
-
- int rc = 0;
-
- while (_search()) {
-
- if (!text_edit->is_selection_active()) {
- //search selects
- break;
- }
-
- //replace area
- Point2i match_from(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
- Point2i match_to(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());
-
- if (match_from < prev_match)
- break; //done
-
- prev_match = match_to;
-
- if (selection_enabled && is_replace_selection_only()) {
-
- if (match_from < selection_begin || match_to > selection_end)
- continue;
-
- //replace but adjust selection bounds
-
- text_edit->insert_text_at_cursor(get_replace_text());
- if (match_to.x == selection_end.x)
- selection_end.y += get_replace_text().length() - get_search_text().length();
- } else {
- //just replace
- text_edit->insert_text_at_cursor(get_replace_text());
- }
- rc++;
- }
- //restore editor state (selection, cursor, scroll)
- text_edit->cursor_set_line(orig_cursor.x);
- text_edit->cursor_set_column(orig_cursor.y);
-
- if (selection_enabled && is_replace_selection_only()) {
- //reselect
- text_edit->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y);
- } else {
- text_edit->deselect();
- }
-
- text_edit->set_v_scroll(vsval);
- //text_edit->set_h_scroll(hsval);
- error_label->set_text(vformat(TTR("Replaced %d occurrence(s)."), rc));
-
- //hide();
- } else {
-
- if (text_edit->get_selection_text() == get_search_text()) {
-
- text_edit->insert_text_at_cursor(get_replace_text());
- }
-
- _search();
- }
- text_edit->end_complex_operation();
-}
-
-bool FindReplaceDialog::_search() {
-
- String text = get_search_text();
- uint32_t flags = 0;
-
- if (is_whole_words())
- flags |= TextEdit::SEARCH_WHOLE_WORDS;
- if (is_case_sensitive())
- flags |= TextEdit::SEARCH_MATCH_CASE;
- if (is_backwards())
- flags |= TextEdit::SEARCH_BACKWARDS;
-
- int line = text_edit->cursor_get_line(), col = text_edit->cursor_get_column();
-
- if (is_backwards()) {
- col -= 1;
- if (col < 0) {
- line -= 1;
- if (line < 0) {
- line = text_edit->get_line_count() - 1;
- }
- col = text_edit->get_line(line).length();
- }
- }
- bool found = text_edit->search(text, flags, line, col, line, col);
-
- if (found) {
- // print_line("found");
- text_edit->unfold_line(line);
- text_edit->cursor_set_line(line);
- if (is_backwards())
- text_edit->cursor_set_column(col);
- else
- text_edit->cursor_set_column(col + text.length());
- text_edit->select(line, col, line, col + text.length());
- set_error("");
- return true;
- } else {
-
- set_error(TTR("Not found!"));
- return false;
- }
-}
-
-void FindReplaceDialog::_prompt_changed() {
-
- if (prompt->is_pressed()) {
- skip->show();
- get_ok()->set_text(TTR("Next"));
- selection_only->set_disabled(true);
-
- } else {
- skip->hide();
- get_ok()->set_text(TTR("Replace"));
- selection_only->set_disabled(false);
- }
-}
-
-void FindReplaceDialog::_skip_pressed() {
-
- _replace_skip_callback();
-}
-
-bool FindReplaceDialog::is_replace_mode() const {
-
- return replace_text->is_visible_in_tree();
-}
-
-bool FindReplaceDialog::is_replace_all_mode() const {
-
- return !prompt->is_pressed();
-}
-
-bool FindReplaceDialog::is_replace_selection_only() const {
-
- return selection_only->is_pressed();
-}
-void FindReplaceDialog::set_replace_selection_only(bool p_enable) {
-
- selection_only->set_pressed(p_enable);
-}
-
-void FindReplaceDialog::ok_pressed() {
-
- _search_callback();
-}
-
-void FindReplaceDialog::_search_text_entered(const String &p_text) {
-
- if (replace_text->is_visible_in_tree())
- return;
- emit_signal("search");
- _search();
-}
-
-void FindReplaceDialog::_replace_text_entered(const String &p_text) {
-
- if (!replace_text->is_visible_in_tree())
- return;
-
- emit_signal("search");
- _replace();
-}
-
-String FindReplaceDialog::get_search_text() const {
-
- return search_text->get_text();
-}
-String FindReplaceDialog::get_replace_text() const {
-
- return replace_text->get_text();
-}
-bool FindReplaceDialog::is_whole_words() const {
-
- return whole_words->is_pressed();
-}
-bool FindReplaceDialog::is_case_sensitive() const {
-
- return case_sensitive->is_pressed();
-}
-bool FindReplaceDialog::is_backwards() const {
-
- return backwards->is_pressed();
-}
-
-void FindReplaceDialog::set_error(const String &p_error) {
-
- error_label->set_text(p_error);
-}
-
-void FindReplaceDialog::set_text_edit(TextEdit *p_text_edit) {
-
- text_edit = p_text_edit;
-}
-
-void FindReplaceDialog::search_next() {
- _search();
-}
-
-void FindReplaceDialog::_bind_methods() {
-
- ClassDB::bind_method("_search_text_entered", &FindReplaceDialog::_search_text_entered);
- ClassDB::bind_method("_replace_text_entered", &FindReplaceDialog::_replace_text_entered);
- ClassDB::bind_method("_prompt_changed", &FindReplaceDialog::_prompt_changed);
- ClassDB::bind_method("_skip_pressed", &FindReplaceDialog::_skip_pressed);
- ADD_SIGNAL(MethodInfo("search"));
- ADD_SIGNAL(MethodInfo("skip"));
-}
-
-FindReplaceDialog::FindReplaceDialog() {
-
- set_self_modulate(Color(1, 1, 1, 0.8));
-
- VBoxContainer *vb = memnew(VBoxContainer);
- add_child(vb);
-
- search_text = memnew(LineEdit);
- vb->add_margin_child(TTR("Search"), search_text);
- search_text->connect("text_entered", this, "_search_text_entered");
-
- replace_label = memnew(Label);
- replace_label->set_text(TTR("Replace By"));
- vb->add_child(replace_label);
- replace_mc = memnew(MarginContainer);
- vb->add_child(replace_mc);
-
- replace_text = memnew(LineEdit);
- replace_text->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- replace_text->set_begin(Point2(15, 132));
- replace_text->set_end(Point2(-15, 135));
-
- replace_mc->add_child(replace_text);
-
- replace_text->connect("text_entered", this, "_replace_text_entered");
-
- MarginContainer *opt_mg = memnew(MarginContainer);
- vb->add_child(opt_mg);
- VBoxContainer *svb = memnew(VBoxContainer);
- opt_mg->add_child(svb);
-
- svb->add_child(memnew(Label));
-
- whole_words = memnew(CheckButton);
- whole_words->set_text(TTR("Whole Words"));
- svb->add_child(whole_words);
-
- case_sensitive = memnew(CheckButton);
- case_sensitive->set_text(TTR("Case Sensitive"));
- svb->add_child(case_sensitive);
-
- backwards = memnew(CheckButton);
- backwards->set_text(TTR("Backwards"));
- svb->add_child(backwards);
-
- opt_mg = memnew(MarginContainer);
- vb->add_child(opt_mg);
- VBoxContainer *rvb = memnew(VBoxContainer);
- opt_mg->add_child(rvb);
- replace_vb = rvb;
- //rvb ->add_child(memnew(HSeparator));
- rvb->add_child(memnew(Label));
-
- prompt = memnew(CheckButton);
- prompt->set_text(TTR("Prompt On Replace"));
- rvb->add_child(prompt);
- prompt->connect("pressed", this, "_prompt_changed");
-
- selection_only = memnew(CheckButton);
- selection_only->set_text(TTR("Selection Only"));
- rvb->add_child(selection_only);
-
- int margin = get_constant("margin", "Dialogs");
- int button_margin = get_constant("button_margin", "Dialogs");
-
- skip = memnew(Button);
- skip->set_anchor(MARGIN_LEFT, ANCHOR_END);
- skip->set_anchor(MARGIN_TOP, ANCHOR_END);
- skip->set_anchor(MARGIN_RIGHT, ANCHOR_END);
- skip->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
- skip->set_begin(Point2(-70, -button_margin));
- skip->set_end(Point2(-10, -margin));
- skip->set_text(TTR("Skip"));
- add_child(skip);
- skip->connect("pressed", this, "_skip_pressed");
-
- error_label = memnew(Label);
- error_label->set_align(Label::ALIGN_CENTER);
- error_label->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));
-
- vb->add_child(error_label);
-
- set_hide_on_ok(false);
-}
-
/*** CODE EDITOR ****/
void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
diff --git a/editor/code_editor.h b/editor/code_editor.h
index f735631ef6..2e6340acc0 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -131,62 +131,6 @@ public:
FindReplaceBar();
};
-class FindReplaceDialog : public ConfirmationDialog {
-
- GDCLASS(FindReplaceDialog, ConfirmationDialog);
-
- LineEdit *search_text;
- LineEdit *replace_text;
- CheckButton *whole_words;
- CheckButton *case_sensitive;
- CheckButton *backwards;
- CheckButton *prompt;
- CheckButton *selection_only;
- Button *skip;
- Label *error_label;
- MarginContainer *replace_mc;
- Label *replace_label;
- VBoxContainer *replace_vb;
-
- void _search_text_entered(const String &p_text);
- void _replace_text_entered(const String &p_text);
- void _prompt_changed();
- void _skip_pressed();
-
- TextEdit *text_edit;
-
-protected:
- void _search_callback();
- void _replace_skip_callback();
-
- bool _search();
- void _replace();
-
- virtual void ok_pressed();
- static void _bind_methods();
-
-public:
- String get_search_text() const;
- String get_replace_text() const;
- bool is_whole_words() const;
- bool is_case_sensitive() const;
- bool is_backwards() const;
- bool is_replace_mode() const;
- bool is_replace_all_mode() const;
- bool is_replace_selection_only() const;
- void set_replace_selection_only(bool p_enable);
-
- void set_error(const String &p_error);
-
- void popup_search();
- void popup_replace();
-
- void set_text_edit(TextEdit *p_text_edit);
-
- void search_next();
- FindReplaceDialog();
-};
-
typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, List<String> *r_options, bool &r_forced);
class CodeTextEditor : public VBoxContainer {