diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 7531b8f55..05ebf46a1 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -294,6 +294,8 @@ class EE_API TextDocument { void deleteToNextWord(); + void deleteWord(); + void deleteCurrentLine(); void selectToPreviousChar(); diff --git a/include/eepp/ui/uiconsole.hpp b/include/eepp/ui/uiconsole.hpp index ce2609f9e..e3ca9de7e 100644 --- a/include/eepp/ui/uiconsole.hpp +++ b/include/eepp/ui/uiconsole.hpp @@ -140,6 +140,10 @@ class EE_API UIConsole : public UIWidget, void setMenuIconSize( size_t menuIconSize ); + KeyBindings& getKeyBindings(); + + TextDocument& getDoc(); + protected: struct TextCache { Text text; diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index ecab43151..14d443cc8 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -1612,6 +1612,14 @@ void TextDocument::deleteToNextWord() { mergeSelection(); } +void TextDocument::deleteWord() { + for ( size_t i = 0; i < mSelection.size(); ++i ) { + moveTo( i, previousWordBoundary( getSelectionIndex( i ).start() ) ); + deleteTo( i, nextWordBoundary( getSelectionIndex( i ).start() ) ); + } + mergeSelection(); +} + void TextDocument::deleteCurrentLine() { BoolScopedOpOptional op( !mDoingTextInput, mDoingTextInput, true ); for ( size_t i = 0; i < mSelection.size(); ++i ) { @@ -2923,6 +2931,7 @@ void TextDocument::initializeCommands() { mCommands["delete-to-next-char"] = [this] { deleteToNextChar(); }; mCommands["delete-current-line"] = [this] { deleteCurrentLine(); }; mCommands["delete-selection"] = [this] { deleteSelection(); }; + mCommands["delete-word"] = [this] { deleteWord(); }; mCommands["move-to-previous-char"] = [this] { moveToPreviousChar(); }; mCommands["move-to-previous-word"] = [this] { moveToPreviousWord(); }; mCommands["move-to-next-char"] = [this] { moveToNextChar(); }; diff --git a/src/eepp/ui/uiconsole.cpp b/src/eepp/ui/uiconsole.cpp index 1b42ce3ad..6452fd342 100644 --- a/src/eepp/ui/uiconsole.cpp +++ b/src/eepp/ui/uiconsole.cpp @@ -139,6 +139,14 @@ void UIConsole::setMenuIconSize( size_t menuIconSize ) { mMenuIconSize = menuIconSize; } +KeyBindings& UIConsole::getKeyBindings() { + return mKeyBindings; +} + +TextDocument& UIConsole::getDoc() { + return mDoc; +} + Font* UIConsole::getFont() const { return mFontStyleConfig.Font; } diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 112c9a4d0..dd9c14989 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -123,7 +123,7 @@ void UITabWidget::setContainerSize() { Float totalSize = totalTabsWidth > mSize.getWidth() ? totalTabsWidth : mSize.getWidth(); mTabBar->setPixelsSize( totalSize - mPaddingPx.Left - mPaddingPx.Right, PixelDensity::dpToPx( mStyleConfig.TabHeight ) ); - mTabBar->setPosition( mPadding.Left, mPadding.Top ); + mTabBar->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top ); mNodeContainer->setPosition( mPadding.Left, mPadding.Top + mStyleConfig.TabHeight ); Sizef s( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabHeight ) - @@ -472,6 +472,8 @@ void UITabWidget::orderTabs() { posTabs(); + updateScroll( true ); + invalidateDraw(); } @@ -1065,31 +1067,32 @@ void UITabWidget::updateScrollBar() { } void UITabWidget::updateScroll( bool updateFocus ) { - if ( mTabScroll->isVisible() ) { - mTabBar->setPixelsPosition( - { mPaddingPx.Left - mTabScroll->getValue(), mTabBar->getPixelsPosition().y } ); - mTabScroll->setPixelsPosition( - { -mTabBar->getPixelsPosition().x, mTabScroll->getPixelsPosition().y } ); + if ( !mTabScroll->isVisible() ) + return; - if ( updateFocus && mTabSelected ) { - Rectf r = mTabScroll->getRectBox(); - Rectf r2 = mTabSelected->getRectBox(); + mTabBar->setPixelsPosition( mPaddingPx.Left - mTabScroll->getValue(), + mTabBar->getPixelsPosition().y ); + mTabScroll->setPixelsPosition( -mTabBar->getPixelsPosition().x, + mTabScroll->getPixelsPosition().y ); - if ( !( r.Left <= r2.Left && r.Right >= r2.Right ) ) { - size_t pIndex = mFocusHistory.size() >= 2 - ? getTabIndex( mFocusHistory.at( mFocusHistory.size() - 2 ) ) - : getTabIndex( mFocusHistory.back() ); + if ( updateFocus && mTabSelected ) { + Rectf r = mTabScroll->getRectBox(); + Rectf r2 = mTabSelected->getRectBox(); - Float x = mTabSelectedIndex > pIndex - ? eeclamp( mTabSelected->getPixelsPosition().x + - mTabSelected->getPixelsSize().getWidth() - - mTabScroll->getPixelsSize().getWidth(), - 0.f, mTabScroll->getMaxValue() ) - : eeclamp( mTabSelected->getPixelsPosition().x, 0.f, - mTabScroll->getMaxValue() ); + if ( !( r.Left <= r2.Left && r.Right >= r2.Right ) ) { + size_t pIndex = mFocusHistory.size() >= 2 + ? getTabIndex( mFocusHistory.at( mFocusHistory.size() - 2 ) ) + : getTabIndex( mFocusHistory.back() ); - mTabScroll->setValue( x ); - } + Float x = mTabSelectedIndex > pIndex + ? eeclamp( mTabSelected->getPixelsPosition().x + + mTabSelected->getPixelsSize().getWidth() - + mTabScroll->getPixelsSize().getWidth(), + 0.f, mTabScroll->getMaxValue() ) + : eeclamp( mTabSelected->getPixelsPosition().x, 0.f, + mTabScroll->getMaxValue() ); + + mTabScroll->setValue( x ); } } } diff --git a/src/thirdparty/SOIL2 b/src/thirdparty/SOIL2 index 58a945833..229324688 160000 --- a/src/thirdparty/SOIL2 +++ b/src/thirdparty/SOIL2 @@ -1 +1 @@ -Subproject commit 58a94583381a341485636ee7feec821acb898540 +Subproject commit 229324688c26f1e31da0171f3f5193f12253619e diff --git a/src/tools/ecode/plugins/git/git.cpp b/src/tools/ecode/plugins/git/git.cpp index eae60dd35..2827b6eca 100644 --- a/src/tools/ecode/plugins/git/git.cpp +++ b/src/tools/ecode/plugins/git/git.cpp @@ -67,7 +67,7 @@ int Git::git( const std::string& args, const std::string& projectDir, std::strin p.readAllStdOut( buf ); int retCode; p.join( &retCode ); - Log::debug( "GitPlugin run: %s %s", mGitPath, args ); + Log::info( "GitPlugin run: %s %s", mGitPath, args ); return retCode; } @@ -86,9 +86,6 @@ bool Git::isGitRepo( const std::string& projectDir ) { std::string Git::branch( const std::string& projectDir ) { std::string buf; - if ( EXIT_SUCCESS == git( "symbolic-ref --short HEAD", projectDir, buf ) ) - return String::rTrim( buf, '\n' ); - if ( EXIT_SUCCESS == git( "rev-parse --abbrev-ref HEAD", projectDir, buf ) ) return String::rTrim( buf, '\n' ); diff --git a/src/tools/ecode/plugins/git/gitplugin.cpp b/src/tools/ecode/plugins/git/gitplugin.cpp index 02b95d285..257766b8b 100644 --- a/src/tools/ecode/plugins/git/gitplugin.cpp +++ b/src/tools/ecode/plugins/git/gitplugin.cpp @@ -1,6 +1,7 @@ #include "gitplugin.hpp" #include #include +#include #include #include #include @@ -628,11 +629,16 @@ void GitPlugin::updateStatusBarSync() { ->setEnabled( !mGitContentView->isEnabled() ); if ( !mGit->getGitFolder().empty() ) { - Lock l( mGitStatusMutex ); - mStatusTree->setModel( GitStatusModel::asModel( mGitStatus.files, this ) ); + { + Lock l( mGitStatusMutex ); + mStatusTree->setModel( GitStatusModel::asModel( mGitStatus.files, this ) ); + } mStatusTree->expandAll(); } + if ( !mStatusBarDisplayBranch ) + return; + if ( !mStatusBar ) getUISceneNode()->bind( "status_bar", mStatusBar ); if ( !mStatusBar ) @@ -702,34 +708,32 @@ void GitPlugin::updateStatusBarSync() { } void GitPlugin::updateStatus( bool force ) { - if ( !mGit || !mGitFound || !mStatusBarDisplayBranch || mRunningUpdateStatus ) + if ( !mGit || !mGitFound || mRunningUpdateStatus ) return; mRunningUpdateStatus++; mThreadPool->run( [this, force] { - if ( !mGit ) + if ( !mGit || mGit->getGitFolder().empty() ) return; - if ( !mGit->getGitFolder().empty() ) { - auto prevBranch = mGitBranches; - { - Lock l( mGitBranchMutex ); - mGitBranches = mGit->branches( repos() ); - } - Git::Status prevGitStatus; - { - Lock l( mGitStatusMutex ); - prevGitStatus = mGitStatus; - } - Git::Status newGitStatus = mGit->status( mStatusRecurseSubmodules ); - { - Lock l( mGitStatusMutex ); - mGitStatus = std::move( newGitStatus ); - if ( !force && mGitBranches == prevBranch && mGitStatus == prevGitStatus ) - return; - } - } else if ( !mStatusButton ) { - return; + decltype( mGitBranches ) prevBranch; + { + auto branches = mGit->branches( repos() ); + Lock l( mGitBranchMutex ); + prevBranch = mGitBranches; + mGitBranches = std::move( branches ); + } + Git::Status prevGitStatus; + { + Lock l( mGitStatusMutex ); + prevGitStatus = mGitStatus; + } + Git::Status newGitStatus = mGit->status( mStatusRecurseSubmodules ); + { + Lock l( mGitStatusMutex ); + mGitStatus = std::move( newGitStatus ); + if ( !force && mGitBranches == prevBranch && mGitStatus == prevGitStatus ) + return; } getUISceneNode()->runOnMainThread( [this] { updateStatusBarSync(); } ); @@ -1004,7 +1008,7 @@ void GitPlugin::branchDelete( Git::Branch branch ) { } void GitPlugin::pull() { - runAsync( [this]() { return mGit->pull( repoSelected() ); }, true, true ); + runAsync( [this]() { return mGit->pull( repoSelected() ); }, true, true, true ); } void GitPlugin::push() { @@ -1023,7 +1027,7 @@ void GitPlugin::push() { } void GitPlugin::fetch() { - runAsync( [this]() { return mGit->fetch( repoSelected() ); }, true, true ); + runAsync( [this]() { return mGit->fetch( repoSelected() ); }, true, true, true ); } void GitPlugin::branchCreate() { @@ -1079,18 +1083,45 @@ void GitPlugin::fastForwardMerge( Git::Branch branch ) { // Branch operations // File operations + +static bool isPath( const std::string& file ) { + bool ret = !file.empty() && file[0] == '/'; +#if EE_PLATFORM == EE_PLATFORM_WIN + if ( !ret ) + ret = LuaPattern::matches( file, "%w:[\\/][\\/]" ); +#endif + return ret; +} + +std::vector GitPlugin::fixFilePaths( const std::vector& files ) { + std::vector paths; + paths.reserve( files.size() ); + for ( const auto& file : files ) { + if ( !isPath( file ) ) { + paths.push_back( mProjectPath + file ); + } else { + paths.push_back( file ); + } + } + return paths; +} + void GitPlugin::stage( const std::vector& files ) { if ( files.empty() ) return; - runAsync( [this, files]() { return mGit->add( files, mGit->repoPath( files[0] ) ); }, true, - false ); + runAsync( + [this, files]() { return mGit->add( fixFilePaths( files ), mGit->repoPath( files[0] ) ); }, + true, false ); } void GitPlugin::unstage( const std::vector& files ) { if ( files.empty() ) return; - runAsync( [this, files]() { return mGit->reset( files, mGit->repoPath( files[0] ) ); }, true, - false ); + runAsync( + [this, files]() { + return mGit->reset( fixFilePaths( files ), mGit->repoPath( files[0] ) ); + }, + true, false ); } // File operations @@ -1197,14 +1228,15 @@ void GitPlugin::updateBranches( bool force ) { if ( !mGit || mGit->getGitFolder().empty() ) return; - auto prevBranch = mGitBranches; + mGit->getSubModules(); + + decltype( mGitBranches ) prevBranch; { Lock l( mGitBranchMutex ); + prevBranch = mGitBranches; mGitBranches = mGit->branches( repos() ); } - mGit->getSubModules(); - auto branches = mGit->getAllBranchesAndTags( Git::RefType::All, {}, repoSelected() ); auto hash = hashBranches( branches ); auto model = GitBranchModel::asModel( std::move( branches ), hash, this ); diff --git a/src/tools/ecode/plugins/git/gitplugin.hpp b/src/tools/ecode/plugins/git/gitplugin.hpp index 7503abb6e..a2af700cc 100644 --- a/src/tools/ecode/plugins/git/gitplugin.hpp +++ b/src/tools/ecode/plugins/git/gitplugin.hpp @@ -179,6 +179,8 @@ class GitPlugin : public PluginBase { const std::string& icon = "" ); std::string repoSelected(); + + std::vector fixFilePaths( const std::vector& files ); }; } // namespace ecode