How to indicate open tabs in tree??

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

How to indicate open tabs in tree??

Post by autocart »

Hello all,

I did not find an option for the following wish:

Is it possible to indicate in the tree, which paths are currently open in tabs?

I am adjusting my MiniTree on each location change to include only the paths of open tabs and all direct subfolders of the current tab's path.
However, I noticed that that is still not good enough, because since the tree is a hierarchical view, it also shows all the folders between "C:" and each tab's folder. Therefore, by looking at the MiniTree, I still sometimes get confused about whether any paths "inbetween" are open in a tab as well or not.

So, does anyone have an idea? E.g. are custom folder icons possible in MiniTree? Or drawing certain folders in bold? Are custom location pins possible with a tweak or some hidden scripting? Anything else? Like I said, I have not found any option like that, but since XY is complex, maybe I overlooked something?

Thx and regards, S.

highend
Posts: 11091
Joined: 06 Feb 2011 00:33

Re: How to indicate open tabs in tree??

Post by highend »

colorfilter()... with all necessary paths
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

Hello highend,

Thank you! That does work, even though it was/is a bit cumbersome to make it work due to the "funny" color filter syntax.
I finally came up with this working solution, for anyone who might want to try it as well:

Code: Select all

  $instantColorfilterDefinition = "";
  $colorfilterColors = "FFFFFF,70B926";
  $i = 0;
  foreach($path, get("Tabs")) {
   if ($i > 0) {
    $instantColorfilterDefinition .= "||";
   }
   $i++;
   $instantColorfilterDefinition .= "T:dir:* //|filter:" . $path ."\>" . $colorfilterColors;
  }
  if (colorfilter() != $instantColorfilterDefinition) {
   colorfilter($instantColorfilterDefinition);
  }
EDIT:
Just noticed one limitation: If the instant color filter is changed by hand, e.g. with the toolbar button, then (1) the current highlighting is gone and (2) it unfortunately cannot be changed back manually. Still, I like this solution so far.

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

Re: How to indicate open tabs in tree??

Post by jupe »

You could also use SC highlight.

highend
Posts: 11091
Joined: 06 Feb 2011 00:33

Re: How to indicate open tabs in tree??

Post by highend »

(2) it unfortunately cannot be changed back manually
Ofc you can, use a perm variable to store the new filter

And this does work for "paths" like "This PC", "Desktop", etc. as well:

Code: Select all

    $colors    = "FFFFFF,70B926";
    $oldFilter = colorfilter();
    $newFilter = "";
    foreach($path, get("Tabs")) {
        $quoted     = (regexmatches($path, "(:|\\)")) ? quote($path . "\") : quote($path);
        $newFilter .= "T:dir:" . $quoted . ">" . $colors . "||";
    }
    if ($oldFilter != $newFilter) {
        colorfilter($newFilter);
        // perm $COLOR_FILTER = $newFilter;
    }

One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

jupe wrote: 16 Oct 2021 04:09 You could also use SC highlight.
Ah, the highlight feature, yes, totally forgot, thx!
Little downside: If one wants to manually deactivate it, it does not have a toolbar button.
Yes, I do know about the entries in the Favorites menu and the Tools / Customize Tree and List Management menus.
Still, I feel it is a bit cumbersome in its own way.
But it certainly is a good alternative. Both have their pros and cons. Thank you for this valuable addition!

EDIT:
One programming con: It seems I cannot delete all highlighting at once easily via scripting. I would have to log all the folders that I highlight on the way, preferably in a perm variable, especially, since, technically, there could also be other highlighted folders present for other reasons. And then I am still not sure if the perm variable will be kept across sessions. It would be better if XY allowed for grouping the highlighted attributes and gave scripting an equivalent access to the List Management / Highlighted Folders... dialog. But as it is, I think, I will stick with the instant color filters. Still, thx again.
Last edited by autocart on 16 Oct 2021 12:19, edited 1 time in total.

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

highend wrote: 16 Oct 2021 08:28
(2) it unfortunately cannot be changed back manually
Ofc you can, use a perm variable to store the new filter

And this does work for "paths" like "This PC", "Desktop", etc. as well:

Code: Select all

        $quoted     = (regexmatches($path, "(:|\\)")) ? quote($path . "\") : quote($path);
Ah, never noticed that the color filter with my set up did not work for those pseudo paths. Thx!

With "manually", though, I mean really manually with on-board options (using the mouse on the toolbar or at least on the menus).
Using a perm variable, even with an alias variable, it seems that I cannot create an instant color filter to be shown in the toolbar drop down, that would successfully use that variable.

EDIT: Highend, your instant color filter definition approach is much simpler. I tried yesterday but maybe I was already too tired since it was late. Thank you again!

highend
Posts: 11091
Joined: 06 Feb 2011 00:33

Re: How to indicate open tabs in tree??

Post by highend »

Create a feature request for supporting variables in color filter definitions?

This would handle it...
And then I am still not sure if the perm variable will be kept across sessions
savesettings can be used for this...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

highend wrote: 16 Oct 2021 12:24 Create a feature request for supporting variables in color filter definitions?
Yes. :tup: 8) I might do that.
highend wrote: 16 Oct 2021 12:24
And then I am still not sure if the perm variable will be kept across sessions
savesettings can be used for this...
I am not sure what you exactly mean, but I mean whether "Configuration | Refresh, Icons, History | Remember permanent variables" is ticked or not. For me personally, I would, of course, hopefully know what it is. But if someone else wants to use my code, it does not help to figure out whether is is ticked or not, because if it is not ticked, then the other person might purposefully not want to have it ticked. So, I would not want to activate it programmatically. But it all is not big deal. I am quite happy with the solution with instant color filters at them moment.

highend
Posts: 11091
Joined: 06 Feb 2011 00:33

Re: How to indicate open tabs in tree??

Post by highend »

I am not sure what you exactly mean
That you can make it survive sessions regardless of the current setting. If somebody doesn't want that, a simple $saveSession = true/false; could be used
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

Ah, savesettings 256;, 256 = pv.dat (permanent variables).
Ok, but I just tried it. If "Configuration | Refresh, Icons, History | Remember permanent variables" is off, then I can savesettins 256; but if XY is closed and reopened the permanent variables are still gone. Besides, I think it would be violating a users wish, if it was different. No, I am ok with the way it is now.

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

FEI (For Everybody's Information :kidding: ):
I now shared the code in the Script Exchange forum: viewtopic.php?f=7&t=23621

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

@jupe, was it you who mentioned the writepv / readpv commands before?
That is a nice idea. Why was that comment deleted again?
These commands would almost be the perfect solution in this case. I must say almost, because, as far as I understood so far:
  • As mentioned before, it would be used from one session to the next.
  • Writepv saves all permanent variables, regardless of who added them.
  • Readpv reads all saved perms that where saved with writepv, and restores their saved values.
  • So, at the time of using readpv there might be perms in existence that do not belong to the current script and that already existed at the time of writepv, but now have a different value. Then their current values would be overwritten.
However, I have the following solution, provided that one uses a "save" naming scheme. To be on the save side, one can check the existance of a variable with isset() before starting to use it: $contents = isset($p_filenamestore)?$p_filenamestore:""; (example from the help file).

Then, one can use these steps for saving only the scripts perms:
  1. Writepv all current perms of this XY's session to a temporary file "Temp Perms".
  2. Temporarily save all script's perms in non-perm variables.
  3. Do a releaseglobals 2;. Releases all permanent variables from memory.
  4. Reset the script's perms in the current session from the temporary non-perm vars of step 2.
  5. Use writepv again to save the scripts perms to another file "Script's Perms". Now only the scripts perms get saved because all others where released before.
  6. Readpv the temporary file "Temp Perms" from step 1 to restore all the perms of this XY's session.
Now the file "Script's Perms" only contains the script's perms and can savely be readpved in a future session. No risk to overwrite other perms not belonging to the script.

So, it is not *the* perfect solution, because it is a bit of a dirty and cumbersome solution. There is also the small risk that a different part of XY (maybe a script reacting to some CEA) might want to update a perm at that very moment while this process is running, I am not sure? So, nothing else should be done in between all these steps in order to minimize this risk. But it should work. :tup:

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

Re: How to indicate open tabs in tree??

Post by jupe »

Yeah I suggested them, but then I decided based on your previous posts that you were probably content with what you had already scripted and therefore wouldn't be interested in the rest of my post, so as an afterthought removed it.

autocart
Posts: 1111
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

No need to be so self-conscious / doubting. I was just not fast enough with replying. Besides, other people reading it in the future might benefit.
Thank you again for these thoughts. :tup:

Post Reply