Private/Invoke-DrawCliMenu.ps1
function Invoke-DrawCliMenu { param ( $MenuItems, $POS, $CurrentSelection, $Multiselect ) $ResetColor = "`e[0m" $SelectionFocusColor = "`e[38;5;227m" $MultiSelectColor = "`e[38;5;49m" $SelectionPrefixGlyph = "$SelectionFocusColor❯$ResetColor" $MultiSelectGlyph = "$MultiSelectColor✔$ResetColor" # Loop through options, highlighting current cursor position. for($i = 0; $i -le $MenuItems.Count; $i ++) { if($null -ne $MenuItems[$i]) { $MenuItem = $MenuItems[$i] # For multiselect menus, show a checkmark for choosen items # or x out for non-choosen items. if ($Multiselect) { if ($CurrentSelection -contains $i) { $MenuItem = "[$MultiSelectGlyph] " + $MultiSelectColor + $MenuItem + $ResetColor } else { $MenuItem = "[ ] " + $MenuItem } } else { if ($i -eq $POS) { Write-Host "[$SelectionPrefixGlyph] $SelectionFocusColor$MenuItem$ResetColor" } else { Write-Host "[_] $MenuItem" } } } } } |