diff --git a/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs b/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs index c38015f6..bea80c99 100644 --- a/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs +++ b/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs @@ -38,9 +38,6 @@ public ICollection GetDefaultKeyBindings(Command command) new KeyBinding { Command = nameof(Command.ToggleWindow), - Ctrl = false, - Alt = false, - Shift = false, Key = (int)ExtendedVirtualKey.Scroll } }; @@ -52,8 +49,6 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.NextTab), Ctrl = true, - Alt = false, - Shift = false, Key = (int)ExtendedVirtualKey.Tab } }; @@ -65,7 +60,6 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.PreviousTab), Ctrl = true, - Alt = false, Shift = true, Key = (int)ExtendedVirtualKey.Tab } @@ -85,9 +79,7 @@ public ICollection GetDefaultKeyBindings(Command command) new KeyBinding { Command = command.ToString(), - Ctrl = true, - Alt = false, - Shift = false, + Alt = true, Key = (int)ExtendedVirtualKey.Number1 + (command - Command.SwitchToTerm1) } }; @@ -99,8 +91,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.NewTab), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.T } }; @@ -112,8 +103,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.ConfigurableNewTab), Ctrl = true, - Alt = false, - Shift = true, + Alt = true, Key = (int)ExtendedVirtualKey.T } }; @@ -138,7 +128,6 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.ChangeTabTitle), Ctrl = true, - Alt = false, Shift = true, Key = (int)ExtendedVirtualKey.R } @@ -151,8 +140,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.CloseTab), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.W } }; @@ -164,8 +152,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.NewWindow), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.N } }; @@ -177,8 +164,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.ConfigurableNewWindow), Ctrl = true, - Alt = false, - Shift = true, + Alt = true, Key = (int)ExtendedVirtualKey.N } }; @@ -190,8 +176,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.ShowSettings), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.Comma } }; @@ -203,8 +188,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.Copy), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.C } }; @@ -216,8 +200,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.Paste), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.V } }; @@ -230,8 +213,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.PasteWithoutNewlines), Ctrl = true, - Alt = false, - Shift = true, + Alt = true, Key = (int)ExtendedVirtualKey.V } }; @@ -243,8 +225,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.Search), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.F } }; @@ -255,9 +236,7 @@ public ICollection GetDefaultKeyBindings(Command command) new KeyBinding { Command = nameof(Command.ToggleFullScreen), - Ctrl = false, Alt = true, - Shift = false, Key = (int)ExtendedVirtualKey.Enter } }; @@ -269,8 +248,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.SelectAll), Ctrl = true, - Alt = false, - Shift = false, + Shift = true, Key = (int)ExtendedVirtualKey.A } }; @@ -282,8 +260,7 @@ public ICollection GetDefaultKeyBindings(Command command) { Command = nameof(Command.Clear), Ctrl = true, - Alt = false, - Shift = false, + Alt = true, Key = (int)ExtendedVirtualKey.L } }; diff --git a/FluentTerminal.App.ViewModels/OverlayViewModel.cs b/FluentTerminal.App.ViewModels/OverlayViewModel.cs new file mode 100644 index 00000000..6f912cc5 --- /dev/null +++ b/FluentTerminal.App.ViewModels/OverlayViewModel.cs @@ -0,0 +1,51 @@ +using FluentTerminal.App.Services; +using GalaSoft.MvvmLight; +using System; + +namespace FluentTerminal.App.ViewModels +{ + public class OverlayViewModel : ViewModelBase + { + private readonly IDispatcherTimer _overlayTimer; + private bool _showOverlay; + private string _overlayContent; + + public OverlayViewModel(IDispatcherTimer dispatcherTimer) + { + _overlayTimer = dispatcherTimer; + _overlayTimer.Interval = new TimeSpan(0, 0, 2); + _overlayTimer.Tick += OnResizeOverlayTimerFinished; + } + + public bool ShowOverlay + { + get => _showOverlay; + set => Set(ref _showOverlay, value); + } + + public string OverlayContent + { + get => _overlayContent; + set => Set(ref _overlayContent, value); + } + + public void Show(string message) + { + OverlayContent = message; + ShowOverlay = true; + + if (_overlayTimer.IsEnabled) + { + _overlayTimer.Stop(); + } + _overlayTimer.Start(); + } + + private void OnResizeOverlayTimerFinished(object sender, object e) + { + _overlayTimer.Stop(); + ShowOverlay = false; + } + + } +} diff --git a/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs b/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs index a880cc73..c5af0b22 100644 --- a/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs +++ b/FluentTerminal.App.ViewModels/Settings/TerminalPageViewModel.cs @@ -150,6 +150,20 @@ public bool BoldText } } + public bool ShowTextCopied + { + get => _terminalOptions.ShowTextCopied; + set + { + if (_terminalOptions.ShowTextCopied != value) + { + _terminalOptions.ShowTextCopied = value; + _settingsService.SaveTerminalOptions(_terminalOptions); + RaisePropertyChanged(); + } + } + } + public IEnumerable Fonts { get; } public int FontSize @@ -223,6 +237,7 @@ private async Task RestoreDefaults() BoldText = defaults.BoldText; BackgroundOpacity = defaults.BackgroundOpacity; ScrollBackLimit = defaults.ScrollBackLimit.ToString(); + ShowTextCopied = defaults.ShowTextCopied; } } diff --git a/FluentTerminal.App.ViewModels/TerminalViewModel.cs b/FluentTerminal.App.ViewModels/TerminalViewModel.cs index 50c0f69e..a62ca819 100644 --- a/FluentTerminal.App.ViewModels/TerminalViewModel.cs +++ b/FluentTerminal.App.ViewModels/TerminalViewModel.cs @@ -15,15 +15,13 @@ namespace FluentTerminal.App.ViewModels public class TerminalViewModel : ViewModelBase { private readonly IKeyboardCommandService _keyboardCommandService; - private readonly IDispatcherTimer _resizeOverlayTimer; private bool _isSelected; private bool _hasNewOutput; - private string _resizeOverlayContent; private string _searchText; - private bool _showResizeOverlay; private bool _showSearchPanel; private TabTheme _tabTheme; private TerminalTheme _terminalTheme; + private TerminalOptions _terminalOptions; private string _tabTitle; private string _shellTitle; private bool _hasCustomTitle; @@ -38,6 +36,8 @@ public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunica SettingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged; SettingsService.KeyBindingsChanged += OnKeyBindingsChanged; + _terminalOptions = SettingsService.GetTerminalOptions(); + TrayProcessCommunicationService = trayProcessCommunicationService; DialogService = dialogService; @@ -52,10 +52,6 @@ public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunica TabThemes = new ObservableCollection(SettingsService.GetTabThemes()); TabTheme = TabThemes.FirstOrDefault(t => t.Id == ShellProfile.TabThemeId); - _resizeOverlayTimer = dispatcherTimer; - _resizeOverlayTimer.Interval = new TimeSpan(0, 0, 2); - _resizeOverlayTimer.Tick += OnResizeOverlayTimerFinished; - CloseCommand = new RelayCommand(async () => await TryClose().ConfigureAwait(false)); FindNextCommand = new RelayCommand(FindNext); FindPreviousCommand = new RelayCommand(FindPrevious); @@ -69,6 +65,9 @@ public TerminalViewModel(ISettingsService settingsService, ITrayProcessCommunica Terminal.SizeChanged += Terminal_SizeChanged; Terminal.TitleChanged += Terminal_TitleChanged; Terminal.Closed += Terminal_Closed; + + Overlay = new OverlayViewModel(dispatcherTimer); + } public event EventHandler Activated; @@ -135,12 +134,6 @@ public bool HasNewOutput set => Set(ref _hasNewOutput, value); } - public string ResizeOverlayContent - { - get => _resizeOverlayContent; - set => Set(ref _resizeOverlayContent, value); - } - public string SearchText { get => _searchText; @@ -153,23 +146,6 @@ public string SearchText public ShellProfile ShellProfile { get; } - public bool ShowResizeOverlay - { - get => _showResizeOverlay; - set - { - Set(ref _showResizeOverlay, value); - if (value) - { - if (_resizeOverlayTimer.IsEnabled) - { - _resizeOverlayTimer.Stop(); - } - _resizeOverlayTimer.Start(); - } - } - } - public bool ShowSearchPanel { get => _showSearchPanel; @@ -191,6 +167,8 @@ public TabTheme TabTheme public Terminal Terminal { get; private set; } + public OverlayViewModel Overlay { get; private set; } + public TerminalTheme TerminalTheme { get => _terminalTheme; @@ -306,14 +284,9 @@ private async void OnKeyBindingsChanged(object sender, EventArgs e) await ApplicationView.RunOnDispatcherThread(() => KeyBindingsChanged?.Invoke(this, EventArgs.Empty)); } - private void OnResizeOverlayTimerFinished(object sender, object e) - { - _resizeOverlayTimer.Stop(); - ShowResizeOverlay = false; - } - private async void OnTerminalOptionsChanged(object sender, TerminalOptions e) { + _terminalOptions = e; await ApplicationView.RunOnDispatcherThread(() => OptionsChanged?.Invoke(this, e)); } @@ -335,6 +308,10 @@ private async void Terminal_KeyboardCommandReceived(object sender, string e) { var selection = await Terminal.GetSelectedText().ConfigureAwait(true); ClipboardService.SetText(selection); + if(_terminalOptions.ShowTextCopied) + { + Overlay.Show("Text copied"); + } break; } case nameof(Command.Paste): @@ -384,8 +361,7 @@ private void Terminal_OutputReceived(object sender, byte[] e) private void Terminal_SizeChanged(object sender, TerminalSize e) { - ResizeOverlayContent = $"{e.Columns} x {e.Rows}"; - ShowResizeOverlay = true; + Overlay.Show($"{e.Columns} x {e.Rows}"); } private void Terminal_TitleChanged(object sender, string e) diff --git a/FluentTerminal.App/FluentTerminal.App.csproj b/FluentTerminal.App/FluentTerminal.App.csproj index 6039651a..e5d488a0 100644 --- a/FluentTerminal.App/FluentTerminal.App.csproj +++ b/FluentTerminal.App/FluentTerminal.App.csproj @@ -154,6 +154,9 @@ CreateKeyBindingDialog.xaml + + OverlayView.xaml + SettingsPage.xaml @@ -322,6 +325,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/FluentTerminal.App/Views/OverlayView.xaml b/FluentTerminal.App/Views/OverlayView.xaml new file mode 100644 index 00000000..bf16205f --- /dev/null +++ b/FluentTerminal.App/Views/OverlayView.xaml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/FluentTerminal.App/Views/OverlayView.xaml.cs b/FluentTerminal.App/Views/OverlayView.xaml.cs new file mode 100644 index 00000000..71ab8e19 --- /dev/null +++ b/FluentTerminal.App/Views/OverlayView.xaml.cs @@ -0,0 +1,12 @@ +using Windows.UI.Xaml.Controls; + +namespace FluentTerminal.App.Views +{ + public sealed partial class OverlayView : UserControl + { + public OverlayView() + { + InitializeComponent(); + } + } +} diff --git a/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml b/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml index c4b15f0c..d4b31676 100644 --- a/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml +++ b/FluentTerminal.App/Views/SettingsPages/TerminalSettings.xaml @@ -132,6 +132,12 @@ GroupName="ScrollBar" IsChecked="{x:Bind ViewModel.VisibleIsSelected, Mode=TwoWay}" /> + + + diff --git a/FluentTerminal.App/Views/TabBar.xaml b/FluentTerminal.App/Views/TabBar.xaml index 40c5b4cc..0509fffa 100644 --- a/FluentTerminal.App/Views/TabBar.xaml +++ b/FluentTerminal.App/Views/TabBar.xaml @@ -59,6 +59,7 @@ VerticalAlignment="Stretch" Background="Transparent" ToolTipService.ToolTip="{x:Bind TabTitle, Mode=OneWay}"> + @@ -66,6 +67,7 @@ + diff --git a/FluentTerminal.App/Views/TerminalView.xaml b/FluentTerminal.App/Views/TerminalView.xaml index 561e61cc..f117cb8a 100644 --- a/FluentTerminal.App/Views/TerminalView.xaml +++ b/FluentTerminal.App/Views/TerminalView.xaml @@ -4,27 +4,22 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:views="using:FluentTerminal.App.Views" d:DesignHeight="300" d:DesignWidth="600" mc:Ignorable="d"> + - - - - - - + + + +