feat(interactive): embedded ConPTY terminal host in UI
Adds a self-contained terminal host: PtyTerminalSession drives a Porta.Pty child directly (custom env) and pumps it through Iciclecreek's XTerm.NET renderer via TerminalControl.Terminal, bypassing LaunchProcess() so a fully-populated environment can be passed. InteractiveTerminalView/ViewModel host it with an order-independent attach/start. Adds Iciclecreek.Avalonia.Terminal 2.0.3. Sets Process="" to suppress the control's auto-launch of a stray shell.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:ClaudeDo.Ui.ViewModels"
|
||||
xmlns:term="using:Iciclecreek.Terminal"
|
||||
x:Class="ClaudeDo.Ui.Views.InteractiveTerminalView"
|
||||
x:DataType="vm:InteractiveTerminalViewModel"
|
||||
x:Name="Root">
|
||||
<!--
|
||||
Process="" suppresses TerminalView.OnLoaded's built-in auto-launch (it otherwise spawns its
|
||||
own cmd.exe/bash the moment this control loads). We drive the pty ourselves via
|
||||
PtyTerminalSession/InteractiveTerminalViewModel instead.
|
||||
-->
|
||||
<term:TerminalControl x:Name="TerminalHost" Process="" />
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using ClaudeDo.Ui.ViewModels;
|
||||
|
||||
namespace ClaudeDo.Ui.Views;
|
||||
|
||||
public partial class InteractiveTerminalView : UserControl
|
||||
{
|
||||
public InteractiveTerminalView()
|
||||
{
|
||||
InitializeComponent();
|
||||
TerminalHost.Loaded += OnTerminalHostLoaded;
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
}
|
||||
|
||||
private void OnDataContextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (DataContext is InteractiveTerminalViewModel vm && TerminalHost.IsLoaded)
|
||||
vm.AttachControl(TerminalHost);
|
||||
}
|
||||
|
||||
private void OnTerminalHostLoaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is InteractiveTerminalViewModel vm)
|
||||
vm.AttachControl(TerminalHost);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user