diff --git a/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs b/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs index 01e643f..347c344 100644 --- a/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs +++ b/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs @@ -3,6 +3,7 @@ using FluentTerminal.Models; using FluentTerminal.Models.Enums; using System; using System.Collections.Generic; +using Windows.Foundation.Metadata; namespace FluentTerminal.App.Services.Implementation { @@ -22,7 +23,6 @@ namespace FluentTerminal.App.Services.Implementation MouseMiddleClickAction = MouseAction.None, MouseRightClickAction = MouseAction.ContextMenu, AlwaysShowTabs = false, - AlwaysUseWinPty = true, ShowNewOutputIndicator = false, EnableTrayIcon = true, ShowCustomTitleInTitlebar = true @@ -366,6 +366,7 @@ namespace FluentTerminal.App.Services.Implementation PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.DoNotModify, + UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8), // Windows 10 1903+ KeyBindings = new [] { new KeyBinding @@ -388,6 +389,7 @@ namespace FluentTerminal.App.Services.Implementation PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.DoNotModify, + UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ KeyBindings = new [] { new KeyBinding @@ -410,6 +412,7 @@ namespace FluentTerminal.App.Services.Implementation PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.ToLF, + UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ KeyBindings = new [] { new KeyBinding diff --git a/FluentTerminal.App.ViewModels/Settings/GeneralPageViewModel.cs b/FluentTerminal.App.ViewModels/Settings/GeneralPageViewModel.cs index 42b75f3..05688bc 100644 --- a/FluentTerminal.App.ViewModels/Settings/GeneralPageViewModel.cs +++ b/FluentTerminal.App.ViewModels/Settings/GeneralPageViewModel.cs @@ -79,20 +79,6 @@ namespace FluentTerminal.App.ViewModels.Settings } } - public bool AlwaysUseWinPty - { - get => _applicationSettings.AlwaysUseWinPty; - set - { - if (_applicationSettings.AlwaysUseWinPty != value) - { - _applicationSettings.AlwaysUseWinPty = value; - _settingsService.SaveApplicationSettings(_applicationSettings); - RaisePropertyChanged(); - } - } - } - public bool ShowCustomTitleInTitlebar { get => _applicationSettings.ShowCustomTitleInTitlebar; @@ -317,7 +303,6 @@ namespace FluentTerminal.App.ViewModels.Settings InactiveTabColorMode = defaults.InactiveTabColorMode; NewTerminalLocation = defaults.NewTerminalLocation; AlwaysShowTabs = defaults.AlwaysShowTabs; - AlwaysUseWinPty = defaults.AlwaysUseWinPty; ShowNewOutputIndicator = defaults.ShowNewOutputIndicator; EnableTrayIcon = defaults.EnableTrayIcon; ShowCustomTitleInTitlebar = defaults.ShowCustomTitleInTitlebar; diff --git a/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs b/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs index 5475ea3..9d83850 100644 --- a/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs +++ b/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs @@ -29,6 +29,7 @@ namespace FluentTerminal.App.ViewModels private TabTheme _selectedTabTheme; private TerminalTheme _selectedTerminalTheme; private string _workingDirectory; + private bool _useConPty; private readonly IApplicationView _applicationView; private readonly IDefaultValueProvider _defaultValueProvider; @@ -84,6 +85,7 @@ namespace FluentTerminal.App.ViewModels SelectedTabTheme = TabThemes.FirstOrDefault(t => t.Id == shellProfile.TabThemeId); PreInstalled = shellProfile.PreInstalled; LineEndingStyle = shellProfile.LineEndingTranslation; + UseConPty = shellProfile.UseConPty; KeyBindings.Clear(); foreach (var keyBinding in shellProfile.KeyBindings.Select(x => new KeyBinding(x)).ToList()) @@ -135,6 +137,12 @@ namespace FluentTerminal.App.ViewModels public ShellProfile Model { get; private set; } public bool PreInstalled { get; private set; } + public bool UseConPty + { + get => _useConPty; + set => Set(ref _useConPty, value); + } + public string Arguments { get => _arguments; @@ -252,6 +260,7 @@ namespace FluentTerminal.App.ViewModels Model.TabThemeId = SelectedTabTheme.Id; Model.TerminalThemeId = SelectedTerminalTheme.Id; Model.LineEndingTranslation = _lineEndingStyle; + Model.UseConPty = UseConPty; Model.KeyBindings = KeyBindings.KeyBindings.Select(x => x.Model).ToList(); _settingsService.SaveShellProfile(Model); @@ -310,6 +319,8 @@ namespace FluentTerminal.App.ViewModels { ShellProfile changedProfile = new ShellProfile { + Id = Model.Id, + PreInstalled = Model.PreInstalled, Arguments = Arguments, Location = Location, Name = Name, @@ -317,6 +328,7 @@ namespace FluentTerminal.App.ViewModels TabThemeId = SelectedTabTheme.Id, TerminalThemeId = SelectedTerminalTheme.Id, LineEndingTranslation = _lineEndingStyle, + UseConPty = UseConPty, KeyBindings = KeyBindings.KeyBindings.Select(x => x.Model).ToList() }; @@ -331,6 +343,7 @@ namespace FluentTerminal.App.ViewModels Name = _fallbackProfile.Name; WorkingDirectory = _fallbackProfile.WorkingDirectory; LineEndingStyle = _fallbackProfile.LineEndingTranslation; + UseConPty = _fallbackProfile.UseConPty; SelectedTerminalTheme = TerminalThemes.FirstOrDefault(t => t.Id == _fallbackProfile.TerminalThemeId); SelectedTabTheme = TabThemes.FirstOrDefault(t => t.Id == _fallbackProfile.TabThemeId); @@ -369,17 +382,7 @@ namespace FluentTerminal.App.ViewModels private void Edit() { - // todo write copy ctor - _fallbackProfile = new ShellProfile - { - Arguments = Model.Arguments, - LineEndingTranslation = Model.LineEndingTranslation, - Location = Model.Location, - Name = Model.Name, - WorkingDirectory = Model.WorkingDirectory, - TabThemeId = Model.TabThemeId, - TerminalThemeId = Model.TerminalThemeId - }; + _fallbackProfile = new ShellProfile(Model); KeyBindings.Editable = true; InEditMode = true; diff --git a/FluentTerminal.App/FluentTerminal.App.csproj b/FluentTerminal.App/FluentTerminal.App.csproj index e4ff064..6cca0fb 100644 --- a/FluentTerminal.App/FluentTerminal.App.csproj +++ b/FluentTerminal.App/FluentTerminal.App.csproj @@ -147,6 +147,7 @@ + KeyBindingsView.xaml diff --git a/FluentTerminal.App/Strings/de/Resources.resw b/FluentTerminal.App/Strings/de/Resources.resw index d7a44d6..d20c727 100644 --- a/FluentTerminal.App/Strings/de/Resources.resw +++ b/FluentTerminal.App/Strings/de/Resources.resw @@ -137,13 +137,15 @@ Schließen TabBar.xaml - + Nachfragen bevor Fenster geschloßen wird - GeneralSettings.xaml + GeneralSettings.xaml +Fuzzy - + Nachfragen bevor Tab geschloßen wird - GeneralSettings.xaml + GeneralSettings.xaml +Fuzzy Farbe @@ -261,10 +263,6 @@ Aktiven Tab unterstreichen GeneralSettings.xaml - - Windows 10 1809+: Immer WinPty verwenden - GeneralSettings.xaml - Über SettingsPage.xaml @@ -812,4 +810,16 @@ Ungültiger Mosh-Port-Spanne + + Ja + + + Nein + + + Sprache + + + Keine + \ No newline at end of file diff --git a/FluentTerminal.App/Strings/en/Resources.resw b/FluentTerminal.App/Strings/en/Resources.resw index 79a9b87..2f683e2 100644 --- a/FluentTerminal.App/Strings/en/Resources.resw +++ b/FluentTerminal.App/Strings/en/Resources.resw @@ -138,13 +138,15 @@ Fuzzy Close TabBar.xaml - + Ask before closing windows - GeneralSettings.xaml + GeneralSettings.xaml +Fuzzy - + Ask before closing tabs - GeneralSettings.xaml + GeneralSettings.xaml +Fuzzy Color @@ -270,10 +272,6 @@ Fuzzy Underline selected tab GeneralSettings.xaml - - Windows 10 1809+: Always use WinPty - GeneralSettings.xaml - About SettingsPage.xaml @@ -850,4 +848,16 @@ Fuzzy Mosh port range is invalid. + + Yes + + + No + + + Language + + + None + \ No newline at end of file diff --git a/FluentTerminal.App/Strings/zh-CN/Resources.resw b/FluentTerminal.App/Strings/zh-CN/Resources.resw index bf4ada5..7b61302 100644 --- a/FluentTerminal.App/Strings/zh-CN/Resources.resw +++ b/FluentTerminal.App/Strings/zh-CN/Resources.resw @@ -138,13 +138,15 @@ Fuzzy 关闭 TabBar.xaml - + 在关闭窗口之前询问 - GeneralSettings.xaml + GeneralSettings.xaml +Fuzzy - + 在关闭标签页之前询问 - GeneralSettings.xaml + GeneralSettings.xaml +Fuzzy 标签颜色 @@ -270,10 +272,6 @@ Fuzzy 当前标签栏下划线 GeneralSettings.xaml - - Windows 10 1809+: 始终使用 WinPty - GeneralSettings.xaml - 关于 SettingsPage.xaml @@ -383,7 +381,7 @@ Fuzzy ShellProfileSettings.xaml - 不改变 + 不改变换行符 ShellProfileSettings.xaml Fuzzy @@ -536,17 +534,17 @@ Fuzzy ThemeSettings.xaml - 转换行结尾为 CR + 转换换行符为 CR ShellProfileSettings.xaml Fuzzy - 转换行结尾为 CR+LF + 转换换行符为 CR+LF ShellProfileSettings.xaml Fuzzy - 转换行结尾为 LF + 转换换行符为 LF ShellProfileSettings.xaml Fuzzy @@ -684,7 +682,7 @@ Fuzzy KeyBindingsView.xaml - 下一个标签页 + 新标签页 Command Fuzzy @@ -791,63 +789,75 @@ Fuzzy Fuzzy - New SSH Tab + 新的 SSH 标签页 - SSH Info + SSH 信息 - user + 用户 - host + 主机 - port + 端口 - Identity file path + SSH IdentityFile 文件地址 - Browse + 浏览 - Use Mosh + 使用 Mosh - Advanced + 高级 - Mosh ports: + Mosh 端口 - Save Shortcut + 保存快捷方式 - Application needs to restart for this change to take effect. + 应用需要重启才能让更改生效 - Invalid Input + 无效输入 - Port cannot be 0. + 端口不能为 0 - User and host are mandatory fields. + 用户名和主机名必须填写 - Username cannot be empty. + 用户名不能为空 - Host cannot be empty. + 主机名不能为空 - SSH port has to be greater than zero. + SSH 端口必须大于 0 - Mosh port cannot be zero. + Mosh 端口不能为 0 - Mosh port range is invalid. + Mosh 端口范围无效 + + + Yes + + + No + + + Language + + + None \ No newline at end of file diff --git a/FluentTerminal.App/Utilities/JumpListHelper.cs b/FluentTerminal.App/Utilities/JumpListHelper.cs index 25e3260..16394fa 100644 --- a/FluentTerminal.App/Utilities/JumpListHelper.cs +++ b/FluentTerminal.App/Utilities/JumpListHelper.cs @@ -23,12 +23,13 @@ namespace FluentTerminal.App.Utilities { var item = JumpListItem.CreateWithArguments(ShellProfileFlag + profile.Id.ToString(), profile.Name); item.Description = profile.Location; - item.Logo = new Uri("ms-appx:///Assets/AppIcons/Full-transparent.png"); jumpList.Items.Add(item); } await jumpList.SaveAsync(); } - }catch (Exception e){ + } + catch (Exception e) + { Logger.Instance.Error(e, "JumpList Update Exception"); } } diff --git a/FluentTerminal.App/Views/BooleanTemplateSelector.cs b/FluentTerminal.App/Views/BooleanTemplateSelector.cs new file mode 100644 index 0000000..60d7c83 --- /dev/null +++ b/FluentTerminal.App/Views/BooleanTemplateSelector.cs @@ -0,0 +1,25 @@ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace FluentTerminal.App.Views +{ + public class BooleanTemplateSelector : DataTemplateSelector + { + public DataTemplate TrueTemplate { get; set; } + public DataTemplate FalseTemplate { get; set; } + + protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) + { + return SelectTemplateCore(item); + } + + protected override DataTemplate SelectTemplateCore(object item) + { + if (item is bool value) + { + return value ? TrueTemplate : FalseTemplate; + } + return null; + } + } +} diff --git a/FluentTerminal.App/Views/SettingsPages/GeneralSettings.xaml b/FluentTerminal.App/Views/SettingsPages/GeneralSettings.xaml index 2cb22f7..a9b8e2d 100644 --- a/FluentTerminal.App/Views/SettingsPages/GeneralSettings.xaml +++ b/FluentTerminal.App/Views/SettingsPages/GeneralSettings.xaml @@ -17,12 +17,12 @@ + Text="General" /> @@ -40,11 +40,15 @@ - + - + - + - + - + @@ -144,12 +160,6 @@ Margin="{StaticResource ItemMargin}" Header="Show new output indicator on background tabs" IsOn="{x:Bind ViewModel.ShowNewOutputIndicator, Mode=TwoWay}" /> - - diff --git a/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml b/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml index 40a5e05..ccfe09d 100644 --- a/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml +++ b/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml @@ -51,7 +51,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -75,6 +75,18 @@ + + + + + + + + + + + + @@ -90,17 +102,20 @@ Grid.RowSpan="3" Grid.Column="0" Background="{ThemeResource SystemControlAcrylicWindowBrush}" /> - + @@ -147,14 +162,14 @@ DefaultLabelPosition="Right" Visibility="{x:Bind ViewModel.SelectedShellProfile.InEditMode, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}"> @@ -204,7 +219,10 @@ Margin="0,0,6,0"> - + @@ -224,10 +242,10 @@ + + - + - + @@ -333,15 +363,15 @@ Text="{x:Bind Name, Mode=OneWay}" /> + + + + + + + + - /// Replace all instances of anything resembling a newline, treating pairs of \r\n in either order as a single linebreak. - /// - public static Regex NewlinePattern = new Regex(@"\n\r|\r\n|\r|\n", RegexOptions.Compiled); - - public ShellProfile() - { - - } - - public ShellProfile(ShellProfile other) - { - Id = other.Id; - PreInstalled = other.PreInstalled; - Name = other.Name; - Arguments = other.Arguments; - Location = other.Location; - WorkingDirectory = other.WorkingDirectory; - TabThemeId = other.TabThemeId; - TerminalThemeId = other.TerminalThemeId; - LineEndingTranslation = other.LineEndingTranslation; - KeyBindings = other.KeyBindings.Select(x => new KeyBinding(x)).ToList(); - } - - public Guid Id { get; set; } - public bool PreInstalled { get; set; } - public string Name { get; set; } - public virtual string Arguments { get; set; } - public virtual string Location { get; set; } - public string WorkingDirectory { get; set; } - public int TabThemeId { get; set; } - public LineEndingStyle LineEndingTranslation { get; set; } - public Dictionary EnvironmentVariables { get; } = new Dictionary(); - - public string TranslateLineEndings(string content) - { - switch (LineEndingTranslation) - { - case LineEndingStyle.ToCR: - return NewlinePattern.Replace(content, "\r"); - case LineEndingStyle.ToCRLF: - return NewlinePattern.Replace(content, "\r\n"); - case LineEndingStyle.ToLF: - return NewlinePattern.Replace(content, "\n"); - case LineEndingStyle.DoNotModify: - default: - return content; - } - } - - public Guid TerminalThemeId { get; set; } - public ICollection KeyBindings { get; set; } = new List(); - - public override bool Equals(object obj) - { - if (obj is ShellProfile other) - { - return other.Id.Equals(Id) - && other.PreInstalled.Equals(PreInstalled) - && other.Name.Equals(Name) - && other.Arguments.Equals(Arguments) - && other.Location.Equals(Location) - && other.WorkingDirectory.Equals(WorkingDirectory) - && other.TabThemeId.Equals(TabThemeId) - && other.TerminalThemeId.Equals(TerminalThemeId) - && other.LineEndingTranslation == LineEndingTranslation - && other.KeyBindings.SequenceEqual(KeyBindings); - } - return false; - } - +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using FluentTerminal.Models.Enums; +using System.Linq; + +namespace FluentTerminal.Models +{ + public class ShellProfile + { + /// + /// Replace all instances of anything resembling a newline, treating pairs of \r\n in either order as a single linebreak. + /// + public static Regex NewlinePattern = new Regex(@"\n\r|\r\n|\r|\n", RegexOptions.Compiled); + + public ShellProfile() + { + + } + + public ShellProfile(ShellProfile other) + { + Id = other.Id; + PreInstalled = other.PreInstalled; + Name = other.Name; + Arguments = other.Arguments; + Location = other.Location; + WorkingDirectory = other.WorkingDirectory; + TabThemeId = other.TabThemeId; + TerminalThemeId = other.TerminalThemeId; + LineEndingTranslation = other.LineEndingTranslation; + UseConPty = other.UseConPty; + KeyBindings = other.KeyBindings.Select(x => new KeyBinding(x)).ToList(); + } + + public Guid Id { get; set; } + public bool PreInstalled { get; set; } + public string Name { get; set; } + public virtual string Arguments { get; set; } + public virtual string Location { get; set; } + public string WorkingDirectory { get; set; } + public int TabThemeId { get; set; } + public LineEndingStyle LineEndingTranslation { get; set; } + public Dictionary EnvironmentVariables { get; } = new Dictionary(); + + public bool UseConPty { get; set; } + + public string TranslateLineEndings(string content) + { + switch (LineEndingTranslation) + { + case LineEndingStyle.ToCR: + return NewlinePattern.Replace(content, "\r"); + case LineEndingStyle.ToCRLF: + return NewlinePattern.Replace(content, "\r\n"); + case LineEndingStyle.ToLF: + return NewlinePattern.Replace(content, "\n"); + case LineEndingStyle.DoNotModify: + default: + return content; + } + } + + public Guid TerminalThemeId { get; set; } + public ICollection KeyBindings { get; set; } = new List(); + + public override bool Equals(object obj) + { + if (obj is ShellProfile other) + { + return other.Id.Equals(Id) + && other.PreInstalled.Equals(PreInstalled) + && other.Name.Equals(Name) + && other.Arguments.Equals(Arguments) + && other.Location.Equals(Location) + && other.WorkingDirectory.Equals(WorkingDirectory) + && other.TabThemeId.Equals(TabThemeId) + && other.TerminalThemeId.Equals(TerminalThemeId) + && other.LineEndingTranslation == LineEndingTranslation + && other.UseConPty == UseConPty + && other.KeyBindings.SequenceEqual(KeyBindings); + } + return false; + } + /// /// Checks the profile for errors and returns string describing the found errors, if any. /// Returns null if no errors found. @@ -86,6 +90,6 @@ namespace FluentTerminal.Models public virtual string ValidateAndGetErrors() { return null; - } - } + } + } } \ No newline at end of file