### Add SvcSystems.UI.Terminal Package Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Installs the SvcSystems.UI.Terminal NuGet package using the .NET CLI. ```bash dotnet add package SvcSystems.UI.Terminal ``` -------------------------------- ### Run Desktop Sample App Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Command to run the desktop sample application. Ensure you are in the project directory. ```bash dotnet run --project src/SvcSystems.UI.Terminal.Desktop ``` -------------------------------- ### Initialize TerminalControlModel in Code-Behind Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Sets up the TerminalControlModel and assigns it to the TerminalView in an Avalonia window's code-behind. ```csharp using Avalonia.Controls; namespace MyApp; public partial class MainWindow : Window { private readonly TerminalControlModel _terminal = new(); public MainWindow() { InitializeComponent(); TerminalView.Model = _terminal; } } ``` -------------------------------- ### Run Headless Tests Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Execute the project's headless tests using the dotnet CLI. Specify the project path and target framework. ```bash dotnet test --project tests/SvcSystems.UI.Terminal.Tests/SvcSystems.UI.Terminal.Tests.csproj -f net10.0 ``` -------------------------------- ### Configure TerminalOptions Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Creates a TerminalControlModel with custom terminal options, such as columns, rows, and resize behavior. ```csharp var model = new TerminalControlModel(new TerminalOptions { Cols = 120, Rows = 30, ReflowOnResize = false, }); ``` -------------------------------- ### Include Default Terminal Styles Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Include the default terminal styling resources in your application if you are hosting the control yourself. This ensures the control uses the predefined font settings and color palette. ```xml ``` -------------------------------- ### Configure Right-Click Action Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Set the behavior for right-clicking the terminal control. Options include showing a context menu, copying/pasting, or ignoring the click. ```xml ``` -------------------------------- ### TerminalOptions Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Configuration options for the TerminalControlModel. ```APIDOC ## TerminalOptions ### Description Defines configuration options used by the `TerminalControlModel` to set up the terminal's behavior and appearance. ### Properties - `Cols` (int): The number of columns for the terminal. - `Rows` (int): The number of rows for the terminal. - `Scrollback` (int): The size of the scrollback buffer. - `ConvertEol` (bool): Whether to convert line endings. - `TabStopWidth` (int): The width of tab stops. - `TermName` (string): The name of the terminal type. - `ReflowOnResize` (bool): Whether to reflow content on resize. ``` -------------------------------- ### Integrate with Local Process or Remote Session Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Demonstrates a common pattern for integrating the TerminalControl with a local process or remote shell, handling both user input and process output. ```csharp var model = new TerminalControlModel(); model.UserInput += (_, e) => { var bytes = e.Data; process.StandardInput.BaseStream.Write(bytes.Span); process.StandardInput.BaseStream.Flush(); }; _ = Task.Run(async () => { var buffer = new byte[4096]; while (true) { var read = await process.StandardOutput.BaseStream.ReadAsync(buffer); if (read == 0) { break; } model.Feed(buffer, read); } }); ``` -------------------------------- ### Terminal APIs Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md APIs for managing the terminal buffer, resizing, and switching between buffers. ```APIDOC ## Terminal ### Description Represents the core terminal functionality, including buffer management, resizing, and buffer switching. ### Methods - `Feed(string)`: Feeds string data to the terminal output. - `Feed(byte[], int)`: Feeds byte array data to the terminal output. - `Resize(int, int)`: Resizes the terminal to the specified number of columns and rows. - `SwitchToAltBuffer()`: Switches the terminal to an alternate buffer. - `SwitchToNormalBuffer()`: Switches the terminal back to the normal buffer. ### Properties - `TitleChanged` (event): Event triggered when the terminal title changes. - `Engine` (Engine): Gets the terminal engine. - `Buffer` (Buffer): Gets the terminal buffer. - `Selection` (Selection): Gets the terminal selection object. - `IsAlternateBufferActive` (bool): Indicates if the alternate buffer is currently active. - `Cols` (int): Gets the number of columns in the terminal. - `Rows` (int): Gets the number of rows in the terminal. - `Title` (string): Gets or sets the terminal title. ``` -------------------------------- ### Conditionally Enable Context Menu Item Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Check if text is selected before enabling a context menu item. Retrieves the selected text. ```csharp if (TerminalView.HasSelection) { var text = TerminalView.CopySelection(); } ``` -------------------------------- ### Handle User Input Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Subscribes to the UserInput event to process data entered by the user in the terminal. ```csharp _terminal.UserInput += (_, e) => { // Send bytes to a pty, process stdin, socket, ssh session, etc. }; ``` -------------------------------- ### Programmatic Clipboard Operations Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Asynchronously copy selected text to the clipboard or paste content from the clipboard into the terminal. ```csharp await TerminalView.CopySelectionAsync(); await TerminalView.PasteFromClipboardAsync(); ``` -------------------------------- ### TerminalControlModel APIs Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md APIs for controlling and querying the terminal output and input. ```APIDOC ## TerminalControlModel ### Description Provides methods for feeding terminal output, sending programmatic input, scrolling, selection, and searching. ### Methods - `Feed(string)`: Feeds string data to the terminal output. - `Feed(byte[], int)`: Feeds byte array data to the terminal output. - `Send(string)`: Sends string data as programmatic input. - `Send(byte[])`: Sends byte array data as programmatic input. - `ScrollLines(int)`: Scrolls the terminal view by a specified number of lines. - `PageUp()`: Scrolls the terminal view up by one page. - `PageDown()`: Scrolls the terminal view down by one page. - `ScrollToYDisp(int)`: Scrolls the terminal view to a specific Y display position. - `ScrollToPosition(double)`: Scrolls the terminal view to a specific position. - `EnsureCaretIsVisible()`: Ensures the caret is within the visible area of the terminal. - `StartSelection(int, int)`: Starts a text selection from a start to end column. - `StartSelectionFromSoftStart()`: Starts a text selection from a soft start position. - `SetSoftSelectionStart(int, int)`: Sets the soft start position for selection. - `DragExtendSelection(int, int)`: Extends the current selection by dragging. - `ShiftExtendSelection(int, int)`: Extends the current selection using shift. - `SelectWordOrExpression(int, int)`: Selects a word or expression at the given position. - `SelectRow(int)`: Selects an entire row. - `SelectAll()`: Selects all text in the terminal. - `ClearSelection()`: Clears the current text selection. - `Search(string)`: Searches for a string within the terminal buffer. - `SelectNextSearchResult()`: Selects the next search result. - `SelectPreviousSearchResult()`: Selects the previous search result. ### Properties - `SelectedText` (string): Gets the currently selected text. - `HasSelection` (bool): Indicates if there is any text selected. - `Title` (string): Gets or sets the terminal window title. - `ScrollOffset` (int): Gets the current scroll offset. - `MaxScrollback` (int): Gets the maximum scrollback buffer size. - `ScrollPosition` (double): Gets or sets the current scroll position. - `ScrollThumbsize` (int): Gets the size of the scroll thumb. - `CanScroll` (bool): Indicates if the terminal can be scrolled. - `CaretColumn` (int): Gets the current column of the caret. - `CaretRow` (int): Gets the current row of the caret. - `IsCaretVisible` (bool): Indicates if the caret is visible. - `IsMouseModeActive` (bool): Indicates if mouse mode is active. - `SizeChanged` (event): Event triggered when the terminal size changes. - `Terminal` (Terminal): Gets the underlying Terminal object. - `SearchService` (SearchService): Gets the SearchService instance. - `OptionAsMetaKey` (bool): Gets or sets whether to treat Option key as Meta. ``` -------------------------------- ### Override Application Resources for Terminal Styling Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Override default terminal styling resources at the application level to match your app's theme. This allows customization of font family, font size, caret brush, selection brush, and the 256-color palette. ```xml Fira Code 14 ``` -------------------------------- ### Direct Styling of TerminalControl Instance Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Customize a single instance of TerminalControl using its direct styling properties. This method takes precedence over application resources and built-in fallbacks for caret and selection. ```xml ``` -------------------------------- ### Search for Text in Terminal Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Search for a specific string within the terminal buffer and select the next search result if found. ```csharp var count = TerminalView.Search("error"); if (count > 0) { TerminalView.SelectNextSearchResult(); } ``` -------------------------------- ### TerminalControl APIs Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md APIs for controlling the visual aspects and user interactions of the terminal. ```APIDOC ## TerminalControl ### Description Provides control over the visual appearance and user interaction features of the terminal, such as selection, copy, paste, and search. ### Properties - `Model` (TerminalControlModel): Gets the associated TerminalControlModel. - `SelectedText` (string): Gets the currently selected text. - `HasSelection` (bool): Indicates if there is any text selected. - `RightClickAction` (RightClickAction): Gets or sets the action performed on right-click. - `IsMouseModeActive` (bool): Indicates if mouse mode is active. - `FontFamily` (string): Gets or sets the font family for the terminal. - `FontSize` (double): Gets or sets the font size for the terminal. - `CaretBrush` (Brush): Gets or sets the brush used for the caret. - `SelectionBrush` (Brush): Gets or sets the brush used for text selection. ### Methods - `SelectAll()`: Selects all text in the terminal. - `CopySelection()`: Copies the selected text to the clipboard. - `CopySelectionAsync()`: Asynchronously copies the selected text to the clipboard. - `Paste(string)`: Pastes text into the terminal. - `PasteFromClipboardAsync()`: Asynchronously pastes text from the clipboard into the terminal. - `Search(string)`: Searches for a string within the terminal buffer. - `SelectNextSearchResult()`: Selects the next search result. - `SelectPreviousSearchResult()`: Selects the previous search result. ### Events - `ContextRequested` (event): Event triggered when a context menu is requested. ``` -------------------------------- ### Integrate TerminalControl in XAML Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Adds the TerminalControl to an Avalonia UI window definition in XAML. ```xml ``` -------------------------------- ### Feed Terminal Output Source: https://github.com/ivanjosipovic/svcsystems.ui.terminal/blob/main/README.md Sends string output to the TerminalControlModel for display. ```csharp _terminal.Feed("Hello from SvcSystems.UI.Terminal\r\n"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.