Cameek.GreenScreen 0.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cameek.GreenScreen --version 0.1.4
                    
NuGet\Install-Package Cameek.GreenScreen -Version 0.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cameek.GreenScreen" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cameek.GreenScreen" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Cameek.GreenScreen" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cameek.GreenScreen --version 0.1.4
                    
#r "nuget: Cameek.GreenScreen, 0.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cameek.GreenScreen@0.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cameek.GreenScreen&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Cameek.GreenScreen&version=0.1.4
                    
Install as a Cake Tool

Cameek.GreenScreen

Cameek.GreenScreen is a .NET 8 terminal UI framework for full-screen Rich or Classic console applications. It provides controls, keyboard and mouse input, TreeView search, image support, ANSI color fallback, native Windows Console input, Linux PTY hosting, and scoped physical-terminal handoff for foreground interactive commands.

This is a pre-1.0 framework release. Install the core package directly, and add the optional Images package when the application uses PngImage.

dotnet add package Cameek.GreenScreen
dotnet add package Cameek.GreenScreen.Images

Scenarios

  • Full-screen terminal UIs with controls such as panels, labels, buttons, dialogs, menus, text boxes, date/time inputs, dropdowns, tree views, text areas, scroll views, progress bars, status bars, and log views.
  • Local terminal rendering over ANSI escape sequences.
  • SSH and container terminal sessions where capability detection can be overridden.
  • Interactive PTY-hosted child processes with argument arrays, working directories, environment overrides, resize, output reads, input writes, exit codes, and lifecycle control.
  • Best-effort floating overlays over PTY output without injecting bytes inside UTF-8 or terminal control sequences.
  • Right-aligned menu bars and mirrored left-expanding submenu trees for compact top-right controls.
  • Foreground interactive commands that temporarily own the physical terminal, then return to the same in-memory UI.
  • Background work that reports safely back to the UI loop without making controls thread-safe.

Terminal Lifecycle

Use SuspendTerminal() when a child must own real stdin, stdout, and stderr. The outermost scope releases GreenScreen's input and alternate screen; disposal reacquires the current terminal size and repaints the existing control tree.

using var app = new TerminalApplication();

shellButton.Clicked += (_, _) =>
{
    using (app.SuspendTerminal())
    {
        using var process = Process.Start(startInfo)
            ?? throw new InvalidOperationException("Failed to start the shell.");
        process.WaitForExit();
    }
};

Keep controls on the UI thread. Use Post to return a background result to the run loop; posted actions run after input dispatch and before Tick in FIFO order.

_ = Task.Run(async () =>
{
    await DoWorkAsync();
    app.Post(_ => status.Text = "Completed");
});

See docs/application-lifecycle.md for launch-after-close, background, foreground handoff, and PTY-managed execution patterns.

Colors

The public drawing model uses TerminalColor instead of ConsoleColor. It supports terminal default colors, ANSI16 colors, indexed 256-color values, and 24-bit RGB truecolor.

buffer.SetHalfBlock(
    x,
    y,
    TerminalColor.Rgb(255, 80, 20),
    TerminalColor.Indexed(45));

AnsiTerminalOptions.ColorMode can be set to Auto, TrueColor, Indexed256, or Ansi16. Auto mode uses conservative environment hints such as COLORTERM=truecolor and TERM=*256color; explicit configuration always wins.

Input Backends

TerminalApplication.InputBackendMode selects how keyboard and mouse input reaches the common TerminalInputEvent model:

  • Auto uses native Windows Console records when a usable Windows console input handle is available; otherwise it uses the ANSI input path.
  • Ansi forces the existing escape-sequence and SGR input path.
  • WindowsConsole requires a usable native Windows Console input handle and throws a clear initialization error when one is unavailable.

Native Windows input enables mouse and resize records while GreenScreen runs, disables Quick Edit for reliable mouse interaction, and restores the exact previous console input mode during cleanup. Controls do not depend on the backend: they receive the same TerminalInputEvent keyboard and mouse abstraction whether the source was ANSI/SGR or Windows Console records.

PTY Hosting

Use PtyProcess for generic child processes. Arguments are passed as an array and are not concatenated through a shell unless you explicitly start a shell yourself.

using var process = PtyProcess.Start(new PtyProcessStartInfo
{
    FileName = "sudo",
    Arguments = { "apt", "install", "kubectl" },
    WorkingDirectory = Environment.CurrentDirectory,
    InitialSize = new Size(120, 32)
});

process.Write("y\n"u8.ToArray());
var exitCode = await process.WaitForExitAsync();

ShellOverlayApplication remains as a convenience shell overlay demo API, but it now sits on top of the generic PTY process layer.

PTY support in this alpha is implemented and tested for Linux. Windows ConPTY and macOS backends are not implemented yet. The task-based ReadAsync and WriteAsync helpers are convenience wrappers over blocking PTY operations; cancellation prevents starting queued work but does not guarantee interruption after the native operation has begun.

Interactive full-screen and host modes require successful raw/no-echo terminal setup. If the original terminal state cannot be captured or raw mode cannot be activated, GreenScreen fails fast instead of continuing in canonical or echoing mode.

Overlays

Overlays are best-effort. GreenScreen tracks PTY output boundaries so it does not inject overlay bytes inside UTF-8 code points, CSI, OSC, DCS, or related string sequences. Overlay changes are versioned, prepared, deferred until a safe child-stream boundary, and committed only after their bytes are written; older commits do not erase newer redraw requests. A replacement draw first clears the previously committed overlay geometry, then draws the new overlay, and then commits the new clear bytes and hit regions. Mouse hit testing follows immutable hit regions from the last committed visible overlay snapshot. It also restores common SGR text attributes after drawing overlays.

This does not make an overlay a protected graphical layer. Full-screen child applications can clear or redraw the same screen area. Suspend overlay rendering for programs such as editors, pagers, nested SSH sessions, and full-screen installers.

InteractiveProcessHost.SuspendOverlay() exposes a scoped public rendering suspension mechanism. It pauses and clears overlay rendering while the scope is alive; draw requests may coalesce while suspended, and the latest state redraws when the outermost scope is disposed. It is not a transparent input handoff mode: normal host input routing and configured mouse forwarding still apply.

The input parser maps common keyboard, mouse, CSI, and SS3 sequences to TerminalInputEvent. Unsupported but syntactically complete terminal control sequences are consumed safely and ignored rather than leaking trailing bytes as typed text.

FocusOrder defines wrapping logical navigation for Tab and Shift+Tab. Applications can opt into Spatial, Sequential, or Classic arrow strategies with UseArrowKeysForFocusNavigation = true; focused controls receive arrows first, so single-line TextBox controls retain Left/Right cursor editing while unhandled arrows can move focus. See docs/navigation.md.

MenuBar supports explicit nested submenu activation. Moving selection with Up/Down does not open child menus; branch items show a directional indicator and open with the expansion-direction arrow, Enter, or Space. MenuBar.Alignment = MenuBarAlignment.Right right-aligns top-level items, and SubmenuDirection = SubmenuExpansionDirection.Left creates mirrored left-expanding submenu trees for compact controls near the right edge.

Unicode

Text rendering uses grapheme enumeration for WriteText and preserves selected wide glyph behavior such as emoji and half-block graphics. It is not a complete Unicode terminal-width engine. CJK width, combining marks, variation selectors, zero-width joiners, and East Asian ambiguous width should be treated as alpha limitations. TextBox editing currently uses UTF-16 string indexes and is optimized for typical Latin input.

Examples

  • Cameek.GreenScreen.ExampleApp - first interactive UI demo.
  • Cameek.GreenScreen.ExampleApp2 - IDE-style viewer demo.
  • Cameek.GreenScreen.ExampleApp3 - editable IDE-style demo.
  • Cameek.GreenScreen.ExampleApp4 - shell overlay with clickable macro buttons.
  • Cameek.GreenScreen.ExampleApp5 - experimental framed embedded shell surface, not a complete terminal emulator.
  • Cameek.GreenScreen.ExampleApp6 - JSONL progress/event prototype kept outside core.
  • Cameek.GreenScreen.ExampleApp7 - truecolor half-block graphics demo with mode fallback switching.
  • Cameek.GreenScreen.ExampleApp8 - generic PTY and overlay fragmentation stress lab.
  • Cameek.GreenScreen.ExampleApp9 - real PTY shell with a compact top-right framed menu overlay and left-expanding nested menus.
  • Cameek.GreenScreen.ExampleApp10 - compact three-row Rich button laboratory with truecolor and automatic 256/ANSI16 fallback.
  • Cameek.GreenScreen.ExampleApp11 - shaded Rich rectangle/panel surface proof of concept and SSH performance test.
  • Cameek.GreenScreen.ExampleApp12 - universal RGB surface renderer lab for frames, captions, accents, deep recessed input surfaces, frameless backgrounds, transparent frame overlays, and split frame/body palette demos.
  • Cameek.GreenScreen.ExampleApp13 - Rich/Classic switching, F6 Unicode/SafeUnicode/ASCII glyph compatibility, transparent panel and TextBox frames, mouse interaction, focus feedback, and diagonal-corner emoji buttons.
  • Cameek.GreenScreen.ExampleApp14 - comprehensive Rich control and image gallery with transparent framed inputs, framed progress, focusable scrolling, multiline editing, PNG and ASCII transparency, focus strategies, and Rich/Classic switching.
  • Cameek.GreenScreen.ExampleApp15 - in-memory Run67-style resource browser with precise semantic fuzzy/contains TreeView search, details, bundled PNG icons, menus, commands, and Rich/Classic switching.
  • Cameek.GreenScreen.ExampleApp16 - physical terminal suspension/resumption and background Post lifecycle lab.

Run the full-screen truecolor demo:

dotnet run --project Cameek.GreenScreen.ExampleApp7

Run the PTY stress lab:

dotnet run --project Cameek.GreenScreen.ExampleApp8

Run the generic shell-host mode:

dotnet run --project Cameek.GreenScreen.ExampleApp8 -- --shell

Run the compact framed PTY menu demo:

dotnet run --project Cameek.GreenScreen.ExampleApp9

Run the Rich button lab:

dotnet run --project Cameek.GreenScreen.ExampleApp10

Run the RGB rectangle SSH/performance lab:

dotnet run --project Cameek.GreenScreen.ExampleApp11

Run the universal RGB surface renderer lab:

dotnet run --project Cameek.GreenScreen.ExampleApp12

Run the Rich/Classic rendering switch lab:

dotnet run --project Cameek.GreenScreen.ExampleApp13

Run the complete Rich control and image gallery:

dotnet run --project Cameek.GreenScreen.ExampleApp14

Run the Run67-style resource browser:

dotnet run --project Cameek.GreenScreen.ExampleApp15

Run the terminal lifecycle lab:

dotnet run --project Cameek.GreenScreen.ExampleApp16

Force the same app into classic UI rendering through the framework-level environment override:

CAMEEK_GREENSCREEN_UI=classic \
dotnet run --project Cameek.GreenScreen.ExampleApp13

Build, Test, Pack

dotnet build Cameek.GreenScreen.sln
dotnet test Cameek.GreenScreen.sln
dotnet pack Cameek.GreenScreen/Cameek.GreenScreen.csproj -c Release -o artifacts/nuget
dotnet pack Cameek.GreenScreen.Images/Cameek.GreenScreen.Images.csproj -c Release -o artifacts/nuget

Release scripts live in .scripts. Use .scripts/tag-latest-version.sh to tag the current version, or .scripts/increase-and-tag-version.sh --patch to bump, commit, push, and tag. Pushed vA.B.C tags trigger NuGet publishing.

Platform-specific PTY tests are written to pass without requiring root or sudo and skip their body when PTY support is unavailable.

Documentation

See:

  • docs/architecture.md
  • docs/terminal-colors.md
  • docs/rgb-surfaces.md
  • docs/pty.md
  • docs/overlays.md
  • docs/compatibility.md
  • docs/application-lifecycle.md
  • docs/controls.md
  • docs/manual-smoke-test.md

License

Licensed under the MIT License. See the LICENSE file for full details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Cameek.GreenScreen:

Package Downloads
Cameek.Run67.Tool

Human-first terminal workflow runner with planning, approvals, durable Run Records, interactive terminal execution, and resume support.

Cameek.GreenScreen.Images

Optional PNG image support for Cameek.GreenScreen.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.14 81 11/25/2026
0.1.13 189 11/4/2026
0.1.10 251 9/12/2026
0.1.9 189 9/3/2026
0.1.7 156 9/3/2026
0.1.6 157 9/2/2026
0.1.5 233 8/7/2026
0.1.4 223 7/15/2026
0.1.3 164 7/15/2026
0.1.1 166 7/14/2026
0.0.1 147 7/5/2026