Rename Pane to Tab
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using FileTime.Core.Providers;
|
using FileTime.Core.Providers;
|
||||||
|
|
||||||
namespace FileTime.App.Core.Pane
|
namespace FileTime.App.Core.Tab
|
||||||
{
|
{
|
||||||
public class PaneItem : IAbsolutePath
|
public class TabItem : IAbsolutePath
|
||||||
{
|
{
|
||||||
public IContentProvider ContentProvider { get; }
|
public IContentProvider ContentProvider { get; }
|
||||||
public string Path { get; }
|
public string Path { get; }
|
||||||
|
|
||||||
public PaneItem(IContentProvider contentProvider, string path)
|
public TabItem(IContentProvider contentProvider, string path)
|
||||||
{
|
{
|
||||||
ContentProvider = contentProvider;
|
ContentProvider = contentProvider;
|
||||||
Path = path;
|
Path = path;
|
||||||
@@ -2,30 +2,30 @@ using System.Collections.ObjectModel;
|
|||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using FileTime.Core.Providers;
|
using FileTime.Core.Providers;
|
||||||
|
|
||||||
namespace FileTime.App.Core.Pane
|
namespace FileTime.App.Core.Tab
|
||||||
{
|
{
|
||||||
public class PaneState
|
public class TabState
|
||||||
{
|
{
|
||||||
private readonly Dictionary<IContainer, List<PaneItem>> _selectedItems;
|
private readonly Dictionary<IContainer, List<TabItem>> _selectedItems;
|
||||||
private readonly Dictionary<IContainer, IReadOnlyList<PaneItem>> _selectedItemsReadOnly;
|
private readonly Dictionary<IContainer, IReadOnlyList<TabItem>> _selectedItemsReadOnly;
|
||||||
public IReadOnlyDictionary<IContainer, IReadOnlyList<PaneItem>> SelectedItems { get; }
|
public IReadOnlyDictionary<IContainer, IReadOnlyList<TabItem>> SelectedItems { get; }
|
||||||
|
|
||||||
public FileTime.Core.Components.Pane Pane { get; }
|
public FileTime.Core.Components.Tab Tab { get; }
|
||||||
|
|
||||||
public PaneState(FileTime.Core.Components.Pane pane)
|
public TabState(FileTime.Core.Components.Tab pane)
|
||||||
{
|
{
|
||||||
Pane = pane;
|
Tab = pane;
|
||||||
|
|
||||||
_selectedItems = new Dictionary<IContainer, List<PaneItem>>();
|
_selectedItems = new Dictionary<IContainer, List<TabItem>>();
|
||||||
_selectedItemsReadOnly = new Dictionary<IContainer, IReadOnlyList<PaneItem>>();
|
_selectedItemsReadOnly = new Dictionary<IContainer, IReadOnlyList<TabItem>>();
|
||||||
SelectedItems = new ReadOnlyDictionary<IContainer, IReadOnlyList<PaneItem>>(_selectedItemsReadOnly);
|
SelectedItems = new ReadOnlyDictionary<IContainer, IReadOnlyList<TabItem>>(_selectedItemsReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSelectedItem(IContentProvider contentProvider, IContainer container, string path)
|
public void AddSelectedItem(IContentProvider contentProvider, IContainer container, string path)
|
||||||
{
|
{
|
||||||
if (!_selectedItems.ContainsKey(container))
|
if (!_selectedItems.ContainsKey(container))
|
||||||
{
|
{
|
||||||
var val = new List<PaneItem>();
|
var val = new List<TabItem>();
|
||||||
_selectedItems.Add(container, val);
|
_selectedItems.Add(container, val);
|
||||||
_selectedItemsReadOnly.Add(container, val.AsReadOnly());
|
_selectedItemsReadOnly.Add(container, val.AsReadOnly());
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ namespace FileTime.App.Core.Pane
|
|||||||
if (content.ContentProvider == contentProvider && content.Path == path) return;
|
if (content.ContentProvider == contentProvider && content.Path == path) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedItems[container].Add(new PaneItem(contentProvider, path));
|
_selectedItems[container].Add(new TabItem(contentProvider, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSelectedItem(IContentProvider contentProvider, IContainer container, string path)
|
public void RemoveSelectedItem(IContentProvider contentProvider, IContainer container, string path)
|
||||||
@@ -65,9 +65,9 @@ namespace FileTime.App.Core.Pane
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyList<PaneItem> GetCurrentSelectedItems() =>
|
public IReadOnlyList<TabItem> GetCurrentSelectedItems() =>
|
||||||
SelectedItems.ContainsKey(Pane.CurrentLocation)
|
SelectedItems.ContainsKey(Tab.CurrentLocation)
|
||||||
? SelectedItems[Pane.CurrentLocation]
|
? SelectedItems[Tab.CurrentLocation]
|
||||||
: new List<PaneItem>().AsReadOnly();
|
: new List<TabItem>().AsReadOnly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,50 +6,50 @@ namespace FileTime.ConsoleUI.App
|
|||||||
{
|
{
|
||||||
public partial class Application
|
public partial class Application
|
||||||
{
|
{
|
||||||
private void ClosePane()
|
private void CloseTab()
|
||||||
{
|
{
|
||||||
var currentPaneIndex = _panes.IndexOf(_selectedPane!);
|
var currentTabIndex = _panes.IndexOf(_selectedTab!);
|
||||||
RemovePane(_selectedPane!);
|
RemoveTab(_selectedTab!);
|
||||||
|
|
||||||
if (_panes.Count > 0)
|
if (_panes.Count > 0)
|
||||||
{
|
{
|
||||||
_selectedPane = _panes[currentPaneIndex == 0 ? 0 : currentPaneIndex - 1];
|
_selectedTab = _panes[currentTabIndex == 0 ? 0 : currentTabIndex - 1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_selectedPane = null;
|
_selectedTab = null;
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveCursorUp() => _selectedPane!.SelectPreviousItem();
|
private void MoveCursorUp() => _selectedTab!.SelectPreviousItem();
|
||||||
private void MoveCursorDown() => _selectedPane!.SelectNextItem();
|
private void MoveCursorDown() => _selectedTab!.SelectNextItem();
|
||||||
private void GoUp() => _selectedPane!.GoUp();
|
private void GoUp() => _selectedTab!.GoUp();
|
||||||
private void Open() => _selectedPane!.Open();
|
private void Open() => _selectedTab!.Open();
|
||||||
|
|
||||||
private void MoveCursorUpPage() => _selectedPane!.SelectPreviousItem(_renderers[_selectedPane].PageSize);
|
private void MoveCursorUpPage() => _selectedTab!.SelectPreviousItem(_renderers[_selectedTab].PageSize);
|
||||||
private void MoveCursorDownPage() => _selectedPane!.SelectNextItem(_renderers[_selectedPane].PageSize);
|
private void MoveCursorDownPage() => _selectedTab!.SelectNextItem(_renderers[_selectedTab].PageSize);
|
||||||
private void MoveCursorToTop() => _selectedPane!.SelectFirstItem();
|
private void MoveCursorToTop() => _selectedTab!.SelectFirstItem();
|
||||||
private void MoveCursorToBottom() => _selectedPane!.SelectLastItem();
|
private void MoveCursorToBottom() => _selectedTab!.SelectLastItem();
|
||||||
|
|
||||||
private void ToggleHidden()
|
private void ToggleHidden()
|
||||||
{
|
{
|
||||||
const string hiddenFilterName = "filter_showhiddenelements";
|
const string hiddenFilterName = "filter_showhiddenelements";
|
||||||
|
|
||||||
IContainer containerToOpen = _selectedPane!.CurrentLocation;
|
IContainer containerToOpen = _selectedTab!.CurrentLocation;
|
||||||
|
|
||||||
if (_selectedPane.CurrentLocation is VirtualContainer oldVirtualContainer)
|
if (_selectedTab.CurrentLocation is VirtualContainer oldVirtualContainer)
|
||||||
{
|
{
|
||||||
containerToOpen = oldVirtualContainer.HasWithName(hiddenFilterName)
|
containerToOpen = oldVirtualContainer.HasWithName(hiddenFilterName)
|
||||||
? oldVirtualContainer.ExceptWithName(hiddenFilterName)
|
? oldVirtualContainer.ExceptWithName(hiddenFilterName)
|
||||||
: GenerateHiddenFilterVirtualContainer(_selectedPane.CurrentLocation);
|
: GenerateHiddenFilterVirtualContainer(_selectedTab.CurrentLocation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
containerToOpen = GenerateHiddenFilterVirtualContainer(_selectedPane.CurrentLocation);
|
containerToOpen = GenerateHiddenFilterVirtualContainer(_selectedTab.CurrentLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedPane.OpenContainer(containerToOpen);
|
_selectedTab.OpenContainer(containerToOpen);
|
||||||
|
|
||||||
static VirtualContainer GenerateHiddenFilterVirtualContainer(IContainer container)
|
static VirtualContainer GenerateHiddenFilterVirtualContainer(IContainer container)
|
||||||
{
|
{
|
||||||
@@ -72,19 +72,19 @@ namespace FileTime.ConsoleUI.App
|
|||||||
|
|
||||||
public void Select()
|
public void Select()
|
||||||
{
|
{
|
||||||
if (_selectedPane!.CurrentSelectedItem != null)
|
if (_selectedTab!.CurrentSelectedItem != null)
|
||||||
{
|
{
|
||||||
var currentSelectedItem = _selectedPane.CurrentSelectedItem;
|
var currentSelectedItem = _selectedTab.CurrentSelectedItem;
|
||||||
if (_paneStates[_selectedPane].ContainsSelectedItem(currentSelectedItem.Provider, _selectedPane.CurrentLocation, currentSelectedItem.FullName!))
|
if (_paneStates[_selectedTab].ContainsSelectedItem(currentSelectedItem.Provider, _selectedTab.CurrentLocation, currentSelectedItem.FullName!))
|
||||||
{
|
{
|
||||||
_paneStates[_selectedPane].RemoveSelectedItem(currentSelectedItem.Provider, _selectedPane.CurrentLocation, currentSelectedItem.FullName!);
|
_paneStates[_selectedTab].RemoveSelectedItem(currentSelectedItem.Provider, _selectedTab.CurrentLocation, currentSelectedItem.FullName!);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_paneStates[_selectedPane].AddSelectedItem(currentSelectedItem.Provider, _selectedPane.CurrentLocation, currentSelectedItem.FullName!);
|
_paneStates[_selectedTab].AddSelectedItem(currentSelectedItem.Provider, _selectedTab.CurrentLocation, currentSelectedItem.FullName!);
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedPane.SelectNextItem();
|
_selectedTab.SelectNextItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,16 +93,16 @@ namespace FileTime.ConsoleUI.App
|
|||||||
_clipboard.Clear();
|
_clipboard.Clear();
|
||||||
_clipboard.SetCommand<CopyCommand>();
|
_clipboard.SetCommand<CopyCommand>();
|
||||||
|
|
||||||
if (_paneStates[_selectedPane!].GetCurrentSelectedItems().Count > 0)
|
if (_paneStates[_selectedTab!].GetCurrentSelectedItems().Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var selectedItem in _paneStates[_selectedPane!].GetCurrentSelectedItems())
|
foreach (var selectedItem in _paneStates[_selectedTab!].GetCurrentSelectedItems())
|
||||||
{
|
{
|
||||||
_clipboard.AddContent(selectedItem.ContentProvider, selectedItem.Path);
|
_clipboard.AddContent(selectedItem.ContentProvider, selectedItem.Path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_clipboard.AddContent(_selectedPane!.CurrentSelectedItem!.Provider, _selectedPane.CurrentSelectedItem.FullName!);
|
_clipboard.AddContent(_selectedTab!.CurrentSelectedItem!.Provider, _selectedTab.CurrentSelectedItem.FullName!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,9 +140,9 @@ namespace FileTime.ConsoleUI.App
|
|||||||
command.Sources.Add(item);
|
command.Sources.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
command.Target = _selectedPane.CurrentLocation is VirtualContainer virtualContainer
|
command.Target = _selectedTab.CurrentLocation is VirtualContainer virtualContainer
|
||||||
? virtualContainer.BaseContainer
|
? virtualContainer.BaseContainer
|
||||||
: _selectedPane.CurrentLocation;
|
: _selectedTab.CurrentLocation;
|
||||||
|
|
||||||
_commandExecutor.ExecuteCommand(command);
|
_commandExecutor.ExecuteCommand(command);
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ namespace FileTime.ConsoleUI.App
|
|||||||
|
|
||||||
private void CreateContainer()
|
private void CreateContainer()
|
||||||
{
|
{
|
||||||
if (_selectedPane?.CurrentLocation != null)
|
if (_selectedTab?.CurrentLocation != null)
|
||||||
{
|
{
|
||||||
_coloredConsoleRenderer.ResetColor();
|
_coloredConsoleRenderer.ResetColor();
|
||||||
MoveToIOLine(2);
|
MoveToIOLine(2);
|
||||||
@@ -161,13 +161,13 @@ namespace FileTime.ConsoleUI.App
|
|||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(newContainerName))
|
if (!string.IsNullOrWhiteSpace(newContainerName))
|
||||||
{
|
{
|
||||||
_selectedPane.CurrentLocation.CreateContainer(newContainerName);
|
_selectedTab.CurrentLocation.CreateContainer(newContainerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Validator(string newPath)
|
void Validator(string newPath)
|
||||||
{
|
{
|
||||||
if (_selectedPane!.CurrentLocation.IsExists(newPath))
|
if (_selectedTab!.CurrentLocation.IsExists(newPath))
|
||||||
{
|
{
|
||||||
_coloredConsoleRenderer.ForegroundColor = _styles.ErrorColor;
|
_coloredConsoleRenderer.ForegroundColor = _styles.ErrorColor;
|
||||||
}
|
}
|
||||||
@@ -182,12 +182,12 @@ namespace FileTime.ConsoleUI.App
|
|||||||
{
|
{
|
||||||
IList<IAbsolutePath> itemsToDelete = null;
|
IList<IAbsolutePath> itemsToDelete = null;
|
||||||
|
|
||||||
if (_paneStates[_selectedPane!].GetCurrentSelectedItems().Count > 0)
|
if (_paneStates[_selectedTab!].GetCurrentSelectedItems().Count > 0)
|
||||||
{
|
{
|
||||||
var delete = true;
|
var delete = true;
|
||||||
|
|
||||||
if (_paneStates[_selectedPane!].GetCurrentSelectedItems().Count == 1
|
if (_paneStates[_selectedTab!].GetCurrentSelectedItems().Count == 1
|
||||||
&& _paneStates[_selectedPane!].GetCurrentSelectedItems()[0] is IContainer container
|
&& _paneStates[_selectedTab!].GetCurrentSelectedItems()[0] is IContainer container
|
||||||
&& container.Items.Count > 0)
|
&& container.Items.Count > 0)
|
||||||
{
|
{
|
||||||
delete = AskForApprove($"The container '{container.Name}' is not empty.");
|
delete = AskForApprove($"The container '{container.Name}' is not empty.");
|
||||||
@@ -195,13 +195,13 @@ namespace FileTime.ConsoleUI.App
|
|||||||
|
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
itemsToDelete = _paneStates[_selectedPane].GetCurrentSelectedItems().Cast<IAbsolutePath>().ToList();
|
itemsToDelete = _paneStates[_selectedTab].GetCurrentSelectedItems().Cast<IAbsolutePath>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_selectedPane?.CurrentSelectedItem != null)
|
else if (_selectedTab?.CurrentSelectedItem != null)
|
||||||
{
|
{
|
||||||
bool delete = true;
|
bool delete = true;
|
||||||
if (_selectedPane?.CurrentSelectedItem is IContainer container && container.Items.Count > 0)
|
if (_selectedTab?.CurrentSelectedItem is IContainer container && container.Items.Count > 0)
|
||||||
{
|
{
|
||||||
delete = AskForApprove($"The container '{container.Name}' is not empty.");
|
delete = AskForApprove($"The container '{container.Name}' is not empty.");
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ namespace FileTime.ConsoleUI.App
|
|||||||
{
|
{
|
||||||
itemsToDelete = new List<IAbsolutePath>()
|
itemsToDelete = new List<IAbsolutePath>()
|
||||||
{
|
{
|
||||||
new AbsolutePath(_selectedPane.CurrentSelectedItem.Provider, _selectedPane.CurrentSelectedItem.FullName!)
|
new AbsolutePath(_selectedTab.CurrentSelectedItem.Provider, _selectedTab.CurrentSelectedItem.FullName!)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using FileTime.Core.Extensions;
|
|||||||
using FileTime.App.Core.Clipboard;
|
using FileTime.App.Core.Clipboard;
|
||||||
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using FileTime.App.Core.Pane;
|
using FileTime.App.Core.Tab;
|
||||||
using FileTime.ConsoleUI.App.UI.Color;
|
using FileTime.ConsoleUI.App.UI.Color;
|
||||||
using FileTime.Core.Command;
|
using FileTime.Core.Command;
|
||||||
|
|
||||||
@@ -14,10 +14,10 @@ namespace FileTime.ConsoleUI.App
|
|||||||
{
|
{
|
||||||
public partial class Application
|
public partial class Application
|
||||||
{
|
{
|
||||||
private readonly List<Pane> _panes = new();
|
private readonly List<Tab> _panes = new();
|
||||||
private readonly Dictionary<Pane, Render> _renderers = new();
|
private readonly Dictionary<Tab, Render> _renderers = new();
|
||||||
private readonly Dictionary<Pane, PaneState> _paneStates = new();
|
private readonly Dictionary<Tab, TabState> _paneStates = new();
|
||||||
private Pane? _selectedPane;
|
private Tab? _selectedTab;
|
||||||
|
|
||||||
private readonly List<CommandBinding> _commandBindings = new();
|
private readonly List<CommandBinding> _commandBindings = new();
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
@@ -49,15 +49,15 @@ namespace FileTime.ConsoleUI.App
|
|||||||
|
|
||||||
public void SetContainer(IContainer currentPath)
|
public void SetContainer(IContainer currentPath)
|
||||||
{
|
{
|
||||||
_selectedPane = CreatePane(currentPath);
|
_selectedTab = CreateTab(currentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pane CreatePane(IContainer container)
|
private Tab CreateTab(IContainer container)
|
||||||
{
|
{
|
||||||
var pane = new Pane(container);
|
var pane = new Tab(container);
|
||||||
_panes.Add(pane);
|
_panes.Add(pane);
|
||||||
|
|
||||||
var paneState = new PaneState(pane);
|
var paneState = new TabState(pane);
|
||||||
_paneStates.Add(pane, paneState);
|
_paneStates.Add(pane, paneState);
|
||||||
|
|
||||||
var renderer = _serviceProvider.GetService<Render>()!;
|
var renderer = _serviceProvider.GetService<Render>()!;
|
||||||
@@ -67,7 +67,7 @@ namespace FileTime.ConsoleUI.App
|
|||||||
return pane;
|
return pane;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemovePane(Pane pane)
|
private void RemoveTab(Tab pane)
|
||||||
{
|
{
|
||||||
_panes.Remove(pane);
|
_panes.Remove(pane);
|
||||||
_renderers.Remove(pane);
|
_renderers.Remove(pane);
|
||||||
@@ -78,7 +78,7 @@ namespace FileTime.ConsoleUI.App
|
|||||||
{
|
{
|
||||||
var commandBindings = new List<CommandBinding>()
|
var commandBindings = new List<CommandBinding>()
|
||||||
{
|
{
|
||||||
new CommandBinding("close pane", Commands.ClosePane, new[] { new ConsoleKeyInfo('q', ConsoleKey.Q, false, false, false) }, ClosePane),
|
new CommandBinding("close pane", Commands.CloseTab, new[] { new ConsoleKeyInfo('q', ConsoleKey.Q, false, false, false) }, CloseTab),
|
||||||
new CommandBinding("cursor up", Commands.MoveCursorUp, new[] { new ConsoleKeyInfo('↑', ConsoleKey.UpArrow, false, false, false) }, MoveCursorUp),
|
new CommandBinding("cursor up", Commands.MoveCursorUp, new[] { new ConsoleKeyInfo('↑', ConsoleKey.UpArrow, false, false, false) }, MoveCursorUp),
|
||||||
new CommandBinding("cursor down", Commands.MoveCursorDown, new[] { new ConsoleKeyInfo('↓', ConsoleKey.DownArrow, false, false, false) }, MoveCursorDown),
|
new CommandBinding("cursor down", Commands.MoveCursorDown, new[] { new ConsoleKeyInfo('↓', ConsoleKey.DownArrow, false, false, false) }, MoveCursorDown),
|
||||||
new CommandBinding("cursor page up", Commands.MoveCursorUpPage, new[] { new ConsoleKeyInfo(' ', ConsoleKey.PageUp, false, false, false) }, MoveCursorUpPage),
|
new CommandBinding("cursor page up", Commands.MoveCursorUpPage, new[] { new ConsoleKeyInfo(' ', ConsoleKey.PageUp, false, false, false) }, MoveCursorUpPage),
|
||||||
@@ -182,9 +182,9 @@ namespace FileTime.ConsoleUI.App
|
|||||||
|
|
||||||
public void PrintUI()
|
public void PrintUI()
|
||||||
{
|
{
|
||||||
if (_selectedPane != null)
|
if (_selectedTab != null)
|
||||||
{
|
{
|
||||||
_renderers[_selectedPane].PrintUI();
|
_renderers[_selectedTab].PrintUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ namespace FileTime.ConsoleUI.App.Command
|
|||||||
{
|
{
|
||||||
public enum Commands
|
public enum Commands
|
||||||
{
|
{
|
||||||
ClosePane,
|
CloseTab,
|
||||||
Copy,
|
Copy,
|
||||||
Cut,
|
Cut,
|
||||||
GoUp,
|
GoUp,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using FileTime.App.Core.Pane;
|
using FileTime.App.Core.Tab;
|
||||||
using FileTime.ConsoleUI.App.UI.Color;
|
using FileTime.ConsoleUI.App.UI.Color;
|
||||||
using FileTime.ConsoleUI.UI.App;
|
using FileTime.ConsoleUI.UI.App;
|
||||||
using FileTime.Core.Components;
|
using FileTime.Core.Components;
|
||||||
@@ -23,8 +23,8 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
private readonly string _paddingLeft;
|
private readonly string _paddingLeft;
|
||||||
private readonly string _paddingRight;
|
private readonly string _paddingRight;
|
||||||
|
|
||||||
public Pane Pane { get; private set; }
|
public Tab Tab { get; private set; }
|
||||||
public PaneState PaneState { get; private set; }
|
public TabState TabState { get; private set; }
|
||||||
|
|
||||||
public int PageSize => Console.WindowHeight - _contentPaddingTop - _contentPaddingBottom;
|
public int PageSize => Console.WindowHeight - _contentPaddingTop - _contentPaddingBottom;
|
||||||
public Render(IColoredConsoleRenderer coloredRenderer, IStyles appStyle)
|
public Render(IColoredConsoleRenderer coloredRenderer, IStyles appStyle)
|
||||||
@@ -37,34 +37,34 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
_contentRowCount = Console.WindowHeight - _contentPaddingTop - _contentPaddingBottom;
|
_contentRowCount = Console.WindowHeight - _contentPaddingTop - _contentPaddingBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(Pane pane, PaneState paneState)
|
public void Init(Tab pane, TabState paneState)
|
||||||
{
|
{
|
||||||
if (pane == null) throw new Exception($"{nameof(pane)} can not be null");
|
if (pane == null) throw new Exception($"{nameof(pane)} can not be null");
|
||||||
if (paneState == null) throw new Exception($"{nameof(paneState)} can not be null");
|
if (paneState == null) throw new Exception($"{nameof(paneState)} can not be null");
|
||||||
|
|
||||||
Pane = pane;
|
Tab = pane;
|
||||||
Pane.CurrentLocationChanged += (o, e) => _currentDisplayStartY = 0;
|
Tab.CurrentLocationChanged += (o, e) => _currentDisplayStartY = 0;
|
||||||
|
|
||||||
PaneState = paneState;
|
TabState = paneState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrintUI()
|
public void PrintUI()
|
||||||
{
|
{
|
||||||
if (Pane != null)
|
if (Tab != null)
|
||||||
{
|
{
|
||||||
PrintPrompt();
|
PrintPrompt();
|
||||||
PrintPanes();
|
PrintTabs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrintPanes()
|
private void PrintTabs()
|
||||||
{
|
{
|
||||||
var previousColumnWidth = (int)Math.Floor(Console.WindowWidth * 0.15) - 1;
|
var previousColumnWidth = (int)Math.Floor(Console.WindowWidth * 0.15) - 1;
|
||||||
var currentColumnWidth = (int)Math.Floor(Console.WindowWidth * 0.4) - 1;
|
var currentColumnWidth = (int)Math.Floor(Console.WindowWidth * 0.4) - 1;
|
||||||
var nextColumnWidth = Console.WindowWidth - currentColumnWidth - previousColumnWidth - 2;
|
var nextColumnWidth = Console.WindowWidth - currentColumnWidth - previousColumnWidth - 2;
|
||||||
var currentVirtualContainer = Pane!.CurrentLocation as VirtualContainer;
|
var currentVirtualContainer = Tab!.CurrentLocation as VirtualContainer;
|
||||||
|
|
||||||
if (Pane.CurrentLocation.GetParent() is var parentContainer && parentContainer is not null)
|
if (Tab.CurrentLocation.GetParent() is var parentContainer && parentContainer is not null)
|
||||||
{
|
{
|
||||||
parentContainer.Refresh();
|
parentContainer.Refresh();
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
: parentContainer,
|
: parentContainer,
|
||||||
currentVirtualContainer != null
|
currentVirtualContainer != null
|
||||||
? currentVirtualContainer.GetRealContainer()
|
? currentVirtualContainer.GetRealContainer()
|
||||||
: Pane.CurrentLocation,
|
: Tab.CurrentLocation,
|
||||||
PrintMode.Previous,
|
PrintMode.Previous,
|
||||||
0,
|
0,
|
||||||
_contentPaddingTop,
|
_contentPaddingTop,
|
||||||
@@ -90,19 +90,19 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
_contentRowCount);
|
_contentRowCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pane.CurrentLocation.Refresh();
|
Tab.CurrentLocation.Refresh();
|
||||||
|
|
||||||
CheckAndSetCurrentDisplayStartY();
|
CheckAndSetCurrentDisplayStartY();
|
||||||
PrintColumn(
|
PrintColumn(
|
||||||
Pane.CurrentLocation,
|
Tab.CurrentLocation,
|
||||||
Pane.CurrentSelectedItem,
|
Tab.CurrentSelectedItem,
|
||||||
PrintMode.Current,
|
PrintMode.Current,
|
||||||
previousColumnWidth + 1,
|
previousColumnWidth + 1,
|
||||||
_contentPaddingTop,
|
_contentPaddingTop,
|
||||||
currentColumnWidth,
|
currentColumnWidth,
|
||||||
_contentRowCount);
|
_contentRowCount);
|
||||||
|
|
||||||
if (Pane.CurrentSelectedItem is IContainer selectedContainer)
|
if (Tab.CurrentSelectedItem is IContainer selectedContainer)
|
||||||
{
|
{
|
||||||
selectedContainer.Refresh();
|
selectedContainer.Refresh();
|
||||||
|
|
||||||
@@ -140,13 +140,13 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
_coloredRenderer.Write(' ');
|
_coloredRenderer.Write(' ');
|
||||||
|
|
||||||
_coloredRenderer.ForegroundColor = _appStyle.ContainerForeground;
|
_coloredRenderer.ForegroundColor = _appStyle.ContainerForeground;
|
||||||
var path = Pane!.CurrentLocation.FullName + "/";
|
var path = Tab!.CurrentLocation.FullName + "/";
|
||||||
_coloredRenderer.Write(path);
|
_coloredRenderer.Write(path);
|
||||||
|
|
||||||
if (Pane.CurrentSelectedItem?.Name != null)
|
if (Tab.CurrentSelectedItem?.Name != null)
|
||||||
{
|
{
|
||||||
_coloredRenderer.ResetColor();
|
_coloredRenderer.ResetColor();
|
||||||
_coloredRenderer.Write($"{{0,-{300 - path.Length}}}", Pane.CurrentSelectedItem.Name);
|
_coloredRenderer.Write($"{{0,-{300 - path.Length}}}", Tab.CurrentSelectedItem.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isSelected = PaneState.ContainsSelectedItem(item.Provider, currentContainer, item.FullName!);
|
var isSelected = TabState.ContainsSelectedItem(item.Provider, currentContainer, item.FullName!);
|
||||||
if (isSelected)
|
if (isSelected)
|
||||||
{
|
{
|
||||||
backgroundColor = _appStyle.SelectedItemBackground;
|
backgroundColor = _appStyle.SelectedItemBackground;
|
||||||
@@ -266,14 +266,14 @@ namespace FileTime.ConsoleUI.App.UI
|
|||||||
{
|
{
|
||||||
const int padding = 5;
|
const int padding = 5;
|
||||||
|
|
||||||
while (Pane.CurrentSelectedIndex < _currentDisplayStartY + padding
|
while (Tab.CurrentSelectedIndex < _currentDisplayStartY + padding
|
||||||
&& _currentDisplayStartY > 0)
|
&& _currentDisplayStartY > 0)
|
||||||
{
|
{
|
||||||
_currentDisplayStartY--;
|
_currentDisplayStartY--;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Pane.CurrentSelectedIndex > _currentDisplayStartY + _contentRowCount - padding
|
while (Tab.CurrentSelectedIndex > _currentDisplayStartY + _contentRowCount - padding
|
||||||
&& _currentDisplayStartY < Pane.CurrentLocation.Items.Count - _contentRowCount)
|
&& _currentDisplayStartY < Tab.CurrentLocation.Items.Count - _contentRowCount)
|
||||||
{
|
{
|
||||||
_currentDisplayStartY++;
|
_currentDisplayStartY++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using FileTime.Core.Models;
|
|||||||
|
|
||||||
namespace FileTime.Core.Components
|
namespace FileTime.Core.Components
|
||||||
{
|
{
|
||||||
public class Pane
|
public class Tab
|
||||||
{
|
{
|
||||||
private IItem? currentSelectedItem;
|
private IItem? currentSelectedItem;
|
||||||
private IContainer currentLocation;
|
private IContainer currentLocation;
|
||||||
@@ -42,7 +42,7 @@ namespace FileTime.Core.Components
|
|||||||
|
|
||||||
public event EventHandler CurrentLocationChanged;
|
public event EventHandler CurrentLocationChanged;
|
||||||
|
|
||||||
public Pane(IContainer currentPath)
|
public Tab(IContainer currentPath)
|
||||||
{
|
{
|
||||||
CurrentLocation = currentPath;
|
CurrentLocation = currentPath;
|
||||||
CurrentSelectedItem = CurrentLocation.Items.Count > 0 ? CurrentLocation.Items[0] : null;
|
CurrentSelectedItem = CurrentLocation.Items.Count > 0 ? CurrentLocation.Items[0] : null;
|
||||||
Reference in New Issue
Block a user