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

Method loadDiffFromPath

src/tools/ecode/ecode.cpp:2684–2729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2682}
2683
2684void App::loadDiffFromPath( const std::string& path ) {
2685 std::string content;
2686 if ( !FileSystem::fileGet( path, content ) )
2687 return;
2688
2689 if ( UIDiffView::isMultiFileDiff( content ) ) {
2690 auto diffViewTitle =
2691 i18n( "diff_viewer", "Diff Viewer" ) + ": " + FileSystem::fileNameFromPath( path );
2692 UIIcon* icon = getUISceneNode()->findIcon( "filetype-diff" );
2693 if ( !icon )
2694 icon = getUISceneNode()->findIcon( "file" );
2695
2696 auto scrollView = UIDiffView::NewMultiFileDiffViewer( content );
2697 auto [tab, iv] = getSplitter()->createWidget( scrollView, diffViewTitle );
2698 if ( icon )
2699 tab->setIcon( icon->getSize( getMenuIconSize() ) );
2700 tab->setText( diffViewTitle );
2701
2702 auto diffView = scrollView->getFirstChild()->asType<UILinearLayout>()->getFirstChild();
2703
2704 while ( diffView ) {
2705 if ( diffView->isType( UI_TYPE_DIFF_VIEW ) )
2706 diffView->asType<UIDiffView>()->setSyntaxColorScheme( *getCurrentColorScheme() );
2707 diffView = diffView->getNextNode();
2708 }
2709 return;
2710 }
2711
2712 auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );
2713 auto* diffView = Tools::UIDiffView::New();
2714 auto [tab, iv] = mSplitter->createWidget( diffView, i18n( "diff_viewer", "Diff Viewer" ) );
2715 if ( !path.empty() ) {
2716 std::string fileName = FileSystem::fileNameFromPath( path );
2717 tab->setText( diffViewTitle + ": " + fileName );
2718 tab->setTooltipText( path );
2719 } else {
2720 tab->setText( diffViewTitle );
2721 }
2722 auto icon = findIcon( "filetype-diff" );
2723 tab->setIcon( icon ? icon : findIcon( "file" ) );
2724
2725 diffView->setHeadersVisible( true );
2726 diffView->loadFromPatch( content, path );
2727 diffView->setSyntaxColorScheme( *getCurrentColorScheme() );
2728 registerUnlockedCommands( *diffView );
2729}
2730
2731void App::loadDiffFromPaths( const std::string& oldPath, const std::string& newPath ) {
2732 auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );

Callers

nothing calls this directly

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