Multi Commander > Script
Sync Panels Navigation
(1/1)
pncdaspropagandas:
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: ---@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) + "\\"}
--- End code ---
PARENT SCRIPT:
--- Code: ---@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}
--- End code ---
PAGE DOWN Script:
--- Code: ---@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])}
}
}
--- End code ---
PAGE UP Script:
--- Code: ---@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])}
}
}
--- End code ---
Gotta say thanks to Mathias!
Mathias (Author):
Wow. impressive.
If there is any script function you are missing let me know.
pncdaspropagandas:
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.
Navigation
[0] Message Index
Go to full version