Created
October 3, 2012 14:53
-
-
Save rismoney/3827353 to your computer and use it in GitHub Desktop.
demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DrawMenu { | |
## supportfunction to the Menu function below | |
param ($menuItems, $menuPosition, $menuTitel) | |
$fcolor = $host.UI.RawUI.ForegroundColor | |
$bcolor = $host.UI.RawUI.BackgroundColor | |
$l = $menuItems.length + 1 | |
cls | |
$menuwidth = $menuTitel.length + 4 | |
Write-Host "* $menuTitel *" -fore $fcolor -back $bcolor | |
Write-Host "" | |
Write-debug "L: $l MenuItems: $menuItems MenuPosition: $menuposition" | |
for ($i = 0; $i -le $l;$i++) { | |
Write-Host "`t" -NoNewLine | |
if ($i -eq $menuPosition) { | |
Write-Host "$($menuItems[$i])" -fore $bcolor -back $fcolor | |
} else { | |
Write-Host "$($menuItems[$i])" -fore $fcolor -back $bcolor | |
} | |
} | |
} | |
function Menu { | |
param ([array]$menuItems, $menuTitel = "MENU") | |
$vkeycode = 0 | |
$pos = 0 | |
DrawMenu $menuItems $pos $menuTitel | |
While ($vkeycode -ne 13) { | |
$press = $host.ui.rawui.readkey("NoEcho,IncludeKeyDown") | |
$vkeycode = $press.virtualkeycode | |
Write-host "$($press.character)" -NoNewLine | |
If ($vkeycode -eq 38) {$pos--} | |
If ($vkeycode -eq 40) {$pos++} | |
if ($pos -lt 0) {$pos = 0} | |
if ($pos -ge $menuItems.length) {$pos = $menuItems.length -1} | |
DrawMenu $menuItems $pos $menuTitel | |
} | |
Write-Output $($menuItems[$pos]) | |
} | |
$options = "install","update","version","uninstall","list","exit" | |
$selection = Menu $options "Welcome to the Chocolatey TUI prealpha prerelease POC" | |
Write-Host "YOU SELECTED : $selection ... DONE!`n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment