Open location in new tab in other file pane Lua script #55
Replies: 3 comments
-
Your path probably contains spaces so the script interprets it as multiple parameters. Wrap the entire path in double quotes. |
Beta Was this translation helpful? Give feedback.
-
@advice2020, With comments: --[[
https://doublecmd.h1n.ru/viewtopic.php?t=8169
]]
local params = {...}
-- Get the script name (for message titles):
local sn = debug.getinfo(1).source
if string.sub(sn, 1, 1) == "@" then sn = string.sub(sn, 2, -1) end
sn = SysUtils.ExtractFileName(sn)
-- Check the number of parameters (this usually helps to avoid some surprises):
if #params ~= 1 then
Dialogs.MessageBox("Check the number of parameters!\nRequires only one.", sn, 0x0030)
return
end
-- Getting the attributes of the passed object (see below):
local attr = SysUtils.FileGetAttr(params[1])
-- Set focus on the opposite (inactive) panel:
DC.ExecuteCommand("cm_FocusSwap")
-- Create a new tab:
DC.ExecuteCommand("cm_NewTab")
-- If the object attributes are retrieved and
-- they do not contain the "directory" attribute...
if (attr ~= -1) and (math.floor(attr / 0x00000010) % 2 == 0) then
-- ...the cursor is on the file,
-- and we will use the path of this file:
DC.ExecuteCommand("cm_ChangeDir", SysUtils.ExtractFileDir(params[1]))
else
-- ...otherwise, it's probably a folder:
DC.ExecuteCommand("cm_ChangeDir", params[1])
end @JonnyTech, see the second paragraph here. |
Beta Was this translation helpful? Give feedback.
-
@Skif-off For any other users maybe reading this in the future.
I find both of these useful depending on the use case. Thank you again |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was recently looking through some of the Lua scripts in this plugin collection. I was surprised to notice that many of the scripts I have seen in forum and Github (created for other users) are not included. I know to you guys the scripts you create maybe are not looked at as being worth adding but I think they are great, why not add them to this collection?
Note:
I am going to make a request post that something like this gets added directly into DC itself.
My feature request posts have unfortunately not been that successful, so for now at least this will be available to users.
I found this script a while back but just got around to testing it.
This is a useful action, I would consider adding this into the collection.
The info at the top does not say it requires any parameters so I only have the line with the path to the Lua script.
Thank You
[Removed original script to eliminate confusion]
Beta Was this translation helpful? Give feedback.
All reactions