use instance for global events
This commit is contained in:
@@ -76,7 +76,7 @@ public class DebuggingService
|
|||||||
var filePath = dict?["source"]?["path"]!.Value<string>()!;
|
var filePath = dict?["source"]?["path"]!.Value<string>()!;
|
||||||
var line = (dict?["line"]?.Value<int>()!).Value;
|
var line = (dict?["line"]?.Value<int>()!).Value;
|
||||||
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value };
|
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value };
|
||||||
GlobalEvents.InvokeDebuggerExecutionStopped(executionStopInfo);
|
GlobalEvents.Instance.InvokeDebuggerExecutionStopped(executionStopInfo);
|
||||||
if (@event.Reason is StoppedEvent.ReasonValue.Exception)
|
if (@event.Reason is StoppedEvent.ReasonValue.Exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Stopped due to exception, continuing");
|
Console.WriteLine("Stopped due to exception, continuing");
|
||||||
|
|||||||
@@ -3,28 +3,29 @@ using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
|||||||
|
|
||||||
namespace SharpIDE.Application.Features.Events;
|
namespace SharpIDE.Application.Features.Events;
|
||||||
|
|
||||||
public static class GlobalEvents
|
public class GlobalEvents
|
||||||
{
|
{
|
||||||
public static event Func<Task> ProjectsRunningChanged = () => Task.CompletedTask;
|
public static GlobalEvents Instance { get; set; } = null!;
|
||||||
public static void InvokeProjectsRunningChanged() => ProjectsRunningChanged?.InvokeParallelFireAndForget();
|
public event Func<Task> ProjectsRunningChanged = () => Task.CompletedTask;
|
||||||
|
public void InvokeProjectsRunningChanged() => ProjectsRunningChanged?.InvokeParallelFireAndForget();
|
||||||
|
|
||||||
public static event Func<Task> StartedRunningProject = () => Task.CompletedTask;
|
public event Func<Task> StartedRunningProject = () => Task.CompletedTask;
|
||||||
public static void InvokeStartedRunningProject() => StartedRunningProject?.InvokeParallelFireAndForget();
|
public void InvokeStartedRunningProject() => StartedRunningProject?.InvokeParallelFireAndForget();
|
||||||
|
|
||||||
public static event Func<SharpIdeProjectModel, Task> ProjectStartedDebugging = _ => Task.CompletedTask;
|
public event Func<SharpIdeProjectModel, Task> ProjectStartedDebugging = _ => Task.CompletedTask;
|
||||||
public static void InvokeProjectStartedDebugging(SharpIdeProjectModel project) => ProjectStartedDebugging?.InvokeParallelFireAndForget(project);
|
public void InvokeProjectStartedDebugging(SharpIdeProjectModel project) => ProjectStartedDebugging?.InvokeParallelFireAndForget(project);
|
||||||
|
|
||||||
public static event Func<SharpIdeProjectModel, Task> ProjectStoppedDebugging = _ => Task.CompletedTask;
|
public event Func<SharpIdeProjectModel, Task> ProjectStoppedDebugging = _ => Task.CompletedTask;
|
||||||
public static void InvokeProjectStoppedDebugging(SharpIdeProjectModel project) => ProjectStoppedDebugging?.InvokeParallelFireAndForget(project);
|
public void InvokeProjectStoppedDebugging(SharpIdeProjectModel project) => ProjectStoppedDebugging?.InvokeParallelFireAndForget(project);
|
||||||
|
|
||||||
public static event Func<SharpIdeProjectModel, Task> ProjectStartedRunning = _ => Task.CompletedTask;
|
public event Func<SharpIdeProjectModel, Task> ProjectStartedRunning = _ => Task.CompletedTask;
|
||||||
public static void InvokeProjectStartedRunning(SharpIdeProjectModel project) => ProjectStartedRunning?.InvokeParallelFireAndForget(project);
|
public void InvokeProjectStartedRunning(SharpIdeProjectModel project) => ProjectStartedRunning?.InvokeParallelFireAndForget(project);
|
||||||
|
|
||||||
public static event Func<SharpIdeProjectModel, Task> ProjectStoppedRunning = _ => Task.CompletedTask;
|
public event Func<SharpIdeProjectModel, Task> ProjectStoppedRunning = _ => Task.CompletedTask;
|
||||||
public static void InvokeProjectStoppedRunning(SharpIdeProjectModel project) => ProjectStoppedRunning?.InvokeParallelFireAndForget(project);
|
public void InvokeProjectStoppedRunning(SharpIdeProjectModel project) => ProjectStoppedRunning?.InvokeParallelFireAndForget(project);
|
||||||
|
|
||||||
public static event Func<ExecutionStopInfo, Task> DebuggerExecutionStopped = _ => Task.CompletedTask;
|
public event Func<ExecutionStopInfo, Task> DebuggerExecutionStopped = _ => Task.CompletedTask;
|
||||||
public static void InvokeDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo) => DebuggerExecutionStopped?.InvokeParallelFireAndForget(executionStopInfo);
|
public void InvokeDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo) => DebuggerExecutionStopped?.InvokeParallelFireAndForget(executionStopInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AsyncEventExtensions
|
public static class AsyncEventExtensions
|
||||||
|
|||||||
@@ -93,13 +93,13 @@ public class RunService
|
|||||||
project.OpenInRunPanel = true;
|
project.OpenInRunPanel = true;
|
||||||
if (isDebug)
|
if (isDebug)
|
||||||
{
|
{
|
||||||
GlobalEvents.InvokeProjectStartedDebugging(project);
|
GlobalEvents.Instance.InvokeProjectStartedDebugging(project);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalEvents.InvokeProjectsRunningChanged();
|
GlobalEvents.Instance.InvokeProjectsRunningChanged();
|
||||||
GlobalEvents.InvokeStartedRunningProject();
|
GlobalEvents.Instance.InvokeStartedRunningProject();
|
||||||
GlobalEvents.InvokeProjectStartedRunning(project);
|
GlobalEvents.Instance.InvokeProjectStartedRunning(project);
|
||||||
}
|
}
|
||||||
project.InvokeProjectStartedRunning();
|
project.InvokeProjectStartedRunning();
|
||||||
await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
|
await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
|
||||||
@@ -115,12 +115,12 @@ public class RunService
|
|||||||
project.Running = false;
|
project.Running = false;
|
||||||
if (isDebug)
|
if (isDebug)
|
||||||
{
|
{
|
||||||
GlobalEvents.InvokeProjectStoppedDebugging(project);
|
GlobalEvents.Instance.InvokeProjectStoppedDebugging(project);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalEvents.InvokeProjectsRunningChanged();
|
GlobalEvents.Instance.InvokeProjectsRunningChanged();
|
||||||
GlobalEvents.InvokeProjectStoppedRunning(project);
|
GlobalEvents.Instance.InvokeProjectStoppedRunning(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
project.InvokeProjectStoppedRunning();
|
project.InvokeProjectStoppedRunning();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public partial class CodeEditorPanel : MarginContainer
|
|||||||
var tabBar = _tabContainer.GetTabBar();
|
var tabBar = _tabContainer.GetTabBar();
|
||||||
tabBar.TabCloseDisplayPolicy = TabBar.CloseButtonDisplayPolicy.ShowAlways;
|
tabBar.TabCloseDisplayPolicy = TabBar.CloseButtonDisplayPolicy.ShowAlways;
|
||||||
tabBar.TabClosePressed += OnTabClosePressed;
|
tabBar.TabClosePressed += OnTabClosePressed;
|
||||||
GlobalEvents.DebuggerExecutionStopped += OnDebuggerExecutionStopped;
|
GlobalEvents.Instance.DebuggerExecutionStopped += OnDebuggerExecutionStopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _UnhandledKeyInput(InputEvent @event)
|
public override void _UnhandledKeyInput(InputEvent @event)
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ public partial class DebugPanel : Control
|
|||||||
//_tabBar.TabClosePressed
|
//_tabBar.TabClosePressed
|
||||||
_tabBar.TabClicked += OnTabBarTabClicked;
|
_tabBar.TabClicked += OnTabBarTabClicked;
|
||||||
_tabsPanel = GetNode<MarginContainer>("%TabsPanel");
|
_tabsPanel = GetNode<MarginContainer>("%TabsPanel");
|
||||||
GlobalEvents.ProjectStartedDebugging += async projectModel =>
|
GlobalEvents.Instance.ProjectStartedDebugging += async projectModel =>
|
||||||
{
|
{
|
||||||
await this.InvokeAsync(() => ProjectStartedDebugging(projectModel));
|
await this.InvokeAsync(() => ProjectStartedDebugging(projectModel));
|
||||||
};
|
};
|
||||||
GlobalEvents.ProjectStoppedDebugging += async projectModel =>
|
GlobalEvents.Instance.ProjectStoppedDebugging += async projectModel =>
|
||||||
{
|
{
|
||||||
await this.InvokeAsync(() => ProjectStoppedDebugging(projectModel));
|
await this.InvokeAsync(() => ProjectStoppedDebugging(projectModel));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public partial class ThreadsVariablesSubTab : Control
|
|||||||
_threadsVboxContainer = GetNode<VBoxContainer>("%ThreadsPanel/VBoxContainer");
|
_threadsVboxContainer = GetNode<VBoxContainer>("%ThreadsPanel/VBoxContainer");
|
||||||
_stackFramesVboxContainer = GetNode<VBoxContainer>("%StackFramesPanel/VBoxContainer");
|
_stackFramesVboxContainer = GetNode<VBoxContainer>("%StackFramesPanel/VBoxContainer");
|
||||||
_variablesVboxContainer = GetNode<VBoxContainer>("%VariablesPanel/VBoxContainer");
|
_variablesVboxContainer = GetNode<VBoxContainer>("%VariablesPanel/VBoxContainer");
|
||||||
GlobalEvents.DebuggerExecutionStopped += OnDebuggerExecutionStopped;
|
GlobalEvents.Instance.DebuggerExecutionStopped += OnDebuggerExecutionStopped;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ public partial class RunPanel : Control
|
|||||||
//_tabBar.TabClosePressed
|
//_tabBar.TabClosePressed
|
||||||
_tabBar.TabClicked += OnTabBarTabClicked;
|
_tabBar.TabClicked += OnTabBarTabClicked;
|
||||||
_tabsPanel = GetNode<MarginContainer>("%TabsPanel");
|
_tabsPanel = GetNode<MarginContainer>("%TabsPanel");
|
||||||
GlobalEvents.ProjectStartedRunning += async projectModel =>
|
GlobalEvents.Instance.ProjectStartedRunning += async projectModel =>
|
||||||
{
|
{
|
||||||
await this.InvokeAsync(() => ProjectStartedRunning(projectModel));
|
await this.InvokeAsync(() => ProjectStartedRunning(projectModel));
|
||||||
};
|
};
|
||||||
GlobalEvents.ProjectStoppedRunning += async projectModel =>
|
GlobalEvents.Instance.ProjectStoppedRunning += async projectModel =>
|
||||||
{
|
{
|
||||||
await this.InvokeAsync(() => ProjectStoppedRunning(projectModel));
|
await this.InvokeAsync(() => ProjectStoppedRunning(projectModel));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Godot;
|
|||||||
using Microsoft.Build.Locator;
|
using Microsoft.Build.Locator;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using SharpIDE.Application.Features.Analysis;
|
using SharpIDE.Application.Features.Analysis;
|
||||||
|
using SharpIDE.Application.Features.Events;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
using SharpIDE.Godot.Features.BottomPanel;
|
using SharpIDE.Godot.Features.BottomPanel;
|
||||||
@@ -34,6 +35,7 @@ public partial class IdeRoot : Control
|
|||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
GodotGlobalEvents.Instance = new GodotGlobalEvents();
|
GodotGlobalEvents.Instance = new GodotGlobalEvents();
|
||||||
|
GlobalEvents.Instance = new GlobalEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
{
|
{
|
||||||
var tasks = SolutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask);
|
var tasks = SolutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask);
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
GlobalEvents.ProjectsRunningChanged += OnProjectsRunningChanged;
|
GlobalEvents.Instance.ProjectsRunningChanged += OnProjectsRunningChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseTab(SharpIdeProjectModel project)
|
private void CloseTab(SharpIdeProjectModel project)
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() => GlobalEvents.ProjectsRunningChanged -= OnProjectsRunningChanged;
|
public void Dispose() => GlobalEvents.Instance.ProjectsRunningChanged -= OnProjectsRunningChanged;
|
||||||
|
|
||||||
private void SetActiveTab(SharpIdeProjectModel project)
|
private void SetActiveTab(SharpIdeProjectModel project)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
GlobalEvents.ProjectsRunningChanged += OnProjectsRunningChanged;
|
GlobalEvents.Instance.ProjectsRunningChanged += OnProjectsRunningChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
@@ -73,5 +73,5 @@
|
|||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() => GlobalEvents.ProjectsRunningChanged -= OnProjectsRunningChanged;
|
public void Dispose() => GlobalEvents.Instance.ProjectsRunningChanged -= OnProjectsRunningChanged;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,8 +136,9 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
GlobalEvents.Instance = new GlobalEvents();
|
||||||
await LoadSolutionFromInteractivePicker(AppState.IdeSettings.AutoOpenLastSolution);
|
await LoadSolutionFromInteractivePicker(AppState.IdeSettings.AutoOpenLastSolution);
|
||||||
GlobalEvents.StartedRunningProject += OnStartedRunningProject;
|
GlobalEvents.Instance.StartedRunningProject += OnStartedRunningProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnProblemSelected(SharpIdeFile file)
|
private void OnProblemSelected(SharpIdeFile file)
|
||||||
|
|||||||
Reference in New Issue
Block a user