summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UConfig.pas35
-rw-r--r--UMain.pas112
2 files changed, 143 insertions, 4 deletions
diff --git a/UConfig.pas b/UConfig.pas
index 1da42a0..9ee6f16 100644
--- a/UConfig.pas
+++ b/UConfig.pas
@@ -25,8 +25,8 @@ uses Classes, ULocale;
resourcestring
ConstAppTitle = 'Tux Commander';
- ConstAboutVersion = '0.6.77-dev';
- ConstAboutBuildDate = '2010-03-22';
+ ConstAboutVersion = '0.6.78-dev';
+ ConstAboutBuildDate = '2010-03-27';
{$IFDEF FPC}
{$INCLUDE fpcver.inc}
@@ -67,6 +67,8 @@ const ConfDefaultNormalItemFGColor = '#000000';
ConfEditorApps: array[1..5] of string = ('gedit', 'gvim', 'emacs', 'nano', 'vi');
ConfTerminalApps: array[1..4] of string = (ConstTerminalCommand_xterm, ConstTerminalCommand_rxvt, ConstTerminalCommand_rxvt2, ConstTerminalCommand_gnometerminal);
ConfTerminalAppsWParam: array[1..4] of string = ('xterm', 'rxvt', 'rxvt', 'gnome-terminal');
+ ConfDiffApps: array[1..2] of string = ('meld', 'diff');
+ ConfDiffDirAppsDirsParams: array[1..2] of string = ('', '-r'); // Arguments used for diffing whole directories, array linked with ConfDiffApps
const SMOOTH_SCROLL_STEPS = 5;
@@ -86,12 +88,14 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems,
ConfMainWindowLeftSortColumn, ConfMainWindowLeftSortType, ConfMainWindowRightSortColumn, ConfMainWindowRightSortType,
ConfSizeFormat, ConfSizeGroupPrecision, ConfCmdLineTerminalBehaviour, ConfViewerTerminalBehaviour,
ConfEditorTerminalBehaviour, ConfLeftTabBarTabIndex, ConfRightTabBarTabIndex, ConfSwitchOtherPanelBehaviour,
- ConfTabMaxLength, ConfDateFormat, ConfTimeFormat, ConfDateTimeFormat, ConfQuickSearchActivationKey: integer;
+ ConfTabMaxLength, ConfDateFormat, ConfTimeFormat, ConfDateTimeFormat, ConfQuickSearchActivationKey,
+ ConfDiffTerminalBehaviour, ConfDiffDirTerminalBehaviour: integer;
ConfLeftPath, ConfRightPath, ConfPanelFont, ConfProfileName, ConfViewer, ConfEditor, ConfTerminalCommand,
ConfNormalItemFGColor, ConfActiveItemFGColor, ConfInactiveItemFGColor, ConfSelectedItemFGColor, ConfLinkItemFGColor,
ConfDotFileItemFGColor, ConfNormalItemBGColor, ConfActiveItemBGColor, ConfInactiveItemBGColor,
- ParamLeftDir, ParamRightDir, ConfCustomDateFormat, ConfCustomTimeFormat: string;
+ ParamLeftDir, ParamRightDir, ConfCustomDateFormat, ConfCustomTimeFormat,
+ ConfDiffCommand, ConfDiffDirCommand: string;
ParamDebug, ConfShowDotFiles, ConfClearReadOnlyAttr, ConfDisableMouseRename, ConfUseSystemFont, ConfUseFileTypeIcons,
ConfFocusRefresh, ConfNewStyleAltO, ConfDirsInBold, ConfDisableDirectoryBrackets, ParamDisableGnome, ConfWMCompatMode,
@@ -273,6 +277,10 @@ begin
ConfReplaceConnectionWarning := True;
ConfWarnUnsavedConnection := True;
ConfViewerMonospaceFont := False;
+ ConfDiffTerminalBehaviour := 0;
+ ConfDiffCommand := ConfAppNA;
+ ConfDiffDirTerminalBehaviour := 0;
+ ConfDiffDirCommand := ConfAppNA;
// Setup default values for colors
@@ -524,6 +532,12 @@ begin
ConfReplaceConnectionWarning := IniFile.ReadBool(ConfProfileName, 'ReplaceConnectionWarning', ConfReplaceConnectionWarning);
ConfWarnUnsavedConnection := IniFile.ReadBool(ConfProfileName, 'WarnUnsavedConnection', ConfWarnUnsavedConnection);
+ (********************************************* NEW SINCE 0.6.71 *************************************************)
+ ConfDiffCommand := IniFile.ReadString(ConfProfileName, 'DiffCommand', ConfDiffCommand);
+ ConfDiffTerminalBehaviour := IniFile.ReadInteger(ConfProfileName, 'DiffTerminalBehaviour', ConfDiffTerminalBehaviour);
+ ConfDiffDirCommand := IniFile.ReadString(ConfProfileName, 'DiffDirCommand', ConfDiffDirCommand);
+ ConfDiffDirTerminalBehaviour := IniFile.ReadInteger(ConfProfileName, 'DiffDirTerminalBehaviour', ConfDiffDirTerminalBehaviour);
+
SearchForDefaultApps;
finally
@@ -619,6 +633,12 @@ begin
IniFile.WriteBool(ConfProfileName, 'ReplaceConnectionWarning', ConfReplaceConnectionWarning);
IniFile.WriteBool(ConfProfileName, 'WarnUnsavedConnection', ConfWarnUnsavedConnection);
+ (********************************************* NEW SINCE 0.6.71 *************************************************)
+ IniFile.WriteString(ConfProfileName, 'DiffCommand', ConfDiffCommand);
+ IniFile.WriteInteger(ConfProfileName, 'DiffTerminalBehaviour', ConfDiffTerminalBehaviour);
+ IniFile.WriteString(ConfProfileName, 'DiffDirCommand', ConfDiffDirCommand);
+ IniFile.WriteInteger(ConfProfileName, 'DiffDirTerminalBehaviour', ConfDiffDirTerminalBehaviour);
+
except
on E: Exception do DebugMsg(['*** Error: Cannot save user settings (', E.ClassName, '): ', E.Message]);
end;
@@ -1100,6 +1120,13 @@ begin
ConfTerminalCommand := ConfTerminalApps[i];
Break;
end;
+ if ConfDiffCommand = ConfAppNA then
+ for i := 1 to Length(ConfDiffApps) do
+ if FileSearch(ConfDiffApps[i], PATH) <> '' then begin
+ ConfDiffCommand := ConfDiffApps[i];
+ ConfDiffDirCommand := Format('%s %s', [ConfDiffApps[i], ConfDiffDirAppsDirsParams[i]]);
+ Break;
+ end;
end;
(********************************************************************************************************************************)
diff --git a/UMain.pas b/UMain.pas
index da3753b..065cc08 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -90,6 +90,7 @@ type
LeftPasswordButton, RightPasswordButton: TGTKImageButton;
PathBoxPopupMenu: TGTKMenuItem;
miPathBoxRefresh, miPathBoxCopyPath: TGTKMenuItem;
+ miDiff, miSynchronizeDirs: TGTKMenuItem;
procedure FormCreate(Sender: TObject); override;
procedure FormDestroy(Sender: TObject);
procedure FormResize(Sender: TObject);
@@ -183,6 +184,8 @@ type
procedure miCopyNamesClick(Sender: TObject);
procedure RightMouseSelectPopupTimerTimer(Sender: TObject);
procedure miQuickConnectClick(Sender: TObject);
+ procedure miDiffClick(Sender: TObject);
+ procedure miSynchronizeDirsClick(Sender: TObject);
private
LeftLastFocused, Editing, QuickFind, RedrawLeftInactive, RedrawRightInactive, StartUp, LeftTabPopup: boolean;
LastWidth, RunningEscSensitive: integer;
@@ -748,6 +751,15 @@ begin
miCreateChecksums.OnClick := miCreateChecksumsClick;
mnuFile.Add(miCreateChecksums);
mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
+ miDiff := TGTKMenuItem.Create(Self);
+ miDiff.Caption := '_Diff';
+ miDiff.OnClick := miDiffClick;
+ mnuFile.Add(miDiff);
+ miSynchronizeDirs := TGTKMenuItem.Create(Self);
+ miSynchronizeDirs.Caption := 'S_ynchronize directories';
+ miSynchronizeDirs.OnClick := miSynchronizeDirsClick;
+ mnuFile.Add(miSynchronizeDirs);
+ mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator));
miExit := TGTKMenuItem.CreateTyped(Self, itImageText);
miExit.Caption := LANGmiExit_Caption;
miExit.StockIcon := 'gtk-quit';
@@ -6504,5 +6516,105 @@ begin
end;
+(********************************************************************************************************************************)
+procedure TFMain.miDiffClick(Sender: TObject);
+var LeftPanel: boolean;
+ SourceListView, TargetListView: TGTKListView;
+ SourceEngine, TargetEngine: TPanelEngine;
+ SourceFile, TargetFile: string;
+ Error: integer;
+begin
+ if LeftListView.Focused then LeftPanel := True else
+ if RightListView.Focused then LeftPanel := False else
+ LeftPanel := LeftLastFocused;
+ if LeftPanel then begin
+ SourceListView := LeftListView;
+ TargetListView := RightListView;
+ SourceEngine := LeftPanelEngine;
+ TargetEngine := RightPanelEngine;
+ end else begin
+ SourceListView := RightListView;
+ TargetListView := LeftListView;
+ SourceEngine := RightPanelEngine;
+ TargetEngine := LeftPanelEngine;
+ end;
+
+ if (not Assigned(SourceListView.Selected)) or (not Assigned(SourceListView.Selected.Data)) or PDataItem(SourceListView.Selected.Data)^.IsDir or
+ PDataItem(SourceListView.Selected.Data)^.UpDir then
+ begin
+ Application.MessageBox(LANGYouMustSelectAValidFile, [mbOK], mbError, mbNone, mbOK);
+ Exit;
+ end;
+
+ SourceFile := IncludeTrailingPathDelimiter(SourceEngine.Path) + PDataItem(SourceListView.Selected.Data)^.FName;
+ TargetFile := '';
+ if Assigned(TargetListView.Selected) and Assigned(TargetListView.Selected.Data) and
+ (not PDataItem(TargetListView.Selected.Data)^.IsDir) and (not PDataItem(TargetListView.Selected.Data)^.UpDir)
+ then TargetFile := IncludeTrailingPathDelimiter(TargetEngine.Path) + PDataItem(TargetListView.Selected.Data)^.FName;
+
+ if SourceEngine is TVFSEngine then
+ if not HandleRunFromArchive(SourceFile, SourceEngine, '', '', True) then Exit;
+
+ if (Length(TargetFile) > 0) and (TargetEngine is TVFSEngine) then
+ if not HandleRunFromArchive(TargetFile, TargetEngine, '', '', True) then Exit;
+
+ if not ExecuteProgram(Format('%s %s %s', [ConfDiffCommand, QuoteStr(SourceFile), QuoteStr(TargetFile)]), SourceEngine.Path, ConfDiffTerminalBehaviour = 0, ConfDiffTerminalBehaviour = 1, Error) then
+ Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [ConfDiffCommand]), [mbOK], mbError, mbNone, mbOK);
+end;
+
+procedure TFMain.miSynchronizeDirsClick(Sender: TObject);
+var LeftPanel: boolean;
+ SourceListView, TargetListView: TGTKListView;
+ SourceEngine, TargetEngine: TPanelEngine;
+ SourceDir, TargetDir: string;
+ Error: integer;
+begin
+ if LeftListView.Focused then LeftPanel := True else
+ if RightListView.Focused then LeftPanel := False else
+ LeftPanel := LeftLastFocused;
+ if LeftPanel then begin
+ SourceListView := LeftListView;
+ TargetListView := RightListView;
+ SourceEngine := LeftPanelEngine;
+ TargetEngine := RightPanelEngine;
+ end else begin
+ SourceListView := RightListView;
+ TargetListView := LeftListView;
+ SourceEngine := RightPanelEngine;
+ TargetEngine := LeftPanelEngine;
+ end;
+
+ if (not Assigned(SourceListView.Selected)) or (not Assigned(SourceListView.Selected.Data)) or
+ ((not PDataItem(SourceListView.Selected.Data)^.IsDir) and (not PDataItem(SourceListView.Selected.Data)^.UpDir)) then
+ begin
+ Application.MessageBox('You must select directory!', [mbOK], mbError, mbNone, mbOK);
+ Exit;
+ end;
+
+ if PDataItem(SourceListView.Selected.Data)^.UpDir
+ then SourceDir := IncludeTrailingPathDelimiter(SourceEngine.Path)
+ else SourceDir := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(SourceEngine.Path) + PDataItem(SourceListView.Selected.Data)^.FName);
+
+ TargetDir := '';
+ if Assigned(TargetListView.Selected) and Assigned(TargetListView.Selected.Data) and
+ (PDataItem(TargetListView.Selected.Data)^.IsDir or PDataItem(TargetListView.Selected.Data)^.UpDir) then
+ begin
+ if PDataItem(TargetListView.Selected.Data)^.UpDir
+ then TargetDir := IncludeTrailingPathDelimiter(TargetEngine.Path)
+ else TargetDir := IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(TargetEngine.Path) + PDataItem(TargetListView.Selected.Data)^.FName);
+ end;
+
+ //* TODO: extract only particular subtree, also use ExtractFromArchive directly instead
+ if SourceEngine is TVFSEngine then
+ if not HandleRunFromArchive(SourceDir, SourceEngine, '', '', True) then Exit;
+
+ if (Length(TargetDir) > 0) and (TargetEngine is TVFSEngine) then
+ if not HandleRunFromArchive(TargetDir, TargetEngine, '', '', True) then Exit;
+
+ if not ExecuteProgram(Format('%s %s %s', [ConfDiffDirCommand, QuoteStr(SourceDir), QuoteStr(TargetDir)]), SourceEngine.Path, ConfDiffDirTerminalBehaviour = 0, ConfDiffDirTerminalBehaviour = 1, Error) then
+ Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [ConfDiffDirCommand]), [mbOK], mbError, mbNone, mbOK);
+end;
+
+
end.