Page 1 of 1
[SOLVED] Display favorite files and folder from the treeview
Posted: 10 Apr 2018 16:10
by Leito
I like using the right-click on the empty space of the treeview to access favorite folders. I'd like to be able to access favorite files by a similar manner.
Is there a way to display favorite files and folders from the treeview? I'm looking at a way to do these for instance:
- Right-click on treeview → opens context menu with favorite folders and files stacked.
- Shift + right-click on treeview → opens context menu with favorite files.
I've seen the following tweak, but it doesn't seem that it answers my request (don't want to use option
1=Favs Full):
Code: Select all
; Tweak: 0=Favs, 1=Favs Full, 2=Drives, 3=Drives+Special, 4=Tabs, 5=FavFiles, 6=Script
CEA_TreeRightClickOnWhite=0
Re: Display favorite files and folder from the treeview
Posted: 10 Apr 2018 16:29
by jupe
Here is a very basic implementation, change that line you mentioned in the ini file and the one underneath to read:
Code: Select all
CEA_TreeRightClickOnWhite=6
CEA_TreeRightClickOnWhite_Script=if <get shift> { $favs = favs('f');} else {$favs = favs('d') . "-<crlf>" . favs('f');}load "$favs", '*' , 's';
It is word wrapped here but it should only occupy 2 lines in the ini file
Re: Display favorite files and folder from the treeview
Posted: 10 Apr 2018 16:40
by Leito
Thanks, that's exactly what I wanted!

Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 10 Apr 2018 17:36
by VeeGee
@
jupe - pretty slick - thanks !

Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 12 Apr 2018 13:37
by Leito
Is it possible to set focus to the list after clicking on a file or a folder?
I used the following tweak, but it's not functional with this script:
Code: Select all
; Tweak: 1 = Tree > List, 2 = Catalog > List, 4 = Address Bar > List, 8 = Favs > List
SetFocusTo=15
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 12 Apr 2018 13:45
by highend
Just add this command at the end of the script:
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 12 Apr 2018 13:50
by Leito
It's that easy!
Thanks

Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 12 Apr 2018 15:58
by Leito
Is there any way to support Shift+Click to open folders in a new tab, like it's possible on the "normal" favorite folders list?
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 12 Apr 2018 16:22
by highend
Sure, use a different script...
Code: Select all
$shift = (<get shift>) ? 1 : 0; $favs = ($shift) ? favs('f') : favs('d'); $type = ($shift) ? 'f' : 'd'; $favs = regexreplace($favs, '^(.*?)(?:\r?\n|$)', '$1||$1'.<crlf>); $sel = popupmenu($favs, 7:='|'); if (!$sel) { end true; } if ($type == 'd' && <get shift>) { tab('new', $sel); } else { goto $sel; } focus;
Too lazy to add icon support for the entries atm. I'll leave that to you (in the end it's nothing more than an additional regexreplace() and a slight modification to the popupmenu() call). Had a minute, did it myself...
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 12 Apr 2018 16:28
by Leito
Thanks, I'll work on that.
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 13 Apr 2018 00:27
by jupe
If you are interested here's a version I had done earlier, it has icons and now includes your recent requests. On the off chance someone wants to use it, it would probably be easier to put it in an external file in <xyscripts> and then add it to the ini like this:
Code: Select all
CEA_TreeRightClickOnWhite_Script=load 'script filename';
Code: Select all
$favs = "";
foreach($line, favs("f"), <crlf>) { $favs .= gpc($line, "file") . ";$line;$line<crlf>";}
if !<get shift> {
$favsD = "";
foreach($line, favs("d"), <crlf>) { $favsD .= gpc($line, "file") . ";$line;$line<crlf>";}
$favs = $favsD . "<crlf>-<crlf>" . $favs;}
$a = popupmenu($favs);
if (<get shift> && (exists($a) == 2 || $a == gettoken(formatlist($favsD, "f", <crlf>, "*;$a;$a"), 2, ";"))) { tab("new", $a); } else { goto $a;}
focus;
P.S, it will only work without modifications in recent versions of XY v18.80.0000+
You may prefer highends version which is probably better for those regex capable, but I had already done this so I am posting it anyway, I haven't thoroughly tested it, but it seems to work ok, and should be an acceptable base for someone to build on, regex would be preferred, but this is how I do it without regex.
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 13 Apr 2018 06:35
by highend
@jupe
Just a small note if you don't mind?
Don't do it like this:
This will always break / show a truncated name for a menu entry for a file / folder if the entry contains a semicolon itself. Use a character
that shouldn't exist...
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 13 Apr 2018 07:16
by jupe
Good point, I never use semicolons in filenames myself and consider them taboo, but they are a valid char, anyway I mainly provide my code blocks as guides rather than fully polished scripts because generally I will never use them myself, and hopefully it encourages others to learn by fixing my mistakes.

that is if they are game enough to try them...
Re: [SOLVED] Display favorite files and folder from the treeview
Posted: 13 Apr 2018 09:11
by highend