UPD: refactor in TfrmMain.LoadTabsCommandLine() : don't repeat ourselves for left and right panels separately; added LoadPanel() procedure that does the job for given panel

This commit is contained in:
Dmitry Frank 2014-06-18 13:18:32 +00:00
commit effd6fe102
2 changed files with 17 additions and 26 deletions

View file

@ -4603,34 +4603,27 @@ procedure TfrmMain.LoadTabsCommandLine(Params: TCommandLineParams);
ANoteBook.PageIndex := ANoteBook.PageCount - 1;
end;
begin
if Params.LeftPath[0] <> #0 then
procedure LoadPanel(aNoteBook: TFileViewNotebook; aPath: UTF8String);
begin
Params.LeftPath:= ReplaceEnvVars(ReplaceTilde(Params.LeftPath));
if not mbFileSystemEntryExists(Params.LeftPath) then
Params.LeftPath:= GetDeepestExistingPath(Params.LeftPath);
if Params.LeftPath[0] <> #0 then
if Length(aPath) <> 0 then
begin
if Params.NewTab then
AddTab(nbLeft, Params.LeftPath)
else
FrameLeft.ChangePathAndSetActiveFile(Params.LeftPath)
aPath:= ReplaceEnvVars(ReplaceTilde(aPath));
if not mbFileSystemEntryExists(aPath) then
aPath:= GetDeepestExistingPath(aPath);
if Length(aPath) <> 0 then
begin
if Params.NewTab then
AddTab(aNoteBook, aPath)
else
aNoteBook.ActivePage.FileView.ChangePathAndSetActiveFile(aPath)
end;
end;
if Params.RightPath[0] <> #0 then
begin
Params.RightPath:= ReplaceEnvVars(ReplaceTilde(Params.RightPath));
if not mbFileSystemEntryExists(Params.RightPath) then
Params.RightPath:= GetDeepestExistingPath(Params.RightPath);
if Params.RightPath[0] <> #0 then
begin
if Params.NewTab then
AddTab(nbRight, Params.RightPath)
else
FrameRight.ChangePathAndSetActiveFile(Params.RightPath);
end;
end;
begin
LoadPanel(nbLeft, Params.LeftPath);
LoadPanel(nbRight, Params.RightPath);
//-- set active panel, if needed
if Params.ActivePanelSpecified then
begin

View file

@ -11,6 +11,7 @@ type
ActiveRight: Boolean;
LeftPath: array[0..1023] of AnsiChar;
RightPath: array[0..1023] of AnsiChar;
ActivePanelPath: array[0..1023] of AnsiChar;
Client: Boolean;
Servername: array[0..1023] of AnsiChar;
end;
@ -110,10 +111,7 @@ begin
// If also found one parameter then use it as path of active panel
if ParamCount - OptInd = 0 then
begin
if CommandLineParams.ActiveRight then
CommandLineParams.RightPath:= ParamStrU(OptInd)
else
CommandLineParams.LeftPath:= ParamStrU(OptInd);
CommandLineParams.ActivePanelPath:= ParamStrU(OptInd);
Inc(OptInd, 1);
end
// If also found two parameters then use it as paths in panels