Ver código fonte

Fixes #945 - Adds simple PowerShell example (#4438)

* pre-alpha -> alpha

* don't build docs for v2_release

* Pulled from v2_release

* Refactor migration guide for Terminal.Gui v2

Restructured and expanded the migration guide to provide a comprehensive resource for transitioning from Terminal.Gui v1 to v2. Key updates include:

- Added a Table of Contents for easier navigation.
- Summarized major architectural changes in v2, including the instance-based application model, IRunnable architecture, and 24-bit TrueColor support.
- Updated examples to reflect new patterns, such as initializers replacing constructors and explicit disposal using `IDisposable`.
- Documented changes to the layout system, including the removal of `Absolute`/`Computed` styles and the introduction of `Viewport`.
- Standardized event patterns to use `object sender, EventArgs args`.
- Detailed updates to the Keyboard, Mouse, and Navigation APIs, including configurable key bindings and viewport-relative mouse coordinates.
- Replaced legacy components like `ScrollView` and `ContextMenu` with built-in scrolling and `PopoverMenu`.
- Clarified disposal rules and introduced best practices for resource management.
- Provided a complete migration example and a summary of breaking changes.

This update aims to simplify the migration process by addressing breaking changes, introducing new features, and aligning with modern .NET conventions.

* Updated runnable

* Add Terminal.Gui integration in PowerShell script

Integrated Terminal.Gui into a PowerShell script by:
- Adding necessary `using namespace` statements.
- Loading DLLs dynamically from a specified `$dllFolder`.
- Creating a Terminal.Gui application with a window and label.
- Providing instructions for building and preparing dependencies.
- Ensuring proper disposal of application resources.
Tig 1 semana atrás
pai
commit
063a6d7e98
1 arquivos alterados com 35 adições e 0 exclusões
  1. 35 0
      Examples/PowershellExample.ps1

+ 35 - 0
Examples/PowershellExample.ps1

@@ -0,0 +1,35 @@
+using namespace Terminal.Gui.App        
+using namespace Terminal.Gui.ViewBase
+using namespace Terminal.Gui.Views
+
+$dllFolder = "..\Terminal.Gui\bin\Debug\net8.0"
+
+# For this to work all dependent DLLs need to be in the $dllFolder folder
+# Do this first:
+#   dotnet build -c Debug /p:CopyLocalLockFileAssemblies=true
+
+Get-ChildItem $dllFolder -Filter *.dll | ForEach-Object {
+    Add-Type -Path $_.FullName -ErrorAction SilentlyContinue
+}
+
+$app = [Application]::Create()
+
+$app.Init()
+
+$win = [Window]@{
+    Title  = "Terminal.Gui in Powershell"
+    Width  = [Dim]::Fill()
+    Height = [Dim]::Fill()
+}
+
+$lbl = [Label]@{
+    Text = "Hello from PowerShell + Terminal.Gui!`nPress ESC to quit"
+    X    = [Pos]::Center()
+    Y    = [Pos]::Center()
+}
+$win.Add($lbl)
+
+$app.Run($win)
+
+$win.Dispose()
+$app.Dispose()