### Install XenoAtom.Terminal.UI package Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/getting-started.md The command to add the XenoAtom.Terminal.UI NuGet package to your .NET project. ```bash dotnet add package XenoAtom.Terminal.UI ``` -------------------------------- ### Install FullscreenDemo as .NET Tool (Shell) Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/samples/FullscreenDemo/readme.md Planned instructions for installing the FullscreenDemo as a global .NET tool. This allows for easy execution of the demo after installation. ```shell dotnet tool install -g XenoAtom.Terminal.UI.FullscreenDemo xenoatom-fullscreen-demo ``` -------------------------------- ### Initialize Splitter in Layout Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/splitter.md Demonstrates how to integrate a VSplitter between two panes within an HStack. This setup enables interactive resizing of the adjacent UI components. ```csharp new HStack( leftPane, new VSplitter(), rightPane ); ``` -------------------------------- ### Initialize and Configure BarChart in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/barchart.md Demonstrates how to instantiate a BarChart, set its title, define the data range, and populate it with BarChartItem objects. This setup uses fluent configuration methods to define the chart's appearance and data content. ```csharp var chart = new BarChart() .Title("Distribution") .Minimum(0) .Maximum(10) .ShowValues(true) .ShowPercentages(false) .Items( new BarChartItem("Alpha", 8), new BarChartItem("Beta", 5), new BarChartItem("Gamma", 2), new BarChartItem("Delta", 1)); ``` -------------------------------- ### Initialize and Configure DataGridControl in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/datagrid.md Demonstrates how to define a bindable data model, create a document and view, and configure a DataGridControl with custom columns. This setup enables sorting, filtering, and typed cell editing. ```csharp using XenoAtom.Terminal.UI; using XenoAtom.Terminal.UI.Controls; using XenoAtom.Terminal.UI.DataGrid; public sealed partial class MyRow { [Bindable] public partial int Id { get; set; } [Bindable] public partial string Name { get; set; } = string.Empty; } var doc = new DataGridListDocument() .AddColumn(MyRow.Accessor.Id) .AddColumn(MyRow.Accessor.Name); using var view = new DataGridDocumentView(doc); var grid = new DataGridControl { View = view, FrozenColumns = 1 }; // Optional: provide typed UI columns to enable typed templates/editors and per-column overrides. grid.Columns.Add(new DataGridColumn { Key = MyRow.Accessor.Id.Name, TypedValueAccessor = MyRow.Accessor.Id, Width = GridLength.Auto, CellAlignment = TextAlignment.Right, }); grid.Columns.Add(new DataGridColumn { Key = MyRow.Accessor.Name.Name, TypedValueAccessor = MyRow.Accessor.Name, Width = GridLength.Star(1), }); var root = new ScrollViewer(grid); ``` -------------------------------- ### TooltipHost Convenience Extension Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/tooltip.md The Tooltip extension method provides a fluent API to wrap any Visual element in a TooltipHost. It simplifies the setup process by assigning the tooltip content directly to the target visual. ```csharp public static TooltipHost Tooltip(this Visual visual, Visual tooltip) { var host = new TooltipHost { Content = visual, TooltipContent = tooltip }; return host; } ``` -------------------------------- ### Initialize and Populate OptionList Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/optionlist.md Demonstrates the basic instantiation of an OptionList and how to populate it with a collection of items using the Items method. ```csharp new OptionList() .Items(["First", "Second"]); ``` -------------------------------- ### Initialize PromptEditor Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/prompteditor.md Demonstrates basic instantiation of the PromptEditor with a state-bound text buffer, prompt markup, and placeholder text. ```csharp var command = new State(string.Empty); var editor = new PromptEditor() .Text(command) .PromptMarkup("[primary]demo[/] [muted]>[/] ") .Placeholder("Type a command… (Tab completes)"); ``` -------------------------------- ### Quick Start: LogControl Sink in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/logging.md Demonstrates how to set up a LogControl sink for XenoAtom.Logging within a XenoAtom.Terminal.UI application. This example initializes the logging manager, configures a TerminalLogControlWriter, and displays log messages in the LogControl. ```csharp using XenoAtom.Logging; using XenoAtom.Logging.Writers; using XenoAtom.Terminal; using XenoAtom.Terminal.UI; using XenoAtom.Terminal.UI.Controls; using var session = Terminal.Open(); var logControl = new LogControl { MaxCapacity = 4000 }.WrapText(true); var terminalWriter = new TerminalLogControlWriter(logControl) { EnableRichFormatting = true, EnableMarkupMessages = true, }; var config = new LogManagerConfig { RootLogger = { MinimumLevel = LogLevel.Info, Writers = { terminalWriter }, } }; LogManager.Initialize(config); var logger = LogManager.GetLogger("MyApp"); logger.Info("Hello from XenoAtom.Logging"); logger.WarnMarkup("[yellow]Careful[/]"); Terminal.Run(logControl, () => TerminalLoopResult.Continue); LogManager.Shutdown(); ``` -------------------------------- ### Render Basic Terminal UI Layout Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/readme.md Demonstrates how to initialize a basic terminal UI using a Group and VStack to organize text content. ```csharp using XenoAtom.Terminal; using XenoAtom.Terminal.UI; using XenoAtom.Terminal.UI.Controls; Terminal.Write(new Group("Welcome") .Content(new VStack("Hello", "from", "Terminal.UI").Spacing(1)) ); ``` -------------------------------- ### Routed Event Dispatch with Source Generator (C#) Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/control-development.md Demonstrates how to expose a routed event from a control using the `[RoutedEvent]` attribute. The source generator creates event identifiers, instance events, and fluent extension methods for handler registration. This example shows a typical button click event. ```csharp public partial class Button : ContentVisual { [RoutedEvent(RoutingStrategy.Bubble)] protected virtual void OnClick(ClickEventArgs e) { } protected override void OnKeyDown(KeyEventArgs e) { if (e.Key is TerminalKey.Enter or TerminalKey.Space) { RaiseEvent(ClickEvent, new ClickEventArgs()); e.Handled = true; } } } ``` -------------------------------- ### Initialize and handle Link activation in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/link.md Demonstrates how to instantiate a Link component with a URI and display text, while attaching an event handler to the Opened event to process navigation. ```csharp new Link("https://github.com/XenoAtom/XenoAtom.Terminal.UI", "Open project") .Opened(e => Terminal.WriteLine($"Opening {e.Uri}")); ``` -------------------------------- ### Initialize TextBlock with static or dynamic content Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/textblock.md Demonstrates how to instantiate a TextBlock with a static string or a dynamic Func provider for reactive text updates. ```csharp new TextBlock("Hello, world!"); var count = new State(0); new TextBlock(() => $"Count: {count.Value}"); ``` -------------------------------- ### Install XenoAtom.CommandLine Packages Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/commandline.md Commands to install the core parser library and the terminal integration package via the .NET CLI. ```shell dotnet add package XenoAtom.CommandLine dotnet add package XenoAtom.CommandLine.Terminal ``` -------------------------------- ### JSON Data Structure Example Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/samples/ControlsDemo/Assets/markdown/markdown-control-sample.md An example of a JSON object representing configuration or data. This snippet highlights the rendering of structured data within the terminal UI. ```json { "name": "markdown-demo", "kind": "controls", "enabled": true, "values": [1, 2, 3, 5, 8, 13] } ``` -------------------------------- ### Initialize Button Control Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/button.md Demonstrates how to instantiate a Button control using the default constructor or the fluent content helper. ```C# // Default constructor var button = new Button(); // Fluent content helper var textButton = new Button(new TextVisual("Click Me")); ``` -------------------------------- ### Initialize ToastHost and Root Layout Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/toast.md Demonstrates how to instantiate a ToastHost as the root element of an application, wrapping existing UI content. ```csharp var root = new ToastHost( new DockLayout() .Top(new Header().Left("My App")) .Content(mainContent) .Bottom(new Footer())); Terminal.Run(root); ``` -------------------------------- ### Install XenoAtom Logging Packages Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/logging.md Installs the necessary XenoAtom.Logging and XenoAtom.Logging.Terminal packages using the .NET CLI. These packages are required for integrating logging functionality into Terminal.UI applications. ```shell dotnet add package XenoAtom.Logging --prerelease dotnet add package XenoAtom.Logging.Terminal --prerelease ``` -------------------------------- ### Create Fullscreen Terminal Applications Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/readme.md Shows how to build a full-screen interactive application with state management, text input, and exit logic. ```csharp using XenoAtom.Terminal; using XenoAtom.Terminal.UI; using XenoAtom.Terminal.UI.Controls; State text = new("Type here"); State exit = new(false); Terminal.Run( new VStack( new TextBox(text), new TextBlock(() => $"The text typed is: {text.Value}"), new Button("Exit").Click(() => exit.Value = true) ), onUpdate: () => exit.Value ? TerminalLoopResult.StopAndKeepVisual : TerminalLoopResult.Continue ); ``` -------------------------------- ### MaskedInput Value and Validation Example Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/maskedinput.md Demonstrates how to access the current value, compact value (without empty slots), and validation status of a MaskedInput control. The example displays these properties in TextBlock controls within a VStack. ```csharp var card = new MaskedInput("9999-9999-9999-9999;_" ); new VStack( card, new TextBlock(() => $"Value: {card.Value}"), new TextBlock(() => $"Compact: {card.CompactValue}"), new TextBlock(() => $"Valid: {card.IsValid}") ).Spacing(1); ``` -------------------------------- ### Create a Basic Placeholder Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/placeholder.md Demonstrates the creation of a simple Placeholder control with a solid background color. It utilizes the `PlaceholderStyle` to define the background color. ```csharp new Placeholder() .Style(PlaceholderStyle.Default with { Background = Colors.SlateBlue }); ``` -------------------------------- ### C# WrapHStack Example with Flow Layout Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/wrapstack.md Demonstrates the creation and configuration of a WrapHStack in C#. This example shows how to set spacing, run spacing, and justification for items within the stack, utilizing a State variable for dynamic justification. ```csharp var justify = new State(WrapJustify.SpaceBetween); var content = new WrapHStack( new Border("alpha").Style(BorderStyle.Rounded), new Border("beta").Style(BorderStyle.Rounded), new Border("gamma").Style(BorderStyle.Rounded), new Border("delta").Style(BorderStyle.Rounded)) .Spacing(1) .RunSpacing(1) .Justify(justify); ``` -------------------------------- ### Initialize and Populate SelectionList Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/selectionlist.md Demonstrates the fluent API usage to instantiate a SelectionList and add items with initial checked states. ```csharp new SelectionList() .AddItem("First") .AddItem("Second", isChecked: true); ``` -------------------------------- ### Add Markdown Package Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/markdownmarkupconverter.md Installs the necessary XenoAtom.Terminal.UI.Extensions.Markdown package using the .NET CLI. ```shell dotnet add package XenoAtom.Terminal.UI.Extensions.Markdown ``` -------------------------------- ### Initialize MarkdownControl Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/markdowncontrol.md Basic implementation of the MarkdownControl to render a simple Markdown string. It automatically disables follow-tail to ensure the document starts at the top. ```csharp using XenoAtom.Terminal.UI.Controls; using XenoAtom.Terminal.UI.Extensions.Markdown; var markdown = """ # Title Paragraph with **strong** text and a [link](https://example.com). """; var control = new MarkdownControl(markdown); ``` -------------------------------- ### Initialize and Configure Padder Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/padder.md Demonstrates how to instantiate a Padder control and apply padding. This is the standard way to add spacing around a content visual. ```csharp new Padder("Padded content").Padding(1); ``` -------------------------------- ### SQL Query Example Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/samples/ControlsDemo/Assets/markdown/markdown-control-sample.md An indented code block demonstrating a SQL query. This illustrates how plain text code blocks are handled and displayed. ```text SELECT id, name, status FROM tasks WHERE status IN ('queued', 'running') ORDER BY id DESC; ``` -------------------------------- ### Item control template slot Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/data_template_specs.md Example of exposing a template slot in a control to allow custom data rendering while defaulting to environment-provided templates. ```csharp public sealed partial class Select : Visual { [Bindable] public partial DataTemplate ItemTemplate { get; set; } } ``` -------------------------------- ### Initialize LogControl Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/logcontrol.md Demonstrates how to instantiate a LogControl, set its maximum capacity, enable text wrapping, and append text or markup content. ```csharp var log = new LogControl { MaxCapacity = 2000, }.WrapText(true); log.AppendLine("Starting…"); log.AppendMarkupLine("[green]✔[/] Ready"); ``` -------------------------------- ### Initialize TextBox Component Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/textbox.md Demonstrates the instantiation of a TextBox control, showing default property settings and optional initial text assignment. ```csharp // Default constructor var textBox = new TextBox(); // Constructor with initial text var namedTextBox = new TextBox("Initial Value"); // Property configuration textBox.IsPassword = true; textBox.PasswordRevealMode = PasswordRevealMode.WhileFocused; textBox.ClipboardMode = TextBoxClipboardMode.CopyText; ``` -------------------------------- ### ListBox Interaction Tests Example Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/listbox.md Provides a file path to the unit tests for ListBox interaction, indicating how the component's behavior is validated. ```csharp src/XenoAtom.Terminal.UI.Tests/ListBoxInteractionTests.cs ``` -------------------------------- ### ListBox ScrollViewer Sizing Tests Example Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/specs/controls/listbox.md Points to tests specifically covering the sizing rules of a ListBox within a ScrollViewer, highlighting integration testing. ```csharp src/XenoAtom.Terminal.UI.Tests/ListControlHorizontalScrollViewerTests.cs ``` -------------------------------- ### Define MenuBar and MenuItems with Commands Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/menubar.md Demonstrates how to create a MenuBar, define Command objects with gestures, and populate the menu structure using MenuItem instances. The command-based items automatically derive their enabled state and shortcut labels from the associated Command. ```csharp using XenoAtom.Terminal; using XenoAtom.Terminal.UI.Commands; using XenoAtom.Terminal.UI.Controls; using XenoAtom.Terminal.UI.Input; var open = new Command { Id = "App.Open", LabelMarkup = "[primary]Open[/]", Gesture = new KeyGesture(TerminalChar.CtrlO, TerminalModifiers.Ctrl), Presentation = CommandPresentation.Menu, Execute = _ => { /* ... */ }, }; var menuBar = new MenuBar(); menuBar.Items.Add(new MenuItem("File") .Items( new MenuItem("Open", open), MenuItem.Separator(), new MenuItem("Exit", () => { /* ... */ }))); ``` -------------------------------- ### Create and Control a Spinner Source: https://context7.com/xenoatom/xenoatom.terminal.ui/llms.txt Demonstrates how to create a basic animated loading indicator and a spinner with a label. It also shows how to control the animation state and apply semantic tones for styling. ```csharp using XenoAtom.Terminal.UI.Controls; // Basic spinner var spinner = new Spinner(); // Spinner with label var loadingSpinner = new Spinner("Loading data..."); // Control animation state var controllableSpinner = new Spinner("Processing...") .IsActive(true); // Set to false to stop animation // With semantic tone var styledSpinner = new Spinner("Please wait...") .Tone(ControlTone.Primary); // Combined with other controls var loadingUI = new HStack( new Spinner(), new TextBlock("Fetching results...") ).Spacing(1); ``` -------------------------------- ### Initialize Center control in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/center.md Demonstrates how to instantiate a Center control with a child element such as a Button. By default, the control initializes with Start alignment for both horizontal and vertical axes. ```csharp new Center(new Button("OK")); ``` -------------------------------- ### Basic Validation Setup in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/validation.md Demonstrates how to wrap a TextBox control with a fixed validation message using ValidationPresenter in C#. This is useful for static error messages. ```csharp var editor = new TextBox("8080") .Validation(new ValidationMessage(ValidationSeverity.Error, "Port is required.")); ``` -------------------------------- ### Initialize and populate LineChart Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/linechart.md Demonstrates the basic instantiation of a LineChart component and how to provide data points using the Values method. This component automatically scales based on the input array. ```csharp new LineChart() .Values([1, 4, 2, 5, 3, 6]); ``` -------------------------------- ### Retrieving Predefined Color Schemes - C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/styling.md Demonstrates how to get a list of all predefined color schemes available in XenoAtom.Terminal.UI. This is useful for displaying available themes or for use in demo applications. ```csharp var schemes = ColorScheme.GetPredefinedSchemes(); ``` -------------------------------- ### Build Fullscreen Applications with Terminal.Run Source: https://context7.com/xenoatom/xenoatom.terminal.ui/llms.txt Initializes a full-screen application using an alternate screen buffer and an interactive event loop. This is the standard approach for complex, user-interactive terminal tools. ```csharp using XenoAtom.Terminal; using XenoAtom.Terminal.UI; using XenoAtom.Terminal.UI.Controls; State text = new("Type here"); State exit = new(false); Terminal.Run( new VStack( new TextBox(text), new TextBlock(() => $"You typed: {text.Value}"), new HStack( new Button("Clear").Click(() => text.Value = ""), new Button("Exit").Click(() => exit.Value = true) ).Spacing(2) ).Spacing(1), onUpdate: () => exit.Value ? TerminalLoopResult.StopAndKeepVisual : TerminalLoopResult.Continue ); ``` -------------------------------- ### Background Color Markup in C# Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/markup.md Illustrates different ways to specify background colors in markup using C#. Examples include 'black on yellow' and 'bg:blue white'. ```csharp new Markup("[black on yellow]Warning[/]"); new Markup("[bg:blue white]Info[/]"); ``` -------------------------------- ### Initialize ListBox with Items Source: https://github.com/xenoatom/xenoatom.terminal.ui/blob/main/site/docs/controls/listbox.md Demonstrates how to instantiate a ListBox control and populate it with a collection of string items. This uses the default data template resolution from the environment. ```csharp new ListBox() .Items(["First", "Second"]); ```