mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-09-22 13:01:05 +03:00
Allow to configure the default diff view (Unified vs Side by side)
This commit is contained in:
@@ -1210,4 +1210,8 @@ Für sichtbare Änderung ecode neu starten.</string>
|
||||
<string name="xmltools_auto_edit_match_desc">Update the matching tag automatically while editing.</string>
|
||||
<string name="xmltools_highlight_match">Highlight Matching Tags</string>
|
||||
<string name="xmltools_highlight_match_desc">Highlight the matching XML or HTML tag at the cursor.</string>
|
||||
<string name="default_diff_view">Default Diff View</string>
|
||||
<string name="default_diff_view_desc">Choose the initial layout used when opening text diffs.</string>
|
||||
<string name="diff_view_side_by_side">Side by Side</string>
|
||||
<string name="diff_view_unified">Unified</string>
|
||||
</resources>
|
||||
|
||||
@@ -1195,4 +1195,8 @@ Restart ecode to see the changes.</string>
|
||||
<string name="xmltools_auto_edit_match_desc">Update the matching tag automatically while editing.</string>
|
||||
<string name="xmltools_highlight_match">Highlight Matching Tags</string>
|
||||
<string name="xmltools_highlight_match_desc">Highlight the matching XML or HTML tag at the cursor.</string>
|
||||
<string name="default_diff_view">Default Diff View</string>
|
||||
<string name="default_diff_view_desc">Choose the initial layout used when opening text diffs.</string>
|
||||
<string name="diff_view_side_by_side">Side by Side</string>
|
||||
<string name="diff_view_unified">Unified</string>
|
||||
</resources>
|
||||
|
||||
@@ -1194,4 +1194,8 @@ Redémarrer ecode pour voir les changements.</string>
|
||||
<string name="xmltools_auto_edit_match_desc">Update the matching tag automatically while editing.</string>
|
||||
<string name="xmltools_highlight_match">Highlight Matching Tags</string>
|
||||
<string name="xmltools_highlight_match_desc">Highlight the matching XML or HTML tag at the cursor.</string>
|
||||
<string name="default_diff_view">Default Diff View</string>
|
||||
<string name="default_diff_view_desc">Choose the initial layout used when opening text diffs.</string>
|
||||
<string name="diff_view_side_by_side">Side by Side</string>
|
||||
<string name="diff_view_unified">Unified</string>
|
||||
</resources>
|
||||
|
||||
@@ -999,4 +999,8 @@ file in the directory tree.</string>
|
||||
<string name="xmltools_auto_edit_match_desc">Update the matching tag automatically while editing.</string>
|
||||
<string name="xmltools_highlight_match">Highlight Matching Tags</string>
|
||||
<string name="xmltools_highlight_match_desc">Highlight the matching XML or HTML tag at the cursor.</string>
|
||||
<string name="default_diff_view">Default Diff View</string>
|
||||
<string name="default_diff_view_desc">Choose the initial layout used when opening text diffs.</string>
|
||||
<string name="diff_view_side_by_side">Side by Side</string>
|
||||
<string name="diff_view_unified">Unified</string>
|
||||
</resources>
|
||||
|
||||
@@ -214,6 +214,9 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath,
|
||||
ini.getValueB( "editor", "restore_editor_selection_on_focus", true );
|
||||
editor.tabJumpMode =
|
||||
UITabWidget::tabJumpModefromString( ini.getValue( "editor", "tab_jump_mode", "linear" ) );
|
||||
editor.diffViewMode = ini.getValue( "editor", "diff_view_mode", "unified" ) == "side_by_side"
|
||||
? UIDiffView::ViewMode::SideBySide
|
||||
: UIDiffView::ViewMode::Unified;
|
||||
|
||||
editor.singleClickNavigation = ini.getValueB( "editor", "single_click_tree_navigation", false );
|
||||
editor.syncProjectTreeWithEditor =
|
||||
@@ -419,6 +422,9 @@ void AppConfig::save( const std::vector<std::string>& recentFiles,
|
||||
UITabWidget::tabJumpModeToString( editor.tabJumpMode ) );
|
||||
ini.setValue( "editor", "new_tab_position", NewTabPosition::toString( editor.newTabPosition ) );
|
||||
ini.setValue( "editor", "custom_date_format", editor.customDateFormat );
|
||||
ini.setValue( "editor", "diff_view_mode",
|
||||
editor.diffViewMode == UIDiffView::ViewMode::SideBySide ? "side_by_side"
|
||||
: "unified" );
|
||||
ini.setValueB( "editor", "single_click_tree_navigation", editor.singleClickNavigation );
|
||||
ini.setValueB( "editor", "sync_project_tree_with_editor", editor.syncProjectTreeWithEditor );
|
||||
ini.setValueB( "editor", "auto_close_xml_tags", editor.autoCloseXMLTags );
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <eepp/system/inifile.hpp>
|
||||
#include <eepp/ui/css/stylesheetlength.hpp>
|
||||
#include <eepp/ui/tools/uicodeeditorsplitter.hpp>
|
||||
#include <eepp/ui/tools/uidiffview.hpp>
|
||||
#include <eepp/ui/uicodeeditor.hpp>
|
||||
#include <eepp/window/window.hpp>
|
||||
|
||||
@@ -131,6 +132,7 @@ struct CodeEditorConfig {
|
||||
UITabWidget::TabJumpMode tabJumpMode{ UITabWidget::TabJumpMode::Linear };
|
||||
NewTabPosition::Position newTabPosition{ NewTabPosition::Last };
|
||||
std::string customDateFormat{ "%d.%m.%Y %H:%M:%S" };
|
||||
UIDiffView::ViewMode diffViewMode{ UIDiffView::ViewMode::Unified };
|
||||
|
||||
bool singleClickNavigation{ false };
|
||||
bool syncProjectTreeWithEditor{ true };
|
||||
|
||||
@@ -2617,8 +2617,10 @@ void App::loadDiffFromMemory( const std::string& content, const std::string& ori
|
||||
auto diffView = scrollView->getFirstChild()->asType<UILinearLayout>()->getFirstChild();
|
||||
|
||||
while ( diffView ) {
|
||||
if ( diffView->isType( UI_TYPE_DIFF_VIEW ) )
|
||||
if ( diffView->isType( UI_TYPE_DIFF_VIEW ) ) {
|
||||
configureDiffView( diffView->asType<UIDiffView>() );
|
||||
diffView->asType<UIDiffView>()->setSyntaxColorScheme( *getCurrentColorScheme() );
|
||||
}
|
||||
diffView = diffView->getNextNode();
|
||||
}
|
||||
return;
|
||||
@@ -2626,6 +2628,7 @@ void App::loadDiffFromMemory( const std::string& content, const std::string& ori
|
||||
|
||||
auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );
|
||||
auto* diffView = Tools::UIDiffView::New();
|
||||
configureDiffView( diffView );
|
||||
diffView->setAutoDeleteOldTempImage( true );
|
||||
auto [tab, iv] = getSplitter()->createWidget( diffView, diffViewTitle );
|
||||
if ( !tab )
|
||||
@@ -2669,8 +2672,10 @@ void App::loadDiffFromPath( const std::string& path ) {
|
||||
auto diffView = scrollView->getFirstChild()->asType<UILinearLayout>()->getFirstChild();
|
||||
|
||||
while ( diffView ) {
|
||||
if ( diffView->isType( UI_TYPE_DIFF_VIEW ) )
|
||||
if ( diffView->isType( UI_TYPE_DIFF_VIEW ) ) {
|
||||
configureDiffView( diffView->asType<UIDiffView>() );
|
||||
diffView->asType<UIDiffView>()->setSyntaxColorScheme( *getCurrentColorScheme() );
|
||||
}
|
||||
diffView = diffView->getNextNode();
|
||||
}
|
||||
return;
|
||||
@@ -2678,6 +2683,7 @@ void App::loadDiffFromPath( const std::string& path ) {
|
||||
|
||||
auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );
|
||||
auto* diffView = Tools::UIDiffView::New();
|
||||
configureDiffView( diffView );
|
||||
auto [tab, iv] = mSplitter->createWidget( diffView, i18n( "diff_viewer", "Diff Viewer" ) );
|
||||
if ( !path.empty() ) {
|
||||
std::string fileName = FileSystem::fileNameFromPath( path );
|
||||
@@ -2698,6 +2704,7 @@ void App::loadDiffFromPath( const std::string& path ) {
|
||||
void App::loadDiffFromPaths( const std::string& oldPath, const std::string& newPath ) {
|
||||
auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );
|
||||
auto* diffView = Tools::UIDiffView::New();
|
||||
configureDiffView( diffView );
|
||||
auto [tab, iv] = mSplitter->createWidget( diffView, i18n( "diff_viewer", "Diff Viewer" ) );
|
||||
if ( !newPath.empty() ) {
|
||||
std::string fileName = FileSystem::fileNameFromPath( newPath );
|
||||
@@ -2718,6 +2725,7 @@ void App::loadDiffFromPaths( const std::string& oldPath, const std::string& newP
|
||||
void App::loadDiffFromStrings( const std::string& str, const std::string& otherStr ) {
|
||||
auto diffViewTitle = i18n( "diff_viewer", "Diff Viewer" );
|
||||
auto* diffView = Tools::UIDiffView::New();
|
||||
configureDiffView( diffView );
|
||||
auto [tab, iv] = mSplitter->createWidget( diffView, i18n( "diff_viewer", "Diff Viewer" ) );
|
||||
tab->setText( diffViewTitle );
|
||||
auto icon = findIcon( "filetype-diff" );
|
||||
@@ -2728,6 +2736,11 @@ void App::loadDiffFromStrings( const std::string& str, const std::string& otherS
|
||||
registerUnlockedCommands( *diffView );
|
||||
}
|
||||
|
||||
void App::configureDiffView( UIDiffView* diffView ) {
|
||||
if ( diffView )
|
||||
diffView->setViewMode( mConfig.editor.diffViewMode );
|
||||
}
|
||||
|
||||
void App::openFileFromPath( const std::string& path ) {
|
||||
std::string ext = FileSystem::fileExtension( path );
|
||||
if ( !Image::isImageExtension( path ) && !SoundFileFactory::isKnownFileExtension( path ) &&
|
||||
|
||||
@@ -584,6 +584,7 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider {
|
||||
const std::string& repoPath = "" );
|
||||
|
||||
void loadDiffFromStrings( const std::string& str, const std::string& otherStr );
|
||||
void configureDiffView( UIDiffView* diffView );
|
||||
|
||||
void createAndShowRecentFolderPopUpMenu( Node* recentFoldersBut );
|
||||
|
||||
|
||||
@@ -903,6 +903,25 @@ void SettingsPanel::addUserSettings( PanelState& panel ) {
|
||||
mApp->getSplitter()->setColorScheme(
|
||||
editorSchemeIds[std::min( selected, editorSchemeIds.size() - 1 )] );
|
||||
} );
|
||||
addChoice(
|
||||
panel,
|
||||
{ "defaultDiffView", "editor.appearance",
|
||||
mApp->i18n( "default_diff_view", "Default Diff View" ),
|
||||
mApp->i18n( "default_diff_view_desc",
|
||||
"Choose the initial layout used when opening text diffs." ) },
|
||||
{ mApp->i18n( "diff_view_unified", "Unified" ),
|
||||
mApp->i18n( "diff_view_side_by_side", "Side by Side" ) },
|
||||
[this] {
|
||||
return mApp->getConfig().editor.diffViewMode == UIDiffView::ViewMode::Unified ? 0 : 1;
|
||||
},
|
||||
[this]( size_t selected ) {
|
||||
auto mode =
|
||||
selected == 0 ? UIDiffView::ViewMode::Unified : UIDiffView::ViewMode::SideBySide;
|
||||
mApp->getConfig().editor.diffViewMode = mode;
|
||||
mApp->getSplitter()->forEachWidgetType( UI_TYPE_DIFF_VIEW, [mode]( UIWidget* widget ) {
|
||||
widget->asType<UIDiffView>()->setViewMode( mode );
|
||||
} );
|
||||
} );
|
||||
auto addEditorBool = [this, &panel]( std::string id, const char* nameKey, const char* name,
|
||||
const char* descriptionKey, const char* description,
|
||||
bool CodeEditorConfig::* member, auto apply ) {
|
||||
|
||||
Reference in New Issue
Block a user