select tab on project run

This commit is contained in:
Matt Parker
2025-08-10 00:30:29 +10:00
parent 05c72d2291
commit 197567d661
2 changed files with 13 additions and 2 deletions

View File

@@ -10,6 +10,9 @@
[Parameter, EditorRequired] [Parameter, EditorRequired]
public SharpIdeProjectModel Project { get; set; } = null!; public SharpIdeProjectModel Project { get; set; } = null!;
[Parameter]
public EventCallback<SharpIdeProjectModel> OnProjectStarted { get; set; }
private TerminalDisplay _terminalDisplayRef = null!; private TerminalDisplay _terminalDisplayRef = null!;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@@ -24,6 +27,7 @@
Guard.Against.Null(Project); Guard.Against.Null(Project);
Guard.Against.Null(Project.RunningOutputChannel, nameof(Project.RunningOutputChannel)); Guard.Against.Null(Project.RunningOutputChannel, nameof(Project.RunningOutputChannel));
if (_terminalDisplayRef is not null) await _terminalDisplayRef.Clear(); if (_terminalDisplayRef is not null) await _terminalDisplayRef.Clear();
await InvokeAsync(async () => await OnProjectStarted.InvokeAsync(Project));
_ = Task.Run(async () => _ = Task.Run(async () =>
{ {
try try

View File

@@ -16,12 +16,12 @@
} }
</style> </style>
@* <MudText>Run</MudText> *@ @* <MudText>Run</MudText> *@
<MudTabs Style="height: 100%" KeepPanelsAlive="true" PanelClass="panels-full-height" TabPanelClass="lowercase-tab-header"> <MudTabs @ref="_mudTabsRef" Style="height: 100%" KeepPanelsAlive="true" PanelClass="panels-full-height" TabPanelClass="lowercase-tab-header">
<ChildContent> <ChildContent>
@foreach (var tab in OpenTabs) @foreach (var tab in OpenTabs)
{ {
<MudTabPanel Style="height: 100%" ID="@tab" Text="@tab.Name"> <MudTabPanel Style="height: 100%" ID="@tab" Text="@tab.Name">
<RunOutputDisplay Project="@tab"/> <RunOutputDisplay Project="@tab" OnProjectStarted="@SetActiveTab"/>
</MudTabPanel> </MudTabPanel>
} }
</ChildContent> </ChildContent>
@@ -46,6 +46,8 @@
[Parameter, EditorRequired] [Parameter, EditorRequired]
public SharpIdeSolutionModel SolutionModel { get; set; } = null!; public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
private MudTabs _mudTabsRef;
private IEnumerable<SharpIdeProjectModel> OpenTabs => SolutionModel.AllProjects.Where(s => s.OpenInRunPanel); private IEnumerable<SharpIdeProjectModel> OpenTabs => SolutionModel.AllProjects.Where(s => s.OpenInRunPanel);
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
@@ -66,4 +68,9 @@
} }
public void Dispose() => GlobalEvents.ProjectsRunningChanged -= OnProjectsRunningChanged; public void Dispose() => GlobalEvents.ProjectsRunningChanged -= OnProjectsRunningChanged;
private void SetActiveTab(SharpIdeProjectModel project)
{
_mudTabsRef.ActivatePanel(project);
}
} }