Swap ALL Panes

Discuss and share scripts and script files...
Post Reply
Mr_Inc
Posts: 13
Joined: 27 Sep 2010 13:17

Swap ALL Panes

Post by Mr_Inc »

Not sure if anyone is interested in this modification to this script for saving the tabs in any pane:
http://www.xyplorer.com/xyfc/viewtopic. ... 943#p43943

But I wanted the ability to swap the entire panes around with all the tabs moving between the panes. I succeeded with this hash up of the above code:

Code: Select all

//needs latest XYplorer BETA version (v9.30.0014, 25-jul-2010) or newer
//Note: depending on your XY settings something may not work as indented.

// save an list of current open Tabs from current panes to P1.ini and P2.ini
   $CurrentPane = get("Pane"); // Remember active Pane to be restored later
   $LoopPane = 1;
   while ($LoopPane<3)  // do for Panes 1 and 2
   {
   Focus "P$LoopPane"; 
   $SubFolderName = "%computername%";  //"Work"; //sub-folder in sessions-folder
   $TabCount = tab(,"c"); //how many tabs are open?
   $Pane = getinfo("Pane"); //which pane is active?
   $Loop = 1;
   $Tabs = "";

   while ($Loop<$TabCount+1)  //for each tab do
   {
     //if (strlen(tab("get","name") < 1)
     $IFTabNameSet = strlen(tab("get","name",$Loop));
     if ($IFTabNameSet < 1)
     {
     $Tabs = $Tabs . tab("get", "data", $Loop) . "|"; //save the path in array "$Tabs" with | as delimiter
     }else{
     $Tabs = $Tabs . tab("get", "data", $Loop) . "?" . tab("get", "name", $Loop) . "|"; //save the tab caption too
     }
     incr $Loop;
    }
   
    //save the array to an file:
    //$folder = inputfolder("<xydata>\sessions", "Select Folder");
    IF (exists("<xydata>\Sessions\$SubFolderName")==0) {new "<xydata>\Sessions\$SubFolderName", dir;}

    writefile("<xydata>\Sessions\$SubFolderName\P$LoopPane.ini", $Tabs, "o");  //Write either P1.ini or P2.ini 
    incr $LoopPane;
    }

   
// ///////////////////////////////////////////////////////////////////////


// open new tabs from P1.ini and P2.ini:
    $LoopPane = 1; 
    while ($LoopPane<3) // Loop between Pane 1 and Pane 2
    {
    Focus "P$LoopPane"; //Focus on Pane#
    //read session file into array "$Tabs":
    if ($LoopPane=="1") {$Tabs = readfile("<xydata>\Sessions\$SubFolderName\P2.ini")};  //Load Opposite Saved Pane
    if ($LoopPane=="2") {$Tabs = readfile("<xydata>\Sessions\$SubFolderName\P1.ini")};  //Load Opposite Saved Pane
    
   
    //a little bit clean up first?
    #352;  //Close all Tabs no prompt
    
    $Loop = 1;
    While(1)
    {
      $NewTab = gettoken($Tabs,$Loop,"|");
      if ($NewTab==""){break;}
      if (strpos($NewTab,"?") == -1)
      {
         tab("new", $NewTab); //open new tab with next token from array
      }else{
         tab("new",    gettoken($NewTab,1,"?"));
         tab("rename", gettoken($NewTab,2,"?"));
      }
    incr $Loop;
    }
    seltab +1;  // Select first tab (Remnant of old tab layout)
    #351;  //Delete First Tab for tidy up
    incr $LoopPane;  // Do other Pane
    }
    
    Focus "P"."$CurrentPane";  //Restore focus to original Pane                                                     
Have fun!

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Swap ALL Panes

Post by SkyFrontier »

People may consider this a bloat without any prior testing - well, test and you certainly envision a few scenarios to work with this errrrr... custom function.
Thank you, Mr_Inc! This is an old wish now fulfilled thru scripting!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Mr_Inc
Posts: 13
Joined: 27 Sep 2010 13:17

Re: Swap ALL Panes

Post by Mr_Inc »

It's a bit clunky but does what I need it to do. I couldn't find out how to stop the tree list refreshing on each tab load, it would look neater if the refresh was suspended as the script executed.

"admin" advised the Swap "All" feature was not available, and as the Save Tab script did work, it seemed natural to use it as a base. Because I don't expect any problems as the process can be re-done to get back where you were, I made sure the script ran without any prompts / user intervention.

Besides, it helped me gain an understanding of the basic scripting; so no bad thing!

admin
Site Admin
Posts: 66249
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Swap ALL Panes

Post by admin »

Not having tested your script (no time) just a tiny syntax remark: instead of incr $Loop; you can also do $Loop++; :)

Post Reply