Ver código fonte

ADD: Viewer - open file under cursor by Shift+F3 (fixes #1276)

Alexander Koblov 1 ano atrás
pai
commit
cdbb2852f6
2 arquivos alterados com 31 adições e 9 exclusões
  1. 11 2
      src/uglobs.pas
  2. 20 7
      src/umaincommands.pas

+ 11 - 2
src/uglobs.pas

@@ -173,7 +173,7 @@ type
 
 const
   { Default hotkey list version number }
-  hkVersion = 62;
+  hkVersion = 63;
   // 54 - In "Viewer" context, added the "W" for "cm_WrapText", "4" for "cm_ShowAsDec", "8" for "cm_ShowOffice".
   // 53 - In "Main" context, change shortcut "Alt+`" to "Alt+0" for the "cm_ActivateTabByIndex".
   // 52 - In "Main" context, add shortcut "Ctrl+Shift+B" for "cm_FlatViewSel".
@@ -1049,11 +1049,20 @@ begin
           Remove(HMHotKey);
         end;
       end;
+      if HotMan.Version < 63 then
+      begin
+        HMHotKey:= FindByCommand('cm_View');
+        if Assigned(HMHotKey) and HMHotKey.SameShortcuts(['F3']) then
+        begin
+          Remove(HMHotKey);
+        end;
+      end;
 
       AddIfNotExists(['F1'],[],'cm_HelpIndex');
       AddIfNotExists(['F2','','',
                       'Shift+F6','',''],'cm_RenameOnly');
-      AddIfNotExists(['F3'],[],'cm_View');
+      AddIfNotExists(['F3','','',
+                      'Shift+F3','','cursor=1',''], 'cm_View');
       AddIfNotExists(['F4'],[],'cm_Edit');
       AddIfNotExists(['F5'],[],'cm_Copy');
       AddIfNotExists(['F6'],[],'cm_Rename');

+ 20 - 7
src/umaincommands.pas

@@ -2017,23 +2017,36 @@ var
   aFile: TFile;
   i, n: Integer;
   IsFile: Boolean;
+  sCmd: String = '';
   AMode: Integer = 0;
+  sParams: String = '';
   Param, AValue: String;
   sl: TStringList = nil;
-  ActiveFile: TFile = nil;
   AllFiles: TFiles = nil;
-  SelectedFiles: TFiles = nil;
+  sStartPath: String = '';
+  ActiveFile: TFile = nil;
   aFileSource: IFileSource;
-  sCmd: string = '';
-  sParams: string = '';
-  sStartPath: string = '';
+  ACursor: Boolean = False;
+  SelectedFiles: TFiles = nil;
   LinksResolveNeeded: Boolean;
 begin
   with frmMain do
   try
-    SelectedFiles := ActiveFrame.CloneSelectedOrActiveFiles;
     ActiveFile := ActiveFrame.CloneActiveFile;
 
+    if (Length(Params) > 0) then
+    begin
+      if GetParamValue(Params, 'cursor', AValue) then
+        GetBoolValue(AValue, ACursor);
+    end;
+
+    if not ACursor then
+      SelectedFiles := ActiveFrame.CloneSelectedOrActiveFiles
+    else begin
+      SelectedFiles:= TFiles.Create(ActiveFrame.CurrentPath);
+      if ActiveFile.IsNameValid then SelectedFiles.Add(ActiveFile.Clone);
+    end;
+
     if SelectedFiles.Count = 0 then
     begin
       msgWarning(rsMsgNoFilesSelected);
@@ -2116,7 +2129,7 @@ begin
       // If only one file was selected then add all files in panel to the list.
       // Works only for directly accessible files and only when using internal viewer.
       if (sl.Count = 1) and (IsFile) and
-         (not gExternalTools[etViewer].Enabled) and
+         (not ACursor) and (not gExternalTools[etViewer].Enabled) and
          ([fspDirectAccess, fspLinksToLocalFiles] * ActiveFrame.FileSource.Properties <> []) then
         begin
           AllFiles := ActiveFrame.CloneFiles;