[SOLVED] Display favorite files and folder from the treeview

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Leito
Posts: 562
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

[SOLVED] Display favorite files and folder from the treeview

Post 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
Last edited by Leito on 10 Apr 2018 16:40, edited 1 time in total.

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Display favorite files and folder from the treeview

Post 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

Leito
Posts: 562
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

Re: Display favorite files and folder from the treeview

Post by Leito »

Thanks, that's exactly what I wanted! :tup:

VeeGee

Re: [SOLVED] Display favorite files and folder from the treeview

Post by VeeGee »

@jupe - pretty slick - thanks ! :tup:

Leito
Posts: 562
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

Re: [SOLVED] Display favorite files and folder from the treeview

Post 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

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [SOLVED] Display favorite files and folder from the treeview

Post by highend »

Just add this command at the end of the script:

Code: Select all

 focus;
One of my scripts helped you out? Please donate via Paypal

Leito
Posts: 562
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

Re: [SOLVED] Display favorite files and folder from the treeview

Post by Leito »

It's that easy! :biggrin:

Thanks :tup:

Leito
Posts: 562
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

Re: [SOLVED] Display favorite files and folder from the treeview

Post 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?

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [SOLVED] Display favorite files and folder from the treeview

Post 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...
One of my scripts helped you out? Please donate via Paypal

Leito
Posts: 562
Joined: 26 Sep 2016 15:37
Location: Windows 10 1809 x64

Re: [SOLVED] Display favorite files and folder from the treeview

Post by Leito »

Thanks, I'll work on that.

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: [SOLVED] Display favorite files and folder from the treeview

Post 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.

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [SOLVED] Display favorite files and folder from the treeview

Post by highend »

@jupe

Just a small note if you don't mind?

Don't do it like this:

Code: Select all

";$line;$line<crlf>"
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...
One of my scripts helped you out? Please donate via Paypal

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: [SOLVED] Display favorite files and folder from the treeview

Post 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. :ninja: that is if they are game enough to try them...

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [SOLVED] Display favorite files and folder from the treeview

Post by highend »

:ninja: :ghost:
One of my scripts helped you out? Please donate via Paypal

Post Reply