Search by regex, modal Enter fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.Core.Models;
|
||||
|
||||
namespace FileTime.App.Core.Services;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class ItemNameConverterService : IItemNameConverterService
|
||||
{
|
||||
var nameLeft = name;
|
||||
|
||||
while (nameLeft.ToLower().IndexOf(searchText, StringComparison.Ordinal) is int rapidTextStart && rapidTextStart != -1)
|
||||
while (nameLeft.ToLower().IndexOf(searchText, StringComparison.Ordinal) is var rapidTextStart && rapidTextStart != -1)
|
||||
{
|
||||
var before = rapidTextStart > 0 ? nameLeft.Substring(0, rapidTextStart) : null;
|
||||
var rapidTravel = nameLeft.Substring(rapidTextStart, searchText.Length);
|
||||
|
||||
@@ -310,13 +310,13 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
|
||||
private Task EnterRapidTravel()
|
||||
{
|
||||
_appState.SwitchViewMode(ViewMode.RapidTravel);
|
||||
_appState.SwitchViewModeAsync(ViewMode.RapidTravel);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ExitRapidTravel()
|
||||
{
|
||||
_appState.SwitchViewMode(ViewMode.Default);
|
||||
_appState.SwitchViewModeAsync(ViewMode.Default);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,10 +106,10 @@ public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
//TODO proper error message
|
||||
if (string.IsNullOrWhiteSpace(searchQuery)) return;
|
||||
|
||||
var searchMatcher = searchCommand.SearchType switch
|
||||
ISearchMatcher searchMatcher = searchCommand.SearchType switch
|
||||
{
|
||||
SearchType.NameContains => new NameContainsMatcher(_itemNameConverterService, searchQuery),
|
||||
//SearchType.NameRegex => new NameRegexMatcher(searchQuery),
|
||||
SearchType.NameRegex => new RegexMatcher(searchQuery),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
||||
AddUserCommand(SortItemsCommand.OrderByDateCommand);
|
||||
AddUserCommand(SortItemsCommand.OrderByDateDescCommand);
|
||||
AddUserCommand(IdentifiableSearchCommand.SearchByNameContains);
|
||||
AddUserCommand(IdentifiableSearchCommand.SearchByRegex);
|
||||
AddUserCommand(SwitchToTabCommand.SwitchToLastTab);
|
||||
AddUserCommand(SwitchToTabCommand.SwitchToTab1);
|
||||
AddUserCommand(SwitchToTabCommand.SwitchToTab2);
|
||||
|
||||
@@ -16,10 +16,10 @@ public abstract partial class AppStateBase : IAppState
|
||||
{
|
||||
private readonly BehaviorSubject<string?> _searchText = new(null);
|
||||
private readonly BehaviorSubject<ITabViewModel?> _selectedTab = new(null);
|
||||
private readonly BehaviorSubject<ViewMode> _viewMode = new(Models.Enums.ViewMode.Default);
|
||||
private readonly DeclarativeProperty<ViewMode> _viewMode = new(Models.Enums.ViewMode.Default);
|
||||
private readonly SourceList<ITabViewModel> _tabs = new();
|
||||
|
||||
public IObservable<ViewMode> ViewMode { get; private set; }
|
||||
public IDeclarativeProperty<ViewMode> ViewMode { get; private set; }
|
||||
|
||||
public ReadOnlyObservableCollection<ITabViewModel> Tabs { get; private set; }
|
||||
public IObservable<string?> SearchText { get; private set; }
|
||||
@@ -31,7 +31,7 @@ public abstract partial class AppStateBase : IAppState
|
||||
partial void OnInitialize()
|
||||
{
|
||||
RapidTravelText = new("");
|
||||
ViewMode = _viewMode.AsObservable();
|
||||
ViewMode = _viewMode;
|
||||
|
||||
var tabsObservable = _tabs.Connect();
|
||||
|
||||
@@ -70,10 +70,7 @@ public abstract partial class AppStateBase : IAppState
|
||||
|
||||
public void SetSearchText(string? searchText) => _searchText.OnNext(searchText);
|
||||
|
||||
public void SwitchViewMode(ViewMode newViewMode)
|
||||
{
|
||||
_viewMode.OnNext(newViewMode);
|
||||
}
|
||||
public async Task SwitchViewModeAsync(ViewMode newViewMode) => await _viewMode.SetValue(newViewMode);
|
||||
|
||||
public void SetSelectedTab(ITabViewModel tabToSelect) => _selectedTab.OnNext(tabToSelect);
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ public partial class ContainerSizeContainerViewModel : ItemViewModel, IContainer
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(IContainer item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
public void Init(IContainer item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
=> Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
@@ -17,8 +17,6 @@ public partial class ElementViewModel : ItemViewModel, IElementViewModel
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(IElement item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
public void Init(IElement item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
=> Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
@@ -96,6 +96,7 @@ public partial class ElementPreviewViewModel : IItemPreviewViewModel, IAsyncInit
|
||||
var encodingsWithPartialResult = binaryCharacter.Where(e => !string.IsNullOrWhiteSpace(e.Value.PartialResult)).ToList();
|
||||
if (encodingsWithPartialResult.Count > 0)
|
||||
{
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.AppendLine("The following partial texts could be read by encodings:");
|
||||
foreach (var binaryByEncoding in encodingsWithPartialResult)
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@ using System.ComponentModel;
|
||||
using System.Reactive.Linq;
|
||||
using DeclarativeProperty;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Behaviors;
|
||||
using FileTime.Core.Helper;
|
||||
using FileTime.Core.Models;
|
||||
using MoreLinq;
|
||||
@@ -37,7 +37,10 @@ public abstract partial class ItemViewModel : IItemViewModel
|
||||
|
||||
public IDeclarativeProperty<IReadOnlyList<ItemNamePart>>? DisplayName { get; private set; }
|
||||
|
||||
public void Init(IItem item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
public void Init(
|
||||
IItem item,
|
||||
ITabViewModel parentTab,
|
||||
ItemViewModelType itemViewModelType)
|
||||
{
|
||||
_parentTab = parentTab;
|
||||
|
||||
@@ -51,7 +54,12 @@ public abstract partial class ItemViewModel : IItemViewModel
|
||||
|
||||
var displayName = itemViewModelType switch
|
||||
{
|
||||
ItemViewModelType.Main => _appState.RapidTravelText.Map(s => (IReadOnlyList<ItemNamePart>) _itemNameConverterService.GetDisplayName(item.DisplayName, s)),
|
||||
ItemViewModelType.Main => _appState.RapidTravelText.Map(async (s, _) =>
|
||||
_appState.ViewMode.Value != Models.Enums.ViewMode.RapidTravel
|
||||
&& _appState.CurrentSelectedTab?.CurrentLocation.Value?.Provider is IItemNameConverterProvider nameConverterProvider
|
||||
? (IReadOnlyList<ItemNamePart>) await nameConverterProvider.GetItemNamePartsAsync(item)
|
||||
: _itemNameConverterService.GetDisplayName(item.DisplayName, s)
|
||||
),
|
||||
_ => new DeclarativeProperty<IReadOnlyList<ItemNamePart>>(new List<ItemNamePart> {new(item.DisplayName)}),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user