Colorize tree to Tab colors

Discuss and share scripts and script files...
Post Reply
klownboy
Posts: 3360
Joined: 28 Feb 2012 19:27

Colorize tree to Tab colors

Post by klownboy »

This script simply colorizes all the folders in the tree to match the color used on your tabs. It's more of a novelty script than a functional one and obviously it's not much good if you haven't colorized tabs. The idea for this script came about from seeing both autocart's https://www.xyplorer.com/xyfc/viewtopi ... c1e1861cde and
highend's viewtopic.php?f=7&t=23619&sid=0daf7bdbc ... c1e1861cde scripts. Thanks to both of you. Unlike those scripts, this script doesn't use CEA Change Locations to colorize a tree folder upon a tab change. It also has the ability to colorize additional folders unrelated to your tabs (accomplish via the $specificColors variable below). Tab colors are obtained from pane.ini in the "<xydata>\Pane\name of tabset\t" folder. I leave it up to you to make sure your tabset is up to date. In a normal savesettings, tab colors are saved to the tabset subfolder "t". So a normal savesettings even to a temp ini will provide the updated information in the pane.ini for the script.

To use the script as a CTB with both left and right click actions enter: load "<xyscripts>\Colorize tree to tab colors.xys";
or make a UDC under User >Manage Commands > Category > "Load Script file" and refer to script in the "Script File" block. For example, to color tree folders to match the tab colors as well as any additional folders specified, assign Keyboard Shortcut to Numpad 5. If you'd rather only color the tree to the tab colors and no other folders, Assign Keyboard Shortcut to Alt Numpad 5 as an example. The script will determine if a modifier was held down in the case of a UDC or a right click in the case of a CTB so the end result will be only colorizing the tree to match the tabs - no other additional folders.
Please let me know if you have an issue. Thanks.

Colorize tree to tab colors_v0.2.xys *** This update allows the user to simply cycle the matching tree to tab colors on and off by hitting the same key again as a toggle, whether it be a CTB or UDC. So it avoids having to press the Instant Color Filtert toolbar button to cycle the tree colors off. Not a huge deal, but it does make it a bit more user friendly.

Code: Select all

   if(colorfilter()) {
      colorfilter(""); end 1;
   }
   else {
      $inCTB = Get('Trigger', 'CTBIndex') > 0;
      if ($inCTB) {
      $trigger = get("trigger", "mousebtn");
      }
      else {
        $trigger = "0";
      }
      savesettings 1, "tempXY.ini";
      $mod = get("trigger","callshift");
      $context = get("trigger","context");
      $oldFilter = colorfilter();
      $newFilter = "";
      $pane = get("pane");
      $Tabset = getkey("Tabset" . $pane, "General");
      $i= "1";
      foreach($path, get("Tabs"),, "e") {
         $colors = getkey("Colors" . $i, "Tabs","<xydata>\Panes\$Tabset\t\pane.ini");
         $quoted_path = ((substr($path, 1,1) == ":") AND (substr($path, -1) != "\"))? quote($path . "\") : quote($path); 
         $newFilter .= "T:dir:" . $quoted_path . ">" . $colors . "||";
         $i++;
      }
      delete 0,0, "<xydata>\tempXY.ini";

// *** this section allows the user to designate colors for any folder unrelated to tabs colors
      if(($trigger == "2") OR ($context == "4" AND $mod > "0")) {
         if ($oldFilter != $newFilter) {
            colorfilter($newFilter);
         }
         end 1;
      }
      else {

     $specificColors = "";
//*** add your own folder color info here as shown; "folderpath|hex color foreground,hex color background"
//*** I included only those that may be on your PC

     $specificColors = <<<>>>
        This PC|FF00FF,FFFFFF
        Links|008000,FFFFFF
        C:\Program Files\|FF8C00,F0FFF0
        C:\Program Files (x86)|008000,FFFFFF
        C:\Windows|0000CD,FFFFFF
    >>>;

      $myFilter = "";
      $specificColors = regexreplace($specificColors, "(^[ \t]+|[ ]*?//.*?$)");
      foreach($pathcolor, $specificColors, <crlf>, "e") {
         $path = gettoken($pathcolor, 1, "|", "t");
         $quoted_path = ((substr($path, 1,1) == ":") AND (substr($path, -1) != "\"))? quote($path . "\") : quote($path);
         $colors = gettoken($pathcolor, 2, "|", "t");
         $myFilter .= "T:dir:" . $quoted_path . ">" . $colors . "||";
      }

         $newFilter = $newFilter . "||" . $myFilter;
         if ($oldFilter != $newFilter) {
             colorfilter($newFilter);
         }
      }
   }
Colorize tree to tab colors_v0.1.xys
(3.88 KiB) Downloaded 28 times
Colorize tree to tab colors_v0.2.xys
(2.26 KiB) Downloaded 30 times
color tree to tabs.jpg
color tree to tabs.jpg (78.66 KiB) Viewed 227 times
Last edited by klownboy on 21 Oct 2021 17:15, edited 1 time in total.
Windows 10, 21H1 Build 19043.1110 at 100% 2560x1440

klownboy
Posts: 3360
Joined: 28 Feb 2012 19:27

Re: Colorize tree to Tab colors

Post by klownboy »

Colorize tree to tab colors_v0.2.xys *** This update allows the user to simply cycle the matching tree to tab colors on and off by hitting the same key again as a toggle. So it avoids having to press the Instant Color Filter toolbar button to cycle the tree colors off/on. Not a huge deal, but it does make it a bit more user friendly. See the first post for the update
Windows 10, 21H1 Build 19043.1110 at 100% 2560x1440

Post Reply