navigation history v1
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using SharpIDE.Application.Features.Analysis;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
|
||||
namespace SharpIDE.Application.Features.NavigationHistory;
|
||||
|
||||
public class IdeNavigationHistoryService
|
||||
{
|
||||
private readonly Stack<IdeNavigationLocation> _backStack = new();
|
||||
private IdeNavigationLocation? _current;
|
||||
private readonly Stack<IdeNavigationLocation> _forwardStack = new();
|
||||
|
||||
public bool CanGoBack => _backStack.Count > 0;
|
||||
public bool CanGoForward => _forwardStack.Count > 0;
|
||||
public IdeNavigationLocation? Current => _current;
|
||||
|
||||
public void RecordNavigation(SharpIdeFile file, SharpIdeFileLinePosition linePosition)
|
||||
{
|
||||
var location = new IdeNavigationLocation(file, linePosition);
|
||||
if (location == _current)
|
||||
{
|
||||
// perhaps we filter out our forward and back navigations like this?
|
||||
return;
|
||||
}
|
||||
if (_current is not null)
|
||||
{
|
||||
_backStack.Push(_current);
|
||||
}
|
||||
_current = location;
|
||||
_forwardStack.Clear();
|
||||
}
|
||||
|
||||
public void GoBack()
|
||||
{
|
||||
if (!CanGoBack) throw new InvalidOperationException("Cannot go back, no history available.");
|
||||
if (_current is not null)
|
||||
{
|
||||
_forwardStack.Push(_current);
|
||||
}
|
||||
_current = _backStack.Pop();
|
||||
// TODO: Fire event
|
||||
}
|
||||
|
||||
public void GoForward()
|
||||
{
|
||||
if (!CanGoForward) throw new InvalidOperationException("Cannot go forward, no history available.");
|
||||
if (_current is not null)
|
||||
{
|
||||
_backStack.Push(_current);
|
||||
}
|
||||
|
||||
_current = _forwardStack.Pop();
|
||||
// TODO: Fire event
|
||||
}
|
||||
}
|
||||
|
||||
public record IdeNavigationLocation(SharpIdeFile File, SharpIdeFileLinePosition LinePosition)
|
||||
{
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using SharpIDE.Application.Features.Build;
|
||||
using SharpIDE.Application.Features.Evaluation;
|
||||
using SharpIDE.Application.Features.FilePersistence;
|
||||
using SharpIDE.Application.Features.FileWatching;
|
||||
using SharpIDE.Application.Features.NavigationHistory;
|
||||
using SharpIDE.Application.Features.Run;
|
||||
using SharpIDE.Application.Features.Search;
|
||||
|
||||
@@ -36,6 +37,7 @@ public partial class DiAutoload : Node
|
||||
services.AddScoped<FileChangedService>();
|
||||
services.AddScoped<DotnetUserSecretsService>();
|
||||
services.AddScoped<IdeFileWatcher>();
|
||||
services.AddScoped<IdeNavigationHistoryService>();
|
||||
services.AddScoped<IdeOpenTabsFileManager>();
|
||||
services.AddScoped<RoslynAnalysis>();
|
||||
services.AddScoped<IdeFileOperationsService>();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.NavigationHistory;
|
||||
|
||||
namespace SharpIDE.Godot.Features.Navigation;
|
||||
|
||||
public partial class ForwardBackwardButtonContainer : HBoxContainer
|
||||
{
|
||||
private Button _backwardButton = null!;
|
||||
private Button _forwardButton = null!;
|
||||
|
||||
[Inject] private readonly IdeNavigationHistoryService _navigationHistoryService = null!;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_backwardButton = GetNode<Button>("BackwardButton");
|
||||
_forwardButton = GetNode<Button>("ForwardButton");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cao2o2singwnb
|
||||
@@ -0,0 +1,16 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bgpc5vsddmakc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cao2o2singwnb" path="res://Features/Navigation/ForwardBackwardButtonContainer.cs" id="1_vep4b"]
|
||||
|
||||
[node name="ForwardBackwardButtonContainer" type="HBoxContainer"]
|
||||
script = ExtResource("1_vep4b")
|
||||
|
||||
[node name="ForwardButton" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
text = " < "
|
||||
|
||||
[node name="BackwardButton" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
text = " > "
|
||||
@@ -4,6 +4,7 @@ using Godot;
|
||||
using ObservableCollections;
|
||||
using R3;
|
||||
using SharpIDE.Application.Features.Analysis;
|
||||
using SharpIDE.Application.Features.NavigationHistory;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
using SharpIDE.Godot.Features.Common;
|
||||
@@ -27,6 +28,8 @@ public partial class SolutionExplorerPanel : MarginContainer
|
||||
public SharpIdeSolutionModel SolutionModel { get; set; } = null!;
|
||||
private Tree _tree = null!;
|
||||
private TreeItem _rootItem = null!;
|
||||
|
||||
[Inject] private readonly IdeNavigationHistoryService _navigationHistoryService = null!;
|
||||
private enum ClipboardOperation { Cut, Copy }
|
||||
|
||||
private (List<IFileOrFolder>, ClipboardOperation)? _itemsOnClipboard;
|
||||
@@ -101,6 +104,7 @@ public partial class SolutionExplorerPanel : MarginContainer
|
||||
_tree.QueueRedraw();
|
||||
});
|
||||
}
|
||||
_navigationHistoryService.RecordNavigation(file, fileLinePosition ?? new SharpIdeFileLinePosition(0, 0));
|
||||
await task.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=19 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
[gd_scene load_steps=20 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://38igu11xwba6" path="res://Inter-VariableFont.ttf" id="1_7ptyn"]
|
||||
[ext_resource type="Script" uid="uid://bavypuy7b375x" path="res://IdeRoot.cs" id="1_whawi"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkty6563cthj8" path="res://Features/Run/Resources/Run.svg" id="2_8x8ub"]
|
||||
[ext_resource type="Script" uid="uid://kvnhndc3l6ih" path="res://Features/CustomControls/InvertedVSplitContainer.cs" id="3_0ybuf"]
|
||||
[ext_resource type="PackedScene" uid="uid://biyhfwx36ium8" path="res://Features/LeftSideBar/LeftSideBar.tscn" id="3_f60gr"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgpc5vsddmakc" path="res://Features/Navigation/ForwardBackwardButtonContainer.tscn" id="3_ptnvy"]
|
||||
[ext_resource type="PackedScene" uid="uid://cy1bb32g7j7dr" path="res://Features/SolutionExplorer/SolutionExplorerPanel.tscn" id="5_s2dv6"]
|
||||
[ext_resource type="PackedScene" uid="uid://bcoytt3bw0gpe" path="res://Features/Run/RunPanel.tscn" id="5_y3aoi"]
|
||||
[ext_resource type="Script" uid="uid://cvvgp42r3nml8" path="res://Features/BottomPanel/BottomPanelManager.cs" id="7_i62lx"]
|
||||
@@ -57,6 +58,9 @@ offset_right = -5.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="ForwardBackwardButtonContainer" parent="VBoxContainer/Panel/HBoxContainer" instance=ExtResource("3_ptnvy")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="OpenSlnButton" type="Button" parent="VBoxContainer/Panel/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
Reference in New Issue
Block a user