Skip to content

Commit

Permalink
Add some basic menu for later
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Sep 20, 2023
1 parent bb0e564 commit 7842396
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/GitHub/private/Auth/Menu/Invoke-DrawMenu.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
}
29 changes: 29 additions & 0 deletions src/GitHub/private/Auth/Menu/Invoke-Meny.ps1
Original file line number Diff line number Diff line change
@@ -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
#>

0 comments on commit 7842396

Please sign in to comment.