diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 791f5fc88..b0ab95598 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -418,6 +418,10 @@ class EE_API TextDocument { void notifyDocumentMoved( const std::string& newPath ); + void toUpperSelection(); + + void toLowerSelection(); + protected: friend class UndoStack; UndoStack mUndoStack; diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index bf4d12912..4c41d5f2c 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -284,6 +284,30 @@ void TextDocument::notifyDocumentMoved( const std::string& path ) { notifyDocumentMoved(); } +void TextDocument::toUpperSelection() { + if ( !hasSelection() ) + return; + + TextRange selection( getSelection() ); + String selectedText( getSelectedText() ); + selectedText.toUpper(); + deleteSelection(); + textInput( selectedText ); + setSelection( selection ); +} + +void TextDocument::toLowerSelection() { + if ( !hasSelection() ) + return; + + TextRange selection( getSelection() ); + String selectedText( getSelectedText() ); + selectedText.toLower(); + deleteSelection(); + textInput( selectedText ); + setSelection( selection ); +} + TextDocument::LoadStatus TextDocument::loadFromFile( const std::string& path ) { mLoading = true; if ( !FileSystem::fileExists( path ) && PackManager::instance()->isFallbackToPacksActive() ) { @@ -1976,6 +2000,8 @@ void TextDocument::initializeCommands() { mCommands["undo"] = [&] { undo(); }; mCommands["redo"] = [&] { redo(); }; mCommands["toggle-line-comments"] = [&] { toggleLineComments(); }; + mCommands["selection-to-upper"] = [&] { toUpperSelection(); }; + mCommands["selection-to-lower"] = [&] { toLowerSelection(); }; } TextDocument::Client::~Client() {} diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 5a80f9e10..9e13753fc 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -95,6 +95,8 @@ const std::map UICodeEditor::getDefaultKeybi { { KEY_KP_MINUS, KeyMod::getDefaultModifier() }, "font-size-shrink" }, { { KEY_0, KeyMod::getDefaultModifier() | KEYMOD_SHIFT }, "font-size-reset" }, { { KEY_KP_DIVIDE, KeyMod::getDefaultModifier() }, "toggle-line-comments" }, + { { KEY_UP, KEYMOD_CTRL | KEYMOD_LALT | KEYMOD_SHIFT }, "selection-to-upper" }, + { { KEY_DOWN, KEYMOD_CTRL | KEYMOD_LALT | KEYMOD_SHIFT }, "selection-to-lower" }, }; } diff --git a/src/tools/ecode/appconfig.cpp b/src/tools/ecode/appconfig.cpp index 210298f32..844420dac 100644 --- a/src/tools/ecode/appconfig.cpp +++ b/src/tools/ecode/appconfig.cpp @@ -97,13 +97,27 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath, editor.syncProjectTreeWithEditor = ini.getValueB( "editor", "sync_project_tree_with_editor", false ); editor.autoCloseXMLTags = ini.getValueB( "editor", "auto_close_xml_tags", true ); + + searchBarConfig.caseSensitive = ini.getValueB( "search_bar", "case_sensitive", false ); + searchBarConfig.luaPattern = ini.getValueB( "search_bar", "lua_pattern", false ); + searchBarConfig.wholeWord = ini.getValueB( "search_bar", "whole_word", false ); + searchBarConfig.escapeSequence = ini.getValueB( "search_bar", "escape_sequence", false ); + + globalSearchBarConfig.caseSensitive = + ini.getValueB( "global_search_bar", "case_sensitive", false ); + globalSearchBarConfig.luaPattern = ini.getValueB( "global_search_bar", "lua_pattern", false ); + globalSearchBarConfig.wholeWord = ini.getValueB( "global_search_bar", "whole_word", false ); + globalSearchBarConfig.escapeSequence = + ini.getValueB( "global_search_bar", "escape_sequence", false ); + iniInfo = FileInfo( ini.path() ); } void AppConfig::save( const std::vector& recentFiles, const std::vector& recentFolders, const std::string& panelPartition, EE::Window::Window* win, - const std::string& colorSchemeName ) { + const std::string& colorSchemeName, const SearchBarConfig& searchBarConfig, + const GlobalSearchBarConfig& globalSearchBarConfig ) { FileInfo configInfo( ini.path() ); if ( iniInfo.getModificationTime() != 0 && @@ -164,6 +178,17 @@ void AppConfig::save( const std::vector& recentFiles, ini.setValueB( "editor", "single_click_tree_navigation", editor.singleClickTreeNavigation ); ini.setValueB( "editor", "sync_project_tree_with_editor", editor.syncProjectTreeWithEditor ); ini.setValueB( "editor", "auto_close_xml_tags", editor.autoCloseXMLTags ); + + ini.setValueB( "search_bar", "case_sensitive", searchBarConfig.caseSensitive ); + ini.setValueB( "search_bar", "lua_pattern", searchBarConfig.luaPattern ); + ini.setValueB( "search_bar", "whole_word", searchBarConfig.wholeWord ); + ini.setValueB( "search_bar", "escape_sequence", searchBarConfig.escapeSequence ); + + ini.setValueB( "global_search_bar", "case_sensitive", globalSearchBarConfig.caseSensitive ); + ini.setValueB( "global_search_bar", "lua_pattern", globalSearchBarConfig.luaPattern ); + ini.setValueB( "global_search_bar", "whole_word", globalSearchBarConfig.wholeWord ); + ini.setValueB( "global_search_bar", "escape_sequence", globalSearchBarConfig.escapeSequence ); + ini.writeFile(); iniState.writeFile(); } diff --git a/src/tools/ecode/appconfig.hpp b/src/tools/ecode/appconfig.hpp index 5cadcd8d5..641924760 100644 --- a/src/tools/ecode/appconfig.hpp +++ b/src/tools/ecode/appconfig.hpp @@ -1,6 +1,7 @@ #ifndef APPCONFIG_HPP #define APPCONFIG_HPP +#include "widgetcommandexecuter.hpp" #include #include #include @@ -73,6 +74,20 @@ struct DocumentConfig { int lineBreakingColumn{ 100 }; }; +struct SearchBarConfig { + bool caseSensitive{ false }; + bool luaPattern{ false }; + bool wholeWord{ false }; + bool escapeSequence{ false }; +}; + +struct GlobalSearchBarConfig { + bool caseSensitive{ false }; + bool luaPattern{ false }; + bool wholeWord{ false }; + bool escapeSequence{ false }; +}; + struct ProjectDocumentConfig { bool useGlobalSettings{ true }; DocumentConfig doc; @@ -88,6 +103,8 @@ struct AppConfig { IniFile ini; IniFile iniState; FileInfo iniInfo; + SearchBarConfig searchBarConfig; + GlobalSearchBarConfig globalSearchBarConfig; void load( const std::string& confPath, std::string& keybindingsPath, std::string& initColorScheme, std::vector& recentFiles, @@ -96,7 +113,9 @@ struct AppConfig { void save( const std::vector& recentFiles, const std::vector& recentFolders, const std::string& panelPartition, - EE::Window::Window* win, const std::string& colorSchemeName ); + EE::Window::Window* win, const std::string& colorSchemeName, + const SearchBarConfig& searchBarConfig, + const GlobalSearchBarConfig& globalSearchBarConfig ); void saveProject( std::string projectFolder, UICodeEditorSplitter* editorSplitter, const std::string& configPath, const ProjectDocumentConfig& docConfig ); diff --git a/src/tools/ecode/docsearchcontroller.cpp b/src/tools/ecode/docsearchcontroller.cpp index 275c87047..5fa7b8956 100644 --- a/src/tools/ecode/docsearchcontroller.cpp +++ b/src/tools/ecode/docsearchcontroller.cpp @@ -5,7 +5,8 @@ DocSearchController::DocSearchController( UICodeEditorSplitter* editorSplitter, mEditorSplitter( editorSplitter ), mApp( app ) {} void DocSearchController::initSearchBar( - UISearchBar* searchBar, std::unordered_map keybindings ) { + UISearchBar* searchBar, const SearchBarConfig& searchBarConfig, + std::unordered_map keybindings ) { mSearchBarLayout = searchBar; mSearchBarLayout->setVisible( false )->setEnabled( false ); auto addClickListener = [&]( UIWidget* widget, std::string cmd ) { @@ -41,6 +42,10 @@ void DocSearchController::initSearchBar( UIPushButton* findNextButton = mSearchBarLayout->find( "find_next" ); UIPushButton* replaceButton = mSearchBarLayout->find( "replace" ); UIPushButton* findReplaceButton = mSearchBarLayout->find( "replace_find" ); + caseSensitiveChk->setChecked( searchBarConfig.caseSensitive ); + luaPatternChk->setChecked( searchBarConfig.luaPattern ); + wholeWordChk->setChecked( searchBarConfig.wholeWord ); + escapeSequenceChk->setChecked( searchBarConfig.escapeSequence ); luaPatternChk->setTooltipText( kbind.getCommandKeybindString( "toggle-lua-pattern" ) ); caseSensitiveChk->setTooltipText( kbind.getCommandKeybindString( "change-case" ) ); @@ -348,3 +353,16 @@ void DocSearchController::onCodeEditorFocusChange( UICodeEditor* editor ) { SearchState& DocSearchController::getSearchState() { return mSearchState; } + +SearchBarConfig DocSearchController::getSearchBarConfig() const { + UICheckBox* caseSensitiveChk = mSearchBarLayout->find( "case_sensitive" ); + UICheckBox* escapeSequenceChk = mSearchBarLayout->find( "escape_sequence" ); + UICheckBox* wholeWordChk = mSearchBarLayout->find( "whole_word" ); + UICheckBox* luaPatternChk = mSearchBarLayout->find( "lua_pattern" ); + SearchBarConfig searchBarConfig; + searchBarConfig.caseSensitive = caseSensitiveChk->isChecked(); + searchBarConfig.luaPattern = luaPatternChk->isChecked(); + searchBarConfig.wholeWord = wholeWordChk->isChecked(); + searchBarConfig.escapeSequence = escapeSequenceChk->isChecked(); + return searchBarConfig; +} diff --git a/src/tools/ecode/docsearchcontroller.hpp b/src/tools/ecode/docsearchcontroller.hpp index d9366b930..ac24903f2 100644 --- a/src/tools/ecode/docsearchcontroller.hpp +++ b/src/tools/ecode/docsearchcontroller.hpp @@ -1,6 +1,7 @@ #ifndef DOCSEARCHCONTROLLER_HPP #define DOCSEARCHCONTROLLER_HPP +#include "appconfig.hpp" #include struct SearchState { @@ -35,6 +36,7 @@ class DocSearchController { void initSearchBar( UISearchBar* searchBar, + const SearchBarConfig& searchBarConfig, std::unordered_map keybindings = getDefaultKeybindings() ); void showFindView(); @@ -55,6 +57,8 @@ class DocSearchController { SearchState& getSearchState(); + SearchBarConfig getSearchBarConfig() const; + protected: UICodeEditorSplitter* mEditorSplitter{ nullptr }; UISearchBar* mSearchBarLayout{ nullptr }; diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index a72e6302c..c04f40fde 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -322,11 +322,12 @@ void App::loadConfig() { } void App::saveConfig() { - mConfig.save( mRecentFiles, mRecentFolders, - mProjectSplitter ? mProjectSplitter->getSplitPartition().toString() : "15%", - mWindow, - mEditorSplitter ? mEditorSplitter->getCurrentColorSchemeName() - : mConfig.editor.colorScheme ); + mConfig.save( + mRecentFiles, mRecentFolders, + mProjectSplitter ? mProjectSplitter->getSplitPartition().toString() : "15%", mWindow, + mEditorSplitter ? mEditorSplitter->getCurrentColorSchemeName() : mConfig.editor.colorScheme, + mDocSearchController->getSearchBarConfig(), + mGlobalSearchController->getGlobalSearchBarConfig() ); } static std::string keybindFormat( std::string str ) { @@ -3000,7 +3001,7 @@ void App::init( std::string file, const Float& pidelDensity, const std::string& - + @@ -3193,13 +3194,13 @@ void App::init( std::string file, const Float& pidelDensity, const std::string& mDocSearchController = std::make_unique( mEditorSplitter, this ); mDocSearchController->initSearchBar( mUISceneNode->find( "search_bar" ), - mDocumentSearchKeybindings ); + mConfig.searchBarConfig, mDocumentSearchKeybindings ); mGlobalSearchController = std::make_unique( mEditorSplitter, mUISceneNode, this ); mGlobalSearchController->initGlobalSearchBar( mUISceneNode->find( "global_search_bar" ), - mGlobalSearchKeybindings ); + mConfig.globalSearchBarConfig, mGlobalSearchKeybindings ); mFileLocator = std::make_unique( mEditorSplitter, mUISceneNode, this ); mFileLocator->initLocateBar( mUISceneNode->find( "locate_bar" ), diff --git a/src/tools/ecode/globalsearchcontroller.cpp b/src/tools/ecode/globalsearchcontroller.cpp index c7e745843..85e5f7234 100644 --- a/src/tools/ecode/globalsearchcontroller.cpp +++ b/src/tools/ecode/globalsearchcontroller.cpp @@ -47,7 +47,8 @@ size_t GlobalSearchController::replaceInFiles( const std::string& replaceText, } void GlobalSearchController::initGlobalSearchBar( - UIGlobalSearchBar* globalSearchBar, std::unordered_map keybindings ) { + UIGlobalSearchBar* globalSearchBar, const GlobalSearchBarConfig& globalSearchBarConfig, + std::unordered_map keybindings ) { mGlobalSearchBarLayout = globalSearchBar; mGlobalSearchBarLayout->setVisible( false )->setEnabled( false ); auto addClickListener = [&]( UIWidget* widget, std::string cmd ) { @@ -86,6 +87,11 @@ void GlobalSearchController::initGlobalSearchBar( UIWidget* searchBarClose = mGlobalSearchBarLayout->find( "global_searchbar_close" ); + caseSensitiveChk->setChecked( globalSearchBarConfig.caseSensitive ); + luaPatternChk->setChecked( globalSearchBarConfig.luaPattern ); + wholeWordChk->setChecked( globalSearchBarConfig.wholeWord ); + escapeSequenceChk->setChecked( globalSearchBarConfig.escapeSequence ); + mGlobalSearchInput = mGlobalSearchBarLayout->find( "global_search_find" ); mGlobalSearchHistoryList = @@ -311,6 +317,19 @@ void GlobalSearchController::clearHistory() { updateGlobalSearchBar(); } +GlobalSearchBarConfig GlobalSearchController::getGlobalSearchBarConfig() const { + UICheckBox* caseSensitiveChk = mGlobalSearchBarLayout->find( "case_sensitive" ); + UICheckBox* wholeWordChk = mGlobalSearchBarLayout->find( "whole_word" ); + UICheckBox* luaPatternChk = mGlobalSearchBarLayout->find( "lua_pattern" ); + UICheckBox* escapeSequenceChk = mGlobalSearchBarLayout->find( "escape_sequence" ); + GlobalSearchBarConfig globalSeachBarConfig; + globalSeachBarConfig.caseSensitive = caseSensitiveChk->isChecked(); + globalSeachBarConfig.luaPattern = luaPatternChk->isChecked(); + globalSeachBarConfig.wholeWord = wholeWordChk->isChecked(); + globalSeachBarConfig.escapeSequence = escapeSequenceChk->isChecked(); + return globalSeachBarConfig; +} + void GlobalSearchController::updateGlobalSearchBar() { mGlobalSearchBarLayout->runOnMainThread( [&] { Float width = eeceil( mGlobalSearchInput->getPixelsSize().getWidth() ); diff --git a/src/tools/ecode/globalsearchcontroller.hpp b/src/tools/ecode/globalsearchcontroller.hpp index 8bda1a8c5..bc1440886 100644 --- a/src/tools/ecode/globalsearchcontroller.hpp +++ b/src/tools/ecode/globalsearchcontroller.hpp @@ -1,6 +1,7 @@ #ifndef GLOBALSEARCHCONTROLLER_HPP #define GLOBALSEARCHCONTROLLER_HPP +#include "appconfig.hpp" #include "projectsearch.hpp" #include @@ -30,7 +31,7 @@ class GlobalSearchController { void updateGlobalSearchBar(); void initGlobalSearchBar( - UIGlobalSearchBar* globalSearchBar, + UIGlobalSearchBar* globalSearchBar, const GlobalSearchBarConfig& globalSearchBarConfig, std::unordered_map keybindings = getDefaultKeybindings() ); void hideGlobalSearchBar(); @@ -55,6 +56,8 @@ class GlobalSearchController { void clearHistory(); + GlobalSearchBarConfig getGlobalSearchBarConfig() const; + protected: UICodeEditorSplitter* mEditorSplitter{ nullptr }; UISceneNode* mUISceneNode{ nullptr }; diff --git a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp index ebcc11bad..cfbcf3c15 100644 --- a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp +++ b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp @@ -23,7 +23,7 @@ AutoCompletePlugin::AutoCompletePlugin() : } AutoCompletePlugin::AutoCompletePlugin( std::shared_ptr pool ) : - mSymbolPattern( "[%añàáâãäåèéêëìíîïòóôõöùúûüýÿÑÀÁÂÃÄÅÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝ][%w_" + mSymbolPattern( "[%a_ñàáâãäåèéêëìíîïòóôõöùúûüýÿÑÀÁÂÃÄÅÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝ][%w_" "ñàáâãäåèéêëìíîïòóôõöùúûüýÿÑÀÁÂÃÄÅÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝ]*" ), mBoxPadding( PixelDensity::dpToPx( Rectf( 4, 4, 4, 4 ) ) ), mPool( pool ) {}