Author Topic: Sync Panels Navigation  (Read 26300 times)

pncdaspropagandas

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Sync Panels Navigation
« on: August 12, 2017, 05:35:18 »
I made 4 scripts to navigate simultaneously on both panels.

It's not safe proof, but it satisfies my needs.

You can ENTER, GO TO PARENT FOLDER, GO SAME LEVEL UP, GO SAME LEVEL DOWN.

For practicity, I associated with keys CTRL + SHIFT + (ENTER / BACKSPACE / PAGE UP / PAGE DOWN)

ENTER script:
Code: [Select]
@var $source_focus_name = GetSourceFocusName();
@var $source_path = GetSourcePath();
@var $target_path = GetTargetPath();

MC.Explorer.Goto SOURCE={($source_path ^ $source_focus_name) + "\\"} TARGET={($target_path ^ $source_focus_name) + "\\"}

PARENT SCRIPT:
Code: [Select]
@var $source_path = GetSourcePath();
@var $source_parent_path;
@var $target_path = GetTargetPath();
@var $target_parent_path;

// Get the parent path
$source_parent_path = StrSub($source_path, 0, StrLen($source_path)-2);
$target_parent_path = StrSub($target_path, 0, StrLen($target_path)-2);

MC.Explorer.Goto SOURCE={$source_parent_path} TARGET={$target_parent_path}


PAGE DOWN Script:
Code: [Select]
@var $source_path = GetSourcePath();
@var $source_parent_path;
@var $target_path = GetTargetPath();
@var $target_parent_path;
@var $pos;
@var $n;
@var $source_next_folder_index = -1;
@var $target_next_folder_index = -1;
@var $arr_directories_source[];
@var $arr_directories_target[];

// Get the parent path
$source_path = StrSub($source_path, 0, StrLen($source_path)-1);
$pos = StrRFind($source_path, '\');
$source_parent_path = StrSub($source_path, 0, $pos);

$target_path = StrSub($target_path, 0, StrLen($target_path)-1);
$pos = StrRFind($target_path, '\');
$target_parent_path = StrSub($target_path, 0, $pos);

// Get files and folders on source parent
$arr_directories_source = FindFiles($source_parent_path ^ '*');
@var $source_path_index = -1;
for ($n=0; $n<arrayCount($arr_directories_source); $n++ )
{
if( StrIsEqual($arr_directories_source[$n], $source_path) )
{
$source_path_index =  $n;
break;
}
}
// Search folder down the array - Source
if( $source_path_index >= 0 )
{
for ($n=($source_path_index+1); $n<arrayCount($arr_directories_source); $n++ )
{
if( IsFolder($arr_directories_source[$n]) )
{
LogAppInfo($arr_directories_source[$n]);
$source_next_folder_index = $n;
break;
}
}
}

if( $source_next_folder_index > -1 )
{
// Get files and folders on target parent
$arr_directories_target = FindFiles($target_parent_path ^ '*');
// Search for same folder name
for ($n=0; $n<arrayCount($arr_directories_target); $n++ )
{
if( IsFolder($arr_directories_target[$n]) )
{
if( StrIsEqual(PathGetNamePart($arr_directories_target[$n]), PathGetNamePart($arr_directories_source[$source_next_folder_index])) )
{
$target_next_folder_index =  $n;
break;
}
}
}
}

if( $source_next_folder_index > -1 )
{
if( $target_next_folder_index > -1 )
{
MC.Explorer.Goto SOURCE={$source_parent_path ^ PathGetNamePart($arr_directories_source[$source_next_folder_index])} TARGET={$target_parent_path ^ PathGetNamePart($arr_directories_target[$target_next_folder_index])}
}
}

PAGE UP Script:
Code: [Select]
@var $source_path = GetSourcePath();
@var $source_parent_path;
@var $target_path = GetTargetPath();
@var $target_parent_path;
@var $pos;
@var $n;
@var $source_next_folder_index = -1;
@var $target_next_folder_index = -1;
@var $arr_directories_source[];
@var $arr_directories_target[];

// Get the parent path
$source_path = StrSub($source_path, 0, StrLen($source_path)-1);
$pos = StrRFind($source_path, '\');
$source_parent_path = StrSub($source_path, 0, $pos);

$target_path = StrSub($target_path, 0, StrLen($target_path)-1);
$pos = StrRFind($target_path, '\');
$target_parent_path = StrSub($target_path, 0, $pos);

// Get files and folders on source parent
$arr_directories_source = FindFiles($source_parent_path ^ '*');
@var $source_path_index = -1;
for ($n=0; $n<arrayCount($arr_directories_source); $n++ )
{
if( StrIsEqual($arr_directories_source[$n], $source_path) )
{
$source_path_index =  $n;
break;
}
}
// Search folder down the array - Source
if( $source_path_index >= 0 )
{
for ($n=($source_path_index-1); $n>=0; $n-- )
{
if( IsFolder($arr_directories_source[$n]) )
{
LogAppInfo($arr_directories_source[$n]);
$source_next_folder_index = $n;
break;
}
}
}

if( $source_next_folder_index > -1 )
{
// Get files and folders on target parent
$arr_directories_target = FindFiles($target_parent_path ^ '*');
// Search for same folder name
for ($n=(arrayCount($arr_directories_target)-1); $n>=0; $n-- )
{
if( IsFolder($arr_directories_target[$n]) )
{
if( StrIsEqual(PathGetNamePart($arr_directories_target[$n]), PathGetNamePart($arr_directories_source[$source_next_folder_index])) )
{
$target_next_folder_index =  $n;
break;
}
}
}
}

if( $source_next_folder_index > -1 )
{
if( $target_next_folder_index > -1 )
{
MC.Explorer.Goto SOURCE={$source_parent_path ^ PathGetNamePart($arr_directories_source[$source_next_folder_index])} TARGET={$target_parent_path ^ PathGetNamePart($arr_directories_target[$target_next_folder_index])}
}
}

Gotta say thanks to Mathias!
« Last Edit: August 12, 2017, 14:44:03 by Mathias (Author) »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4386
    • View Profile
    • Multi Commander
Re: Sync Panels Navigation
« Reply #1 on: August 12, 2017, 14:42:54 »
Wow.  impressive.

If there is any script function you are missing let me know.
« Last Edit: August 12, 2017, 14:46:15 by Mathias (Author) »

pncdaspropagandas

  • Contributor
  • Active Member
  • *****
  • Posts: 93
    • View Profile
Re: Sync Panels Navigation
« Reply #2 on: August 14, 2017, 12:54:33 »
Thanks!

One function that would decrease the overhead is to return the folders. Just like FindFiles but with option to filter folders. Could be a parameter maybe, or a '*/' filter. But if is requires a lot of work, don't bother.