ADD: Feature Request [ 1869250 ] Принудительный вход в архив по ctrl+PageDown

This commit is contained in:
Alexander Koblov 2008-01-26 10:40:21 +00:00
commit 9f9f2ae60f
8 changed files with 151 additions and 10 deletions

View file

@ -1,4 +1,5 @@
18.01.2008 FIX: Bug [ 1869790 ] Опции -> цвета файлов - нелогичность
26.01.2008 ADD: Feature Request [ 1869250 ] Try to open archive by Ctrl+PageDown
18.01.2008 FIX: Bug [ 1869790 ] Опции -> цвета файлов - нелогичность
17.01.2007 FIX: Bug [ 1869784 ] Папки и diff
17.01.2007 FIX: Bug [ 1870772 ] Навигация lynx, "вправо" на "уровень выше"
13.01.2007 FIX: Bug [ 1869757 ] Внешний редактор

View file

@ -1308,6 +1308,13 @@ object frmMain: TfrmMain
DisableIfNoHandler = True
OnExecute = actContextMenuExecute
end
object actOpenArchive: TAction
Category = 'File'
Caption = 'Try open archive'
DisableIfNoHandler = True
OnExecute = actOpenArchiveExecute
ShortCut = 16418
end
end
object pmHotList: TPopupMenu
left = 152

View file

@ -75,5 +75,6 @@ TFRMMAIN.ACTFOCUSCMDLINE.CAPTION=Focus command line
TFRMMAIN.ACTTRANSFERLEFT.CAPTION=Transfer dir under cursor to left window
TFRMMAIN.ACTTRANSFERRIGHT.CAPTION=Transfer dir under cursor to right window
TFRMMAIN.ACTCONTEXTMENU.CAPTION=Show context menu
TFRMMAIN.ACTOPENARCHIVE.CAPTION=Try open archive
TFRMMAIN.TBEDIT.CAPTION=Edit
TFRMMAIN.TBDELETE.CAPTION=Delete

View file

@ -56,6 +56,7 @@ type
actAddPathToCmdLine: TAction;
actFocusCmdLine: TAction;
actContextMenu: TAction;
actOpenArchive: TAction;
actTransferRight: TAction;
actTransferLeft: TAction;
actRightOpenDrives: TAction;
@ -201,6 +202,7 @@ type
procedure actExtractFilesExecute(Sender: TObject);
procedure actFocusCmdLineExecute(Sender: TObject);
procedure actLeftOpenDrivesExecute(Sender: TObject);
procedure actOpenArchiveExecute(Sender: TObject);
procedure actOpenVFSListExecute(Sender: TObject);
procedure actPackFilesExecute(Sender: TObject);
procedure actRightOpenDrivesExecute(Sender: TObject);
@ -515,6 +517,11 @@ begin
pmDrivesMenu.PopUp(p.x, p.y);
end;
procedure TfrmMain.actOpenArchiveExecute(Sender: TObject);
begin
ActiveFrame.pnlFile.TryOpenArchive(ActiveFrame.GetActiveItem);
end;
procedure TfrmMain.actOpenVFSListExecute(Sender: TObject);
begin
ActiveFrame.pnlFile.LoadVFSListInPanel;
@ -2068,8 +2075,13 @@ begin
begin
with ActiveFrame do
begin
if pnlFile.GetActiveItem^.sName='..' then Exit;
pnlFile.cdDownLevel(pnlFile.GetActiveItem);
if not (pnlFile.GetActiveItem^.sName='..') then
begin
if FPS_ISDIR(pnlFile.GetActiveItem^.iMode) or (pnlFile.GetActiveItem^.bLinkIsDir) then
pnlFile.cdDownLevel(pnlFile.GetActiveItem)
else
actOpenArchive.Execute;
end;
end;
Key:=0;
Exit;

View file

@ -1907,3 +1907,7 @@ msgstr ""
msgid "Delete file \%s"
msgstr ""
#: TFRMMAIN.ACTOPENARCHIVE.CAPTION
msgid "Try open archive"
msgstr ""

View file

@ -62,6 +62,7 @@ type
procedure Sort;
procedure UpdatePanel;
// procedure ChDir(sDir:String);
procedure TryOpenArchive(pfri:PFileRecItem);
procedure ChooseFile(pfri:PFileRecItem); // main input node
procedure ExecuteFile(const sName:String; bTerm:Boolean);
function GetFileItem(iIndex:Integer):TFileRecItem;
@ -198,8 +199,9 @@ var
sDir:String;
sDummy:String;
VFSFileList : TFileList;
sTempDir : String;
I : Integer;
sTempDir,
sFileName : String;
I, iIndex : Integer;
begin
with frp^ do
begin
@ -256,7 +258,7 @@ begin
begin
if fVFS.FindModule(sName, False) then // if archive
begin
fVFSmoduleList.AddObject(fVFS.ArcFullName + '=' + sPath, fVFS.VFSmodule);
iIndex := fVFSmoduleList.AddObject(fVFS.ArcFullName + '=' + sPath, fVFS.VFSmodule);
//DebugLn('sPath ==' + sPath);
@ -266,12 +268,19 @@ begin
//DebugLn('ActiveDir == ' + ActiveDir);
sName := ActiveDir + sName;
sFileName := sName;
VFSFileList.AddItem(frp);
sTempDir := GetTempDir;
{if }fVFS.VFSmodule.VFSCopyOut(VFSFileList, sTempDir, 0);{ then}
begin
if not fVFS.LoadAndOpen(sTempDir + ExtractDirLevel(ActiveDir, sName)) then Exit;
if not fVFS.LoadAndOpen(sTempDir + ExtractDirLevel(ActiveDir, sFileName)) then
begin
// restore old plugin module and delete it from list
fVFS.VFSmodule := TVFSmodule(fVFSmoduleList.Objects[iIndex]);
fVFS.ArcFullName := fVFSmoduleList.Names[iIndex];
fVFSmoduleList.Delete(iIndex);
Exit;
end;
//DebugLn('sTempDir + sName == ' + sTempDir + sName);
fVFS.VFSmodule.VFSList(PathDelim, fFileList);
@ -375,6 +384,61 @@ begin
InvertFileSection(fFileList.GetItem(i));
end;
procedure TFilePanel.TryOpenArchive(pfri:PFileRecItem);
var
VFSFileList : TFileList;
sTempDir,
sFileName : String;
iIndex : Integer;
begin
with pfri^ do
if fPanelMode = pmDirectory then // in real file system
begin
if fVFS.TryFindModule(sPath + sName) then
begin
fVFS.VFSmodule.VFSList(PathDelim, fFileList);
fPanelMode := pmArchive;
fActiveDir := fVFS.ArcFullName + DirectorySeparator;
end;
end
else // in Virtual File System
begin
iIndex := fVFSmoduleList.AddObject(fVFS.ArcFullName + '=' + sPath, fVFS.VFSmodule);
//DebugLn('sPath ==' + sPath);
VFSFileList := TFileList.Create;
VFSFileList.CurrentDirectory := ActiveDir;
//DebugLn('ActiveDir == ' + ActiveDir);
sName := ActiveDir + sName;
sFileName := sName;
//DebugLn('sFileName = ', sFileName);
VFSFileList.AddItem(pfri);
sTempDir := GetTempDir;
{if }fVFS.VFSmodule.VFSCopyOut(VFSFileList, sTempDir, 0);{ then}
begin
//DebugLn('sTempDir + sName == ' + sTempDir + ExtractDirLevel(ActiveDir, sFileName));
if not fVFS.TryFindModule(sTempDir + ExtractDirLevel(ActiveDir, sFileName)) then
begin
// restore old plugin module and delete it from list
fVFS.VFSmodule := TVFSmodule(fVFSmoduleList.Objects[iIndex]);
fVFSmoduleList.Delete(iIndex);
Exit;
end;
fVFS.VFSmodule.VFSList(PathDelim, fFileList);
fPanelMode:=pmArchive;
fActiveDir := fVFS.ArcFullName + DirectorySeparator;
end;
end; // in VFS
if gShowIcons then
fFileList.UpdateFileInformation(fPanelMode);
Sort;
end;
procedure TFilePanel.ChooseFile(pfri:PFileRecItem);
var

View file

@ -1,2 +1,3 @@
ufilelist.pas
uOSUtils.pas
uOSUtils.pas
uvfs.pas

View file

@ -49,8 +49,25 @@ type
function cdUpLevel(frp:PFileRecItem; var flist: TFileList) : Boolean;
function cdDownLevel(frp:PFileRecItem; var flist: TFileList) : Boolean;
{en
Tries to find plugin for archive by content
@param(sFileName Archive file name)
@returns(@true if plugin found, @false otherwise)
}
function TryFindModule(const sFileName:String):Boolean;
{en
Tries to find plugin by file name
@param(sFileName File name)
@param(bLoadModule Load plugin module if found)
@returns(@true if plugin found, @false otherwise)
}
function FindModule(const sFileName:String; bLoadModule : Boolean = True):Boolean;
{en
Load plugin module and open VFS
@param(sFileName File name)
@param(bGetOpenResult if @true then return VFSOpen result)
@returns(@true if plugin module load, @false otherwise)
}
function LoadAndOpen(const sFileName:String; bGetOpenResult : Boolean = True) : Boolean;
function LoadVFSList(var fl:TFileList) : Boolean;
property VFSType : TVFSType read FVFSType;
@ -115,6 +132,40 @@ begin
Result := True;
end;
function TVFS.TryFindModule(const sFileName: String): Boolean;
var
I, iCount,
Index : Integer;
sPlugin : String;
begin
if not FileExists(sFileName) then Exit(False);
iCount := FWCXPlugins.Count - 1;
for I := 0 to iCount do
begin
sPlugin := FWCXPlugins.ValueFromIndex[I];
Index := Pos(',', sPlugin) + 1;
FCurrentPlugin := GetCmdDirFromEnvVar(Copy(sPlugin, Index, Length(sPlugin)));
FVFSModule := TWCXModule.Create;
Result := FVFSModule.LoadModule(FCurrentPlugin);
if Result then
begin
try
Result := False;
if FVFSModule.VFSOpen(sFileName, True) then // found
begin
sLastArchive := sFileName;
Exit(True);
end
else
FVFSModule.UnloadModule;
except
FVFSModule.UnloadModule;
end;
end;
end; // for
end;
function TVFS.FindModule(const sFileName:String; bLoadModule : Boolean = True):Boolean;
var