PowershellExample.ps1 807 B

1234567891011121314151617181920212223242526272829303132333435
  1. using namespace Terminal.Gui.App
  2. using namespace Terminal.Gui.ViewBase
  3. using namespace Terminal.Gui.Views
  4. $dllFolder = "..\Terminal.Gui\bin\Debug\net8.0"
  5. # For this to work all dependent DLLs need to be in the $dllFolder folder
  6. # Do this first:
  7. # dotnet build -c Debug /p:CopyLocalLockFileAssemblies=true
  8. Get-ChildItem $dllFolder -Filter *.dll | ForEach-Object {
  9. Add-Type -Path $_.FullName -ErrorAction SilentlyContinue
  10. }
  11. $app = [Application]::Create()
  12. $app.Init()
  13. $win = [Window]@{
  14. Title = "Terminal.Gui in Powershell"
  15. Width = [Dim]::Fill()
  16. Height = [Dim]::Fill()
  17. }
  18. $lbl = [Label]@{
  19. Text = "Hello from PowerShell + Terminal.Gui!`nPress ESC to quit"
  20. X = [Pos]::Center()
  21. Y = [Pos]::Center()
  22. }
  23. $win.Add($lbl)
  24. $app.Run($win)
  25. $win.Dispose()
  26. $app.Dispose()