mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
UIDocFindReplace: first working version completed. TextDocument: Fixed findTextLast when using case-insensitive search. StyleSheet: Added StyleSheet::markerExists. ecode: DocSearchController minor refactor.
85 lines
2.2 KiB
C++
85 lines
2.2 KiB
C++
#ifndef ECODE_DOCSEARCHCONTROLLER_HPP
|
|
#define ECODE_DOCSEARCHCONTROLLER_HPP
|
|
|
|
#include "appconfig.hpp"
|
|
#include <eepp/ee.hpp>
|
|
|
|
namespace ecode {
|
|
|
|
struct SearchState {
|
|
UICodeEditor* editor{ nullptr };
|
|
String text;
|
|
TextRange range = TextRange();
|
|
bool caseSensitive{ false };
|
|
bool wholeWord{ false };
|
|
bool escapeSequences{ false };
|
|
TextDocument::FindReplaceType type{ TextDocument::FindReplaceType::Normal };
|
|
void reset() {
|
|
editor = nullptr;
|
|
range = TextRange();
|
|
text = "";
|
|
}
|
|
};
|
|
|
|
class App;
|
|
class UISearchBar;
|
|
|
|
class DocSearchController {
|
|
public:
|
|
static std::unordered_map<std::string, std::string> getDefaultKeybindings() {
|
|
return { { "mod+g", "repeat-find" },
|
|
{ "escape", "close-searchbar" },
|
|
{ "mod+r", "replace-selection" },
|
|
{ "mod+shift+n", "find-and-replace" },
|
|
{ "mod+shift+r", "replace-all" },
|
|
{ "mod+s", "change-case" },
|
|
{ "mod+w", "change-whole-word" },
|
|
{ "mod+l", "toggle-lua-pattern" },
|
|
{ "mod+e", "change-escape-sequence" },
|
|
{ "mod+shift+g", "find-prev" } };
|
|
}
|
|
|
|
DocSearchController( UICodeEditorSplitter*, App* app );
|
|
|
|
void initSearchBar(
|
|
UISearchBar* searchBar, const SearchBarConfig& searchBarConfig,
|
|
std::unordered_map<std::string, std::string> keybindings = getDefaultKeybindings() );
|
|
|
|
void showFindView();
|
|
|
|
bool findPrevText( SearchState& search );
|
|
|
|
bool findNextText( SearchState& search );
|
|
|
|
bool replaceSelection( SearchState& search, const String& replacement );
|
|
|
|
int replaceAll( SearchState& search, const String& replace );
|
|
|
|
bool findAndReplace( SearchState& search, const String& replace );
|
|
|
|
void hideSearchBar();
|
|
|
|
void onCodeEditorFocusChange( UICodeEditor* editor );
|
|
|
|
SearchState& getSearchState();
|
|
|
|
SearchBarConfig getSearchBarConfig() const;
|
|
|
|
protected:
|
|
UICodeEditorSplitter* mEditorSplitter{ nullptr };
|
|
UITextInput* mFindInput{ nullptr };
|
|
UITextInput* mReplaceInput{ nullptr };
|
|
UISearchBar* mSearchBarLayout{ nullptr };
|
|
UICheckBox* mCaseSensitiveChk{ nullptr };
|
|
UICheckBox* mEscapeSequenceChk{ nullptr };
|
|
UICheckBox* mWholeWordChk{ nullptr };
|
|
UICheckBox* mLuaPatternChk{ nullptr };
|
|
App* mApp{ nullptr };
|
|
SearchState mSearchState;
|
|
String mLastSearch;
|
|
};
|
|
|
|
} // namespace ecode
|
|
|
|
#endif // ECODE_DOCSEARCHCONTROLLER_HPP
|