diff --git a/src/GitHub/private/Auth/Menu/Invoke-DrawMenu.ps1 b/src/GitHub/private/Auth/Menu/Invoke-DrawMenu.ps1 new file mode 100644 index 000000000..4ca69a42e --- /dev/null +++ b/src/GitHub/private/Auth/Menu/Invoke-DrawMenu.ps1 @@ -0,0 +1,29 @@ +function Invoke-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 + Clear-Host + $menuwidth = $menuTitel.length + 4 + Write-Host "`t" -NoNewline + Write-Host ('*' * $menuwidth) -fore $fcolor -back $bcolor + Write-Host "`t" -NoNewline + Write-Host "* $menuTitel *" -fore $fcolor -back $bcolor + Write-Host "`t" -NoNewline + Write-Host ('*' * $menuwidth) -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 + } + } +} diff --git a/src/GitHub/private/Auth/Menu/Invoke-Meny.ps1 b/src/GitHub/private/Auth/Menu/Invoke-Meny.ps1 new file mode 100644 index 000000000..dcdbe6091 --- /dev/null +++ b/src/GitHub/private/Auth/Menu/Invoke-Meny.ps1 @@ -0,0 +1,29 @@ +function Menu { + ## Generate a small "DOS-like" menu. + ## Choose a menuitem using up and down arrows, select by pressing ENTER + param ( + [array]$menuItems, + $menuTitel = 'MENU' + ) + $vkeycode = 0 + $pos = 0 + Invoke-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 } + Invoke-DrawMenu $menuItems $pos $menuTitel + } + Write-Output $($menuItems[$pos]) +} + + +<# +? What account do you want to log into? [Use arrows to move, type to filter] +> GitHub.com + GitHub Enterprise Server +#>