mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-04 18:44:59 +00:00
feature: supports searching revision files (#775)
This commit is contained in:
parent
536f225867
commit
894f3e9b03
10 changed files with 350 additions and 15 deletions
|
@ -3,6 +3,7 @@ using System;
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
|
||||
|
@ -118,5 +119,85 @@ namespace SourceGit.Views
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnSearchBoxKeyDown(object _, KeyEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ViewModels.CommitDetail;
|
||||
if (vm == null)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
FileTree.SetSearchResult(vm.RevisionFileSearchFilter);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Down || e.Key == Key.Up)
|
||||
{
|
||||
if (vm.IsRevisionFileSearchSuggestionOpen)
|
||||
{
|
||||
SearchSuggestionBox.Focus(NavigationMethod.Tab);
|
||||
SearchSuggestionBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
if (vm.IsRevisionFileSearchSuggestionOpen)
|
||||
{
|
||||
vm.RevisionFileSearchSuggestion.Clear();
|
||||
vm.IsRevisionFileSearchSuggestionOpen = false;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchBoxTextChanged(object _, TextChangedEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ViewModels.CommitDetail;
|
||||
if (vm == null)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(vm.RevisionFileSearchFilter))
|
||||
FileTree.SetSearchResult(null);
|
||||
}
|
||||
|
||||
private void OnSearchSuggestionBoxKeyDown(object _, KeyEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ViewModels.CommitDetail;
|
||||
if (vm == null)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
vm.RevisionFileSearchSuggestion.Clear();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Enter && SearchSuggestionBox.SelectedItem is string content)
|
||||
{
|
||||
vm.RevisionFileSearchFilter = content;
|
||||
TxtSearchRevisionFiles.CaretIndex = content.Length;
|
||||
FileTree.SetSearchResult(vm.RevisionFileSearchFilter);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchSuggestionDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ViewModels.CommitDetail;
|
||||
if (vm == null)
|
||||
return;
|
||||
|
||||
var content = (sender as StackPanel)?.DataContext as string;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
vm.RevisionFileSearchFilter = content;
|
||||
TxtSearchRevisionFiles.CaretIndex = content.Length;
|
||||
FileTree.SetSearchResult(vm.RevisionFileSearchFilter);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue