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

Method loadDiffFromMemory

src/tools/ecode/ecode.cpp:2640–2682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2638}
2639
2640void App::loadDiffFromMemory( const std::string& content, const std::string& originalFilePath ) {
2641 if ( UIDiffView::isMultiFileDiff( content ) ) {
2642 auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" ) + ": " + originalFilePath;
2643 UIIcon* icon = getUISceneNode()->findIcon( "filetype-diff" );
2644 if ( !icon )
2645 icon = getUISceneNode()->findIcon( "file" );
2646
2647 auto scrollView = UIDiffView::NewMultiFileDiffViewer( content );
2648 auto [tab, iv] = getSplitter()->createWidget( scrollView, diffViewTitle );
2649 if ( icon )
2650 tab->setIcon( icon->getSize( getMenuIconSize() ) );
2651 tab->setText( diffViewTitle );
2652
2653 auto diffView = scrollView->getFirstChild()->asType<UILinearLayout>()->getFirstChild();
2654
2655 while ( diffView ) {
2656 if ( diffView->isType( UI_TYPE_DIFF_VIEW ) )
2657 diffView->asType<UIDiffView>()->setSyntaxColorScheme( *getCurrentColorScheme() );
2658 diffView = diffView->getNextNode();
2659 }
2660 return;
2661 }
2662
2663 auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );
2664 auto* diffView = Tools::UIDiffView::New();
2665 auto [tab, iv] = getSplitter()->createWidget( diffView, diffViewTitle );
2666 if ( !originalFilePath.empty() ) {
2667 std::string fileName = FileSystem::fileNameFromPath( originalFilePath );
2668 tab->setText( diffViewTitle + ": " + fileName );
2669 tab->setTooltipText( originalFilePath );
2670 } else {
2671 tab->setText( diffViewTitle );
2672 }
2673 UIIcon* icon = getUISceneNode()->findIcon( "filetype-diff" );
2674 if ( !icon )
2675 icon = getUISceneNode()->findIcon( "file" );
2676 if ( icon )
2677 tab->setIcon( icon->getSize( getMenuIconSize() ) );
2678 diffView->setHeadersVisible( true );
2679 diffView->loadFromPatch( content, originalFilePath );
2680 diffView->setSyntaxColorScheme( *getCurrentColorScheme() );
2681 registerUnlockedCommands( *diffView );
2682}
2683
2684void App::loadDiffFromPath( const std::string& path ) {
2685 std::string content;

Callers 1

diffMethod · 0.80

Calls 14

getFirstChildMethod · 0.80
setSyntaxColorSchemeMethod · 0.80
getNextNodeMethod · 0.80
setTooltipTextMethod · 0.80
loadFromPatchMethod · 0.80
NewFunction · 0.50
findIconMethod · 0.45
createWidgetMethod · 0.45
setIconMethod · 0.45
getSizeMethod · 0.45
setTextMethod · 0.45
isTypeMethod · 0.45

Tested by

no test coverage detected