diff --git a/FluentTerminal.App.Services/IShellProfileMigrationService.cs b/FluentTerminal.App.Services/IShellProfileMigrationService.cs new file mode 100644 index 0000000..2a0a6b5 --- /dev/null +++ b/FluentTerminal.App.Services/IShellProfileMigrationService.cs @@ -0,0 +1,9 @@ +using FluentTerminal.Models; + +namespace FluentTerminal.App.Services +{ + public interface IShellProfileMigrationService + { + void Migrate(ShellProfile profile); + } +} diff --git a/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs b/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs index 5a987ae..d79abd2 100644 --- a/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs +++ b/FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs @@ -452,12 +452,17 @@ namespace FluentTerminal.App.Services.Implementation { Id = GetDefaultShellProfileId(), Name = "Powershell", + MigrationVersion = ShellProfile.CurrentMigrationVersion, Arguments = string.Empty, Location = @"C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe", PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.DoNotModify, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8), // Windows 10 1903+ + EnvironmentVariables = new Dictionary + { + ["TERM"] = "xterm-256color" + }, KeyBindings = new [] { new KeyBinding @@ -475,12 +480,17 @@ namespace FluentTerminal.App.Services.Implementation { Id = Guid.Parse("ab942a61-7673-4755-9bd8-765aff91d9a3"), Name = "CMD", + MigrationVersion = ShellProfile.CurrentMigrationVersion, Arguments = string.Empty, Location = @"C:\Windows\System32\cmd.exe", PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.DoNotModify, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ + EnvironmentVariables = new Dictionary + { + ["TERM"] = "xterm-256color" + }, KeyBindings = new [] { new KeyBinding @@ -498,12 +508,17 @@ namespace FluentTerminal.App.Services.Implementation { Id= Guid.Parse("e5785ad6-584f-40cb-bdcd-d5b3b3953e7f"), Name = "WSL", + MigrationVersion = ShellProfile.CurrentMigrationVersion, Arguments = string.Empty, Location = @"C:\windows\system32\wsl.exe", PreInstalled = true, WorkingDirectory = string.Empty, LineEndingTranslation = LineEndingStyle.ToLF, UseConPty = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7), // Windows 10 1809+ + EnvironmentVariables = new Dictionary + { + ["TERM"] = "xterm-256color" + }, KeyBindings = new [] { new KeyBinding diff --git a/FluentTerminal.App.Services/Implementation/SettingsService.cs b/FluentTerminal.App.Services/Implementation/SettingsService.cs index c06477f..96f4dd7 100644 --- a/FluentTerminal.App.Services/Implementation/SettingsService.cs +++ b/FluentTerminal.App.Services/Implementation/SettingsService.cs @@ -280,13 +280,18 @@ namespace FluentTerminal.App.Services.Implementation { return _shellProfiles.GetAll().Select(x => JsonConvert.DeserializeObject((string)x)).ToList(); } + public IEnumerable GetSshProfiles() { if (_sshProfiles == null) + { return new List(); + } else + { return _sshProfiles.GetAll() - .Select(x => JsonConvert.DeserializeObject((string) x)).ToList(); + .Select(x => JsonConvert.DeserializeObject((string)x)).ToList(); + } } public IEnumerable GetTabThemes() diff --git a/FluentTerminal.App.Services/Implementation/ShellProfileMigrationService.cs b/FluentTerminal.App.Services/Implementation/ShellProfileMigrationService.cs new file mode 100644 index 0000000..90dc9d8 --- /dev/null +++ b/FluentTerminal.App.Services/Implementation/ShellProfileMigrationService.cs @@ -0,0 +1,32 @@ +using FluentTerminal.Models; +using System; +using System.Collections.Generic; + +namespace FluentTerminal.App.Services.Implementation +{ + public class ShellProfileMigrationService : IShellProfileMigrationService + { + private readonly Dictionary> _migrationSteps = new Dictionary> + { + [1] = new Action(profile => + { + profile.EnvironmentVariables["TERM"] = "xterm-256color"; + }) + }; + + + public void Migrate(ShellProfile profile) + { + while(profile.MigrationVersion < ShellProfile.CurrentMigrationVersion) + { + ApplyMigrationStep(profile, profile.MigrationVersion + 1); + } + } + + private void ApplyMigrationStep(ShellProfile profile, int targetVersion) + { + _migrationSteps[targetVersion](profile); + profile.MigrationVersion = targetVersion; + } + } +} diff --git a/FluentTerminal.App.ViewModels/EnvironmentVariableViewModel.cs b/FluentTerminal.App.ViewModels/EnvironmentVariableViewModel.cs new file mode 100644 index 0000000..f0963a2 --- /dev/null +++ b/FluentTerminal.App.ViewModels/EnvironmentVariableViewModel.cs @@ -0,0 +1,25 @@ +using GalaSoft.MvvmLight; +using System; + +namespace FluentTerminal.App.ViewModels +{ + public class EnvironmentVariableViewModel : ViewModelBase + { + private string _name; + private string _value; + + public Guid Id { get; } = Guid.NewGuid(); + + public string Name + { + get => _name; + set => Set(ref _name, value); + } + + public string Value + { + get => _value; + set => Set(ref _value, value); + } + } +} diff --git a/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs b/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs index f1533bf..2ebfd55 100644 --- a/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs +++ b/FluentTerminal.App.ViewModels/ShellProfileViewModel.cs @@ -11,9 +11,9 @@ using FluentTerminal.App.ViewModels.Profiles; namespace FluentTerminal.App.ViewModels { /// - /// Extends , and implements only "Set as default" logic. + /// Extends , and implements only "Set as default" logic. /// - public class ShellProfileViewModel : ShellProfileViewModelBase + public class ShellProfileViewModel : ProfileViewModelBase { #region Fields diff --git a/FluentTerminal.App.ViewModels/ShellProfileViewModelBase.cs b/FluentTerminal.App.ViewModels/ShellProfileViewModelBase.cs index 06b8e85..1d568a8 100644 --- a/FluentTerminal.App.ViewModels/ShellProfileViewModelBase.cs +++ b/FluentTerminal.App.ViewModels/ShellProfileViewModelBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using FluentTerminal.App.Services; @@ -14,10 +15,10 @@ using GalaSoft.MvvmLight.Command; namespace FluentTerminal.App.ViewModels { /// - /// Base class for all shell profile view models. Implements logic for saving, editing, resetting, etc. + /// Base class for all profile view models. Implements logic for saving, editing, resetting, etc. /// /// - public abstract class ShellProfileViewModelBase : ViewModelBase where T : ProfileProviderViewModelBase + public abstract class ProfileViewModelBase : ViewModelBase where T : ProfileProviderViewModelBase { #region Fields @@ -25,6 +26,7 @@ namespace FluentTerminal.App.ViewModels protected readonly ISettingsService SettingsService; private List _bindingsBeforeEdit; + private Dictionary _environmentVariablesBeforeEdit; private string _nameBeforeEdit; #endregion Fields @@ -53,6 +55,8 @@ namespace FluentTerminal.App.ViewModels public KeyBindingsViewModel KeyBindings { get; } + public ObservableCollection EnvironmentVariables { get; } = new ObservableCollection(); + public T ProfileVm { get; protected set; } #endregion Properties @@ -79,7 +83,7 @@ namespace FluentTerminal.App.ViewModels #region Constructor - protected ShellProfileViewModelBase(ShellProfile shellProfile, ISettingsService settingsService, IDialogService dialogService, bool isNew) + protected ProfileViewModelBase(ShellProfile shellProfile, ISettingsService settingsService, IDialogService dialogService, bool isNew) { SettingsService = settingsService; DialogService = dialogService; @@ -87,6 +91,15 @@ namespace FluentTerminal.App.ViewModels KeyBindings = new KeyBindingsViewModel(shellProfile.Id.ToString(), dialogService, string.Empty, false); + foreach (var environmentVariable in shellProfile.EnvironmentVariables) + { + EnvironmentVariables.Add(new EnvironmentVariableViewModel + { + Name = environmentVariable.Key, + Value = environmentVariable.Value + }); + } + Initialize(shellProfile); DeleteCommand = new AsyncCommand(Delete, CanDelete); @@ -115,9 +128,10 @@ namespace FluentTerminal.App.ViewModels protected virtual bool HasChanges() { - return ProfileVm.HasChanges() || !_nameBeforeEdit.NullableEqualTo(_name) || - !(_bindingsBeforeEdit?.SequenceEqual(KeyBindings.KeyBindings.Select(x => x.Model).ToList()) ?? - false); + return ProfileVm.HasChanges() + || !_nameBeforeEdit.NullableEqualTo(_name) + || !(_bindingsBeforeEdit?.SequenceEqual(KeyBindings.KeyBindings.Select(x => x.Model).ToList()) ?? false) + || !(_environmentVariablesBeforeEdit?.SequenceEqual(EnvironmentVariables.ToDictionary(x => x.Name, x => x.Value)) ?? false); } private async Task Delete() @@ -141,6 +155,7 @@ namespace FluentTerminal.App.ViewModels } _bindingsBeforeEdit = KeyBindings.KeyBindings.Select(x => x.Model).ToList(); + _environmentVariablesBeforeEdit = EnvironmentVariables.ToDictionary(x => x.Name, x => x.Value); _nameBeforeEdit = _name; KeyBindings.Editable = true; @@ -189,11 +204,26 @@ namespace FluentTerminal.App.ViewModels return; } + if (EnvironmentVariables.Select(x => x.Name).Any(x => string.IsNullOrWhiteSpace(x))) + { + await DialogService.ShowMessageDialogAsnyc(I18N.Translate("InvalidInput"), I18N.Translate("EmptyEnvironmentVariableName"), DialogButton.OK); + + return; + } + + if (EnvironmentVariables.Select(x => x.Name).Distinct().Count() != EnvironmentVariables.Count) + { + await DialogService.ShowMessageDialogAsnyc(I18N.Translate("InvalidInput"), I18N.Translate("DuplicateEnvironmentVariable"), DialogButton.OK); + + return; + } + var profile = ProfileVm.Model; profile.Id = Id; profile.Name = _name; profile.KeyBindings = KeyBindings.KeyBindings.Select(x => x.Model).ToList(); + profile.EnvironmentVariables = EnvironmentVariables.ToDictionary(x => x.Name, x => x.Value); if (profile is SshProfile sshProfile) { diff --git a/FluentTerminal.App.ViewModels/SshProfileViewModel.cs b/FluentTerminal.App.ViewModels/SshProfileViewModel.cs index 0e84eb5..7b83b22 100644 --- a/FluentTerminal.App.ViewModels/SshProfileViewModel.cs +++ b/FluentTerminal.App.ViewModels/SshProfileViewModel.cs @@ -5,10 +5,10 @@ using FluentTerminal.Models; namespace FluentTerminal.App.ViewModels { /// - /// Extends , and doesn't implement any additional logic because in + /// Extends , and doesn't implement any additional logic because in /// case of SSH profiles no additional logic is needed. /// - public class SshProfileViewModel : ShellProfileViewModelBase + public class SshProfileViewModel : ProfileViewModelBase { #region Constructor diff --git a/FluentTerminal.App/App.xaml.cs b/FluentTerminal.App/App.xaml.cs index da4ad6e..7b02140 100755 --- a/FluentTerminal.App/App.xaml.cs +++ b/FluentTerminal.App/App.xaml.cs @@ -103,6 +103,7 @@ namespace FluentTerminal.App builder.RegisterType().As().InstancePerDependency(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterInstance(applicationDataContainers); _container = builder.Build(); @@ -110,6 +111,19 @@ namespace FluentTerminal.App _settingsService = _container.Resolve(); _settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged; + var shellProfileMigrationService = _container.Resolve(); + foreach (var profile in _settingsService.GetShellProfiles()) + { + shellProfileMigrationService.Migrate(profile); + _settingsService.SaveShellProfile(profile); + } + + foreach (var profile in _settingsService.GetSshProfiles()) + { + shellProfileMigrationService.Migrate(profile); + _settingsService.SaveSshProfile(profile); + } + _trayProcessCommunicationService = _container.Resolve(); _dialogService = _container.Resolve(); diff --git a/FluentTerminal.App/FluentTerminal.App.csproj b/FluentTerminal.App/FluentTerminal.App.csproj index 17f04f9..4938979 100644 --- a/FluentTerminal.App/FluentTerminal.App.csproj +++ b/FluentTerminal.App/FluentTerminal.App.csproj @@ -163,6 +163,9 @@ + + EnvironmentVariablesView.xaml + KeyBindingsView.xaml @@ -404,6 +407,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/FluentTerminal.App/Strings/de/Resources.resw b/FluentTerminal.App/Strings/de/Resources.resw index c1a7f18..3b9d4cf 100644 --- a/FluentTerminal.App/Strings/de/Resources.resw +++ b/FluentTerminal.App/Strings/de/Resources.resw @@ -287,9 +287,10 @@ Fuzzy Themes SettingsPage.xaml - + Hinzufügen - ShellProfileSettings.xaml + ShellProfileSettings.xaml +Fuzzy Argumente @@ -541,8 +542,9 @@ Fuzzy ShellProfileSettings.xaml - Sind Sie sicher dass Sie "{0}" Tab schließen wollen? - ViewModel + Sind Sie sicher dass Sie den Tab "{0}" schließen wollen? + ViewModel +Fuzzy Sind Sie sicher dass Sie dieses Fenster schließen wollen? @@ -657,9 +659,10 @@ Fuzzy Tastaturkürzel KeyBindingSettings.xaml - + Löschen - KeyBindingsView.xaml + KeyBindingsView.xaml +Fuzzy Bearbeiten @@ -752,6 +755,7 @@ Fuzzy Neuer SSH-Tab + Fuzzy Neuer SSH-Tab @@ -929,18 +933,45 @@ Fuzzy Quick Launch - New quick launch tab + Neuer Quick Launch-Tab - New quick launch window + Neues Quick Launch-Fenster - New quick tab + Neuer Quick Launch-Tab - File not found: + Datei nicht gefunden: - Invalid link. + Ungültiger Verweis. + + + Tab hier ablegen + + + Linke Tabs schließen + + + Andere Tabs schließen + + + Rechte Tabs schließen + + + Tab duplizieren + + + Duplizieren + + + Es können keine zwei Umgebungsvariablen mit dem gleichen Namen erstellt werden. + + + Es kann keine Umgebungsvariable ohne Name erstellt werden. + + + Umgebungsvariablen \ No newline at end of file diff --git a/FluentTerminal.App/Strings/en/Resources.resw b/FluentTerminal.App/Strings/en/Resources.resw index 6651486..20b6340 100644 --- a/FluentTerminal.App/Strings/en/Resources.resw +++ b/FluentTerminal.App/Strings/en/Resources.resw @@ -296,9 +296,10 @@ Fuzzy Themes SettingsPage.xaml - + Add - ShellProfileSettings.xaml + ShellProfileSettings.xaml +Fuzzy Arguments @@ -550,8 +551,9 @@ Fuzzy ShellProfileSettings.xaml - Are you sure you want to close "{0}" tab? - ViewModel + Are you sure you want to close "{0}" tab? + ViewModel +Fuzzy Are you sure you want to close this window? @@ -671,9 +673,10 @@ Fuzzy Keybindings KeyBindingSettings.xaml - + Delete - KeyBindingsView.xaml + KeyBindingsView.xaml +Fuzzy Edit @@ -979,27 +982,29 @@ Fuzzy Drop tab here - Drop hint - Close Tabs to the Left - TabBar.xaml + Close tabs to the left - Close Other Tabs - TabBar.xaml + Close other tabs - Close Tabs to the Right - TabBar.xaml + Close tabs to the right Duplicate tab - Command -Fuzzy Duplicate - TabBar.xaml + + + Cannot define two environment variables with the same name. + + + Cannot define an environment variable without a name. + + + Environment variables \ No newline at end of file diff --git a/FluentTerminal.App/Strings/es/Resources.resw b/FluentTerminal.App/Strings/es/Resources.resw index 4f72ae4..170047f 100644 --- a/FluentTerminal.App/Strings/es/Resources.resw +++ b/FluentTerminal.App/Strings/es/Resources.resw @@ -285,9 +285,10 @@ Temas SettingsPage.xaml - + Añadir - ShellProfileSettings.xaml + ShellProfileSettings.xaml +Fuzzy Argumentos @@ -539,7 +540,7 @@ Fuzzy ShellProfileSettings.xaml - ¿Quieres cerrar "{0}" pestaña? + Are you sure you want to close "{0}" tab? ViewModel @@ -654,9 +655,10 @@ Fuzzy Atajos KeyBindingSettings.xaml - + Borrar - KeyBindingsView.xaml + KeyBindingsView.xaml +Fuzzy Editar @@ -749,6 +751,7 @@ Fuzzy Nueva pestaña remota + Fuzzy Nueva pestaña SSH @@ -934,4 +937,31 @@ Fuzzy Invalid link. + + Drop tab here + + + Close tabs to the left + + + Close other tabs + + + Close tabs to the right + + + Duplicate tab + + + Duplicate + + + Cannot define two environment variables with the same name. + + + Cannot define an environment variable without a name. + + + Environment variables + \ No newline at end of file diff --git a/FluentTerminal.App/Strings/fr/Resources.resw b/FluentTerminal.App/Strings/fr/Resources.resw index 8e4c32f..adfa576 100644 --- a/FluentTerminal.App/Strings/fr/Resources.resw +++ b/FluentTerminal.App/Strings/fr/Resources.resw @@ -158,7 +158,7 @@ Fuzzy Fuzzy - Afficher le titre de l'onglet personnalisé également dans la barre de titre + Afficher le titre de l'onglet personnalisé également dans la barre de titre GeneralSettings.xaml @@ -240,7 +240,7 @@ Fuzzy MainPage.xaml - Afficher dans la barre d'état système + Afficher dans la barre d'état système GeneralSettings.xaml @@ -265,7 +265,7 @@ Fuzzy GeneralSettings.xaml - Souligner l'onglet sélectionné + Souligner l'onglet sélectionné GeneralSettings.xaml @@ -296,9 +296,10 @@ Fuzzy Thèmes SettingsPage.xaml - + Ajouter - ShellProfileSettings.xaml + ShellProfileSettings.xaml +Fuzzy Arguments @@ -511,7 +512,7 @@ Fuzzy ShellProfileSettings.xaml - Couleur d'onglet + Couleur d'onglet ShellProfileSettings.xaml @@ -550,7 +551,7 @@ Fuzzy ShellProfileSettings.xaml - Êtes-vous sûr de vouloir fermer "{0}" onglets? + Êtes-vous sûr de vouloir fermer "{0}" onglets? ViewModel @@ -594,7 +595,7 @@ Fuzzy ViewModel - Désactivé par l'utilisateur. Veuillez le réactiver dans l'onglet Démarrage du Gestionnaire des Tâches. + Désactivé par l'utilisateur. Veuillez le réactiver dans l'onglet Démarrage du Gestionnaire des Tâches. ViewModel @@ -606,11 +607,11 @@ Fuzzy ViewModel - L'opération ne peut pas être terminée en raison de l'erreur suivante: + L'opération ne peut pas être terminée en raison de l'erreur suivante: ViewModel - L'importation du thème a échouer + L'importation du thème a échouer ViewModel @@ -643,7 +644,7 @@ Fuzzy KeyBindingSettings.xaml - Changer le titre de l'onglet + Changer le titre de l'onglet Command Fuzzy @@ -653,7 +654,7 @@ Fuzzy Fuzzy - Fermer l'onglet + Fermer l'onglet Command Fuzzy @@ -671,9 +672,10 @@ Fuzzy Raccourcis clavier KeyBindingSettings.xaml - + Effacer - KeyBindingsView.xaml + KeyBindingsView.xaml +Fuzzy Editer @@ -804,7 +806,7 @@ Fuzzy port - Chemin du fichier d'identité + Chemin du fichier d'identité Fuzzy @@ -824,7 +826,7 @@ Fuzzy Fuzzy - L'application doit redémarrer pour que cette modification soit prise en compte. + L'application doit redémarrer pour que cette modification soit prise en compte. Entrée invalide @@ -839,10 +841,10 @@ Fuzzy Fuzzy - Le nom d'utilisateur ne peut pas être vide. + Le nom d'utilisateur ne peut pas être vide. - L'hôte ne peut être vide. + L'hôte ne peut être vide. Fuzzy @@ -854,7 +856,7 @@ Fuzzy Fuzzy - La plage de ports Mosh n'est pas valide. + La plage de ports Mosh n'est pas valide. Oui @@ -891,7 +893,7 @@ Fuzzy Fuzzy - Couleur d'onglet: + Couleur d'onglet: Fuzzy @@ -899,7 +901,7 @@ Fuzzy Fuzzy - Nom d'utilisateur + Nom d'utilisateur Fuzzy @@ -923,10 +925,10 @@ Fuzzy Les paramètres ont été importés du fichier - Le fichier d'identification n'existe pas + Le fichier d'identification n'existe pas - Utilisez le nom d'utilisateur Windows lors de l'ouverture d'URL SSH qui don't spécifier un + Utilisez le nom d'utilisateur Windows lors de l'ouverture d'URL SSH qui don't spécifier un Mosh par défaut pour les connexions SSH @@ -941,7 +943,7 @@ Fuzzy Commande non valide. - L'emplacement ne peut pas être vide. + L'emplacement ne peut pas être vide. Mutter les bips du terminal @@ -979,27 +981,30 @@ Fuzzy Drop tab here - Drop indice Fermer les onglets à gauche - TabBar.xaml Fermer les autres onglets - TabBar.xaml Fermer les onglets à droite - TabBar.xaml Onglet dupliquer - Command -Fuzzy + Fuzzy Dupliquer - TabBar.xaml - + + Cannot define two environment variables with the same name. + + + Cannot define an environment variable without a name. + + + Environment variables + + \ 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 6a73660..2dc2f10 100644 --- a/FluentTerminal.App/Strings/zh-CN/Resources.resw +++ b/FluentTerminal.App/Strings/zh-CN/Resources.resw @@ -285,9 +285,10 @@ 主题 SettingsPage.xaml - + 添加 - ShellProfileSettings.xaml + ShellProfileSettings.xaml +Fuzzy 参数 @@ -538,7 +539,7 @@ Fuzzy ShellProfileSettings.xaml - 是否要关闭"{0}"标签页? + Are you sure you want to close "{0}" tab? ViewModel @@ -655,9 +656,10 @@ Fuzzy 快捷键 KeyBindingSettings.xaml - + 删除 - KeyBindingsView.xaml + KeyBindingsView.xaml +Fuzzy 编辑 @@ -751,6 +753,7 @@ Fuzzy 新建远程标签页 + Fuzzy 新建 SSH 标签 @@ -926,4 +929,31 @@ Fuzzy Invalid link. + + Drop tab here + + + Close tabs to the left + + + Close other tabs + + + Close tabs to the right + + + Duplicate tab + + + Duplicate + + + Cannot define two environment variables with the same name. + + + Cannot define an environment variable without a name. + + + Environment variables + \ No newline at end of file diff --git a/FluentTerminal.App/Views/EnvironmentVariablesView.xaml b/FluentTerminal.App/Views/EnvironmentVariablesView.xaml new file mode 100644 index 0000000..8b5f839 --- /dev/null +++ b/FluentTerminal.App/Views/EnvironmentVariablesView.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FluentTerminal.App/Views/EnvironmentVariablesView.xaml.cs b/FluentTerminal.App/Views/EnvironmentVariablesView.xaml.cs new file mode 100644 index 0000000..d4a4a81 --- /dev/null +++ b/FluentTerminal.App/Views/EnvironmentVariablesView.xaml.cs @@ -0,0 +1,40 @@ +using FluentTerminal.App.ViewModels; +using System; +using System.Collections.ObjectModel; +using System.Linq; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace FluentTerminal.App.Views +{ + public sealed partial class EnvironmentVariablesView : UserControl + { + public ObservableCollection EnvironmentVariables + { + get { return (ObservableCollection)GetValue(EnvironmentVariablesProperty); } + set { SetValue(EnvironmentVariablesProperty, value); } + } + + public static readonly DependencyProperty EnvironmentVariablesProperty = + DependencyProperty.Register(nameof(EnvironmentVariables), typeof(ObservableCollection), typeof(EnvironmentVariablesView), new PropertyMetadata(null)); + + public EnvironmentVariablesView() + { + InitializeComponent(); + } + + private void OnAddTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) + { + EnvironmentVariables.Add(new EnvironmentVariableViewModel()); + } + + private void OnRemoveTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) + { + if (sender is HyperlinkButton button) + { + var item = EnvironmentVariables.FirstOrDefault(x => x.Id == (Guid)button.Tag); + EnvironmentVariables.Remove(item); + } + } + } +} diff --git a/FluentTerminal.App/Views/KeyBindingsView.xaml b/FluentTerminal.App/Views/KeyBindingsView.xaml index 7eab770..4f861d5 100644 --- a/FluentTerminal.App/Views/KeyBindingsView.xaml +++ b/FluentTerminal.App/Views/KeyBindingsView.xaml @@ -82,15 +82,15 @@ Text="{x:Bind Key, Mode=OneWay, Converter={StaticResource IntToExtendedVirtualKeyConverter}}" /> diff --git a/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml b/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml index 512d8fa..74fcb8f 100644 --- a/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml +++ b/FluentTerminal.App/Views/SettingsPages/ShellProfileSettings.xaml @@ -260,6 +260,14 @@ + + + + + @@ -346,6 +354,30 @@ FontWeight="Light" /> + + + + + + + + + + + + + + + + + + + + + + @@ -490,6 +498,30 @@ FontWeight="Light" /> + + + + + + + + + + + + + + + + + public static readonly Regex NewlinePattern = new Regex(@"\n\r|\r\n|\r|\n", RegexOptions.Compiled); + public const int CurrentMigrationVersion = 1; public ShellProfile() { @@ -42,9 +43,11 @@ namespace FluentTerminal.Models public string WorkingDirectory { get; set; } public int TabThemeId { get; set; } public LineEndingStyle LineEndingTranslation { get; set; } - public Dictionary EnvironmentVariables { get; } = new Dictionary(); + public Dictionary EnvironmentVariables { get; set; } = new Dictionary(); public bool UseConPty { get; set; } + public int MigrationVersion { get; set; } + /// /// For attaching a data to the profile. This property doesn't get serialized nor cloned. /// diff --git a/FluentTerminal.SystemTray/Program.cs b/FluentTerminal.SystemTray/Program.cs index be24928..5116a50 100644 --- a/FluentTerminal.SystemTray/Program.cs +++ b/FluentTerminal.SystemTray/Program.cs @@ -62,7 +62,7 @@ namespace FluentTerminal.SystemTray containerBuilder.RegisterType().SingleInstance(); containerBuilder.RegisterType().As(); containerBuilder.RegisterType().As().SingleInstance(); - containerBuilder.RegisterType().As(); + containerBuilder.RegisterType().As().SingleInstance(); containerBuilder.RegisterInstance(Dispatcher.CurrentDispatcher).SingleInstance(); var container = containerBuilder.Build(); diff --git a/FluentTerminal.SystemTray/Services/TerminalsManager.cs b/FluentTerminal.SystemTray/Services/TerminalsManager.cs index 8bfee29..adf33e3 100644 --- a/FluentTerminal.SystemTray/Services/TerminalsManager.cs +++ b/FluentTerminal.SystemTray/Services/TerminalsManager.cs @@ -192,7 +192,6 @@ namespace FluentTerminal.SystemTray.Services public string GetDefaultEnvironmentVariableString(Dictionary additionalVariables) { var environmentVariables = Environment.GetEnvironmentVariables(); - environmentVariables["TERM"] = "xterm-256color"; environmentVariables["TERM_PROGRAM"] = "FluentTerminal"; environmentVariables["TERM_PROGRAM_VERSION"] = $"{Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}.{Package.Current.Id.Version.Revision}";