mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 01:56:31 +03:00
eepp:
Added Window::flash(). FileSystemModel will not spam invalidations when not needed. UIAbstractTableView and UIAbstractView won't queue more than 1 invalidation per frame when invalidations comes from a non-main thread. ecode: UniversalLocator now understands pasted file paths (with and withouth cursor position) and allows to go to that file and position.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "universallocator.hpp"
|
||||
#include "ecode.hpp"
|
||||
#include "pathhelper.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace ecode {
|
||||
@@ -136,22 +137,28 @@ void UniversalLocator::toggleLocateBar() {
|
||||
}
|
||||
|
||||
void UniversalLocator::updateFilesTable() {
|
||||
auto text = mLocateInput->getText();
|
||||
|
||||
if ( pathHasPosition( text ) ) {
|
||||
auto pathAndPos = getPathAndPosition( text );
|
||||
text = pathAndPos.first;
|
||||
}
|
||||
|
||||
if ( !mApp->isDirTreeReady() ) {
|
||||
mLocateTable->setModel( ProjectDirectoryTree::emptyModel( getLocatorCommands() ) );
|
||||
mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) );
|
||||
} else if ( !mLocateInput->getText().empty() ) {
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN || defined( __EMSCRIPTEN_PTHREADS__ )
|
||||
mApp->getDirTree()->asyncFuzzyMatchTree(
|
||||
mLocateInput->getText(), LOCATEBAR_MAX_RESULTS, [&]( auto res ) {
|
||||
mUISceneNode->runOnMainThread( [&, res] {
|
||||
text, LOCATEBAR_MAX_RESULTS, [this, text]( auto res ) {
|
||||
mUISceneNode->runOnMainThread( [this, res] {
|
||||
mLocateTable->setModel( res );
|
||||
mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) );
|
||||
mLocateTable->scrollToTop();
|
||||
} );
|
||||
} );
|
||||
#else
|
||||
mLocateTable->setModel(
|
||||
mApp->getDirTree()->fuzzyMatchTree( mLocateInput->getText(), LOCATEBAR_MAX_RESULTS ) );
|
||||
mLocateTable->setModel( mApp->getDirTree()->fuzzyMatchTree( text, LOCATEBAR_MAX_RESULTS ) );
|
||||
mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) );
|
||||
mLocateTable->scrollToTop();
|
||||
#endif
|
||||
@@ -335,22 +342,13 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
|
||||
auto range = rangeStr.isValid()
|
||||
? TextRange::fromString( rangeStr.asStdString() )
|
||||
: TextRange();
|
||||
UITab* tab = mSplitter->isDocumentOpen( path, true );
|
||||
if ( !tab ) {
|
||||
FileInfo fileInfo( path );
|
||||
if ( fileInfo.exists() && fileInfo.isRegularFile() )
|
||||
mApp->loadFileFromPath( path, true, nullptr,
|
||||
[range]( UICodeEditor* editor, auto ) {
|
||||
if ( range.isValid() )
|
||||
editor->goToLine( range.start() );
|
||||
} );
|
||||
} else {
|
||||
tab->getTabWidget()->setTabSelected( tab );
|
||||
if ( range.isValid() ) {
|
||||
UICodeEditor* editor = tab->getOwnedWidget()->asType<UICodeEditor>();
|
||||
editor->goToLine( range.start() );
|
||||
}
|
||||
if ( !range.isValid() && !FileSystem::isRelativePath( path ) &&
|
||||
pathHasPosition( mLocateInput->getText() ) &&
|
||||
String::startsWith( mLocateInput->getText().toUtf8(), path ) ) {
|
||||
auto pathAndPos = getPathAndPosition( mLocateInput->getText() );
|
||||
range = { pathAndPos.second, pathAndPos.second };
|
||||
}
|
||||
focusOrLoadFile( path, range );
|
||||
mLocateBarLayout->execute( "close-locatebar" );
|
||||
} else {
|
||||
Variant rangeStr( modelEvent->getModel()->data(
|
||||
@@ -525,6 +523,24 @@ std::shared_ptr<FileListModel> UniversalLocator::openDocumentsModel( const std::
|
||||
return std::make_shared<FileListModel>( ffiles, fnames );
|
||||
}
|
||||
|
||||
void UniversalLocator::focusOrLoadFile( const std::string& path, const TextRange& range ) {
|
||||
UITab* tab = mSplitter->isDocumentOpen( path, true );
|
||||
if ( !tab ) {
|
||||
FileInfo fileInfo( path );
|
||||
if ( fileInfo.exists() && fileInfo.isRegularFile() )
|
||||
mApp->loadFileFromPath( path, true, nullptr, [range]( UICodeEditor* editor, auto ) {
|
||||
if ( range.isValid() )
|
||||
editor->goToLine( range.start() );
|
||||
} );
|
||||
} else {
|
||||
tab->getTabWidget()->setTabSelected( tab );
|
||||
if ( range.isValid() ) {
|
||||
UICodeEditor* editor = tab->getOwnedWidget()->asType<UICodeEditor>();
|
||||
editor->goToLine( range.start() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UniversalLocator::updateOpenDocumentsTable() {
|
||||
mLocateTable->setModel(
|
||||
openDocumentsModel( mLocateInput->getText().substr( 2 ).trim().toUtf8() ) );
|
||||
|
||||
Reference in New Issue
Block a user