search modal v1
This commit is contained in:
29
src/SharpIDE.Application/Features/Search/SearchService.cs
Normal file
29
src/SharpIDE.Application/Features/Search/SearchService.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO.MemoryMappedFiles;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
|
||||
namespace SharpIDE.Application.Features.Search;
|
||||
|
||||
public static class SearchService
|
||||
{
|
||||
public static async Task FindInFiles(SharpIdeSolutionModel solutionModel, string searchTerm)
|
||||
{
|
||||
if (searchTerm.Length < 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var files = solutionModel.AllFiles;
|
||||
ConcurrentBag<string> results = [];
|
||||
await Parallel.ForEachAsync(files, async (file, ct) =>
|
||||
{
|
||||
await foreach (var (index, line) in File.ReadLinesAsync(file.Path, ct).Index().WithCancellation(ct))
|
||||
{
|
||||
if (line.Contains(searchTerm, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
results.Add($"{file.Path} (Line {index + 1}): {line.Trim()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
8
src/SharpIDE.Godot/Features/Search/SearchWindow.cs
Normal file
8
src/SharpIDE.Godot/Features/Search/SearchWindow.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
|
||||
namespace SharpIDE.Godot.Features.Search;
|
||||
|
||||
public partial class SearchWindow : PopupPanel
|
||||
{
|
||||
|
||||
}
|
||||
1
src/SharpIDE.Godot/Features/Search/SearchWindow.cs.uid
Normal file
1
src/SharpIDE.Godot/Features/Search/SearchWindow.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bah6tmifl41ce
|
||||
45
src/SharpIDE.Godot/Features/Search/SearchWindow.tscn
Normal file
45
src/SharpIDE.Godot/Features/Search/SearchWindow.tscn
Normal file
@@ -0,0 +1,45 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://8lk0qj233a7p"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bah6tmifl41ce" path="res://Features/Search/SearchWindow.cs" id="1_ft33p"]
|
||||
|
||||
[node name="SearchWindow" type="PopupPanel"]
|
||||
oversampling_override = 1.0
|
||||
initial_position = 5
|
||||
size = Vector2i(1200, 800)
|
||||
visible = true
|
||||
script = ExtResource("1_ft33p")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = -4.0
|
||||
offset_bottom = -4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 5
|
||||
theme_override_constants/margin_top = 5
|
||||
theme_override_constants/margin_right = 5
|
||||
theme_override_constants/margin_bottom = 5
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 43.615)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Find in Files"
|
||||
|
||||
[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = " 30 matches in 5 files"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Test"
|
||||
@@ -7,6 +7,7 @@ using SharpIDE.Godot.Features.BottomPanel;
|
||||
using SharpIDE.Godot.Features.CodeEditor;
|
||||
using SharpIDE.Godot.Features.CustomControls;
|
||||
using SharpIDE.Godot.Features.Run;
|
||||
using SharpIDE.Godot.Features.Search;
|
||||
using SharpIDE.Godot.Features.SolutionExplorer;
|
||||
|
||||
namespace SharpIDE.Godot;
|
||||
@@ -16,6 +17,7 @@ public partial class IdeRoot : Control
|
||||
private Button _openSlnButton = null!;
|
||||
private Button _buildSlnButton = null!;
|
||||
private FileDialog _fileDialog = null!;
|
||||
private SearchWindow _searchWindow = null!;
|
||||
private CodeEditorPanel _codeEditorPanel = null!;
|
||||
private SolutionExplorerPanel _solutionExplorerPanel = null!;
|
||||
private InvertedVSplitContainer _invertedVSplitContainer = null!;
|
||||
@@ -35,6 +37,7 @@ public partial class IdeRoot : Control
|
||||
_runMenuButton = GetNode<Button>("%RunMenuButton");
|
||||
_codeEditorPanel = GetNode<CodeEditorPanel>("%CodeEditorPanel");
|
||||
_fileDialog = GetNode<FileDialog>("%OpenSolutionDialog");
|
||||
_searchWindow = GetNode<SearchWindow>("%SearchWindow");
|
||||
_solutionExplorerPanel = GetNode<SolutionExplorerPanel>("%SolutionExplorerPanel");
|
||||
_runPanel = GetNode<RunPanel>("%RunPanel");
|
||||
_invertedVSplitContainer = GetNode<InvertedVSplitContainer>("%InvertedVSplitContainer");
|
||||
@@ -103,4 +106,12 @@ public partial class IdeRoot : Control
|
||||
//await this.InvokeAsync(() => _runPanel.NewRunStarted(runnableProject));
|
||||
});
|
||||
}
|
||||
|
||||
public override void _UnhandledKeyInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed(InputStringNames.FindInFiles))
|
||||
{
|
||||
_searchWindow.Popup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://b2oniigcp5ew5"]
|
||||
[gd_scene load_steps=17 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"]
|
||||
@@ -12,6 +12,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://co6dkhdolriej" path="res://Features/Build/BuildPanel.tscn" id="9_rllbf"]
|
||||
[ext_resource type="PackedScene" uid="uid://tqpmww430cor" path="res://Features/Problems/ProblemsPanel.tscn" id="11_b7c1a"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkjips8oudqou" path="res://Features/Debug_/DebugPanel.tscn" id="11_s2dv6"]
|
||||
[ext_resource type="PackedScene" uid="uid://8lk0qj233a7p" path="res://Features/Search/SearchWindow.tscn" id="13_7ptyn"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_s2dv6"]
|
||||
default_font = ExtResource("1_7ptyn")
|
||||
@@ -165,3 +166,7 @@ file_mode = 0
|
||||
access = 2
|
||||
filters = PackedStringArray("*.sln", "*.slnx")
|
||||
use_native_dialog = true
|
||||
|
||||
[node name="SearchWindow" parent="." instance=ExtResource("13_7ptyn")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
||||
@@ -6,4 +6,5 @@ public static class InputStringNames
|
||||
{
|
||||
public static readonly StringName CodeFixes = "CodeFixes";
|
||||
public static readonly StringName StepOver = "StepOver";
|
||||
public static readonly StringName FindInFiles = nameof(FindInFiles);
|
||||
}
|
||||
Reference in New Issue
Block a user