Formatting output for
inputselect()
where you want to have a divider always at the same position is a pain in the a** because imho there isn't a 100% reliable way to do this with tabs.Spaces are perfect and can be calculated accurately but only if a fixed-size font is used. So... Would it be possible to give that command another parameter "font=<font>,<style>,<size>" which would allow us to override the current configured one? If <style> and <size> are left out, they could be retrieved from the current configured one...
A demo script:
Code: Select all
$relationShips = <<<>>>
ShowDragStatusBox <--> General | Safety Belts, Network | Safety Belts | Show drag status box
DisallowDragging <--> General | Safety Belts, Network | Safety Belts | Disallow left-dragging from folder tree
DisallowDraggingFromList <--> General | Safety Belts, Network | Safety Belts | Disallow left-dragging from file list
ConfirmDrop <--> General | Safety Belts, Network | Safety Belts | Confirm drag and drop
ConfirmFileOp <--> General | Safety Belts, Network | Safety Belts | Confirm copy and move operations
ConfirmFileDelete <--> General | Safety Belts, Network | Safety Belts | Confirm delete operations
DeleteOnKeyUp <--> General | Safety Belts, Network | Safety Belts | Delete on key up
DisallowDeleteByKeyTree <--> General | Safety Belts, Network | Safety Belts | Disallow delete by key in folder tree
PortableDevicesReadOnly <--> General | Safety Belts, Network | Safety Belts | Treat portable devices as read-only
DFCProtection <--> General | Safety Belts, Network | Safety Belts | Directional formatting codes protection
NetworkNetServerEnum <--> General | Safety Belts, Network | Network | Fast network enumeration
AssumeServersExist <--> General | Safety Belts, Network | Network | Assume that servers are available
NetworkPrecheckServers <--> General | Safety Belts, Network | Network | Pre-check availability of servers
CacheServers <--> General | Safety Belts, Network | Network | Cache network servers
>>>;
// Reformat $relationShips
$iniKeys = regexreplace($relationShips, "^([^ ]+)([ ].*?)(?=\r?\n|$)", "$1");
// Get longest iniKey
$maxLen = 0;
foreach($entry, $iniKeys, <crlf>, "e") {
$len = strlen($entry);
if ($len > $maxLen) { $maxLen = $len; }
}
// Reformat by longest iniKey as reference
$newRelationShips = "";
foreach($line, $relationShips, <crlf>, "e") {
$iniKey = regexreplace($line, "^([^ ]+)([ ].+?$)", "$1");
$guiKey = regexreplace($line, "^(.+ <--> )(.+?$)", "$2");
$lenIniKey = strlen($iniKey);
$padding = $maxLen - $lenIniKey;
$newRelationShips .= $iniKey . strrepeat(<space>, $padding) . " <--> " . $guiKey . <crlf>;
// $padding = ($maxLen - $lenIniKey) / 4;
// $newRelationShips .= $iniKey . strrepeat(<tab>, $padding) . " <-->" . <tab> . $guiKey . <crlf>;
}
$sel = inputselect("Type to find...", $newRelationShips, <crlf>, 4+32+64+4096, , 800, 600);