1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Add include/exclude to FindInFiles for filtering files.

This commit is contained in:
Daylily-Zeleen
2024-04-12 12:43:23 +08:00
parent 80a3d205f1
commit 1bccf5c9a3
3 changed files with 126 additions and 1 deletions

View File

@@ -46,6 +46,8 @@ public:
void set_match_case(bool p_match_case);
void set_folder(const String &folder);
void set_filter(const HashSet<String> &exts);
void set_includes(const HashSet<String> &p_include_wildcards);
void set_excludes(const HashSet<String> &p_exclude_wildcards);
String get_search_text() const { return _pattern; }
@@ -69,9 +71,13 @@ private:
void _scan_dir(const String &path, PackedStringArray &out_folders, PackedStringArray &out_files_to_scan);
void _scan_file(const String &fpath);
bool _is_file_matched(const HashSet<String> &p_wildcards, const String &p_file_path, bool p_case_sensitive) const;
// Config
String _pattern;
HashSet<String> _extension_filter;
HashSet<String> _include_wildcards;
HashSet<String> _exclude_wildcards;
String _root_dir;
bool _whole_words = true;
bool _match_case = true;
@@ -115,6 +121,8 @@ public:
bool is_whole_words() const;
String get_folder() const;
HashSet<String> get_filter() const;
HashSet<String> get_includes() const;
HashSet<String> get_excludes() const;
protected:
void _notification(int p_what);
@@ -130,6 +138,8 @@ private:
void _on_search_text_submitted(const String &text);
void _on_replace_text_submitted(const String &text);
String validate_filter_wildcard(const String &p_expression) const;
FindInFilesMode _mode;
LineEdit *_search_text_line_edit = nullptr;
@@ -143,6 +153,9 @@ private:
Button *_replace_button = nullptr;
FileDialog *_folder_dialog = nullptr;
HBoxContainer *_filters_container = nullptr;
LineEdit *_includes_line_edit = nullptr;
LineEdit *_excludes_line_edit = nullptr;
HashMap<String, bool> _filters_preferences;
};