### Add EasyWindowsTerminalControl Package
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/README.md
Install the EasyWindowsTerminalControl NuGet package using the .NET CLI.
```bash
dotnet add package EasyWindowsTerminalControl
```
--------------------------------
### Manual TermPTY Creation and Process Start
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Manually create and configure a `TermPTY` instance for advanced control over terminal process startup. This includes setting buffer size, binary writer usage, and initial process dimensions.
```csharp
using EasyWindowsTerminalControl;
using System.Threading.Tasks;
public partial class MainWindow : Window
{
private async void StartCustomProcess()
{
// Create TermPTY with custom settings
var term = new TermPTY(
READ_BUFFER_SIZE: 1024 * 32,
USE_BINARY_WRITER: false
);
// Subscribe to ready event
term.TermReady += (s, e) =>
{
Dispatcher.Invoke(() =>
{
terminalControl.ConPTYTerm = term;
});
};
// Start process with specific dimensions
await Task.Run(() => term.Start(
command: "python.exe -i",
consoleWidth: 120,
consoleHeight: 40,
logOutput: true
));
}
}
```
--------------------------------
### Window Enumeration and Identification
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/Microsoft.Terminal.WinUI3/NativeMethods.txt
Functions for enumerating child windows, getting window class names, and identifying the focused window.
```APIDOC
## EnumChildWindows
### Description
Enumerates through all child windows of a parent window, passing the handle of each child window to an application-defined callback function.
### Method
Call
### Endpoint
N/A (Function Call)
## GetClassName
### Description
Retrieves the name of the class to which a window belongs.
### Method
Call
### Endpoint
N/A (Function Call)
## GetFocus
### Description
Retrieves the handle to the window (if any) that has the keyboard focus.
### Method
Call
### Endpoint
N/A (Function Call)
## GetWindowThreadProcessId
### Description
Retrieves the thread identifier of the process that created the window and, optionally, the identifier of the thread that created the window.
### Method
Call
### Endpoint
N/A (Function Call)
## GetCurrentThreadId
### Description
Retrieves the thread identifier of the current thread.
### Method
Call
### Endpoint
N/A (Function Call)
## IsWindow
### Description
Determines whether a handle is a valid window handle.
### Method
Call
### Endpoint
N/A (Function Call)
## IsChild
### Description
Determines whether a window is a child window of the specified parent window.
### Method
Call
### Endpoint
N/A (Function Call)
```
--------------------------------
### Strip ANSI Escape Sequences from Terminal Output
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Utility method `StripColors` to remove ANSI escape sequences, BOM characters, bells, and backspaces from terminal output strings, returning plain text. Also shows how to get cleaned console text directly.
```csharp
using EasyWindowsTerminalControl;
public class OutputProcessor
{
public string ProcessTerminalOutput(string rawOutput)
{
// Strip all ANSI/VT escape sequences
string cleanText = TermPTY.StripColors(rawOutput);
return cleanText;
}
public void SaveCleanLog(EasyTerminalControl terminal, string filePath)
{
// GetConsoleText with stripVTCodes uses StripColors internally
string cleanLog = terminal.ConPTYTerm.GetConsoleText(stripVTCodes: true);
File.WriteAllText(filePath, cleanLog);
}
}
```
--------------------------------
### Initialize EasyTerminalControl in XAML
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/README.md
Declare an EasyTerminalControl in XAML and specify the startup command line argument.
```xml
```
--------------------------------
### TermPTY Constructor and Methods
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/README.md
Details on the TermPTY class, including its constructor and methods for interacting with the terminal.
```APIDOC
## TermPTY
### Constructor
- **TermPTY(int READ_BUFFER_SIZE = 1024 * 16, bool USE_BINARY_WRITER = false, IProcessFactory ProcessFactory=null)**
- **Parameters**:
- **READ_BUFFER_SIZE** (int, optional, default: 16384): The read buffer is the maximum that can be read at once, rarely would it need to be changed.
- **USE_BINARY_WRITER** (bool, optional, default: false): If enabled, data is transmitted as binary. By default, data is transmitted as UTF8 text.
- **ProcessFactory** (IProcessFactory, optional): Interface responsible for creating the actual process. If you need more control, implement this.
- **Description**: The constructor for the TermPTY class. Handles process creation and terminal interaction. Note that if `USE_BINARY_WRITER` is false, binary data will be converted to UTF8 strings, potentially causing issues.
### Methods
#### ClearUITerminal(bool fullReset = false)
- **Parameters**:
- **fullReset** (bool, optional, default: false): Whether to perform a full reset.
- **Description**: Clears the screen using the proper VT sequences.
#### WriteToUITerminal(ReadOnlySpan str)
- **Parameters**:
- **str** (ReadOnlySpan): The string to write to the terminal UI.
- **Description**: Simulates output to the Terminal UI.
#### WriteToTerm(ReadOnlySpan input)
- **Parameters**:
- **input** (ReadOnlySpan): The character span to write to the conpty directly.
- **Description**: Write to the conpty directly as if input came from the Terminal UI.
#### WriteToTermBinary(ReadOnlySpan input)
- **Parameters**:
- **input** (ReadOnlySpan): The byte span to write to the conpty directly.
- **Description**: Write to the conpty directly taking a byte array. Note if USE_BINARY_WRITER is not enabled this will just be converted to a UTF8 string.
#### InterceptOutputToUITerminal / InterceptInputToTermApp
- **Description**: These methods allow you to manipulate data sent to or from the terminal using a delegate.
- **Delegate Signature**: `void InterceptDelegate(ref Span str)`
- **Usage**: Allows modification of data before it's sent to the UI or the terminal application. You can return a whole new span if desired.
```
--------------------------------
### Window Geometry and System Parameters
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/Microsoft.Terminal.WinUI3/NativeMethods.txt
Functions for retrieving window dimensions and system-wide parameters.
```APIDOC
## GetDpiForWindow
### Description
Retrieves the DPI (dots per inch) value for the specified window.
### Method
Call
### Endpoint
N/A (Function Call)
## GetWindowRect
### Description
Retrieves the dimensions of the bounding rectangle of an unclipped window.
### Method
Call
### Endpoint
N/A (Function Call)
## SystemParametersInfo
### Description
Retrieves or sets the status of one or more system-wide parameters.
### Method
Call
### Endpoint
N/A (Function Call)
```
--------------------------------
### Window Manipulation and Properties
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/Microsoft.Terminal.WinUI3/NativeMethods.txt
Functions for setting window properties, controlling visibility, and managing window relationships.
```APIDOC
## SetWindowPos
### Description
Changes the size, position, and ordering of a window. This function includes the GetWindowLong function to retrieve extended window information.
### Method
Call
### Endpoint
N/A (Function Call)
## ShowWindowAsync
### Description
Modifies the visibility of a window. This function is asynchronous.
### Method
Call
### Endpoint
N/A (Function Call)
## EnableWindow
### Description
Enables or disables mouse and keyboard input to the specified window.
### Method
Call
### Endpoint
N/A (Function Call)
## SetParent
### Description
Changes the parent window of a specified child window.
### Method
Call
### Endpoint
N/A (Function Call)
## GetParent
### Description
Retrieves a handle to the specified window's parent window, if any.
### Method
Call
### Endpoint
N/A (Function Call)
## GetWindowLong
### Description
Retrieves 32-bit (32-bit applications) or 64-bit (64-bit applications) values for a specified offset into the extra window memory of a window.
### Method
Call
### Endpoint
N/A (Function Call)
## ShowWindow
### Description
Sets the show state of a window.
### Method
Call
### Endpoint
N/A (Function Call)
```
--------------------------------
### Convert System.Windows.Media.Color to COLORREF
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Provides a helper method `ColorToVal` to convert `System.Windows.Media.Color` objects into the `uint` COLORREF format required for terminal theming. This is used when creating custom `TerminalTheme` objects.
```csharp
using EasyWindowsTerminalControl;
using System.Windows.Media;
public class ThemeHelper
{
public static TerminalTheme CreateThemeFromColors(
Color background,
Color foreground,
Color selection)
{
return new TerminalTheme
{
DefaultBackground = EasyTerminalControl.ColorToVal(background),
DefaultForeground = EasyTerminalControl.ColorToVal(foreground),
DefaultSelectionBackground = EasyTerminalControl.ColorToVal(selection),
CursorStyle = CursorStyle.BlinkingBar,
ColorTable = new uint[] {
0x0C0C0C, 0x1F0FC5, 0x0EA113, 0x009CC1,
0xDA3700, 0x981788, 0xDD963A, 0xCCCCCC,
0x767676, 0x5648E7, 0x0CC616, 0xA5F1F9,
0xFF783B, 0x9E00B4, 0xD6D661, 0xF2F2F2
}
};
}
}
```
--------------------------------
### Configure Terminal Theming in WPF
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Define and apply a custom TerminalTheme to the EasyTerminalControl. This includes default colors, cursor style, and the VT100 color palette.
```csharp
using EasyWindowsTerminalControl;
using Microsoft.Terminal.Wpf;
using System.Windows.Media;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// Define custom theme
var customTheme = new TerminalTheme
{
DefaultBackground = EasyTerminalControl.ColorToVal(Color.FromRgb(0, 0, 30)),
DefaultForeground = EasyTerminalControl.ColorToVal(Colors.LightYellow),
DefaultSelectionBackground = 0xcccccc,
CursorStyle = CursorStyle.BlinkingBar,
// Standard 16-color VT100 palette
ColorTable = new uint[] {
0x0C0C0C, 0x1F0FC5, 0x0EA113, 0x009CC1,
0xDA3700, 0x981788, 0xDD963A, 0xCCCCCC,
0x767676, 0x5648E7, 0x0CC616, 0xA5F1F9,
0xFF783B, 0x9E00B4, 0xD6D661, 0xF2F2F2
}
};
// Apply theme to control
terminalControl.Theme = customTheme;
}
}
```
--------------------------------
### Close Terminal Input Stream (EOF)
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Demonstrates how to close the standard input pipe to a terminal application, effectively sending an EOF signal. Also shows how to forcefully terminate the terminal process.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
private void SendEOF_Click(object sender, RoutedEventArgs e)
{
// Close stdin pipe to send EOF
terminalControl.ConPTYTerm.CloseStdinToApp();
}
private void StopProcess_Click(object sender, RoutedEventArgs e)
{
// Forcefully terminate the external process
terminalControl.ConPTYTerm.StopExternalTermOnly();
}
}
```
--------------------------------
### Writing to the Terminal UI
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Simulates program output directly on the terminal screen, allowing injection of ANSI/VT sequences for formatted messages and status updates.
```APIDOC
## WriteToUITerminal
### Description
Displays text directly on the terminal screen without sending it to the console application. This method simulates output from the program, allowing injection of ANSI/VT sequences directly to the rendering layer. This is useful for displaying messages, status updates, or custom colored output.
### Method
`WriteToUITerminal`
### Parameters
- **message** (string) - Required - The text or ANSI/VT sequence to write to the terminal UI.
### Request Example
```csharp
string message = "\x1b[32m[SUCCESS]\x1b[0m Operation completed!\r\n";
terminalControl.ConPTYTerm.WriteToUITerminal(message);
```
### Response
This method does not return a value.
```
--------------------------------
### Basic XAML Usage for EasyTerminalControl
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Embed the EasyTerminalControl in your WPF window's XAML. Configure startup command, theme, font, and input capture.
```xml
```
--------------------------------
### Write to Terminal Application Input
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Use the WriteToTerm method to send text or commands to the running console application. Useful for automation and scripted interactions.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
private void ExecuteCommand(string command)
{
// Write command to terminal as if typed by user
terminalControl.ConPTYTerm.WriteToTerm(command + "\r");
}
private void RunGitStatus_Click(object sender, RoutedEventArgs e)
{
// Inject a git status command
ExecuteCommand("git status");
}
private void SendCtrlC_Click(object sender, RoutedEventArgs e)
{
// Send Ctrl+C to interrupt current process
terminalControl.ConPTYTerm.WriteToTerm("\x03");
}
}
```
--------------------------------
### Enable and Retrieve Terminal Session Logs
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Enable logging to buffer terminal output. Retrieve the buffered output with `GetConsoleText()`, optionally stripping VT escape codes. The log buffer can be cleared using `ConsoleOutputLog.Clear()`.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// Enable logging in XAML or code
terminalControl.LogConPTYOutput = true;
}
private void SaveSessionLog_Click(object sender, RoutedEventArgs e)
{
// Get logged output with VT codes stripped
string cleanText = terminalControl.ConPTYTerm.GetConsoleText(stripVTCodes: true);
// Get raw output including all ANSI sequences
string rawText = terminalControl.ConPTYTerm.GetConsoleText(stripVTCodes: false);
// Save to file
File.WriteAllText("session_log.txt", cleanText);
// Clear the buffer
terminalControl.ConPTYTerm.ConsoleOutputLog.Clear();
}
}
```
--------------------------------
### EasyTerminalControl Methods
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/README.md
Methods available on the EasyTerminalControl class for managing the terminal process.
```APIDOC
## EasyTerminalControl Methods
### DisconnectConPTYTerm()
- **Description**: Mostly useful if you plan to connect another ConPTYTerm to the frontend.
### RestartTerm(TermPTY useTerm = null, bool disposeOld=true)
- **Parameters**:
- **useTerm** (TermPTY, optional): Use your own TermPTY instance rather than the default one.
- **disposeOld** (bool, optional, default: true): Whether to dispose of the old TermPTY instance.
- **Description**: Restarts the process in a clean term with a new TermPTY instance. Can set `useTerm` to use your own TermPTY instance rather than ours. Any properties (ie StartupCommandLine) that have been changed the new version is used.
```
--------------------------------
### Restart Terminal Session
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Restart the terminal process to a clean state. Optionally, provide a custom `TermPTY` instance for specific configurations or change the startup command before restarting.
```csharp
using EasyWindowsTerminalControl;
using System.Threading.Tasks;
public partial class MainWindow : Window
{
private async void RestartTerminal_Click(object sender, RoutedEventArgs e)
{
// Restart with clean terminal state
await terminalControl.RestartTerm(disposeOld: true);
}
private async void SwitchToCmd_Click(object sender, RoutedEventArgs e)
{
// Change the startup command before restart
terminalControl.StartupCommandLine = "cmd.exe";
await terminalControl.RestartTerm();
}
private async void AttachCustomTerm_Click(object sender, RoutedEventArgs e)
{
// Create custom TermPTY with larger buffer
var customTerm = new TermPTY(READ_BUFFER_SIZE: 1024 * 32);
await terminalControl.RestartTerm(useTerm: customTerm);
}
}
```
--------------------------------
### Window Styles and Messages
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/Microsoft.Terminal.WinUI3/NativeMethods.txt
Constants and structures related to window styles and messages.
```APIDOC
## WM_*
### Description
Constants representing Windows messages used for communication between windows.
### Method
N/A (Constants)
### Endpoint
N/A
## WINDOWPOS
### Description
Contains information about the size, position, and ordering of a window during window management operations.
### Method
N/A (Structure)
### Endpoint
N/A
## WINDOW_STYLE
### Description
Constants representing various window styles that define the appearance and behavior of a window.
### Method
N/A (Constants)
### Endpoint
N/A
```
--------------------------------
### Write to Terminal UI with ANSI Codes
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Simulates program output directly to the terminal rendering layer using ANSI escape codes for formatting. Useful for status messages and custom colored output.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
private void ShowStatusMessage()
{
// Write colored text directly to terminal UI
// Uses ANSI escape codes for formatting
string message = "\x1b[32m[SUCCESS]\x1b[0m Operation completed!\r\n";
terminalControl.ConPTYTerm.WriteToUITerminal(message);
}
private void ShowWarning()
{
// Yellow warning with bold text
string warning = "\x1b[1;33m[WARNING]\x1b[0m Check configuration.\r\n";
terminalControl.ConPTYTerm.WriteToUITerminal(warning);
}
}
```
--------------------------------
### Initialize ReadDelimitedTermPTY for Delimited Output
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Configures a ReadDelimitedTermPTY to buffer and process terminal output in chunks, separated by a specified delimiter. Useful for custom protocols or service-mode applications.
```csharp
using EasyWindowsTerminalControl;
using System;
public partial class ProcessWindow : Window
{
private const string DELIMITER = "__END_OUTPUT__";
public ProcessWindow()
{
InitializeComponent();
// Create delimited terminal with timeout
var delimitedTerm = new ReadDelimitedTermPTY(
READ_BUFFER_SIZE: 1024 * 16,
USE_BINARY_WRITER: false,
delimiter: DELIMITER.AsSpan(),
MaxWaitTimeoutForDelimiter: TimeSpan.FromSeconds(5)
);
terminalControl.ConPTYTerm = delimitedTerm;
}
private void SendDelimitedCommand(string input)
{
// Service expects input followed by delimiter marker
string commandWithDelimiter = $"{input}\n{DELIMITER}\n";
terminalControl.ConPTYTerm.WriteToTerm(commandWithDelimiter);
}
}
```
--------------------------------
### Enable Win32 Input Mode
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Configures the terminal control to use Win32 input mode, which transmits full INPUT_RECORD data for enhanced key event handling and better support for complex control sequences. This mode is enabled by default.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// Enable Win32 input mode for better key handling (enabled by default)
terminalControl.Win32InputMode = true;
}
private void ToggleInputMode()
{
// Can also be set programmatically on the TermPTY
terminalControl.ConPTYTerm.Win32DirectInputMode(enable: true);
}
}
```
--------------------------------
### Configure Read-Only Mode and Cursor Visibility
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Disables user input and hides the cursor for display-only scenarios. Re-enable by setting `IsReadOnly` to false and `IsCursorVisible` to true.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
private void SetReadOnlyMode()
{
// Disable user input (programmatic input still works)
terminalControl.IsReadOnly = true;
// Hide the cursor
terminalControl.IsCursorVisible = false;
}
private void SetInteractiveMode()
{
// Re-enable user input
terminalControl.IsReadOnly = false;
// Show the cursor
terminalControl.IsCursorVisible = true;
}
}
```
--------------------------------
### EasyTerminalControl Properties
Source: https://github.com/mitchcapper/easywindowsterminalcontrol/blob/master/README.md
Properties of the EasyTerminalControl class that allow for customization and control of the terminal's behavior.
```APIDOC
## EasyTerminalControl Properties
### StartupCommandLine
- **Type**: string
- **Default**: "powershell.exe"
- **Description**: The full command line to launch for the application to run. Can contain any arguments as well.
### IsReadOnly
- **Type**: bool?
- **Write Only**: true
- **Default**: null
- **Description**: Ignores all input from the Terminal GUI, this includes things like resize notifications so may have unintended affects. It is actually a helper to setting it on the underlying ConPTYTerm.
### IsCursorVisible
- **Type**: bool?
- **Write Only**: true
- **Default**: null
- **Description**: Controls if the cursor is showing. Note apps emitting VT codes can re-enable it.
### Theme
- **Type**: TerminalTheme?
- **Write Only**: true
- **Description**: Sets the default terminal theme, background, foreground, cursor style, etc.
### LogConPTYOutput
- **Type**: bool
- **Default**: false
- **Description**: If the underlying TermPTY instance should be told to log the application output to its buffer (can call ConPTYTerm.GetConsoleText() to retrieve).
### Win32InputMode
- **Type**: bool
- **Default**: true
- **Description**: Standard VT sequences can't quite transmit all the key data that INPUT_RECORD could. This uses a 'key record' sequence to transmit all the original information that conpty knows how to translate into VT codes.
### InputCapture
- **Type**: INPUT_CAPTURE flags enum
- **Description**: Controls what specialized keys should be captured by the control (tab, arrow keys).
### FontSizeWhenSettingTheme
- **Type**: int
- **Default**: 12
- **Description**: The font size for terminal text, if you set this after the control is initialized it won't take effect until you call `SetTheme` directly.
### FontFamilyWhenSettingTheme
- **Type**: FontFamily
- **Default**: "Cascadia Code"
- **Description**: Font to use for terminal text, similar behavior to font-size above in terms of changes after initialized.
### ConPTYTerm
- **Type**: TermPTY
- **Description**: Allows you to change the TermPTY.
### Terminal
- **Write Only**: true
- **Description**: Represents the terminal interface.
```
--------------------------------
### Clear Terminal Screen
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Clears the terminal screen using VT sequences. Set `fullReset` to true for a complete reset of all terminal parameters.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
private void ClearScreen_Click(object sender, RoutedEventArgs e)
{
// Soft clear - just clears visible content
terminalControl.ConPTYTerm.ClearUITerminal(fullReset: false);
}
private void FullReset_Click(object sender, RoutedEventArgs e)
{
// Hard clear - resets all terminal parameters
terminalControl.ConPTYTerm.ClearUITerminal(fullReset: true);
}
}
```
--------------------------------
### Read-Only Mode and Cursor Visibility
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Configures the terminal for display-only scenarios by disabling user input and hiding the cursor.
```APIDOC
## Read-Only Mode and Cursor Visibility
### Description
These properties control whether user input is accepted and whether the cursor is visible. They are useful for log viewers or read-only terminal displays.
### Properties
- **IsReadOnly** (bool) - Set to `true` to disable user input. Programmatic input still works. Set to `false` to re-enable user input.
- **IsCursorVisible** (bool) - Set to `false` to hide the cursor. Set to `true` to show the cursor.
### Request Example
```csharp
// Set read-only mode and hide cursor
terminalControl.IsReadOnly = true;
terminalControl.IsCursorVisible = false;
// Set interactive mode and show cursor
terminalControl.IsReadOnly = false;
terminalControl.IsCursorVisible = true;
```
```
--------------------------------
### Clearing the Terminal
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Clears the terminal screen with an option for a full reset of terminal parameters.
```APIDOC
## ClearUITerminal
### Description
Clears the terminal screen by sending VT sequences. If `fullReset` is true, it also resets all terminal parameters to their defaults.
### Method
`ClearUITerminal`
### Parameters
- **fullReset** (bool) - Optional - If true, resets all terminal parameters to defaults. Defaults to false.
### Request Example
```csharp
// Soft clear - just clears visible content
terminalControl.ConPTYTerm.ClearUITerminal(fullReset: false);
// Hard clear - resets all terminal parameters
terminalControl.ConPTYTerm.ClearUITerminal(fullReset: true);
```
### Response
This method does not return a value.
```
--------------------------------
### Detach and Re-attach Terminal Instance
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Detach a running terminal session from its current control without terminating the process. This allows the session to be attached to a different `EasyTerminalControl` instance, potentially in a new window.
```csharp
using EasyWindowsTerminalControl;
public partial class MainWindow : Window
{
private void OpenInNewWindow_Click(object sender, RoutedEventArgs e)
{
// Detach the terminal from current control
TermPTY existingTerm = terminalControl.DisconnectConPTYTerm();
// Create new window and attach the running terminal
var newWindow = new SecondWindow();
newWindow.terminalControl.ConPTYTerm = existingTerm;
newWindow.Show();
}
}
```
--------------------------------
### Intercept Terminal Input/Output
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Manipulate data streams between the terminal UI and the console application using delegates. Useful for logging, filtering, or modifying I/O.
```csharp
using EasyWindowsTerminalControl;
using System;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// Intercept output from app before it reaches terminal UI
terminalControl.ConPTYTerm.InterceptOutputToUITerminal = (ref Span output) =>
{
// Log all output
string text = output.ToString();
LogOutput(text);
// Optionally modify: set output to empty span to suppress
// output = Span.Empty;
};
// Intercept input from terminal UI before it reaches app
terminalControl.ConPTYTerm.InterceptInputToTermApp = (ref Span input) =>
{
// Log all user input
string text = input.ToString();
LogInput(text);
// Block certain commands by clearing the span
if (text.Contains("rm -rf"))
{
input = Span.Empty;
}
};
}
private void LogOutput(string text) => Debug.WriteLine($"OUT: {text}");
private void LogInput(string text) => Debug.WriteLine($"IN: {text}");
}
```
--------------------------------
### Input/Output Interception
Source: https://context7.com/mitchcapper/easywindowsterminalcontrol/llms.txt
Intercepts and modifies data flowing between the terminal UI and the console application.
```APIDOC
## Input/Output Interception Delegates
### Description
These delegates allow manipulation of data streams between the terminal UI and the console application. You can modify, filter, or log all terminal I/O.
### Delegates
- **InterceptOutputToUITerminal** (delegate) - Intercepts output from the application before it reaches the terminal UI. The delegate receives a `ref Span` representing the output data.
- **InterceptInputToTermApp** (delegate) - Intercepts input from the terminal UI before it reaches the application. The delegate receives a `ref Span` representing the input data.
### Request Example
```csharp
// Intercept output from app before it reaches terminal UI
terminalControl.ConPTYTerm.InterceptOutputToUITerminal = (ref Span output) =>
{
// Log all output
string text = output.ToString();
LogOutput(text);
// Optionally modify: set output to empty span to suppress
// output = Span.Empty;
};
// Intercept input from terminal UI before it reaches app
terminalControl.ConPTYTerm.InterceptInputToTermApp = (ref Span input) =>
{
// Log all user input
string text = input.ToString();
LogInput(text);
// Block certain commands by clearing the span
if (text.Contains("rm -rf"))
{
input = Span.Empty;
}
};
// Helper methods for logging (example)
// private void LogOutput(string text) => Debug.WriteLine($"OUT: {text}");
// private void LogInput(string text) => Debug.WriteLine($"IN: {text}");
```
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.