MCPcopy Create free account
hub / github.com/SpartanJ/eepp / loadAsyncFromURL

Method loadAsyncFromURL

src/eepp/ui/uicodeeditor.cpp:574–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574bool 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
609bool UICodeEditor::save() {
610 return mDoc->save();

Callers

nothing calls this directly

Calls 4

hasThreadPoolMethod · 0.80
tokenizeAsyncMethod · 0.80
getHighlighterMethod · 0.80
getThreadPoolMethod · 0.45

Tested by

no test coverage detected