This file consists of two user facing scripts:
- Show Dual Location (showDual)
- Show Dual Location with List Configurations (showDualConfig)
The second does the same but attempts to include the list configurations.
Some notes:
- With as new as the feature and script are, it should be obvious but this hasn't been tested much and there are no guarantees that its output is and will always be correct.
- I did my best to include Quick Name Searches and Visual Filters but if a tab has both you'll have to pick one or the other. As far as I can tell there is no reliable way to do both to a single tab with Dual Locations.
- To retrieve the configurations this script must dive into the INI files and that requires saving the settings. When building a Dual Location with Configurations you will be prompted and if you accept the settings will be saved.
- Also, since the INI files are not documented Don is the only one who truly understands them. I think I am collecting the correct data for the configurations but I could very well be wrong.
- Lastly, I always try to avoid making unnecessary changes to the current state of XY, however to get all the needed information about the active tabs this script will need to activate the inactive pane. It will return focus to the originally active pane at the end. This could be avoided by retrieving all information from the INI files, but I didn't want to force saving settings for all cases.
Code: Select all
"Show Dual Location||1 : showDual"
Global $G_LOCATION = '';
Sub('_buildDual');
Text $G_LOCATION, /*width*/, /*height*/, 'Dual Location Builder';
"Show Dual Location with List Configurations : showDualConfig"
End ! Confirm("This will required saving the settings to read values from the INI files.<br><br>Do you wish to continue?");
Global $G_INCLUDE_SETTINGS = True;
SaveSettings;
Sub('showDual');
"- : _-" //---------------------------------------------------------------------
"Build Dual Location||4 : _buildDual"
Global $G_LOCATION;
// Get active pane.
$ap = Get('Pane');
// Get location for active pane.
Sub('_getLocation');
$apl = $G_LOCATION;
// Get location for inactive pane.
Focus('PI');
Sub('_getLocation');
$ipl = $G_LOCATION;
Focus('PI');
// Construct location depending on which was originally active.
$G_LOCATION = "DUAL:$ap";
if ($ap == 1) {
$G_LOCATION = "$G_LOCATION.$apl||$ipl";
} else {
$G_LOCATION = "$G_LOCATION.$ipl||$apl";
}
"Get Tab Location||4 : _getLocation"
Global $G_LOCATION, $G_INCLUDE_SETTINGS;
// If a tab has both a Visual Filter and a Quick Name Search
// the term will only contain the search.
$G_LOCATION = Tab('Get','Term');
$vf = Get('VisualFilter');
// If the term does not contain the active visual filter...
if ($vf && $G_LOCATION UnLike "*|$vf") {
$vf = Tab('Get', 'Data') . "|$vf";
// If the term is not a search...
if ($G_LOCATION UnLike "*?*") {
// Use generated visual filter location.
$G_LOCATION = $vf;
} else {
// Prompt the user if they want to use the search or the filter.
$response = InputSelect(<<<#HEREDOC
The active tab in pane <get Pane> has both a quick name search and a visual filter applied.
This cannot be easily recreated with a Dual Location.
Please select your preferred location.#HEREDOC, "$G_LOCATION<crlf>$vf", "<crlf>", 1, /*cancel*/,/*width*/,/*height*/, 'Dual Location Builder');
// Obey their response
// But if they didn't select anything we default to the search.
if ($response) {
$G_LOCATION = $response;
}
}
}
// If the user wants to include view settings....
if ($G_INCLUDE_SETTINGS) {
// Find the correct pane.ini.
// It should always be the temp one, but failback safely just in case.
$paneDir = "<xypane>";
$paneINI = "$paneDir\t\pane.ini";
if (Exists($paneINI) != 1) {
$paneINI = "$paneDir\pane.ini";
End Exists($paneINI) != 1,, 1;
}
// Tab index.
$tidx = Tab('Get');
$avalue = GetKey("A$tidx", 'Tabs', $paneINI, 1);
if ($avalue != '') {
// A# contains many settings but I believe we only need tokens 4, 9, 14.
$view = GetToken($avalue, 9, "<tab>", 't');
$sort = GetToken($avalue, 4, "<tab>", 't');
$list = GetToken($avalue, 14, "<tab>", 't');
$G_LOCATION = $G_LOCATION . ">>$view,$sort,$list";
}
}
XYplorer Beta Club