mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
TextDocument events fixes.
Update eepp shields status.
This commit is contained in:
@@ -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.
|
||||
|
||||
[](https://github.com/SpartanJ/eepp/actions?query=workflow%3ALinux)
|
||||
[](https://github.com/SpartanJ/eepp/actions?query=workflow%3AWindows)
|
||||
[](https://github.com/SpartanJ/eepp/actions?query=workflow%3AmacOS)
|
||||
[](https://github.com/SpartanJ/eepp/actions?query=workflow%3ALinux)
|
||||
[](https://github.com/SpartanJ/eepp/actions?query=workflow%3AWindows)
|
||||
[](https://github.com/SpartanJ/eepp/actions?query=workflow%3AmacOS)
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 8.0.2, 2022-12-03T16:01:31. -->
|
||||
<!-- Written by QtCreator 8.0.2, 2022-12-14T16:51:12. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -268,7 +268,7 @@
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">../../projects/mingw32</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-e config=debug_x86_64</value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-e config=debug_x86_64 -e verbose=true</value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">make.sh</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
@@ -303,7 +303,7 @@
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">../../projects/mingw32</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-e config=release_x86_64</value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-e config=release_x86_64 -e verbose=true</value>
|
||||
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand">make.sh</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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> 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
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
#include <eepp/system/iostreamstring.hpp>
|
||||
#include <eepp/system/log.hpp>
|
||||
#include <eepp/window/engine.hpp>
|
||||
|
||||
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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user