Saving sort order for several directories
Saving sort order for several directories
Hi,
It would be nice if I could save sort order per folder, like the download folder would automatically sorted by "write time" if I enter.
Or is it already possible?
thx
It would be nice if I could save sort order per folder, like the download folder would automatically sorted by "write time" if I enter.
Or is it already possible?
thx
- buniak_a_h
- Posts: 4266
- Joined: Sat 20 Apr, 2013 00:17
- Location: Санкт-Петробад
- Has thanked: 222 times
- Been thanked: 644 times
- Contact:
Saving sort order for several directories
See viewtopic.php?t=10521&start=60 :
Replacelordmuzer wrote: ↑Thu 23 Feb, 2023 00:23Работает на актуальной ночной сборке (Works on the latest nightly build)Code: Select all
Event { description = "PanelChangeDir"; group = "FolderChanged"; action = function() far.Message("changed!", nil, "w") end; }
far.Message("changed!", nil, "w")
with script as you needSaving sort order for several directories
Thank you, this looks really interesting, can you give me a hint where these scripts are processed? Is it far itslef or a plugin?
Is it only in the newest nightly builds?
I can't really understand russian.
Is it only in the newest nightly builds?
I can't really understand russian.
-
- Posts: 6836
- Joined: Thu 23 Mar, 2006 21:36
- Location: Israel
- Has thanked: 41 times
- Been thanked: 530 times
Saving sort order for several directories
Far itself + plugin LuaMacro
This feature ("emitting events on folder change") - yes.
I wouldn't recommend to go that way unless you are willing to spent many many hours studying FAR plugins' API and FAR macrosystem.
On the other hand I'm not aware of any ready solution of what you want to get.
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Saving sort order for several directories
In most cases browsers' built-in translation (e.g. in Chrome, Edge) is good enough to understand the discussions and make use of the tips, tricks, and scripts. As you can see, most of this forum is in Russian, so most useful and advanced stuff is in Russian (among much “noise” though).
Фар есть инструмент, а не нянька. © 2009 DrKnS
Saving sort order for several directories
well, I'm stuck.
As pretty much everything is stateless and I can't add custom data to the panel and a CTRL-U also swaps the sides without any notification
I have no idea how could I restore the original sorting in the same panel.
Any ideas?
Code: Select all
local F = far.Flags
local savesortmode
Event { description = "PanelChangeDir";
group = "FolderChanged";
action = function()
if panel.GetPanelDirectory(1).Name == "C:\\Program Files\\Far Manager\\Plugins\\LuaMacro" then
pinfo = panel.GetPanelInfo(nil, 1)
if pinfo.PanelType == F.PTYPE_FILEPANEL then
if not (pinfo.SortMode == F.SM_MTIME) then
savesortmode = pinfo.SortMode
panel.SetSortMode(nil, 1, F.SM_MTIME)
end
end
else
if savesortmode then
panel.SetSortMode(nil, 0, savesortmode) <-------- 0 is okay on TAB, not okey on leaving the directory on in the same panel
savesortmode=nil
end
end
end;
}
I have no idea how could I restore the original sorting in the same panel.
Any ideas?
- buniak_a_h
- Posts: 4266
- Joined: Sat 20 Apr, 2013 00:17
- Location: Санкт-Петробад
- Has thanked: 222 times
- Been thanked: 644 times
- Contact:
Saving sort order for several directories
You can restore sorting "by default":
Code: Select all
panel.SetSortMode(nil, 1, Far.GetConfig("Panel." .. (APanel.Left and "Left" or "Right") .. ".SortMode")
panel.SetSortMode(nil, 0, Far.GetConfig("Panel." .. (PPanel.Left and "Left" or "Right") .. ".SortMode")
Saving sort order for several directories
Thank you buniak_a_h, thank you all,
this APanel, PPanel and its properties gave me some ideas, here is what I'm came up with, let's see how it performs:
Next step is to store the dirs and sort modes somewhere with an editor. Some day....
this APanel, PPanel and its properties gave me some ideas, here is what I'm came up with, let's see how it performs:
Code: Select all
local targetdir = "C:\\Program Files\\Far Manager\\Plugins\\LuaMacro"
local F = far.Flags
local SaveSortMode
Event { description = "PanelChangeDir";
group = "FolderChanged";
action = function()
if SaveSortMode then
if PPanel.Path == targetdir then
panel.SetSortMode(nil, 0, SaveSortMode)
else
panel.SetSortMode(nil, 1, SaveSortMode)
end
SaveSortMode = nil
else
if APanel.Path == targetdir then
pinfo = panel.GetPanelInfo(nil, 1)
if pinfo.PanelType == F.PTYPE_FILEPANEL then
if not (pinfo.SortMode == F.SM_MTIME) then
SaveSortMode = pinfo.SortMode
panel.SetSortMode(nil, 1, F.SM_MTIME)
end
end
end
end
end;
}
Last edited by HaRT on Fri 03 Mar, 2023 13:00, edited 1 time in total.
Reason: Fix indentation, enable syntax highlighting.
Reason: Fix indentation, enable syntax highlighting.
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Saving sort order for several directories
Atys, you likely want
local pinfo = …
rather than having it global.Фар есть инструмент, а не нянька. © 2009 DrKnS