| 572 | } |
| 573 | |
| 574 | bool UICodeEditor::loadAsyncFromURL( |
| 575 | const std::string& url, const Http::Request::FieldTable& headers, |
| 576 | std::function<void( std::shared_ptr<TextDocument>, bool )> onLoaded ) { |
| 577 | bool wasLocked = isLocked(); |
| 578 | if ( !wasLocked ) |
| 579 | setLocked( true ); |
| 580 | bool ret = mDoc->loadAsyncFromURL( |
| 581 | url, headers, |
| 582 | [this, onLoaded, wasLocked]( TextDocument*, bool success ) { |
| 583 | if ( mMinimapEnabled && getUISceneNode()->hasThreadPool() ) |
| 584 | mDoc->getHighlighter()->tokenizeAsync( getUISceneNode()->getThreadPool(), [this] { |
| 585 | runOnMainThread( [this] { invalidateDraw(); } ); |
| 586 | } ); |
| 587 | |
| 588 | runOnMainThread( [this, success, onLoaded, wasLocked] { |
| 589 | if ( !wasLocked ) |
| 590 | setLocked( false ); |
| 591 | onDocumentLoaded(); |
| 592 | if ( onLoaded ) |
| 593 | onLoaded( mDoc, success ); |
| 594 | } ); |
| 595 | }, |
| 596 | [this]( const Http&, const Http::Request&, const Http::Response&, |
| 597 | const Http::Request::Status& status, size_t /*totalBytes*/, |
| 598 | size_t /*currentBytes*/ ) { |
| 599 | if ( status == Http::Request::ContentReceived ) { |
| 600 | runOnMainThread( [this] { invalidateDraw(); } ); |
| 601 | } |
| 602 | return true; |
| 603 | } ); |
| 604 | if ( !ret && !wasLocked ) |
| 605 | setLocked( false ); |
| 606 | return ret; |
| 607 | } |
| 608 | |
| 609 | bool UICodeEditor::save() { |
| 610 | return mDoc->save(); |
nothing calls this directly
no test coverage detected