diff --git a/include/eepp/graphics/fontfamily.hpp b/include/eepp/graphics/fontfamily.hpp index 6e9f6a6b6..e2196940d 100644 --- a/include/eepp/graphics/fontfamily.hpp +++ b/include/eepp/graphics/fontfamily.hpp @@ -7,7 +7,8 @@ namespace EE { namespace Graphics { class EE_API FontFamily { public: - static void loadFromRegular( FontTrueType* font ); + static void loadFromRegular( FontTrueType* font, std::string overwriteFontName = "" ); + private: static std::string findType( const std::string& fontpath, const std::string& fontname, const std::string& ext, const std::vector& names ); diff --git a/src/eepp/graphics/fontfamily.cpp b/src/eepp/graphics/fontfamily.cpp index 9c32df8af..333dee2e9 100644 --- a/src/eepp/graphics/fontfamily.cpp +++ b/src/eepp/graphics/fontfamily.cpp @@ -3,7 +3,7 @@ namespace EE { namespace Graphics { -void FontFamily::loadFromRegular( FontTrueType* font ) { +void FontFamily::loadFromRegular( FontTrueType* font, std::string overwriteFontName ) { if ( font == nullptr || font->getInfo().fontpath.empty() || font->getInfo().filename.empty() ) return; @@ -11,7 +11,9 @@ void FontFamily::loadFromRegular( FontTrueType* font ) { if ( ext.empty() ) return; - std::string fontname( FileSystem::fileRemoveExtension( font->getInfo().filename ) ); + std::string fontname( overwriteFontName.empty() + ? FileSystem::fileRemoveExtension( font->getInfo().filename ) + : overwriteFontName ); if ( String::endsWith( fontname, "-Regular" ) ) { auto pos( fontname.find_last_of( '-' ) ); fontname.resize( pos ); diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index f92e6bb2d..9dbaed4d2 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -2435,7 +2435,7 @@ int TextDocument::replaceAll( const String& text, const String& replace, const b if ( text.empty() ) return 0; bool wasRunningTransaction = isRunningTransaction(); - if ( wasRunningTransaction ) + if ( !wasRunningTransaction ) setRunningTransaction( true ); int count = 0; TextRange found; @@ -2451,7 +2451,7 @@ int TextDocument::replaceAll( const String& text, const String& replace, const b count++; } } while ( found.isValid() && endOfDoc() != found.end() ); - if ( wasRunningTransaction ) + if ( !wasRunningTransaction ) setRunningTransaction( false ); setSelection( startedPosition ); return count; diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 2b015ac02..d752f1312 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -159,11 +159,8 @@ void App::updateEditorTitle( UICodeEditor* editor ) { void App::setAppTitle( const std::string& title ) { std::string fullTitle( mWindowTitle ); - if ( !mCurrentProject.empty() ) { - std::string currentProject( FileSystem::fileNameFromPath( mCurrentProject ) ); - if ( !currentProject.empty() ) - fullTitle += " - " + currentProject; - } + if ( !mCurrentProjectName.empty() ) + fullTitle += " - " + mCurrentProjectName; if ( !title.empty() ) fullTitle += " - " + title; @@ -171,13 +168,19 @@ void App::setAppTitle( const std::string& title ) { if ( mBenchmarkMode ) fullTitle += " - " + String::toString( mWindow->getFPS() ) + " FPS"; - mUISceneNode->runOnMainThread( [this, fullTitle] { mWindow->setTitle( fullTitle ); } ); + if ( mCurWindowTitle != fullTitle ) { + mCurWindowTitle = fullTitle; + if ( Engine::isRunninMainThread() ) { + mWindow->setTitle( fullTitle ); + } else { + mUISceneNode->runOnMainThread( [this, fullTitle] { mWindow->setTitle( fullTitle ); } ); + } + } } void App::onDocumentModified( UICodeEditor* editor, TextDocument& ) { bool isDirty = editor->getDocument().isDirty(); - bool wasDirty = - !mWindow->getTitle().empty() && mWindow->getTitle()[mWindow->getTitle().size() - 1] == '*'; + bool wasDirty = !mCurWindowTitle.empty() && mCurWindowTitle[mCurWindowTitle.size() - 1] == '*'; if ( isDirty != wasDirty ) setAppTitle( titleFromEditor( editor ) ); @@ -1526,7 +1529,8 @@ void App::updateDocInfoLocation() { } void App::updateDocInfo( TextDocument& doc ) { - if ( mConfig.editor.showDocInfo && mDocInfo && mSplitter->curEditorExistsAndFocused() ) { + if ( !doc.isRunningTransaction() && mConfig.editor.showDocInfo && mDocInfo && + mSplitter->curEditorExistsAndFocused() ) { mDocInfo->setVisible( true ); updateDocInfoLocation(); mDocInfo->setText( String::format( @@ -1970,6 +1974,7 @@ void App::closeEditors() { } ); mCurrentProject = ""; + mCurrentProjectName = ""; mDirTree = nullptr; if ( mFileSystemListener ) mFileSystemListener->setDirTree( mDirTree ); @@ -2984,6 +2989,7 @@ void App::loadFolder( const std::string& path ) { FileSystem::dirAddSlashAtEnd( rpath ); mCurrentProject = rpath; + mCurrentProjectName = FileSystem::fileNameFromPath( mCurrentProject ); mPluginManager->setWorkspaceFolder( rpath ); loadDirTree( rpath ); diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index a6f473c7c..83eefbb89 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -424,6 +424,7 @@ class App : public UICodeEditorSplitter::Client { EE::Window::Window* mWindow{ nullptr }; UISceneNode* mUISceneNode{ nullptr }; UIConsole* mConsole{ nullptr }; + std::string mCurWindowTitle; std::string mWindowTitle{ "ecode" }; UIMainLayout* mMainLayout{ nullptr }; UILayout* mBaseLayout{ nullptr }; @@ -469,6 +470,7 @@ class App : public UICodeEditorSplitter::Client { ProjectDocumentConfig mProjectDocConfig; std::unordered_set mTmpDocs; std::string mCurrentProject; + std::string mCurrentProjectName; FontTrueType* mFont{ nullptr }; FontTrueType* mFontMono{ nullptr }; FontTrueType* mTerminalFont{ nullptr }; diff --git a/src/tools/eterm/eterm.cpp b/src/tools/eterm/eterm.cpp index 93d65ce3b..fbdce6dc1 100644 --- a/src/tools/eterm/eterm.cpp +++ b/src/tools/eterm/eterm.cpp @@ -230,12 +230,16 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) { if ( fontPath && FileSystem::fileExists( fontPath.Get() ) ) { FileInfo file( fontPath.Get() ); fontMono = FontTrueType::New( "monospace" ); - if ( !fontMono->loadFromFile( file.getFilepath() ) ) + if ( fontMono->loadFromFile( file.getFilepath() ) ) { + FontFamily::loadFromRegular( fontMono ); + } else { fontMono = nullptr; + } } if ( fontMono == nullptr ) { fontMono = FontTrueType::New( "monospace" ); fontMono->loadFromFile( resPath + "fonts/DejaVuSansMonoNerdFontComplete.ttf" ); + FontFamily::loadFromRegular( fontMono, "DejaVuSansMono" ); } if ( FileSystem::fileExists( resPath + "fonts/NotoColorEmoji.ttf" ) ) {