diff --git a/src/eepp/ui/doc/languages/cpp.cpp b/src/eepp/ui/doc/languages/cpp.cpp index eb94a2370..f30b56444 100644 --- a/src/eepp/ui/doc/languages/cpp.cpp +++ b/src/eepp/ui/doc/languages/cpp.cpp @@ -8,8 +8,8 @@ void addCPP() { SyntaxDefinitionManager::instance()->add( { "C++", - { "%.cpp$", "%.cc$", "%.cxx$", "%.c++$", "%.hh$", "%.inl$", "%.hxx$", "%.hpp$", - "%.h++$" }, + { "%.cpp$", "%.cc$", "%.cxx$", "%.c++$", "%.hh$", "%.inl$", "%.hxx$", "%.hpp$", "%.h++$", + "%.tcc$" }, { { { "R%\"xml%(", "%)xml%\"" }, "function", "XML" }, { { "R%\"css%(", "%)css%\"" }, "function", "CSS" }, diff --git a/src/tools/ecode/projectbuild.cpp b/src/tools/ecode/projectbuild.cpp index e4af03bc5..7597e9fdb 100644 --- a/src/tools/ecode/projectbuild.cpp +++ b/src/tools/ecode/projectbuild.cpp @@ -1201,7 +1201,9 @@ void ProjectBuildManager::updateRunConfig() { UIDropDownList* buildList = buildTab->find( "build_list" ); UIDropDownList* runConfigList = buildTab->find( "run_config_list" ); + auto runName = mConfig.runName; runConfigList->getListBox()->clear(); + mConfig.runName = runName; String first = buildList->getListBox()->getItemSelectedText(); if ( !first.empty() ) { diff --git a/src/tools/ecode/universallocator.cpp b/src/tools/ecode/universallocator.cpp index 67da5902a..917234960 100644 --- a/src/tools/ecode/universallocator.cpp +++ b/src/tools/ecode/universallocator.cpp @@ -125,7 +125,7 @@ UniversalLocator::UniversalLocator( UICodeEditorSplitter* editorSplitter, UIScen showCommandPalette(); return true; }, - [this]( const Variant& vName, const ModelEvent* modelEvent ) { + [this]( const Variant&, const ModelEvent* modelEvent ) { ModelIndex idx( modelEvent->getModel()->index( modelEvent->getModelIndex().row(), 2 ) ); if ( idx.isValid() ) { String cmd = modelEvent->getModel()->data( idx, ModelRole::Display ).toString(); @@ -155,12 +155,14 @@ UniversalLocator::UniversalLocator( UICodeEditorSplitter* editorSplitter, UIScen nullptr } ); mLocatorProviders.push_back( - { ".", mUISceneNode->i18n( "search_for_symbols_in_current_document", "Search for Symbols in Current Document" ), + { ".", + mUISceneNode->i18n( "search_for_symbols_in_current_document", + "Search for Symbols in Current Document" ), [this]( auto ) { showDocumentSymbol(); return true; }, - [this]( const Variant& vName, const ModelEvent* modelEvent ) { + [this]( const Variant&, const ModelEvent* modelEvent ) { Variant rangeStr( modelEvent->getModel()->data( modelEvent->getModel()->index( modelEvent->getModelIndex().row(), 1 ), ModelRole::Custom ) ); @@ -227,8 +229,8 @@ UniversalLocator::UniversalLocator( UICodeEditorSplitter* editorSplitter, UIScen // clang-format off mLocatorProviders.push_back( { "sb", mUISceneNode->i18n( "switch_build", "Switch Build" ), [this](auto) { - showSwitchBuild(); - return true; + showSwitchBuild(); + return true; }, [this]( const Variant& vName, const ModelEvent* ) { auto pbm = mApp->getProjectBuildManager(); @@ -266,6 +268,32 @@ UniversalLocator::UniversalLocator( UICodeEditorSplitter* editorSplitter, UIScen } } } ); + mLocatorProviders.push_back( + { "srt", mUISceneNode->i18n( "switch_run_target", "Switch Run Target" ), + [this]( auto ) { + showSwitchRunTarget(); + return true; + }, + [this]( const Variant& vName, const ModelEvent* ) { + auto pbm = mApp->getProjectBuildManager(); + if ( nullptr == pbm ) + return; + auto cfg = pbm->getConfig(); + auto build = pbm->getBuild( cfg.buildName ); + if ( build != nullptr ) { + std::string runTarget = vName.toString(); + auto it = std::find_if( build->runConfigs().begin(), build->runConfigs().end(), + [&runTarget]( const ProjectBuildStep& run ) { + return run.name == runTarget; + } ); + if ( it != build->runConfigs().end() ) { + cfg.runName = runTarget; + pbm->setConfig( cfg ); + mLocateBarLayout->execute( "close-locatebar" ); + } + } + } } ); + mLocatorProviders.push_back( { "ft", mUISceneNode->i18n( "switch_file_type", "Switch File Type" ), [this]( auto ) { @@ -747,7 +775,7 @@ UniversalLocator::openBuildModel( const std::string& match ) { String::startsWith( String::toLower( build.first ), String::toLower( match ) ) ) buildNames.push_back( build.first ); } - std::stable_sort( buildNames.begin(), buildNames.end() ); + std::sort( buildNames.begin(), buildNames.end() ); return ItemListOwnerModel::create( buildNames ); } @@ -774,6 +802,18 @@ void UniversalLocator::showSwitchBuildType() { mApp->getStatusBar()->updateState(); } +void UniversalLocator::showSwitchRunTarget() { + showBar(); + + if ( mLocateInput->getText().empty() || !String::startsWith( mLocateInput->getText(), "srt " ) ) + mLocateInput->setText( "srt " ); + + if ( mLocateInput->getText().size() >= 4 ) + updateSwitchRunTargetTable(); + updateLocateBar(); + mApp->getStatusBar()->updateState(); +} + std::shared_ptr> UniversalLocator::openBuildTypeModel( const std::string& match ) { if ( nullptr == mApp->getProjectBuildManager() ) @@ -790,16 +830,41 @@ UniversalLocator::openBuildTypeModel( const std::string& match ) { return ItemListOwnerModel::create( {} ); std::vector buildTypeNames; - buildTypeNames.reserve( builds.size() ); + buildTypeNames.reserve( buildTypes.size() ); for ( const auto& build : buildTypes ) { if ( match.empty() || String::startsWith( String::toLower( build ), String::toLower( match ) ) ) buildTypeNames.push_back( build ); } - std::stable_sort( buildTypeNames.begin(), buildTypeNames.end() ); + std::sort( buildTypeNames.begin(), buildTypeNames.end() ); return ItemListOwnerModel::create( buildTypeNames ); } +std::shared_ptr> +UniversalLocator::openRunTargetModel( const std::string& match ) { + if ( nullptr == mApp->getProjectBuildManager() ) + return ItemListOwnerModel::create( {} ); + const auto& builds = mApp->getProjectBuildManager()->getBuilds(); + const auto& cfg = mApp->getProjectBuildManager()->getConfig(); + auto buildIt = builds.find( cfg.buildName ); + if ( buildIt == builds.end() ) + return ItemListOwnerModel::create( {} ); + const auto& build = buildIt->second; + const auto& runs = build.runConfigs(); + if ( runs.empty() ) + return ItemListOwnerModel::create( {} ); + + std::vector runTargetNames; + runTargetNames.reserve( runs.size() ); + for ( const auto& run : runs ) { + if ( match.empty() || + String::startsWith( String::toLower( run.name ), String::toLower( match ) ) ) + runTargetNames.push_back( run.name ); + } + std::sort( runTargetNames.begin(), runTargetNames.end() ); + return ItemListOwnerModel::create( runTargetNames ); +} + void UniversalLocator::updateSwitchBuildTypeTable() { mLocateTable->setModel( openBuildTypeModel( mLocateInput->getText().substr( 4 ).trim().toUtf8() ) ); @@ -813,6 +878,19 @@ void UniversalLocator::updateSwitchBuildTypeTable() { mLocateTable->setColumnsVisible( { 0 } ); } +void UniversalLocator::updateSwitchRunTargetTable() { + mLocateTable->setModel( + openRunTargetModel( mLocateInput->getText().substr( 4 ).trim().toUtf8() ) ); + if ( mLocateTable->getModel()->rowCount() > 0 && nullptr != mApp->getProjectBuildManager() ) { + ModelIndex idx = + mLocateTable->findRowWithText( mApp->getProjectBuildManager()->getConfig().runName ); + mLocateTable->getSelection().set( idx.isValid() ? idx + : mLocateTable->getModel()->index( 0 ) ); + } + mLocateTable->scrollToTop(); + mLocateTable->setColumnsVisible( { 0 } ); +} + void UniversalLocator::showSwitchFileType() { showBar(); diff --git a/src/tools/ecode/universallocator.hpp b/src/tools/ecode/universallocator.hpp index 4d455e684..604708cfe 100644 --- a/src/tools/ecode/universallocator.hpp +++ b/src/tools/ecode/universallocator.hpp @@ -67,6 +67,8 @@ class UniversalLocator { void showSwitchBuildType(); + void showSwitchRunTarget(); + void showSwitchFileType(); protected: @@ -104,6 +106,8 @@ class UniversalLocator { void updateSwitchBuildTypeTable(); + void updateSwitchRunTargetTable(); + void updateSwitchFileTypeTable(); void requestWorkspaceSymbol(); @@ -129,6 +133,8 @@ class UniversalLocator { std::shared_ptr> openBuildTypeModel( const std::string& match ); + std::shared_ptr> openRunTargetModel( const std::string& match ); + std::shared_ptr> openFileTypeModel( const std::string& match ); bool findCapability( PluginCapability );