diff --git a/README.md b/README.md index cfa9b099e..c92f285d5 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ **eepp** is an open source cross-platform game and application development framework heavily focused on the development of rich graphical user interfaces. -[![Linux status](https://img.shields.io/github/workflow/status/SpartanJ/eepp/Linux/develop?label=Linux)](https://github.com/SpartanJ/eepp/actions?query=workflow%3ALinux) -[![Windows status](https://img.shields.io/github/workflow/status/SpartanJ/eepp/Windows/develop?label=Windows)](https://github.com/SpartanJ/eepp/actions?query=workflow%3AWindows) -[![macOS status](https://img.shields.io/github/workflow/status/SpartanJ/eepp/macOS/develop?label=macOS)](https://github.com/SpartanJ/eepp/actions?query=workflow%3AmacOS) +[![Linux status](https://img.shields.io/github/actions/workflow/status/SpartanJ/eepp/eepp-linux-build-check.yml?branch=develop)](https://github.com/SpartanJ/eepp/actions?query=workflow%3ALinux) +[![Windows status](https://img.shields.io/github/actions/workflow/status/SpartanJ/eepp/eepp-windows-build-check.yml?branch=develop)](https://github.com/SpartanJ/eepp/actions?query=workflow%3AWindows) +[![macOS status](https://img.shields.io/github/actions/workflow/status/SpartanJ/eepp/eepp-macos-build-check.yml?branch=develop)](https://github.com/SpartanJ/eepp/actions?query=workflow%3AmacOS) ## Features diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 63de0371f..4dc595142 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -60,6 +60,10 @@ class EE_API TextDocument { virtual void onDocumentClosed( TextDocument* ) = 0; virtual void onDocumentDirtyOnFileSystem( TextDocument* ) = 0; virtual void onDocumentMoved( TextDocument* ) = 0; + virtual void onDocumentReloaded( TextDocument* doc ) { + onDocumentClosed( doc ); + onDocumentLoaded( doc ); + } }; TextDocument( bool verbose = true ); @@ -488,6 +492,8 @@ class EE_API TextDocument { void notifyDocumentLoaded(); + void notifyDocumentReloaded(); + void notifyTextChanged( const DocumentContentChange& ); void notifyCursorChanged(); diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 2f30ed6c9..381bf36e3 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -268,7 +268,7 @@ ../../projects/mingw32 - -e config=debug_x86_64 + -e config=debug_x86_64 -e verbose=true make.sh true GenericProjectManager.GenericMakeStep @@ -303,7 +303,7 @@ ../../projects/mingw32 - -e config=release_x86_64 + -e config=release_x86_64 -e verbose=true make.sh true GenericProjectManager.GenericMakeStep diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index e685994cb..ec98eee84 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -169,8 +169,6 @@ TextDocument::LoadStatus TextDocument::loadFromStream( IOStream& file, std::stri if ( mAutoDetectIndentType ) guessIndentType(); - notifyTextChanged( { { { 0, 0 }, { 0, 0 } }, "" } ); - if ( mVerbose ) Log::info( "Document \"%s\" loaded in %.2fms.", path.c_str(), clock.getElapsedTime().asMilliseconds() ); @@ -464,7 +462,7 @@ TextDocument::LoadStatus TextDocument::reload() { mFileRealPath = FileInfo::isLink( mFilePath ) ? FileInfo( FileInfo( mFilePath ).linksTo() ) : FileInfo( mFilePath ); resetSyntax(); - notifyTextChanged( { { { 0, 0 }, { 0, 0 } }, "" } ); + notifyDocumentReloaded(); setSelection( sanitizePosition( selection.start() ) ); } return ret; @@ -2010,6 +2008,12 @@ void TextDocument::notifyDocumentLoaded() { } } +void TextDocument::notifyDocumentReloaded() { + for ( auto& client : mClients ) { + client->onDocumentReloaded( this ); + } +} + void TextDocument::notifyDocumentSaved() { for ( auto& client : mClients ) { client->onDocumentSaved( this ); diff --git a/src/eepp/ui/models/filesystemmodel.cpp b/src/eepp/ui/models/filesystemmodel.cpp index bd17f9285..ea357c58f 100644 --- a/src/eepp/ui/models/filesystemmodel.cpp +++ b/src/eepp/ui/models/filesystemmodel.cpp @@ -493,31 +493,7 @@ size_t FileSystemModel::getFileIndex( Node* parent, const FileInfo& file ) { return pos; } -std::string getFileSystemEventTypeName( FileSystemEventType action ) { - switch ( action ) { - case FileSystemEventType::Add: - return "Add"; - case FileSystemEventType::Modified: - return "Modified"; - case FileSystemEventType::Delete: - return "Delete"; - case FileSystemEventType::Moved: - return "Moved"; - default: - return "Bad Action"; - } -} - bool FileSystemModel::handleFileEventLocked( const FileEvent& event ) { - if ( Log::instance() && Log::instance()->getLogLevelThreshold() == LogLevel::Debug ) { - std::string txt = - "DIR ( " + event.directory + " ) FILE ( " + - ( ( event.oldFilename.empty() ? "" : "from file " + event.oldFilename + " to " ) + - event.filename ) + - " ) has event " + getFileSystemEventTypeName( event.type ); - Log::debug( txt ); - } - switch ( event.type ) { case FileSystemEventType::Add: { FileInfo file( event.directory + event.filename, false ); diff --git a/src/tools/ecode/filesystemlistener.cpp b/src/tools/ecode/filesystemlistener.cpp index 36395eff5..88a9d379d 100644 --- a/src/tools/ecode/filesystemlistener.cpp +++ b/src/tools/ecode/filesystemlistener.cpp @@ -2,6 +2,21 @@ namespace ecode { +std::string getFileSystemEventTypeName( FileSystemEventType action ) { + switch ( action ) { + case FileSystemEventType::Add: + return "Add"; + case FileSystemEventType::Modified: + return "Modified"; + case FileSystemEventType::Delete: + return "Delete"; + case FileSystemEventType::Moved: + return "Moved"; + default: + return "Bad Action"; + } +} + FileSystemListener::FileSystemListener( UICodeEditorSplitter* splitter, std::shared_ptr fileSystemModel ) : mSplitter( splitter ), mFileSystemModel( fileSystemModel ) {} @@ -16,6 +31,18 @@ void FileSystemListener::handleFileAction( efsw::WatchID, const std::string& dir case efsw::Actions::Delete: case efsw::Actions::Moved: { FileEvent event( (FileSystemEventType)action, dir, filename, oldFilename ); + + if ( Log::instance() && Log::instance()->getLogLevelThreshold() == LogLevel::Debug ) { + std::string txt = + "DIR ( " + event.directory + " ) FILE ( " + + ( ( event.oldFilename.empty() ? "" + : "from file " + event.oldFilename + " to " ) + + event.filename ) + + " ) has event " + getFileSystemEventTypeName( event.type ); + + Log::debug( txt ); + } + mFileSystemModel.get()->handleFileEvent( event ); if ( mDirTree ) @@ -79,4 +106,4 @@ void FileSystemListener::notifyMove( const FileInfo& oldFile, const FileInfo& ne } ); } -} +} // namespace ecode diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp index ab11ee6cd..3228947aa 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using namespace EE::System; @@ -49,6 +50,18 @@ void LSPDocumentClient::onDocumentDirtyOnFileSystem( TextDocument* ) {} void LSPDocumentClient::onDocumentMoved( TextDocument* ) {} +void LSPDocumentClient::onDocumentReloaded( TextDocument* ) { + URI uri = mDoc->getURI(); + TextDocument* doc = mDoc; + LSPClientServer* server = mServer; + auto version = ++mVersion; + mServer->getThreadPool()->run( [server, doc, uri, version]() { + server->didClose( uri ); + server->removeDoc( doc ); + server->didOpen( doc, version ); + } ); +} + TextDocument* LSPDocumentClient::getDoc() const { return mDoc; } @@ -63,7 +76,11 @@ int LSPDocumentClient::getVersion() const { void LSPDocumentClient::notifyOpen() { eeASSERT( mDoc ); - mServer->didOpen( mDoc, ++mVersion ); + if ( Engine::instance()->isMainThread() ) { + mServer->getThreadPool()->run( [this]() { mServer->didOpen( mDoc, ++mVersion ); } ); + } else { + mServer->didOpen( mDoc, ++mVersion ); + } } } // namespace ecode diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp index 28e7c11d5..bae61e80d 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp @@ -28,6 +28,7 @@ class LSPDocumentClient : public TextDocument::Client { virtual void onDocumentClosed( TextDocument* ); virtual void onDocumentDirtyOnFileSystem( TextDocument* ); virtual void onDocumentMoved( TextDocument* ); + virtual void onDocumentReloaded( TextDocument* ); void notifyOpen();