mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
ecode: Added "sb" (switch build) and "sbt" (switch build type) commands to the universal locator. Added two commands to switch between the folder tree view and the build view.
This commit is contained in:
@@ -384,7 +384,7 @@ Anchor.error:hover {
|
||||
<PushButton lw="mp" lg="center" id="open_recent_folder" text='@string(open-recent-folder, "Open Recent Folder...")' margin-top="4dp" />
|
||||
</vbox>
|
||||
</RelativeLayout>
|
||||
<Tab text='@string("project", "Project")' owns="project_view_cont" text-as-fallback="true" icon="icon(folder-open, 12dp)" />
|
||||
<Tab id="treeview_tab" text='@string("project", "Project")' owns="project_view_cont" text-as-fallback="true" icon="icon(folder-open, 12dp)" />
|
||||
</TabWidget>
|
||||
<vbox>
|
||||
<Splitter id="main_splitter" lw="mp" lh="0" lw8="1" orientation="vertical">
|
||||
|
||||
@@ -1886,7 +1886,9 @@ std::vector<std::string> App::getUnlockedCommands() {
|
||||
"tree-view-configure-ignore-files",
|
||||
"show-open-documents",
|
||||
"open-workspace-symbol-search",
|
||||
"open-document-symbol-search" };
|
||||
"open-document-symbol-search",
|
||||
"show-folder-treeview-tab",
|
||||
"show-build-tab" };
|
||||
}
|
||||
|
||||
bool App::isUnlockedCommand( const std::string& command ) {
|
||||
@@ -2472,6 +2474,18 @@ void App::createNewTerminal() {
|
||||
}
|
||||
}
|
||||
|
||||
void App::showFolderTreeViewTab() {
|
||||
UITab* tab = mSidePanel->find<UITab>( "treeview_tab" );
|
||||
if ( tab )
|
||||
tab->setTabSelected();
|
||||
}
|
||||
|
||||
void App::showBuildTab() {
|
||||
UITab* tab = mSidePanel->find<UITab>( "build_tab" );
|
||||
if ( tab )
|
||||
tab->setTabSelected();
|
||||
}
|
||||
|
||||
std::string App::getNewFilePath( const FileInfo& file, UIMessageBox* msgBox, bool keepDir ) {
|
||||
auto fileName( msgBox->getTextInput()->getText().toUtf8() );
|
||||
auto folderPath( file.getDirectoryPath() );
|
||||
|
||||
@@ -183,6 +183,10 @@ class App : public UICodeEditorSplitter::Client {
|
||||
|
||||
UIStatusBar* getStatusBar() const { return mStatusBar; }
|
||||
|
||||
void showFolderTreeViewTab();
|
||||
|
||||
void showBuildTab();
|
||||
|
||||
template <typename T> void registerUnlockedCommands( T& t ) {
|
||||
t.setCommand( "keybindings", [this] { loadFileFromPath( mKeybindingsPath ); } );
|
||||
t.setCommand( "debug-draw-boxes-toggle", [this] { debugDrawBoxesToggle(); } );
|
||||
@@ -251,6 +255,8 @@ class App : public UICodeEditorSplitter::Client {
|
||||
mProjectBuildManager->cancelBuild();
|
||||
}
|
||||
} );
|
||||
t.setCommand( "show-folder-treeview-tab", [this] { showFolderTreeViewTab(); } );
|
||||
t.setCommand( "show-build-tab", [this] { showBuildTab(); } );
|
||||
t.setCommand( "open-workspace-symbol-search",
|
||||
[this] { mUniversalLocator->showWorkspaceSymbol(); } );
|
||||
t.setCommand( "open-document-symbol-search",
|
||||
|
||||
@@ -624,6 +624,13 @@ ProjectBuildOutputParser ProjectBuildManager::getOutputParser( const std::string
|
||||
return {};
|
||||
}
|
||||
|
||||
ProjectBuild* ProjectBuildManager::getBuild( const std::string& buildName ) {
|
||||
auto buildIt = mBuilds.find( buildName );
|
||||
if ( buildIt != mBuilds.end() )
|
||||
return &buildIt->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ProjectBuildManager::hasBuildCommands( const std::string& name ) {
|
||||
auto buildIt = mBuilds.find( name );
|
||||
if ( buildIt != mBuilds.end() )
|
||||
@@ -651,7 +658,25 @@ ProjectBuildConfiguration ProjectBuildManager::getConfig() const {
|
||||
}
|
||||
|
||||
void ProjectBuildManager::setConfig( const ProjectBuildConfiguration& config ) {
|
||||
mConfig = config;
|
||||
bool buildNameChanged = false;
|
||||
bool buildTypeChanged = false;
|
||||
|
||||
if ( mConfig.buildName != config.buildName ) {
|
||||
mConfig.buildName = config.buildName;
|
||||
buildNameChanged = true;
|
||||
updateSidePanelTab();
|
||||
}
|
||||
|
||||
if ( mConfig.buildType != config.buildType ) {
|
||||
mConfig.buildType = config.buildType;
|
||||
buildTypeChanged = true;
|
||||
updateBuildType();
|
||||
}
|
||||
|
||||
if ( buildNameChanged )
|
||||
updateSidePanelTab();
|
||||
else if ( buildTypeChanged )
|
||||
updateBuildType();
|
||||
}
|
||||
|
||||
void ProjectBuildManager::buildCurrentConfig( StatusBuildOutputController* sboc ) {
|
||||
@@ -852,13 +877,18 @@ void ProjectBuildManager::buildSidePanelTab() {
|
||||
)html" );
|
||||
mTab = mSidePanel->add( mUISceneNode->getTranslatorStringFromKey( "build", "Build" ), node,
|
||||
icon ? icon->getSize( PixelDensity::dpToPx( 12 ) ) : nullptr );
|
||||
mTab->setId( "build_tab" );
|
||||
mTab->setTextAsFallback( true );
|
||||
|
||||
updateSidePanelTab();
|
||||
}
|
||||
|
||||
void ProjectBuildManager::updateSidePanelTab() {
|
||||
if ( mTab == nullptr )
|
||||
return;
|
||||
UIWidget* buildTab = mTab->getOwnedWidget()->find<UIWidget>( "build_tab" );
|
||||
if ( buildTab == nullptr )
|
||||
return;
|
||||
UIDropDownList* buildList = buildTab->find<UIDropDownList>( "build_list" );
|
||||
UIPushButton* buildButton = buildTab->find<UIPushButton>( "build_button" );
|
||||
UIPushButton* cleanButton = buildTab->find<UIPushButton>( "clean_button" );
|
||||
@@ -938,7 +968,11 @@ void ProjectBuildManager::updateSidePanelTab() {
|
||||
}
|
||||
|
||||
void ProjectBuildManager::updateBuildType() {
|
||||
if ( mTab == nullptr )
|
||||
return;
|
||||
UIWidget* buildTab = mTab->getOwnedWidget()->find<UIWidget>( "build_tab" );
|
||||
if ( buildTab == nullptr )
|
||||
return;
|
||||
UIDropDownList* buildList = buildTab->find<UIDropDownList>( "build_list" );
|
||||
UIDropDownList* buildTypeList = buildTab->find<UIDropDownList>( "build_type_list" );
|
||||
|
||||
|
||||
@@ -205,8 +205,7 @@ class ProjectBuild {
|
||||
struct ProjectBuildCommand : public ProjectBuildStep {
|
||||
ProjectBuildConfig config;
|
||||
|
||||
ProjectBuildCommand( const ProjectBuildStep& step ) :
|
||||
ProjectBuildStep( step ) {}
|
||||
ProjectBuildCommand( const ProjectBuildStep& step ) : ProjectBuildStep( step ) {}
|
||||
};
|
||||
|
||||
using ProjectBuildCommands = std::vector<ProjectBuildCommand>;
|
||||
@@ -264,6 +263,8 @@ class ProjectBuildManager {
|
||||
|
||||
const std::string& getProjectFile() const { return mProjectFile; }
|
||||
|
||||
ProjectBuild* getBuild( const std::string& buildName );
|
||||
|
||||
bool hasBuild( const std::string& name ) { return mBuilds.find( name ) != mBuilds.end(); }
|
||||
|
||||
bool hasBuildCommands( const std::string& name );
|
||||
|
||||
@@ -156,6 +156,7 @@ void UniversalLocator::updateFilesTable() {
|
||||
mLocateTable->setModel( res );
|
||||
mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) );
|
||||
mLocateTable->scrollToTop();
|
||||
updateLocateBarSync();
|
||||
} );
|
||||
} );
|
||||
#else
|
||||
@@ -202,11 +203,8 @@ void UniversalLocator::updateCommandPaletteTable() {
|
||||
#endif
|
||||
} else if ( mCommandPalette.getCurModel() ) {
|
||||
mLocateTable->setModel( mCommandPalette.getCurModel() );
|
||||
|
||||
mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) );
|
||||
}
|
||||
|
||||
mLocateTable->setColumnsVisible( { 0, 1 } );
|
||||
}
|
||||
|
||||
void UniversalLocator::showLocateTable() {
|
||||
@@ -214,6 +212,7 @@ void UniversalLocator::showLocateTable() {
|
||||
Vector2f pos( mLocateInput->convertToWorldSpace( { 0, 0 } ) );
|
||||
pos.y -= mLocateTable->getPixelsSize().getHeight();
|
||||
mLocateTable->setPixelsPosition( pos );
|
||||
updateFilesTable();
|
||||
}
|
||||
|
||||
void UniversalLocator::goToLine() {
|
||||
@@ -222,8 +221,9 @@ void UniversalLocator::goToLine() {
|
||||
}
|
||||
|
||||
static bool isCommand( const std::string& filename ) {
|
||||
return !filename.empty() && ( filename == "> " || filename == ": " || filename == "l " ||
|
||||
filename == ". " || filename == "o " );
|
||||
return !filename.empty() &&
|
||||
( filename == "> " || filename == ": " || filename == "l " || filename == ". " ||
|
||||
filename == "o " || filename == "sb " || filename == "sbt " );
|
||||
}
|
||||
|
||||
void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locateInput ) {
|
||||
@@ -271,10 +271,14 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
|
||||
showOpenDocuments();
|
||||
} else if ( String::startsWith( inputTxt, ". " ) ) {
|
||||
showDocumentSymbol();
|
||||
} else if ( String::startsWith( inputTxt, "sb " ) ) {
|
||||
showSwitchBuild();
|
||||
} else if ( String::startsWith( inputTxt, "sbt " ) ) {
|
||||
showSwitchBuildType();
|
||||
} else {
|
||||
showLocateTable();
|
||||
updateFilesTable();
|
||||
}
|
||||
updateLocateBarSync();
|
||||
} );
|
||||
mLocateInput->addEventListener( Event::OnPressEnter, [this]( const Event* ) {
|
||||
KeyEvent keyEvent( mLocateTable, Event::KeyDown, KEY_RETURN, SCANCODE_UNKNOWN, 0, 0 );
|
||||
@@ -329,6 +333,32 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
|
||||
mLocateInput->setText( vName.toString() );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( String::startsWith( mLocateInput->getText(), "sb " ) ) {
|
||||
auto pbm = mApp->getProjectBuildManager();
|
||||
auto cfg = pbm->getConfig();
|
||||
std::string buildName = vName.toString();
|
||||
if ( pbm->hasBuild( buildName ) ) {
|
||||
cfg.buildName = buildName;
|
||||
pbm->setConfig( cfg );
|
||||
mLocateBarLayout->execute( "close-locatebar" );
|
||||
}
|
||||
return;
|
||||
} else if ( String::startsWith( mLocateInput->getText(), "sbt " ) ) {
|
||||
auto pbm = mApp->getProjectBuildManager();
|
||||
auto cfg = pbm->getConfig();
|
||||
auto build = pbm->getBuild( cfg.buildName );
|
||||
if ( build != nullptr ) {
|
||||
std::string buildType = vName.toString();
|
||||
if ( build->buildTypes().find( buildType ) != build->buildTypes().end() ) {
|
||||
cfg.buildType = buildType;
|
||||
pbm->setConfig( cfg );
|
||||
mLocateBarLayout->execute( "close-locatebar" );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Variant vPath( modelEvent->getModel()->data(
|
||||
modelEvent->getModel()->index( modelEvent->getModelIndex().row(), 1 ),
|
||||
ModelRole::Display ) );
|
||||
@@ -375,19 +405,26 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
|
||||
} );
|
||||
}
|
||||
|
||||
void UniversalLocator::updateLocateBar() {
|
||||
mLocateBarLayout->runOnMainThread( [this] {
|
||||
Float width = eeceil( mLocateInput->getPixelsSize().getWidth() );
|
||||
mLocateTable->setPixelsSize( width,
|
||||
mLocateTable->getRowHeight() * LOCATEBAR_MAX_VISIBLE_ITEMS );
|
||||
width -= mLocateTable->getVerticalScrollBar()->getPixelsSize().getWidth();
|
||||
void UniversalLocator::updateLocateBarSync() {
|
||||
Float width = eeceil( mLocateInput->getPixelsSize().getWidth() );
|
||||
mLocateTable->setPixelsSize( width,
|
||||
mLocateTable->getRowHeight() * LOCATEBAR_MAX_VISIBLE_ITEMS );
|
||||
width -= mLocateTable->getVerticalScrollBar()->getPixelsSize().getWidth();
|
||||
if ( mLocateTable->getModel()->columnCount() == 2 ) {
|
||||
mLocateTable->setColumnsVisible( { 0, 1 } );
|
||||
mLocateTable->setColumnWidth( 0, eeceil( width * 0.5 ) );
|
||||
mLocateTable->setColumnWidth( 1, width - mLocateTable->getColumnWidth( 0 ) );
|
||||
Vector2f pos( mLocateInput->convertToWorldSpace( { 0, 0 } ) );
|
||||
pos.y -= mLocateTable->getPixelsSize().getHeight();
|
||||
mLocateTable->setPixelsPosition( pos );
|
||||
} );
|
||||
} else {
|
||||
mLocateTable->setColumnsVisible( { 0 } );
|
||||
mLocateTable->setColumnWidth( 0, width );
|
||||
}
|
||||
Vector2f pos( mLocateInput->convertToWorldSpace( { 0, 0 } ) );
|
||||
pos.y -= mLocateTable->getPixelsSize().getHeight();
|
||||
mLocateTable->setPixelsPosition( pos );
|
||||
}
|
||||
|
||||
void UniversalLocator::updateLocateBar() {
|
||||
mLocateBarLayout->runOnMainThread( [this] { updateLocateBarSync(); } );
|
||||
}
|
||||
|
||||
void UniversalLocator::showBar() {
|
||||
@@ -421,7 +458,10 @@ void UniversalLocator::showLocateBar() {
|
||||
showBar();
|
||||
|
||||
if ( !mLocateInput->getText().empty() &&
|
||||
( mLocateInput->getText()[0] == '>' || mLocateInput->getText()[0] == ':' ) )
|
||||
( mLocateInput->getText()[0] == '>' || mLocateInput->getText()[0] == ':' ||
|
||||
mLocateInput->getText()[0] == '.' ||
|
||||
String::startsWith( mLocateInput->getText(), "sb " ) ||
|
||||
String::startsWith( mLocateInput->getText(), "sbt " ) ) )
|
||||
mLocateInput->setText( "" );
|
||||
|
||||
if ( mApp->getDirTree() && !mLocateTable->getModel() ) {
|
||||
@@ -556,6 +596,94 @@ void UniversalLocator::updateOpenDocumentsTable() {
|
||||
mLocateTable->scrollToTop();
|
||||
}
|
||||
|
||||
void UniversalLocator::showSwitchBuild() {
|
||||
showBar();
|
||||
|
||||
if ( mLocateInput->getText().empty() || !String::startsWith( mLocateInput->getText(), "sb " ) )
|
||||
mLocateInput->setText( "sb " );
|
||||
|
||||
if ( mLocateInput->getText().size() >= 3 )
|
||||
updateSwitchBuildTable();
|
||||
updateLocateBar();
|
||||
mApp->getStatusBar()->updateState();
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemListOwnerModel<std::string>>
|
||||
UniversalLocator::openBuildModel( const std::string& match ) {
|
||||
const auto& builds = mApp->getProjectBuildManager()->getBuilds();
|
||||
std::vector<std::string> buildNames;
|
||||
if ( builds.empty() )
|
||||
return ItemListOwnerModel<std::string>::create( {} );
|
||||
buildNames.reserve( builds.size() );
|
||||
for ( const auto& build : builds ) {
|
||||
if ( match.empty() ||
|
||||
String::startsWith( String::toLower( build.first ), String::toLower( match ) ) )
|
||||
buildNames.push_back( build.first );
|
||||
}
|
||||
std::stable_sort( buildNames.begin(), buildNames.end() );
|
||||
return ItemListOwnerModel<std::string>::create( buildNames );
|
||||
}
|
||||
|
||||
void UniversalLocator::updateSwitchBuildTable() {
|
||||
mLocateTable->setModel( openBuildModel( mLocateInput->getText().substr( 3 ).trim().toUtf8() ) );
|
||||
if ( mLocateTable->getModel()->rowCount() > 0 ) {
|
||||
ModelIndex idx =
|
||||
mLocateTable->findRowWithText( mApp->getProjectBuildManager()->getConfig().buildName );
|
||||
mLocateTable->getSelection().set( idx.isValid() ? idx
|
||||
: mLocateTable->getModel()->index( 0 ) );
|
||||
}
|
||||
mLocateTable->scrollToTop();
|
||||
}
|
||||
|
||||
void UniversalLocator::showSwitchBuildType() {
|
||||
showBar();
|
||||
|
||||
if ( mLocateInput->getText().empty() || !String::startsWith( mLocateInput->getText(), "sbt " ) )
|
||||
mLocateInput->setText( "sbt " );
|
||||
|
||||
if ( mLocateInput->getText().size() >= 4 )
|
||||
updateSwitchBuildTypeTable();
|
||||
updateLocateBar();
|
||||
mApp->getStatusBar()->updateState();
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemListOwnerModel<std::string>>
|
||||
UniversalLocator::openBuildTypeModel( const std::string& match ) {
|
||||
const auto& builds = mApp->getProjectBuildManager()->getBuilds();
|
||||
const auto& cfg = mApp->getProjectBuildManager()->getConfig();
|
||||
|
||||
auto buildIt = builds.find( cfg.buildName );
|
||||
if ( buildIt == builds.end() )
|
||||
return ItemListOwnerModel<std::string>::create( {} );
|
||||
const auto& build = buildIt->second;
|
||||
const auto& buildTypes = build.buildTypes();
|
||||
if ( buildTypes.empty() )
|
||||
return ItemListOwnerModel<std::string>::create( {} );
|
||||
|
||||
std::vector<std::string> buildTypeNames;
|
||||
buildTypeNames.reserve( builds.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() );
|
||||
return ItemListOwnerModel<std::string>::create( buildTypeNames );
|
||||
}
|
||||
|
||||
void UniversalLocator::updateSwitchBuildTypeTable() {
|
||||
mLocateTable->setModel(
|
||||
openBuildTypeModel( mLocateInput->getText().substr( 4 ).trim().toUtf8() ) );
|
||||
if ( mLocateTable->getModel()->rowCount() > 0 ) {
|
||||
ModelIndex idx =
|
||||
mLocateTable->findRowWithText( mApp->getProjectBuildManager()->getConfig().buildType );
|
||||
mLocateTable->getSelection().set( idx.isValid() ? idx
|
||||
: mLocateTable->getModel()->index( 0 ) );
|
||||
}
|
||||
mLocateTable->scrollToTop();
|
||||
mLocateTable->setColumnsVisible( { 0 } );
|
||||
}
|
||||
|
||||
void UniversalLocator::onCodeEditorFocusChange( UICodeEditor* editor ) {
|
||||
if ( !mLocateTable || !mLocateTable->isVisible() )
|
||||
return;
|
||||
@@ -725,6 +853,9 @@ std::vector<ProjectDirectoryTree::CommandInfo> UniversalLocator::getLocatorComma
|
||||
mUISceneNode->i18n( "go_to_line_in_current_document", "Go To Line in Current Document" ),
|
||||
icon } );
|
||||
vec.push_back( { "o ", mUISceneNode->i18n( "open_documents", "Open Documents" ), icon } );
|
||||
vec.push_back( { "sb ", mUISceneNode->i18n( "switch_build", "Switch Build" ), icon } );
|
||||
vec.push_back(
|
||||
{ "sbt ", mUISceneNode->i18n( "switch_build_type", "Switch Build Type" ), icon } );
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,10 @@ class UniversalLocator {
|
||||
|
||||
void showOpenDocuments();
|
||||
|
||||
void showSwitchBuild();
|
||||
|
||||
void showSwitchBuildType();
|
||||
|
||||
protected:
|
||||
UILocateBar* mLocateBarLayout{ nullptr };
|
||||
UITableView* mLocateTable{ nullptr };
|
||||
@@ -60,18 +64,26 @@ class UniversalLocator {
|
||||
|
||||
void updateLocateBar();
|
||||
|
||||
void updateLocateBarSync();
|
||||
|
||||
void showBar();
|
||||
|
||||
PluginRequestHandle processResponse( const PluginMessage& msg );
|
||||
|
||||
void requestWorkspaceSymbol();
|
||||
|
||||
void updateWorkspaceSymbol( const LSPSymbolInformationList& info );
|
||||
|
||||
void requestDocumentSymbol();
|
||||
|
||||
void updateDocumentSymbol( const LSPSymbolInformationList& info );
|
||||
|
||||
void updateOpenDocumentsTable();
|
||||
|
||||
void updateSwitchBuildTable();
|
||||
|
||||
void updateSwitchBuildTypeTable();
|
||||
|
||||
void requestWorkspaceSymbol();
|
||||
|
||||
void requestDocumentSymbol();
|
||||
|
||||
std::string getCurDocURI();
|
||||
|
||||
std::vector<ProjectDirectoryTree::CommandInfo> getLocatorCommands() const;
|
||||
@@ -83,11 +95,13 @@ class UniversalLocator {
|
||||
const LSPSymbolInformationList& list, const std::string& query, const size_t& limit,
|
||||
std::function<void( std::shared_ptr<LSPSymbolInfoModel> )> cb );
|
||||
|
||||
void updateOpenDocumentsTable();
|
||||
|
||||
std::shared_ptr<FileListModel> openDocumentsModel( const std::string& match );
|
||||
|
||||
void focusOrLoadFile( const std::string& path, const TextRange& range = {} );
|
||||
|
||||
std::shared_ptr<ItemListOwnerModel<std::string>> openBuildModel( const std::string& match );
|
||||
|
||||
std::shared_ptr<ItemListOwnerModel<std::string>> openBuildTypeModel( const std::string& match );
|
||||
};
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
Reference in New Issue
Block a user