Compare commits

...
48 Commits
Author SHA1 Message Date
FelixSe 6830adb788 Increase version, add generated files to .gitignore 2018-02-22 22:33:18 +01:00
FelixSe 02e015371c Supress webview native context menu 2018-02-22 22:07:21 +01:00
FelixSe 80bdfa012c Show notification if registering hotkey for toggle window fails 2018-02-20 22:04:23 +01:00
FelixSe 70326e9585 Add missing whitespace in product name 2018-02-20 22:04:20 +01:00
FelixSe c0e1415b6e Use shell executable name as tab title 2018-02-20 21:56:51 +01:00
FelixSe 13a3402b58 Improve error message for failed shell startup 2018-02-20 18:41:34 +01:00
FelixSe 73703412f8 Fix for shells no longer getting cleaned up on window close 2018-02-20 18:18:45 +01:00
FelixSe ab226d95d4 Added option to confirm before closing tab/window 2018-02-19 23:34:22 +01:00
FelixSe de7a76bb3b Add icons to settings pages 2018-02-19 21:01:09 +01:00
FelixSe 379f58b4b8 Rename open to show in tray icon 2018-02-19 20:38:37 +01:00
FelixSe 3a04cd3db2 Close tabs with middle click 2018-02-19 20:37:25 +01:00
FelixSe df0d3f080b Use non acrylic accent color for resize overlay 2018-02-19 19:34:54 +01:00
FelixSe 04131d271a Improve size of titlebar button icons 2018-02-19 19:31:31 +01:00
FelixSe d66fe26634 Global hotkey for show/hide window 2018-02-18 23:10:05 +01:00
FelixSe 8870f0621c Keyboard shortcuts 2018-02-18 21:08:22 +01:00
FelixSe e5250a7ae8 Reorderable tabs for windows 2018-02-17 17:32:48 +01:00
FelixSe b2b6cedf2c Increase version to 0.1.5.0 2018-02-16 17:37:54 +01:00
Felix e777c2c5ac Update README.md 2018-02-16 17:31:46 +01:00
FelixSe 7dcd8e1fbb Make background opacity configurable 2018-02-15 23:00:30 +01:00
FelixSe 37518cf88b Terminal Settings 2018-02-15 22:26:55 +01:00
FelixSe ca0e22b8d0 Reenable settings window title bar when navigation view is collapsed 2018-02-15 16:50:06 +01:00
FelixSe 074f5f9c7e Wrap dialogs in service 2018-02-14 18:00:00 +01:00
FelixSe 0b40963c82 change theme also on existing windows 2018-02-14 11:56:52 +01:00
FelixSe 0b6b8a9968 Fix selection color for xterm.js theme 2018-02-14 10:04:20 +01:00
FelixSe 47613454c7 Switch to official xterm.js 2018-02-14 10:04:05 +01:00
FelixSe 96d063b4fd Theme settings 2018-02-13 23:36:23 +01:00
FelixSe fec44fb0b5 fix context menu integrations for directories that contain whitespaces 2018-02-06 19:12:39 +01:00
FelixSe 58e7de5271 fix explorer integration path for installations where HomeDrive is not C: 2018-02-06 19:09:20 +01:00
FelixSe 466b7a7503 Display default window title again when terminal is resetting its title 2018-02-05 23:30:04 +01:00
FelixSe 50f9c84420 Support specifying the startup directory via command line and provide basic Explorer context menu integration 2018-02-05 23:23:03 +01:00
FelixSe f07dae98ee Escape shell executable path in commandLine 2018-02-04 00:12:44 +01:00
FelixSe 1cc74f79b4 Fix shell arguments 2018-02-03 23:34:07 +01:00
FelixSe 60c4f0518d Recover missing Client files 2018-02-03 23:20:53 +01:00
FelixSe f9fb05b194 Removed generated files from repository and added to .gitignore 2018-02-03 22:45:17 +01:00
FelixSe d933f60b8b Merge branch 'master' of https://github.com/felixse/FluentTerminal 2018-02-03 22:40:33 +01:00
FelixSe 45bba6e2eb Use hyper.js xterm fork for now instead of including it in this repository 2018-02-03 22:39:32 +01:00
FelixSe 210aeedc25 Update winpty to 0.4.3 2018-02-03 22:04:22 +01:00
Felix acfb8e8883 Update README.md 2018-02-03 21:46:00 +01:00
FelixSe 9b61d11f6a Added settings window to configure which shell to use 2018-02-03 21:25:34 +01:00
FelixSe 49ee8489d6 finished resize overlay 2018-01-31 21:18:13 +01:00
FelixSe 7b485ce407 setup dependency injection 2018-01-31 19:37:41 +01:00
FelixSe 66465b525f add MVVM infrastructure 2018-01-31 19:26:34 +01:00
FelixSe 9c5d8c27fd Move logic from web client to app to prepare configuration 2018-01-29 22:26:37 +01:00
FelixSe 4ae3be544b Resize terminal on window resize 2018-01-28 22:06:57 +01:00
FelixSe e32e0398ee Remove unnecessary build step 2018-01-28 22:05:38 +01:00
FelixSe fab22f2479 cleanup app.xaml.cs 2018-01-28 21:50:20 +01:00
Felix b2151c69ab Merge pull request #1 from vitorgrs/master
Remove splashscreen
2018-01-25 22:45:40 +01:00
Vitor Mikaelson f5fba8517a Remove splashscreen 2018-01-25 20:51:02 +00:00
372 changed files with 4893 additions and 49314 deletions

No files matched your search

+3
View File
@@ -1,5 +1,7 @@
# Project specific
FluentTerminal.App/Win32
FluentTerminal.SystemTray/Client
FluentTerminal.Client/dist
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
@@ -289,3 +291,4 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
FluentTerminal.Client/dist/bundle.js
@@ -0,0 +1,3 @@
reg add "HKCU\Software\Classes\Directory\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" \"new %%1\"" /f
reg add "HKCU\Software\Classes\Directory\Background\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" \"new %%V\"" /f
reg add "HKCU\Software\Classes\LibraryFolder\Background\shell\Open Fluent Terminal here\command" /d "\"%LOCALAPPDATA%\Microsoft\WindowsApps\flute.exe\" \"new %%V\"" /f
@@ -0,0 +1,3 @@
reg delete "HKCU\Software\Classes\Directory\shell\Open Fluent Terminal here" /f
reg delete "HKCU\Software\Classes\Directory\Background\shell\Open Fluent Terminal here" /f
reg delete "HKCU\Software\Classes\LibraryFolder\Background\shell\Open Fluent Terminal here" /f
+153 -74
View File
@@ -1,6 +1,10 @@
using FluentTerminal.App.Views;
using Autofac;
using FluentTerminal.App.Services;
using FluentTerminal.App.Services.Implementation;
using FluentTerminal.App.ViewModels;
using FluentTerminal.App.Views;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
@@ -11,56 +15,108 @@ using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using IContainer = Autofac.IContainer;
namespace FluentTerminal.App
{
sealed partial class App : Application
{
public static BackgroundTaskDeferral AppServiceDeferral = null;
public static AppServiceConnection Connection = null;
public static App Instance;
private bool _alreadyLaunched;
private IContainer _container;
private int _openTerminalWindows;
private int? _settingsWindowId;
public App()
{
InitializeComponent();
Instance = this;
var builder = new ContainerBuilder();
builder.RegisterType<SettingsService>().As<ISettingsService>().SingleInstance();
builder.RegisterType<DefaultValueProvider>().As<IDefaultValueProvider>().SingleInstance();
builder.RegisterType<TerminalService>().As<ITerminalService>().SingleInstance();
builder.RegisterType<DialogService>().As<IDialogService>().SingleInstance();
builder.RegisterType<KeyboardCommandService>().As<IKeyboardCommandService>().InstancePerDependency();
builder.RegisterType<MainViewModel>().InstancePerDependency();
builder.RegisterType<SettingsViewModel>().InstancePerDependency();
_container = builder.Build();
}
public static BackgroundTaskDeferral AppServiceDeferral = null;
public static AppServiceConnection Connection = null;
public static App Instance;
int? _settingsWindowId;
int idCreate = 0;
List<int> idSaved = new List<int>();
protected override async void OnLaunched(LaunchActivatedEventArgs e)
public async Task CreateNewTerminalWindow(string startupDirectory)
{
var launch = FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync().AsTask();
var clearCache = WebView.ClearTemporaryWebDataAsync().AsTask();
var viewModel = _container.Resolve<MainViewModel>();
viewModel.AddTerminal(startupDirectory);
var id = await CreateSecondaryView(typeof(MainPage), viewModel, true);
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id);
}
await Task.WhenAll(launch, clearCache);
public void SettingsWindowClosed()
{
_settingsWindowId = null;
}
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
public async Task ShowSettings()
{
if (_settingsWindowId == null)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Window.Current.Content = rootFrame;
var viewModel = _container.Resolve<SettingsViewModel>();
_settingsWindowId = await CreateSecondaryView(typeof(SettingsPage), viewModel, true);
}
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(_settingsWindowId.Value);
}
if (rootFrame.Content == null)
public void TerminalWindowClosed()
{
_openTerminalWindows--;
}
protected override async void OnActivated(IActivatedEventArgs args)
{
if (args is CommandLineActivatedEventArgs commandLineActivated)
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
rootFrame.Navigate(typeof(MainPage), e.Arguments);
idSaved.Add(ApplicationView.GetForCurrentView().Id);
if (string.IsNullOrWhiteSpace(commandLineActivated.Operation.Arguments))
{
return;
}
var arguments = commandLineActivated.Operation.Arguments.Split(' ', 2);
var command = arguments[0];
var parameter = arguments.Length > 1 ? arguments[1] : string.Empty;
if (_alreadyLaunched)
{
if (command == "settings")
{
await ShowSettings();
}
else if (command == "new")
{
await CreateNewTerminalWindow(parameter);
}
}
else
{
if (command == "settings")
{
var viewModel = _container.Resolve<SettingsViewModel>();
await CreateMainView(typeof(SettingsPage), viewModel, true);
}
else if (command == "new")
{
var viewModel = _container.Resolve<MainViewModel>();
viewModel.AddTerminal(parameter);
await CreateMainView(typeof(MainPage), viewModel, true);
}
}
}
else if (false) //todo: add option to create new windows on launch
{
await CreateNewWindow(typeof(MainPage), true);
}
Window.Current.Activate();
}
protected override void OnBackgroundActivated(BackgroundActivatedEventArgs args)
{
// connection established from the fulltrust process
base.OnBackgroundActivated(args);
if (args.TaskInstance.TriggerDetails is AppServiceTriggerDetails details)
{
@@ -71,6 +127,73 @@ namespace FluentTerminal.App
}
}
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
if (!_alreadyLaunched)
{
var viewModel = _container.Resolve<MainViewModel>();
viewModel.AddTerminal(null);
await CreateMainView(typeof(MainPage), viewModel, true);
Window.Current.Activate();
}
else if (_openTerminalWindows == 0)
{
var viewModel = _container.Resolve<MainViewModel>();
viewModel.AddTerminal(null);
await CreateSecondaryView(typeof(MainPage), viewModel, true);
}
}
private async Task CreateMainView(Type pageType, INotifyPropertyChanged viewModel, bool extendViewIntoTitleBar)
{
var launch = FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync().AsTask();
var clearCache = WebView.ClearTemporaryWebDataAsync().AsTask();
await Task.WhenAll(launch, clearCache);
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = extendViewIntoTitleBar;
if (pageType == typeof(MainPage))
{
_openTerminalWindows++;
}
rootFrame.Navigate(pageType, viewModel);
}
_alreadyLaunched = true;
Window.Current.Activate();
}
private async Task<int> CreateSecondaryView(Type pageType, INotifyPropertyChanged viewModel, bool ExtendViewIntoTitleBar)
{
int windowId = 0;
await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = ExtendViewIntoTitleBar;
var frame = new Frame();
frame.Navigate(pageType, viewModel);
Window.Current.Content = frame;
Window.Current.Activate();
windowId = ApplicationView.GetForCurrentView().Id;
});
if (pageType == typeof(MainPage))
{
_openTerminalWindows++;
}
return windowId;
}
private void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
if (args.Request.Message.ContainsKey("exit"))
@@ -86,49 +209,5 @@ namespace FluentTerminal.App
AppServiceDeferral.Complete();
}
}
public async Task<int> CreateNewWindow(Type pageType, bool ExtendViewIntoTitleBar)
{
var create = CoreApplication.CreateNewView();
await create.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = ExtendViewIntoTitleBar;
var frame = new Frame();
frame.Navigate(pageType, null);
Window.Current.Content = frame;
Window.Current.Activate();
idCreate = ApplicationView.GetForCurrentView().Id;
});
for (int i = idSaved.Count - 1; i >= 0; i--)
if (await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
idCreate, ViewSizePreference.Default,
idSaved[i], ViewSizePreference.Default)
) break;
idSaved.Add(idCreate);
return idCreate;
}
public async Task ShowNew()
{
var id = await CreateNewWindow(typeof(MainPage), true);
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id);
}
public async Task ShowSettings()
{
if (_settingsWindowId == null)
{
_settingsWindowId = await CreateNewWindow(typeof(Views.SettingsPage), false);
}
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(_settingsWindowId.Value);
}
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.
@@ -0,0 +1,40 @@
using Microsoft.Xaml.Interactivity;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
namespace FluentTerminal.App.Behaviors
{
public class MiddleClickBehavior : Trigger<UIElement>
{
private bool _middleButtonPressed;
protected override void OnAttached()
{
AssociatedObject.PointerPressed += OnPointerPressed;
AssociatedObject.PointerReleased += OnPointerReleased;
}
protected override void OnDetaching()
{
AssociatedObject.PointerPressed -= OnPointerPressed;
AssociatedObject.PointerReleased -= OnPointerReleased;
}
private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(AssociatedObject);
_middleButtonPressed = point.Properties.IsMiddleButtonPressed;
}
private void OnPointerReleased(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(AssociatedObject);
var middleButtonStillPressed = point.Properties.IsMiddleButtonPressed;
if (_middleButtonPressed && !middleButtonStillPressed)
{
Interaction.ExecuteActions(AssociatedObject, Actions, null);
}
}
}
}
@@ -0,0 +1,27 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace FluentTerminal.App.Converters
{
public class FalseToVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is Boolean collapsed)
{
return collapsed ? Visibility.Collapsed : Visibility.Visible;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is Visibility visibility)
{
return visibility == Visibility.Collapsed;
}
return null;
}
}
}
@@ -0,0 +1,50 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace FluentTerminal.App.Converters
{
public class IntToVisibilityConverter : DependencyObject, IValueConverter
{
public static readonly DependencyProperty ElseProperty =
DependencyProperty.Register(nameof(Else), typeof(Visibility), typeof(IntToVisibilityConverter), new PropertyMetadata(Visibility.Collapsed));
public static readonly DependencyProperty IfProperty =
DependencyProperty.Register(nameof(If), typeof(int), typeof(IntToVisibilityConverter), new PropertyMetadata(0));
public static readonly DependencyProperty ThenProperty =
DependencyProperty.Register(nameof(Then), typeof(Visibility), typeof(IntToVisibilityConverter), new PropertyMetadata(Visibility.Visible));
public Visibility Else
{
get { return (Visibility)GetValue(ElseProperty); }
set { SetValue(ElseProperty, value); }
}
public int If
{
get { return (int)GetValue(IfProperty); }
set { SetValue(IfProperty, value); }
}
public Visibility Then
{
get { return (Visibility)GetValue(ThenProperty); }
set { SetValue(ThenProperty, value); }
}
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is int count)
{
return count == If ? Then : Else;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,22 @@
using System;
using Windows.UI.Xaml.Data;
namespace FluentTerminal.App.Converters
{
public class NegateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is bool boolean)
{
return !boolean;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,39 @@
using FluentTerminal.App.ViewModels;
using FluentTerminal.App.Views;
using System;
using System.Collections.Generic;
using Windows.UI.Xaml.Data;
namespace FluentTerminal.App.Converters
{
internal class TerminalViewModelToViewConverter : IValueConverter
{
private Dictionary<int, TerminalView> _viewDictionary;
public TerminalViewModelToViewConverter()
{
_viewDictionary = new Dictionary<int, TerminalView>();
}
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is TerminalViewModel terminal)
{
if (_viewDictionary.TryGetValue(terminal.Id, out TerminalView view))
{
return view;
}
var newView = new TerminalView(terminal);
_viewDictionary.Add(terminal.Id, newView);
return newView;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,27 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace FluentTerminal.App.Converters
{
public class TrueToVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is Boolean visible)
{
return visible ? Visibility.Visible : Visibility.Collapsed;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is Visibility visibility)
{
return visibility == Visibility.Visible;
}
return null;
}
}
}
+205 -14
View File
@@ -19,7 +19,7 @@
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>FluentTerminal.App_StoreKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>8FA8EF727E767FAE5409DDD1694C1CEE054A2962</PackageCertificateThumbprint>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
</PropertyGroup>
@@ -99,6 +99,32 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Behaviors\MiddleClickBehavior.cs" />
<Compile Include="Converters\FalseToVisibleConverter.cs" />
<Compile Include="Converters\IntToVisibilityConverter.cs" />
<Compile Include="Converters\NegateConverter.cs" />
<Compile Include="Converters\TerminalViewModelToViewConverter.cs" />
<Compile Include="Converters\TrueToVisibleConverter.cs" />
<Compile Include="Services\IDialogService.cs" />
<Compile Include="Services\Implementation\DialogService.cs" />
<Compile Include="Services\Implementation\KeyboardCommandService.cs" />
<Compile Include="Services\IKeyboardCommandService.cs" />
<Compile Include="Utilities\ApplicationDataContainerExtensions.cs" />
<Compile Include="Services\IDefaultValueProvider.cs" />
<Compile Include="Services\Implementation\DefaultValueProvider.cs" />
<Compile Include="Services\Implementation\SettingsService.cs" />
<Compile Include="Services\Implementation\TerminalService.cs" />
<Compile Include="Services\ISettingsService.cs" />
<Compile Include="Services\ITerminalService.cs" />
<Compile Include="Utilities\ColorExtensions.cs" />
<Compile Include="Utilities\HttpJsonContent.cs" />
<Compile Include="Utilities\IHttpContentExtensions.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\ThemeViewModel.cs" />
<Compile Include="ViewModels\TerminalViewModel.cs" />
<Compile Include="Views\BindableColorsTitleBar.cs" />
<Compile Include="Views\ITerminalView.cs" />
<Compile Include="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
@@ -106,16 +132,37 @@
<Compile Include="Views\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TerminalPage.xaml.cs">
<DependentUpon>TerminalPage.xaml</DependentUpon>
<Compile Include="Views\SettingsPages\ThemeSettings.xaml.cs">
<DependentUpon>ThemeSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPages\TerminalSettings.xaml.cs">
<DependentUpon>TerminalSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPages\GeneralSettings.xaml.cs">
<DependentUpon>GeneralSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPages\KeyBindingSettings.xaml.cs">
<DependentUpon>KeyBindingSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPages\ShellSettings.xaml.cs">
<DependentUpon>ShellSettings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TerminalColorPicker.xaml.cs">
<DependentUpon>TerminalColorPicker.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TerminalView.xaml.cs">
<DependentUpon>TerminalView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets\settingsicons.ttf" />
<None Include="FluentTerminal.App_StoreKey.pfx" />
<None Include="FluentTerminal.App_TemporaryKey.pfx" />
<Content Include="Win32\FluentTerminal.Models.dll" />
<Content Include="Win32\FluentTerminal.Models.pdb" />
<Content Include="Win32\FluentTerminal.SystemTray.exe.config" />
</ItemGroup>
<ItemGroup>
@@ -166,13 +213,6 @@
<Content Include="Assets\AppIcons\Wide310x150Logo.scale-400.png" />
<None Include="Package.StoreAssociation.xml" />
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
<Content Include="Win32\Client\bundle.js" />
<Content Include="Win32\Client\index.html" />
<Content Include="Win32\Client\style.css" />
@@ -182,16 +222,113 @@
<Content Include="Win32\Fleck.dll" />
<Content Include="Win32\FluentTerminal.SystemTray.exe" />
<Content Include="Win32\FluentTerminal.SystemTray.pdb" />
<Content Include="Win32\GlobalHotKey.dll" />
<Content Include="Win32\Microsoft.Owin.dll" />
<Content Include="Win32\Microsoft.Owin.FileSystems.dll" />
<Content Include="Win32\Microsoft.Owin.Host.HttpListener.dll" />
<Content Include="Win32\Microsoft.Owin.Hosting.dll" />
<Content Include="Win32\Microsoft.Owin.StaticFiles.dll" />
<Content Include="Win32\Microsoft.Win32.Primitives.dll" />
<Content Include="Win32\netstandard.dll" />
<Content Include="Win32\Newtonsoft.Json.dll" />
<Content Include="Win32\Owin.dll" />
<Content Include="Win32\System.AppContext.dll" />
<Content Include="Win32\System.Collections.Concurrent.dll" />
<Content Include="Win32\System.Collections.dll" />
<Content Include="Win32\System.Collections.NonGeneric.dll" />
<Content Include="Win32\System.Collections.Specialized.dll" />
<Content Include="Win32\System.ComponentModel.dll" />
<Content Include="Win32\System.ComponentModel.EventBasedAsync.dll" />
<Content Include="Win32\System.ComponentModel.Primitives.dll" />
<Content Include="Win32\System.ComponentModel.TypeConverter.dll" />
<Content Include="Win32\System.Console.dll" />
<Content Include="Win32\System.Data.Common.dll" />
<Content Include="Win32\System.Diagnostics.Contracts.dll" />
<Content Include="Win32\System.Diagnostics.Debug.dll" />
<Content Include="Win32\System.Diagnostics.FileVersionInfo.dll" />
<Content Include="Win32\System.Diagnostics.Process.dll" />
<Content Include="Win32\System.Diagnostics.StackTrace.dll" />
<Content Include="Win32\System.Diagnostics.TextWriterTraceListener.dll" />
<Content Include="Win32\System.Diagnostics.Tools.dll" />
<Content Include="Win32\System.Diagnostics.TraceSource.dll" />
<Content Include="Win32\System.Diagnostics.Tracing.dll" />
<Content Include="Win32\System.Drawing.Primitives.dll" />
<Content Include="Win32\System.Dynamic.Runtime.dll" />
<Content Include="Win32\System.Globalization.Calendars.dll" />
<Content Include="Win32\System.Globalization.dll" />
<Content Include="Win32\System.Globalization.Extensions.dll" />
<Content Include="Win32\System.IO.Compression.dll" />
<Content Include="Win32\System.IO.Compression.ZipFile.dll" />
<Content Include="Win32\System.IO.dll" />
<Content Include="Win32\System.IO.FileSystem.dll" />
<Content Include="Win32\System.IO.FileSystem.DriveInfo.dll" />
<Content Include="Win32\System.IO.FileSystem.Primitives.dll" />
<Content Include="Win32\System.IO.FileSystem.Watcher.dll" />
<Content Include="Win32\System.IO.IsolatedStorage.dll" />
<Content Include="Win32\System.IO.MemoryMappedFiles.dll" />
<Content Include="Win32\System.IO.Pipes.dll" />
<Content Include="Win32\System.IO.UnmanagedMemoryStream.dll" />
<Content Include="Win32\System.Linq.dll" />
<Content Include="Win32\System.Linq.Expressions.dll" />
<Content Include="Win32\System.Linq.Parallel.dll" />
<Content Include="Win32\System.Linq.Queryable.dll" />
<Content Include="Win32\System.Net.Http.dll" />
<Content Include="Win32\System.Net.Http.Formatting.dll" />
<Content Include="Win32\System.Net.NameResolution.dll" />
<Content Include="Win32\System.Net.NetworkInformation.dll" />
<Content Include="Win32\System.Net.Ping.dll" />
<Content Include="Win32\System.Net.Primitives.dll" />
<Content Include="Win32\System.Net.Requests.dll" />
<Content Include="Win32\System.Net.Security.dll" />
<Content Include="Win32\System.Net.Sockets.dll" />
<Content Include="Win32\System.Net.WebHeaderCollection.dll" />
<Content Include="Win32\System.Net.WebSockets.Client.dll" />
<Content Include="Win32\System.Net.WebSockets.dll" />
<Content Include="Win32\System.ObjectModel.dll" />
<Content Include="Win32\System.Reflection.dll" />
<Content Include="Win32\System.Reflection.Extensions.dll" />
<Content Include="Win32\System.Reflection.Primitives.dll" />
<Content Include="Win32\System.Resources.Reader.dll" />
<Content Include="Win32\System.Resources.ResourceManager.dll" />
<Content Include="Win32\System.Resources.Writer.dll" />
<Content Include="Win32\System.Runtime.CompilerServices.VisualC.dll" />
<Content Include="Win32\System.Runtime.dll" />
<Content Include="Win32\System.Runtime.Extensions.dll" />
<Content Include="Win32\System.Runtime.Handles.dll" />
<Content Include="Win32\System.Runtime.InteropServices.dll" />
<Content Include="Win32\System.Runtime.InteropServices.RuntimeInformation.dll" />
<Content Include="Win32\System.Runtime.Numerics.dll" />
<Content Include="Win32\System.Runtime.Serialization.Formatters.dll" />
<Content Include="Win32\System.Runtime.Serialization.Json.dll" />
<Content Include="Win32\System.Runtime.Serialization.Primitives.dll" />
<Content Include="Win32\System.Runtime.Serialization.Xml.dll" />
<Content Include="Win32\System.Security.Claims.dll" />
<Content Include="Win32\System.Security.Cryptography.Algorithms.dll" />
<Content Include="Win32\System.Security.Cryptography.Csp.dll" />
<Content Include="Win32\System.Security.Cryptography.Encoding.dll" />
<Content Include="Win32\System.Security.Cryptography.Primitives.dll" />
<Content Include="Win32\System.Security.Cryptography.X509Certificates.dll" />
<Content Include="Win32\System.Security.Principal.dll" />
<Content Include="Win32\System.Security.SecureString.dll" />
<Content Include="Win32\System.Text.Encoding.dll" />
<Content Include="Win32\System.Text.Encoding.Extensions.dll" />
<Content Include="Win32\System.Text.RegularExpressions.dll" />
<Content Include="Win32\System.Threading.dll" />
<Content Include="Win32\System.Threading.Overlapped.dll" />
<Content Include="Win32\System.Threading.Tasks.dll" />
<Content Include="Win32\System.Threading.Tasks.Parallel.dll" />
<Content Include="Win32\System.Threading.Thread.dll" />
<Content Include="Win32\System.Threading.ThreadPool.dll" />
<Content Include="Win32\System.Threading.Timer.dll" />
<Content Include="Win32\System.ValueTuple.dll" />
<Content Include="Win32\System.Web.Http.dll" />
<Content Include="Win32\System.Web.Http.Owin.dll" />
<Content Include="Win32\System.Xml.ReaderWriter.dll" />
<Content Include="Win32\System.Xml.XDocument.dll" />
<Content Include="Win32\System.Xml.XmlDocument.dll" />
<Content Include="Win32\System.Xml.XmlSerializer.dll" />
<Content Include="Win32\System.Xml.XPath.dll" />
<Content Include="Win32\System.Xml.XPath.XDocument.dll" />
<Content Include="Win32\Unity.Abstractions.dll" />
<Content Include="Win32\Unity.Abstractions.pdb" />
<Content Include="Win32\Unity.Configuration.dll" />
@@ -230,29 +367,83 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TerminalPage.xaml">
<Page Include="Views\SettingsPages\ThemeSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPages\TerminalSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPages\GeneralSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPages\KeyBindingSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPages\ShellSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TerminalColorPicker.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TerminalView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac">
<Version>4.6.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.0.6</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.3.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>10.0.3</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.21.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<SDKReference Include="WindowsDesktop, Version=10.0.16299.0">
<Name>Windows Desktop Extensions for the UWP</Name>
</SDKReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FluentTerminal.Models\FluentTerminal.Models.csproj">
<Project>{5EA40453-A0AA-449E-8406-D6EA51D7E70E}</Project>
<Name>FluentTerminal.Models</Name>
</ProjectReference>
<ProjectReference Include="..\FluentTerminal.RuntimeComponent\FluentTerminal.RuntimeComponent.csproj">
<Project>{BAAE6239-343F-454C-977F-F81F91715961}</Project>
<Name>FluentTerminal.RuntimeComponent</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)\FluentTerminal.App\bin\$(PlatformName)\$(ConfigurationName)\AppX\Win32" 2&gt; NULL
xcopy /y /s "$(SolutionDir)FluentTerminal.SystemTray\bin\$(PlatformName)\$(ConfigurationName)" "$(SolutionDir)\FluentTerminal.App\bin\$(PlatformName)\$(ConfigurationName)\AppX\Win32"
</PostBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+8 -3
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp desktop rescap">
<Identity Name="53621FSApps.FluentTerminal" Publisher="CN=BDC72197-B634-438A-B863-16DCB7D90C85" Version="0.1.3.0" />
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp desktop rescap">
<Identity Name="53621FSApps.FluentTerminal" Publisher="CN=BDC72197-B634-438A-B863-16DCB7D90C85" Version="0.1.6.0" />
<mp:PhoneIdentity PhoneProductId="f7225014-f405-4342-ad2e-ebf6ac60ea2c" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Fluent Terminal</DisplayName>
@@ -23,13 +23,18 @@
<uap:ShowOn Tile="square310x310Logo" />
</uap:ShowNameOnTiles>
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\AppIcons\SplashScreen.png" />
<uap:SplashScreen Image="Assets\AppIcons\SplashScreen.png" uap5:Optional="true" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.appService">
<uap:AppService Name="FluentTerminalAppService" />
</uap:Extension>
<desktop:Extension Category="windows.fullTrustProcess" Executable="Win32\FluentTerminal.SystemTray.exe" />
<uap5:Extension Category="windows.appExecutionAlias" Executable="FluentTerminal.App.exe" EntryPoint="FluentTerminal.App.App">
<uap5:AppExecutionAlias>
<uap5:ExecutionAlias Alias="flute.exe" />
</uap5:AppExecutionAlias>
</uap5:Extension>
</Extensions>
</Application>
</Applications>
@@ -0,0 +1,16 @@
using FluentTerminal.Models;
using System;
using System.Collections.Generic;
namespace FluentTerminal.App.Services
{
public interface IDefaultValueProvider
{
ShellConfiguration GetDefaultShellConfiguration();
TerminalOptions GetDefaultTerminalOptions();
IEnumerable<KeyBinding> GetDefaultKeyBindings();
ApplicationSettings GetDefaultApplicationSettings();
Guid GetDefaultThemeId();
IEnumerable<TerminalTheme> GetPreInstalledThemes();
}
}
@@ -0,0 +1,15 @@
using System.Threading.Tasks;
namespace FluentTerminal.App.Services
{
public enum DialogButton
{
OK,
Cancel
}
public interface IDialogService
{
Task<DialogButton> ShowDialogAsnyc(string title, string content, params DialogButton[] buttons);
}
}
@@ -0,0 +1,11 @@
using FluentTerminal.Models.Enums;
using System;
namespace FluentTerminal.App.Services
{
public interface IKeyboardCommandService
{
void RegisterCommandHandler(Command command, Action handler);
void SendCommand(Command command);
}
}
@@ -0,0 +1,33 @@
using FluentTerminal.Models;
using System;
using System.Collections.Generic;
namespace FluentTerminal.App.Services
{
public interface ISettingsService
{
event EventHandler CurrentThemeChanged;
event EventHandler TerminalOptionsChanged;
event EventHandler ApplicationSettingsChanged;
ShellConfiguration GetShellConfiguration();
void SaveShellConfiguration(ShellConfiguration shellConfiguration);
TerminalOptions GetTerminalOptions();
void SaveTerminalOptions(TerminalOptions terminalOptions);
ApplicationSettings GetApplicationSettings();
void SaveApplicationSettings(ApplicationSettings applicationSettings);
IEnumerable<KeyBinding> GetKeyBindings();
TerminalTheme GetCurrentTheme();
Guid GetCurrentThemeId();
TerminalTheme GetTheme(Guid id);
void SaveCurrentThemeId(Guid id);
IEnumerable<TerminalTheme> GetThemes();
void SaveTheme(TerminalTheme theme);
void DeleteTheme(Guid id);
}
}
@@ -0,0 +1,11 @@
using FluentTerminal.Models;
using System.Threading.Tasks;
namespace FluentTerminal.App.Services
{
public interface ITerminalService
{
Task<CreateTerminalResponse> CreateTerminal(TerminalSize size, ShellConfiguration shellConfiguration);
Task ResizeTerminal(int id, TerminalSize size);
}
}
@@ -0,0 +1,198 @@
using FluentTerminal.Models;
using FluentTerminal.Models.Enums;
using System;
using System.Collections.Generic;
using Windows.System;
namespace FluentTerminal.App.Services.Implementation
{
internal class DefaultValueProvider : IDefaultValueProvider
{
public ShellConfiguration GetDefaultShellConfiguration()
{
return new ShellConfiguration
{
Shell = ShellType.PowerShell,
CustomShellLocation = string.Empty,
WorkingDirectory = string.Empty,
Arguments = string.Empty
};
}
public TerminalOptions GetDefaultTerminalOptions()
{
return new TerminalOptions
{
BellStyle = BellStyle.None,
CursorBlink = true,
CursorStyle = CursorStyle.Block,
FontFamily = "Consolas",
FontSize = 13
};
}
public Guid GetDefaultThemeId()
{
return Guid.Parse("281e4352-bb50-47b7-a691-2b13830df95e");
}
public IEnumerable<TerminalTheme> GetPreInstalledThemes()
{
var defaultXterm = new TerminalTheme
{
Id = GetDefaultThemeId(),
Author = "xterm.js",
Name = "Xterm.js Default",
PreInstalled = true,
BackgroundOpacity = 0.8,
Colors = new TerminalColors
{
Black = "#2e3436",
Red = "#cc0000",
Green = "#4e9a06",
Yellow = "#c4a000",
Blue = "#3465a4",
Magenta = "#75507b",
Cyan = "#06989a",
White = "#d3d7cf",
BrightBlack = "#555753",
BrightRed = "#ef2929",
BrightGreen = "#8ae234",
BrightYellow = "#fce94f",
BrightBlue = "#729fcf",
BrightMagenta = "#ad7fa8",
BrightCyan = "#34e2e2",
BrightWhite = "#eeeeec",
Foreground = "#ffffff",
Background = "#000000",
Cursor = "#ffffff",
CursorAccent = "#000000",
Selection = "rgba(255, 255, 255, 0.3)"
}
};
var powerShell = new TerminalTheme
{
Id = Guid.Parse("3571ce1b-31ce-4cf7-ae15-e0bff70c3eea"),
Author = "Microsoft",
Name = "PowerShell",
PreInstalled = true,
BackgroundOpacity = 0.8,
Colors = new TerminalColors
{
Black = "#000000",
Red = "#800000",
Green = "#008000",
Yellow = "#EEEDF0",
Blue = "#000080",
Magenta = "#012456",
Cyan = "#008080",
White = "#c0c0c0",
BrightBlack = "#808080",
BrightRed = "#ff0000",
BrightGreen = "#00ff00",
BrightYellow = "#ffff00",
BrightBlue = "#0000ff",
BrightMagenta = "#ff00ff",
BrightCyan = "#00ffff",
BrightWhite = "#ffffff",
Foreground = "#ffffff",
Background = "#012456",
Cursor = "#fedba9",
CursorAccent = "#000000",
Selection = "#fedba9"
}
};
return new[] { defaultXterm, powerShell };
}
public IEnumerable<KeyBinding> GetDefaultKeyBindings()
{
return new[]
{
new KeyBinding
{
Command = Command.NewTab,
Ctrl = true,
Alt = false,
Meta = false,
Shift = false,
Key = (int)VirtualKey.T
},
new KeyBinding
{
Command = Command.CloseTab,
Ctrl = true,
Alt = false,
Meta = false,
Shift = false,
Key = (int)VirtualKey.W
},
new KeyBinding
{
Command = Command.NextTab,
Ctrl = true,
Alt = false,
Meta = false,
Shift = false,
Key = (int)VirtualKey.Tab
},
new KeyBinding
{
Command = Command.PreviousTab,
Ctrl = true,
Alt = false,
Meta = false,
Shift = true,
Key = (int)VirtualKey.Tab
},
new KeyBinding
{
Command = Command.NewWindow,
Ctrl = true,
Alt = false,
Meta = false,
Shift = false,
Key = (int)VirtualKey.N
},
new KeyBinding
{
Command = Command.ShowSettings,
Ctrl = true,
Alt = false,
Meta = false,
Shift = false,
Key = 188 // comma
},
new KeyBinding
{
Command = Command.Copy,
Ctrl = true,
Alt = false,
Meta = false,
Shift = true,
Key = (int)VirtualKey.C
},
new KeyBinding
{
Command = Command.Paste,
Ctrl = true,
Alt = false,
Meta = false,
Shift = false,
Key = (int)VirtualKey.V
}
};
}
public ApplicationSettings GetDefaultApplicationSettings()
{
return new ApplicationSettings
{
ConfirmClosingTabs = false,
ConfirmClosingWindows = false
};
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Threading.Tasks;
using Windows.UI.Popups;
namespace FluentTerminal.App.Services.Implementation
{
internal class DialogService : IDialogService
{
public async Task<DialogButton> ShowDialogAsnyc(string title, string content, params DialogButton[] buttons)
{
var dialog = new MessageDialog(content, title);
foreach (var button in buttons)
{
dialog.Commands.Add(new UICommand(button.ToString()));
}
var result = await dialog.ShowAsync();
return Enum.Parse<DialogButton>(result.Label);
}
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using FluentTerminal.Models.Enums;
namespace FluentTerminal.App.Services.Implementation
{
public class KeyboardCommandService : IKeyboardCommandService
{
private Dictionary<Command, Action> _commandHandlers = new Dictionary<Command, Action>();
public void RegisterCommandHandler(Command command, Action handler)
{
_commandHandlers[command] = handler;
}
public void SendCommand(Command command)
{
if (_commandHandlers.TryGetValue(command, out Action handler))
{
handler.Invoke();
return;
}
throw new Exception($"No handler registered for command: {command}");
}
}
}
@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentTerminal.App.Utilities;
using FluentTerminal.Models;
using Newtonsoft.Json;
using Windows.Storage;
namespace FluentTerminal.App.Services.Implementation
{
internal class SettingsService : ISettingsService
{
private readonly IDefaultValueProvider _defaultValueProvider;
private ApplicationDataContainer _localSettings;
private ApplicationDataContainer _themes;
private ApplicationDataContainer _roamingSettings;
public event EventHandler CurrentThemeChanged;
public event EventHandler TerminalOptionsChanged;
public event EventHandler ApplicationSettingsChanged;
public SettingsService(IDefaultValueProvider defaultValueProvider)
{
_defaultValueProvider = defaultValueProvider;
_localSettings = ApplicationData.Current.LocalSettings;
_roamingSettings = ApplicationData.Current.RoamingSettings;
_themes = _roamingSettings.CreateContainer("Themes", ApplicationDataCreateDisposition.Always);
foreach (var theme in _defaultValueProvider.GetPreInstalledThemes())
{
_themes.WriteValueAsJson(theme.Id.ToString(), theme);
}
ApplicationData.Current.DataChanged += OnDataChanged;
}
private void OnDataChanged(ApplicationData sender, object args)
{
//todo handle data changed for roaming settings
}
public ShellConfiguration GetShellConfiguration()
{
return _localSettings.ReadValueFromJson(nameof(ShellConfiguration), _defaultValueProvider.GetDefaultShellConfiguration());
}
public void SaveShellConfiguration(ShellConfiguration shellConfiguration)
{
_localSettings.WriteValueAsJson(nameof(ShellConfiguration), shellConfiguration);
}
public TerminalTheme GetCurrentTheme()
{
var id = GetCurrentThemeId();
return GetTheme(id);
}
public Guid GetCurrentThemeId()
{
if (_roamingSettings.Values.TryGetValue("CurrentTheme", out object value))
{
return (Guid)value;
}
return _defaultValueProvider.GetDefaultThemeId();
}
public void SaveCurrentThemeId(Guid id)
{
_roamingSettings.Values["CurrentTheme"] = id;
CurrentThemeChanged?.Invoke(this, EventArgs.Empty);
}
public void SaveTheme(TerminalTheme theme)
{
_themes.WriteValueAsJson(theme.Id.ToString(), theme);
if (theme.Id == GetCurrentThemeId())
{
CurrentThemeChanged?.Invoke(this, EventArgs.Empty);
}
}
public void DeleteTheme(Guid id)
{
_themes.Values.Remove(id.ToString());
}
public IEnumerable<TerminalTheme> GetThemes()
{
return _themes.Values.Select(x => JsonConvert.DeserializeObject<TerminalTheme>((string)x.Value)).ToList();
}
public TerminalTheme GetTheme(Guid id)
{
return _themes.ReadValueFromJson(id.ToString(), default(TerminalTheme));
}
public TerminalOptions GetTerminalOptions()
{
return _roamingSettings.ReadValueFromJson(nameof(TerminalOptions), _defaultValueProvider.GetDefaultTerminalOptions());
}
public void SaveTerminalOptions(TerminalOptions terminalOptions)
{
_roamingSettings.WriteValueAsJson(nameof(TerminalOptions), terminalOptions);
TerminalOptionsChanged?.Invoke(this, EventArgs.Empty);
}
public ApplicationSettings GetApplicationSettings()
{
return _roamingSettings.ReadValueFromJson(nameof(ApplicationSettings), _defaultValueProvider.GetDefaultApplicationSettings());
}
public void SaveApplicationSettings(ApplicationSettings applicationSettings)
{
_roamingSettings.WriteValueAsJson(nameof(ApplicationSettings), applicationSettings);
ApplicationSettingsChanged?.Invoke(this, EventArgs.Empty);
}
public IEnumerable<KeyBinding> GetKeyBindings()
{
return _roamingSettings.ReadValueFromJson("KeyBindings", _defaultValueProvider.GetDefaultKeyBindings());
}
}
}
@@ -0,0 +1,37 @@
using System;
using System.Threading.Tasks;
using FluentTerminal.App.Utilities;
using FluentTerminal.Models;
using Windows.Web.Http;
namespace FluentTerminal.App.Services.Implementation
{
internal class TerminalService : ITerminalService
{
private readonly HttpClient _httpClient;
public TerminalService()
{
_httpClient = new HttpClient();
}
public async Task<CreateTerminalResponse> CreateTerminal(TerminalSize size, ShellConfiguration shellConfiguration)
{
var request = new CreateTerminalRequest
{
Size = size,
Configuration = shellConfiguration
};
var response = await _httpClient.PostAsync(new Uri($"http://localhost:9000/terminals"), HttpJsonContent.From(request));
var createTerminalResponse = await response.Content.ReadAs<CreateTerminalResponse>();
return createTerminalResponse;
}
public Task ResizeTerminal(int id, TerminalSize size)
{
return _httpClient.PostAsync(new Uri($"http://localhost:9000/terminals/{id}/resize"), HttpJsonContent.From(size)).AsTask();
}
}
}
+276
View File
@@ -11,6 +11,7 @@
<SolidColorBrush x:Key="TitleBarHoverBackgroundColor" Color="#18FFFFFF" />
<SolidColorBrush x:Key="TitleBarPressedBackgroundColor" Color="#30FFFFFF" />
<SolidColorBrush x:Key="DisabledForegroundColor" Color="#80FFFFFF" />
<Style x:Key="TitleBarButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
@@ -68,4 +69,279 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ColorPreviewButtonStyle" TargetType="Button">
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
<ContentPresenter
x:Name="ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ThemeAppBarButtonStyle" TargetType="AppBarButton">
<Setter Property="BorderBrush" Value="{ThemeResource AppBarButtonBorderBrush}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Width" Value="68" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="AllowFocusOnInteraction" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="AppBarButton">
<Grid
x:Name="Root"
MinWidth="{TemplateBinding MinWidth}"
MaxWidth="{TemplateBinding MaxWidth}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid x:Name="ContentRoot" MinHeight="{ThemeResource AppBarThemeMinHeight}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Viewbox
x:Name="ContentViewbox"
Height="20"
Margin="0,14,0,4"
HorizontalAlignment="Stretch"
AutomationProperties.AccessibilityView="Raw">
<ContentPresenter
x:Name="Content"
Height="20"
Content="{TemplateBinding Icon}"
Foreground="{TemplateBinding Foreground}" />
</Viewbox>
<TextBlock
x:Name="TextLabel"
Grid.Row="1"
Margin="2,0,2,6"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{TemplateBinding FontFamily}"
FontSize="12"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Label}"
TextAlignment="Center"
TextWrapping="Wrap" />
<TextBlock
x:Name="OverflowTextLabel"
Margin="12,0,12,0"
Padding="0,5,0,7"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontFamily="{TemplateBinding FontFamily}"
FontSize="15"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Label}"
TextAlignment="Left"
TextTrimming="Clip"
TextWrapping="NoWrap"
Visibility="Collapsed" />
</Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="FullSize" />
<VisualState x:Name="Compact">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="LabelOnRight">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentViewbox" Storyboard.TargetProperty="Margin">
<DiscreteObjectKeyFrame KeyTime="0" Value="12,14,0,14" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="MinHeight">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="(Grid.Row)">
<DiscreteObjectKeyFrame KeyTime="0" Value="0" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="(Grid.Column)">
<DiscreteObjectKeyFrame KeyTime="0" Value="1" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="TextAlignment">
<DiscreteObjectKeyFrame KeyTime="0" Value="Left" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Margin">
<DiscreteObjectKeyFrame KeyTime="0" Value="8,15,12,17" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="LabelCollapsed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="MinHeight">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Overflow">
<VisualState.Setters>
<Setter Target="ContentRoot.MinHeight" Value="0" />
<Setter Target="ContentViewbox.Visibility" Value="Collapsed" />
<Setter Target="TextLabel.Visibility" Value="Collapsed" />
<Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="OverflowWithToggleButtons">
<VisualState.Setters>
<Setter Target="ContentRoot.MinHeight" Value="0" />
<Setter Target="ContentViewbox.Visibility" Value="Collapsed" />
<Setter Target="TextLabel.Visibility" Value="Collapsed" />
<Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
<Setter Target="OverflowTextLabel.Margin" Value="38,0,12,0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="OverflowWithMenuIcons">
<VisualState.Setters>
<Setter Target="ContentRoot.MinHeight" Value="0" />
<Setter Target="ContentViewbox.HorizontalAlignment" Value="Left" />
<Setter Target="ContentViewbox.VerticalAlignment" Value="Center" />
<Setter Target="ContentViewbox.Width" Value="16" />
<Setter Target="ContentViewbox.Height" Value="16" />
<Setter Target="ContentViewbox.Margin" Value="12,0,12,0" />
<Setter Target="TextLabel.Visibility" Value="Collapsed" />
<Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
<Setter Target="OverflowTextLabel.Margin" Value="38,0,12,0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="OverflowWithToggleButtonsAndMenuIcons">
<VisualState.Setters>
<Setter Target="ContentRoot.MinHeight" Value="0" />
<Setter Target="ContentViewbox.HorizontalAlignment" Value="Left" />
<Setter Target="ContentViewbox.VerticalAlignment" Value="Center" />
<Setter Target="ContentViewbox.Width" Value="16" />
<Setter Target="ContentViewbox.Height" Value="16" />
<Setter Target="ContentViewbox.Margin" Value="38,0,12,0" />
<Setter Target="TextLabel.Visibility" Value="Collapsed" />
<Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
<Setter Target="OverflowTextLabel.Margin" Value="76,0,12,0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="Root.Background" Value="{StaticResource TitleBarHoverBackgroundColor}" />
<Setter Target="Root.BorderBrush" Value="{ThemeResource AppBarButtonBorderBrushPointerOver}" />
</VisualState.Setters>
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="Root.Background" Value="{StaticResource TitleBarPressedBackgroundColor}" />
<Setter Target="Root.BorderBrush" Value="{ThemeResource AppBarButtonBorderBrushPressed}" />
</VisualState.Setters>
<Storyboard>
<PointerDownThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="Root.Background" Value="Transparent" />
<Setter Target="Root.BorderBrush" Value="{ThemeResource AppBarButtonBorderBrushDisabled}" />
<Setter Target="Content.Foreground" Value="{StaticResource DisabledForegroundColor}" />
<Setter Target="TextLabel.Foreground" Value="{StaticResource DisabledForegroundColor}" />
<Setter Target="OverflowTextLabel.Foreground" Value="{StaticResource DisabledForegroundColor}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="OverflowNormal">
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentRoot" />
</Storyboard>
</VisualState>
<VisualState x:Name="OverflowPointerOver">
<VisualState.Setters>
<Setter Target="Root.Background" Value="{StaticResource TitleBarHoverBackgroundColor}" />
<Setter Target="Root.BorderBrush" Value="{ThemeResource AppBarButtonBorderBrushPointerOver}" />
</VisualState.Setters>
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentRoot" />
</Storyboard>
</VisualState>
<VisualState x:Name="OverflowPressed">
<VisualState.Setters>
<Setter Target="Root.Background" Value="{StaticResource TitleBarPressedBackgroundColor}" />
<Setter Target="Root.BorderBrush" Value="{ThemeResource AppBarButtonBorderBrushPressed}" />
</VisualState.Setters>
<Storyboard>
<PointerDownThemeAnimation Storyboard.TargetName="ContentRoot" />
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="InputModeStates">
<VisualState x:Name="InputModeDefault" />
<VisualState x:Name="TouchInputMode">
<VisualState.Setters>
<Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="GameControllerInputMode">
<VisualState.Setters>
<Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using System;
using Windows.Storage;
namespace FluentTerminal.App.Utilities
{
public static class ApplicationDataContainerExtensions
{
public static T ReadValueFromJson<T>(this ApplicationDataContainer container, string name, T fallbackValue)
{
if (container.Values.TryGetValue(name, out object value))
{
if (fallbackValue == null)
{
fallbackValue = Activator.CreateInstance<T>();
}
JsonConvert.PopulateObject((string)value, fallbackValue);
}
return fallbackValue;
}
public static void WriteValueAsJson<T>(this ApplicationDataContainer container, string name, T value)
{
var serialized = JsonConvert.SerializeObject(value);
container.Values[name] = serialized;
}
}
}
@@ -0,0 +1,49 @@
using Microsoft.Toolkit.Uwp.Helpers;
using System.Globalization;
using Windows.UI;
namespace FluentTerminal.App.Utilities
{
public static class ColorExtensions
{
public static string ToColorString(this Color color, bool allowTransparency)
{
if (allowTransparency)
{
return $"rgba({color.R:G}, {color.G:G}, {color.B:G}, {ToDoubleString(color.A)})";
}
else
{
return $"#{color.R:X2}{color.G:X2}{color.B:X2}";
}
}
private static string ToDoubleString(byte alpha)
{
return (alpha / 256.0).ToString(CultureInfo.InvariantCulture);
}
public static Color FromString(this string colorString)
{
if (colorString.Contains("rgba("))
{
colorString = colorString.Replace("rgba(", string.Empty);
colorString = colorString.Replace(")", string.Empty);
var parts = colorString.Split(", ");
return new Color
{
A = (byte)(int)(double.Parse(parts[3]) * 256.0),
R = byte.Parse(parts[0]),
G = byte.Parse(parts[1]),
B = byte.Parse(parts[2])
};
}
else
{
return colorString.ToColor();
}
}
}
}
@@ -0,0 +1,14 @@
using Newtonsoft.Json;
using Windows.Web.Http;
namespace FluentTerminal.App.Utilities
{
public static class HttpJsonContent
{
public static HttpStringContent From(object content)
{
var serialized = JsonConvert.SerializeObject(content);
return new HttpStringContent(serialized, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");
}
}
}
@@ -0,0 +1,16 @@
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
using Windows.Web.Http;
namespace FluentTerminal.App.Utilities
{
public static class IHttpContentExtensions
{
public static async Task<T> ReadAs<T>(this IHttpContent content)
{
var contentBody = await content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(contentBody);
}
}
}
@@ -0,0 +1,198 @@
using FluentTerminal.App.Services;
using FluentTerminal.Models;
using FluentTerminal.Models.Enums;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.Core.Preview;
namespace FluentTerminal.App.ViewModels
{
public class MainViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
private readonly IKeyboardCommandService _keyboardCommandService;
private readonly ISettingsService _settingsService;
private readonly ITerminalService _terminalService;
private ApplicationSettings _applicationSettings;
private string _background;
private double _backgroundOpacity;
private CoreDispatcher _dispatcher;
private int _nextTerminalId;
private TerminalViewModel _selectedTerminal;
public MainViewModel(ISettingsService settingsService, ITerminalService terminalService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService)
{
_settingsService = settingsService;
_settingsService.CurrentThemeChanged += OnCurrentThemeChanged;
_settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
_terminalService = terminalService;
_dialogService = dialogService;
_keyboardCommandService = keyboardCommandService;
_keyboardCommandService.RegisterCommandHandler(Command.NewTab, () => AddTerminal(null));
_keyboardCommandService.RegisterCommandHandler(Command.CloseTab, CloseCurrentTab);
_keyboardCommandService.RegisterCommandHandler(Command.NextTab, SelectNextTab);
_keyboardCommandService.RegisterCommandHandler(Command.PreviousTab, SelectPreviousTab);
_keyboardCommandService.RegisterCommandHandler(Command.NewWindow, async () => await NewWindow());
_keyboardCommandService.RegisterCommandHandler(Command.ShowSettings, async () => await ShowSettings());
var currentTheme = _settingsService.GetCurrentTheme();
Background = currentTheme.Colors.Background;
BackgroundOpacity = currentTheme.BackgroundOpacity;
_applicationSettings = _settingsService.GetApplicationSettings();
AddTerminalCommand = new RelayCommand(() => AddTerminal(null));
ShowSettingsCommand = new RelayCommand(async () => await ShowSettings());
_dispatcher = CoreApplication.GetCurrentView().Dispatcher;
SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += OnCloseRequest;
}
public RelayCommand AddTerminalCommand { get; }
public string Background
{
get => _background;
set => Set(ref _background, value);
}
public double BackgroundOpacity
{
get => _backgroundOpacity;
set => Set(ref _backgroundOpacity, value);
}
public TerminalViewModel SelectedTerminal
{
get => _selectedTerminal;
set
{
if (Set(ref _selectedTerminal, value))
{
SelectedTerminal?.FocusTerminal();
}
}
}
public RelayCommand ShowSettingsCommand { get; }
public ObservableCollection<TerminalViewModel> Terminals { get; } = new ObservableCollection<TerminalViewModel>();
public void AddTerminal(string startupDirectory)
{
var terminal = new TerminalViewModel(GetNextTerminalId(), _settingsService, _terminalService, _dialogService, _keyboardCommandService, _applicationSettings, startupDirectory);
terminal.CloseRequested += OnTerminalCloseRequested;
Terminals.Add(terminal);
SelectedTerminal = terminal;
}
public void CloseAllTerminals()
{
foreach (var terminal in Terminals)
{
terminal.CloseView();
}
}
private void CloseCurrentTab()
{
SelectedTerminal?.CloseCommand.Execute(null);
}
private int GetNextTerminalId()
{
return _nextTerminalId++;
}
private Task NewWindow()
{
return App.Instance.CreateNewTerminalWindow(null);
}
private async void OnApplicationSettingsChanged(object sender, EventArgs e)
{
await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
_applicationSettings = _settingsService.GetApplicationSettings();
});
}
private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
{
var deferral = e.GetDeferral();
if (_applicationSettings.ConfirmClosingWindows)
{
var result = await _dialogService.ShowDialogAsnyc("Please confirm", "Are you sure you want to close this window?", DialogButton.OK, DialogButton.Cancel);
if (result == DialogButton.OK)
{
CloseAllTerminals();
App.Instance.TerminalWindowClosed();
}
else
{
e.Handled = true;
}
}
else
{
CloseAllTerminals();
App.Instance.TerminalWindowClosed();
}
deferral.Complete();
}
private async void OnCurrentThemeChanged(object sender, System.EventArgs e)
{
await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
var currentTheme = _settingsService.GetCurrentTheme();
Background = currentTheme.Colors.Background;
BackgroundOpacity = currentTheme.BackgroundOpacity;
});
}
private void OnTerminalCloseRequested(object sender, EventArgs e)
{
if (Terminals.Count == 1)
{
return;
}
if (sender is TerminalViewModel terminal)
{
terminal.CloseView();
if (SelectedTerminal == terminal)
{
SelectedTerminal = Terminals.LastOrDefault(t => t != terminal);
}
Terminals.Remove(terminal);
}
}
private void SelectNextTab()
{
var currentIndex = Terminals.IndexOf(SelectedTerminal);
var nextIndex = (currentIndex + 1) % Terminals.Count;
SelectedTerminal = Terminals[nextIndex];
}
private void SelectPreviousTab()
{
var currentIndex = Terminals.IndexOf(SelectedTerminal);
var previousIndex = (currentIndex - 1 + Terminals.Count) % Terminals.Count;
SelectedTerminal = Terminals[previousIndex];
}
private Task ShowSettings()
{
return App.Instance.ShowSettings();
}
}
}
@@ -0,0 +1,371 @@
using FluentTerminal.App.Services;
using FluentTerminal.Models;
using FluentTerminal.Models.Enums;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Graphics.Canvas.Text;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage.Pickers;
namespace FluentTerminal.App.ViewModels
{
public class SettingsViewModel : ViewModelBase
{
private readonly IDefaultValueProvider _defaultValueProvider;
private readonly IDialogService _dialogService;
private readonly ISettingsService _settingsService;
private ApplicationSettings _applicationSettings;
private ThemeViewModel _selectedTheme;
private ShellConfiguration _shellConfiguration;
private TerminalOptions _terminalOptions;
public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService)
{
_settingsService = settingsService;
_defaultValueProvider = defaultValueProvider;
_dialogService = dialogService;
BrowseForCustomShellCommand = new RelayCommand(async () => await BrowseForCustomShell());
BrowseForWorkingDirectoryCommand = new RelayCommand(async () => await BrowseForWorkingDirectory());
RestoreDefaultsCommand = new RelayCommand<string>(async (area) => await RestoreDefaults(area));
CreateThemeCommand = new RelayCommand(CreateTheme);
_shellConfiguration = _settingsService.GetShellConfiguration();
_terminalOptions = _settingsService.GetTerminalOptions();
_applicationSettings = _settingsService.GetApplicationSettings();
ShellType = _shellConfiguration.Shell;
var activeThemeId = _settingsService.GetCurrentThemeId();
foreach (var theme in _settingsService.GetThemes())
{
var viewModel = new ThemeViewModel(theme, _settingsService, _dialogService);
viewModel.Activated += OnThemeActivated;
viewModel.Deleted += OnThemeDeleted;
if (theme.Id == activeThemeId)
{
viewModel.IsActive = true;
}
Themes.Add(viewModel);
}
SelectedTheme = Themes.First();
Fonts = CanvasTextFormat.GetSystemFontFamilies().OrderBy(s => s);
Sizes = Enumerable.Range(1, 72);
}
public string Arguments
{
get => _shellConfiguration.Arguments;
set
{
if (_shellConfiguration.Arguments != value)
{
_shellConfiguration.Arguments = value;
_settingsService.SaveShellConfiguration(_shellConfiguration);
RaisePropertyChanged();
}
}
}
public bool BarIsSelected
{
get => CursorStyle == CursorStyle.Bar;
set => CursorStyle = CursorStyle.Bar;
}
public bool BlockIsSelected
{
get => CursorStyle == CursorStyle.Block;
set => CursorStyle = CursorStyle.Block;
}
public RelayCommand BrowseForCustomShellCommand { get; }
public RelayCommand BrowseForWorkingDirectoryCommand { get; }
public bool CMDIsSelected
{
get => ShellType == ShellType.CMD;
set => ShellType = ShellType.CMD;
}
public bool ConfirmClosingTabs
{
get => _applicationSettings.ConfirmClosingTabs;
set
{
if (_applicationSettings.ConfirmClosingTabs != value)
{
_applicationSettings.ConfirmClosingTabs = value;
_settingsService.SaveApplicationSettings(_applicationSettings);
RaisePropertyChanged();
}
}
}
public bool ConfirmClosingWindows
{
get => _applicationSettings.ConfirmClosingWindows;
set
{
if (_applicationSettings.ConfirmClosingWindows != value)
{
_applicationSettings.ConfirmClosingWindows = value;
_settingsService.SaveApplicationSettings(_applicationSettings);
RaisePropertyChanged();
}
}
}
public RelayCommand CreateThemeCommand { get; set; }
public bool CursorBlink
{
get => _terminalOptions.CursorBlink;
set
{
if (_terminalOptions.CursorBlink != value)
{
_terminalOptions.CursorBlink = value;
_settingsService.SaveTerminalOptions(_terminalOptions);
RaisePropertyChanged();
}
}
}
public bool CustomShellIsSelected
{
get => ShellType == ShellType.Custom;
set => ShellType = ShellType.Custom;
}
public string CustomShellLocation
{
get => _shellConfiguration.CustomShellLocation;
set
{
if (_shellConfiguration.CustomShellLocation != value)
{
_shellConfiguration.CustomShellLocation = value;
_settingsService.SaveShellConfiguration(_shellConfiguration);
RaisePropertyChanged();
}
}
}
public string FontFamily
{
get => _terminalOptions.FontFamily;
set
{
if (_terminalOptions.FontFamily != value)
{
_terminalOptions.FontFamily = value;
_settingsService.SaveTerminalOptions(_terminalOptions);
RaisePropertyChanged();
}
}
}
public IEnumerable<string> Fonts { get; }
public int FontSize
{
get => _terminalOptions.FontSize;
set
{
if (_terminalOptions.FontSize != value)
{
_terminalOptions.FontSize = value;
_settingsService.SaveTerminalOptions(_terminalOptions);
RaisePropertyChanged();
}
}
}
public bool PoweShellIsSelected
{
get => ShellType == ShellType.PowerShell;
set => ShellType = ShellType.PowerShell;
}
public RelayCommand<string> RestoreDefaultsCommand { get; }
public ThemeViewModel SelectedTheme
{
get => _selectedTheme;
set => Set(ref _selectedTheme, value);
}
public ShellType ShellType
{
get => _shellConfiguration.Shell;
set
{
if (_shellConfiguration.Shell != value)
{
_shellConfiguration.Shell = value;
_settingsService.SaveShellConfiguration(_shellConfiguration);
RaisePropertyChanged();
RaisePropertyChanged(nameof(CustomShellIsSelected));
RaisePropertyChanged(nameof(PoweShellIsSelected));
RaisePropertyChanged(nameof(CMDIsSelected));
}
}
}
public IEnumerable<int> Sizes { get; }
public ObservableCollection<ThemeViewModel> Themes { get; } = new ObservableCollection<ThemeViewModel>();
public bool UnderlineIsSelected
{
get => CursorStyle == CursorStyle.Underline;
set => CursorStyle = CursorStyle.Underline;
}
public string WorkingDirectory
{
get => _shellConfiguration.WorkingDirectory;
set
{
if (_shellConfiguration.WorkingDirectory != value)
{
_shellConfiguration.WorkingDirectory = value;
_settingsService.SaveShellConfiguration(_shellConfiguration);
RaisePropertyChanged();
}
}
}
private CursorStyle CursorStyle
{
get => _terminalOptions.CursorStyle;
set
{
if (_terminalOptions.CursorStyle != value)
{
_terminalOptions.CursorStyle = value;
_settingsService.SaveTerminalOptions(_terminalOptions);
RaisePropertyChanged();
RaisePropertyChanged(nameof(BlockIsSelected));
RaisePropertyChanged(nameof(BarIsSelected));
RaisePropertyChanged(nameof(UnderlineIsSelected));
}
}
}
private async Task BrowseForCustomShell()
{
var picker = new FileOpenPicker();
picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
picker.FileTypeFilter.Add(".exe");
var file = await picker.PickSingleFileAsync().AsTask();
if (file != null)
{
CustomShellLocation = file.Path;
}
}
private async Task BrowseForWorkingDirectory()
{
var picker = new FolderPicker();
picker.FileTypeFilter.Add(".whatever"); // else a ComException is thrown
picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
var folder = await picker.PickSingleFolderAsync();
if (folder != null)
{
WorkingDirectory = folder.Path;
}
}
private void CreateTheme()
{
var defaultTheme = _settingsService.GetTheme(_defaultValueProvider.GetDefaultThemeId());
var theme = new TerminalTheme
{
Id = Guid.NewGuid(),
PreInstalled = false,
Name = "New Theme",
BackgroundOpacity = defaultTheme.BackgroundOpacity,
Colors = new TerminalColors(defaultTheme.Colors)
};
_settingsService.SaveTheme(theme);
var viewModel = new ThemeViewModel(theme, _settingsService, _dialogService);
viewModel.Activated += OnThemeActivated;
viewModel.Deleted += OnThemeDeleted;
Themes.Add(viewModel);
SelectedTheme = viewModel;
}
private void OnThemeActivated(object sender, EventArgs e)
{
if (sender is ThemeViewModel activatedTheme)
{
_settingsService.SaveCurrentThemeId(activatedTheme.Id);
foreach (var theme in Themes)
{
theme.IsActive = theme.Id == activatedTheme.Id;
}
}
}
private void OnThemeDeleted(object sender, EventArgs e)
{
if (sender is ThemeViewModel theme)
{
if (SelectedTheme == theme)
{
SelectedTheme = Themes.First();
}
Themes.Remove(theme);
if (theme.IsActive)
{
Themes.First().IsActive = true;
_settingsService.SaveCurrentThemeId(Themes.First().Id);
}
_settingsService.DeleteTheme(theme.Id);
}
}
private async Task RestoreDefaults(string area)
{
var result = await _dialogService.ShowDialogAsnyc("Please confirm", "Are you sure you want to restore default values for this page?", DialogButton.OK, DialogButton.Cancel);
if (result == DialogButton.OK && area == "shell")
{
var defaults = _defaultValueProvider.GetDefaultShellConfiguration();
ShellType = defaults.Shell;
CustomShellLocation = defaults.CustomShellLocation;
WorkingDirectory = defaults.WorkingDirectory;
Arguments = defaults.Arguments;
}
else if (result == DialogButton.OK && area == "terminal")
{
var defaults = _defaultValueProvider.GetDefaultTerminalOptions();
CursorBlink = defaults.CursorBlink;
CursorStyle = defaults.CursorStyle;
FontFamily = defaults.FontFamily;
FontSize = defaults.FontSize;
}
else if (result == DialogButton.OK && area == "general")
{
var defaults = _defaultValueProvider.GetDefaultApplicationSettings();
ConfirmClosingWindows = defaults.ConfirmClosingWindows;
ConfirmClosingTabs = defaults.ConfirmClosingTabs;
}
}
}
}
@@ -0,0 +1,240 @@
using FluentTerminal.App.Services;
using FluentTerminal.App.Views;
using FluentTerminal.Models;
using FluentTerminal.Models.Enums;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Core;
using Windows.UI.Xaml;
namespace FluentTerminal.App.ViewModels
{
public class TerminalViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
private readonly IKeyboardCommandService _keyboardCommandService;
private readonly ISettingsService _settingsService;
private readonly ITerminalService _terminalService;
private ApplicationSettings _applicationSettings;
private CoreDispatcher _dispatcher;
private string _resizeOverlayContent;
private DispatcherTimer _resizeOverlayTimer;
private bool _showResizeOverlay;
private string _startupDirectory;
private int _terminalId;
private ITerminalView _terminalView;
private string _title;
public TerminalViewModel(int id, ISettingsService settingsService, ITerminalService terminalService, IDialogService dialogService, IKeyboardCommandService keyboardCommandService, ApplicationSettings applicationSettings, string startupDirectory)
{
Id = id;
Title = DefaultTitle;
_settingsService = settingsService;
_settingsService.CurrentThemeChanged += OnCurrentThemeChanged;
_settingsService.TerminalOptionsChanged += OnTerminalOptionsChanged;
_settingsService.ApplicationSettingsChanged += OnApplicationSettingsChanged;
_terminalService = terminalService;
_dialogService = dialogService;
_keyboardCommandService = keyboardCommandService;
_applicationSettings = applicationSettings;
_startupDirectory = startupDirectory;
_resizeOverlayTimer = new DispatcherTimer();
_resizeOverlayTimer.Interval = new TimeSpan(0, 0, 2);
_resizeOverlayTimer.Tick += OnResizeOverlayTimerFinished;
CloseCommand = new RelayCommand(async () => await InvokeCloseRequested());
_dispatcher = CoreApplication.GetCurrentView().Dispatcher;
}
public event EventHandler CloseRequested;
public event EventHandler<string> TitleChanged;
public RelayCommand CloseCommand { get; }
public int Id { get; private set; }
public bool Initialized { get; private set; }
public string DefaultTitle { get; private set; } = "Fluent Terminal";
public string ResizeOverlayContent
{
get => _resizeOverlayContent;
set => Set(ref _resizeOverlayContent, value);
}
public bool ShowResizeOverlay
{
get => _showResizeOverlay;
set
{
Set(ref _showResizeOverlay, value);
if (value)
{
if (_resizeOverlayTimer.IsEnabled)
{
_resizeOverlayTimer.Stop();
}
_resizeOverlayTimer.Start();
}
}
}
public string Title
{
get => _title;
set
{
value = string.IsNullOrWhiteSpace(value) ? DefaultTitle: value;
if (Set(ref _title, value))
{
TitleChanged?.Invoke(this, Title);
}
}
}
public void CloseView()
{
_terminalView.Close();
}
public Task FocusTerminal()
{
return _terminalView?.FocusTerminal();
}
public async Task OnViewIsReady(ITerminalView terminalView)
{
_terminalView = terminalView;
var options = _settingsService.GetTerminalOptions();
var theme = _settingsService.GetCurrentTheme();
var keyBindings = _settingsService.GetKeyBindings();
var size = await _terminalView.CreateTerminal(options, theme.Colors, keyBindings);
var configuration = _settingsService.GetShellConfiguration();
if (!string.IsNullOrWhiteSpace(_startupDirectory))
{
configuration.WorkingDirectory = _startupDirectory;
}
var response = await _terminalService.CreateTerminal(size, configuration);
if (response.Success)
{
_terminalId = response.Id;
_terminalView.TerminalSizeChanged += OnTerminalSizeChanged;
_terminalView.TerminalTitleChanged += OnTerminalTitleChanged;
_terminalView.KeyboardCommandReceived += OnKeyboardCommandReceived;
DefaultTitle = response.ShellExecutableName;
Title = DefaultTitle;
await _terminalView.ConnectToSocket(response.WebSocketUrl);
Initialized = true;
}
else
{
await _dialogService.ShowDialogAsnyc("Error", response.Error, DialogButton.OK);
}
await FocusTerminal();
}
private async Task InvokeCloseRequested()
{
if (_applicationSettings.ConfirmClosingTabs)
{
var result = await _dialogService.ShowDialogAsnyc("Please confirm", "Are you sure you want to close this tab?", DialogButton.OK, DialogButton.Cancel);
if (result == DialogButton.Cancel)
{
return;
}
}
CloseRequested?.Invoke(this, EventArgs.Empty);
}
private async void OnApplicationSettingsChanged(object sender, EventArgs e)
{
await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
_applicationSettings = _settingsService.GetApplicationSettings();
});
}
private async void OnCurrentThemeChanged(object sender, EventArgs e)
{
await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
var currentTheme = _settingsService.GetCurrentTheme();
await _terminalView.ChangeTheme(currentTheme.Colors);
});
}
private async void OnKeyboardCommandReceived(object sender, Command e)
{
if (e == Command.Copy)
{
var selection = await _terminalView.GetSelection();
var dataPackage = new DataPackage();
dataPackage.SetText(selection);
Clipboard.SetContent(dataPackage);
}
else if (e == Command.Paste)
{
var content = Clipboard.GetContent();
if (content.Contains(StandardDataFormats.Text))
{
var text = await content.GetTextAsync();
await _terminalView.Write(text);
}
}
else
{
_keyboardCommandService.SendCommand(e);
}
}
private void OnResizeOverlayTimerFinished(object sender, object e)
{
_resizeOverlayTimer.Stop();
ShowResizeOverlay = false;
}
private async void OnTerminalOptionsChanged(object sender, EventArgs e)
{
await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
var options = _settingsService.GetTerminalOptions();
await _terminalView.ChangeOptions(options);
});
}
private async void OnTerminalSizeChanged(object sender, TerminalSize e)
{
if (!Initialized)
{
return;
}
ResizeOverlayContent = $"{e.Columns} x {e.Rows}";
ShowResizeOverlay = true;
await _terminalService.ResizeTerminal(_terminalId, e);
}
private void OnTerminalTitleChanged(object sender, string e)
{
Title = e;
}
}
}
@@ -0,0 +1,369 @@
using FluentTerminal.App.Services;
using FluentTerminal.App.Utilities;
using FluentTerminal.Models;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Microsoft.Toolkit.Uwp.Helpers;
using System;
using System.Threading.Tasks;
using Windows.UI;
namespace FluentTerminal.App.ViewModels
{
public class ThemeViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
private readonly ISettingsService _settingsService;
private string _author;
private Color _background;
private double _backgroundOpacity;
private Color _black;
private Color _blue;
private Color _brightBlack;
private Color _brightBlue;
private Color _brightCyan;
private Color _brightGreen;
private Color _brightMagenta;
private Color _brightRed;
private Color _brightWhite;
private Color _brightYellow;
private Color _cursor;
private Color _cursorAccent;
private Color _cyan;
private string _fallBackAuthor;
private double _fallBackBackgroundOpacity;
private TerminalColors _fallBackColors;
private string _fallBackName;
private Color _foreground;
private Color _green;
private bool _inEditMode;
private bool _isActive;
private Color _magenta;
private string _name;
private Color _red;
private Color _selection;
private TerminalTheme _theme;
private Color _white;
private Color _yellow;
public ThemeViewModel(TerminalTheme theme, ISettingsService settingsService, IDialogService dialogService)
{
_theme = theme;
_settingsService = settingsService;
_dialogService = dialogService;
Name = _theme.Name;
Author = _theme.Author;
Id = _theme.Id;
BackgroundOpacity = _theme.BackgroundOpacity;
Black = _theme.Colors.Black.ToColor();
Red = _theme.Colors.Red.ToColor();
Green = _theme.Colors.Green.ToColor();
Yellow = _theme.Colors.Yellow.ToColor();
Blue = _theme.Colors.Blue.ToColor();
Magenta = _theme.Colors.Magenta.ToColor();
Cyan = _theme.Colors.Cyan.ToColor();
White = _theme.Colors.White.ToColor();
BrightBlack = _theme.Colors.BrightBlack.ToColor();
BrightRed = _theme.Colors.BrightRed.ToColor();
BrightGreen = _theme.Colors.BrightGreen.ToColor();
BrightYellow = _theme.Colors.BrightYellow.ToColor();
BrightBlue = _theme.Colors.BrightBlue.ToColor();
BrightMagenta = _theme.Colors.BrightMagenta.ToColor();
BrightCyan = _theme.Colors.BrightCyan.ToColor();
BrightWhite = _theme.Colors.BrightWhite.ToColor();
Background = _theme.Colors.Background.ToColor();
Foreground = _theme.Colors.Foreground.ToColor();
Cursor = _theme.Colors.Cursor.ToColor();
CursorAccent = _theme.Colors.CursorAccent.ToColor();
Selection = _theme.Colors.Selection.FromString();
SetActiveCommand = new RelayCommand(SetActive);
DeleteCommand = new RelayCommand(async () => await Delete(), CanDelete);
EditCommand = new RelayCommand(Edit, CanEdit);
CancelEditCommand = new RelayCommand(async () => await CancelEdit());
SaveChangesCommand = new RelayCommand(SaveChanges);
}
public event EventHandler Activated;
public event EventHandler Deleted;
public string Author
{
get => _author;
set => Set(ref _author, value);
}
public Color Background
{
get => _background;
set => Set(ref _background, value);
}
public double BackgroundOpacity
{
get => _backgroundOpacity;
set => Set(ref _backgroundOpacity, value);
}
public Color Black
{
get => _black;
set => Set(ref _black, value);
}
public Color Blue
{
get => _blue;
set => Set(ref _blue, value);
}
public Color BrightBlack
{
get => _brightBlack;
set => Set(ref _brightBlack, value);
}
public Color BrightBlue
{
get => _brightBlue;
set => Set(ref _brightBlue, value);
}
public Color BrightCyan
{
get => _brightCyan;
set => Set(ref _brightCyan, value);
}
public Color BrightGreen
{
get => _brightGreen;
set => Set(ref _brightGreen, value);
}
public Color BrightMagenta
{
get => _brightMagenta;
set => Set(ref _brightMagenta, value);
}
public Color BrightRed
{
get => _brightRed;
set => Set(ref _brightRed, value);
}
public Color BrightWhite
{
get => _brightWhite;
set => Set(ref _brightWhite, value);
}
public Color BrightYellow
{
get => _brightYellow;
set => Set(ref _brightYellow, value);
}
public RelayCommand CancelEditCommand { get; }
public Color Cursor
{
get => _cursor;
set => Set(ref _cursor, value);
}
public Color CursorAccent
{
get => _cursorAccent;
set => Set(ref _cursorAccent, value);
}
public Color Cyan
{
get => _cyan;
set => Set(ref _cyan, value);
}
public RelayCommand DeleteCommand { get; }
public RelayCommand EditCommand { get; }
public Color Foreground
{
get => _foreground;
set => Set(ref _foreground, value);
}
public Color Green
{
get => _green;
set => Set(ref _green, value);
}
public Guid Id { get; }
public bool InEditMode
{
get => _inEditMode;
set => Set(ref _inEditMode, value);
}
public bool IsActive
{
get => _isActive;
set => Set(ref _isActive, value);
}
public Color Magenta
{
get => _magenta;
set => Set(ref _magenta, value);
}
public string Name
{
get => _name;
set => Set(ref _name, value);
}
public Color Red
{
get => _red;
set => Set(ref _red, value);
}
public RelayCommand SaveChangesCommand { get; }
public Color Selection
{
get => _selection;
set => Set(ref _selection, value);
}
public RelayCommand SetActiveCommand { get; }
public Color White
{
get => _white;
set => Set(ref _white, value);
}
public Color Yellow
{
get => _yellow;
set => Set(ref _yellow, value);
}
public void SaveChanges()
{
_theme.Name = Name;
_theme.Author = Author;
_theme.BackgroundOpacity = BackgroundOpacity;
_theme.Colors.Black = Black.ToColorString(false);
_theme.Colors.Red = Red.ToColorString(false);
_theme.Colors.Green = Green.ToColorString(false);
_theme.Colors.Yellow = Yellow.ToColorString(false);
_theme.Colors.Blue = Blue.ToColorString(false);
_theme.Colors.Magenta = Magenta.ToColorString(false);
_theme.Colors.Cyan = Cyan.ToColorString(false);
_theme.Colors.White = White.ToColorString(false);
_theme.Colors.BrightBlack = BrightBlack.ToColorString(false);
_theme.Colors.BrightRed = BrightRed.ToColorString(false);
_theme.Colors.BrightGreen = BrightGreen.ToColorString(false);
_theme.Colors.BrightYellow = BrightYellow.ToColorString(false);
_theme.Colors.BrightBlue = BrightBlue.ToColorString(false);
_theme.Colors.BrightMagenta = BrightMagenta.ToColorString(false);
_theme.Colors.BrightCyan = BrightCyan.ToColorString(false);
_theme.Colors.BrightWhite = BrightWhite.ToColorString(false);
_theme.Colors.Background = Background.ToColorString(false);
_theme.Colors.Foreground = Foreground.ToColorString(false);
_theme.Colors.Cursor = Cursor.ToColorString(false);
_theme.Colors.CursorAccent = CursorAccent.ToColorString(false);
_theme.Colors.Selection = Selection.ToColorString(true);
_settingsService.SaveTheme(_theme);
InEditMode = false;
}
private async Task CancelEdit()
{
var result = await _dialogService.ShowDialogAsnyc("Please confirm", "Are you sure you want to discard all changes?", DialogButton.OK, DialogButton.Cancel);
if (result == DialogButton.OK)
{
Black = _fallBackColors.Black.ToColor();
Red = _fallBackColors.Red.ToColor();
Green = _fallBackColors.Green.ToColor();
Yellow = _fallBackColors.Yellow.ToColor();
Blue = _fallBackColors.Blue.ToColor();
Magenta = _fallBackColors.Magenta.ToColor();
Cyan = _fallBackColors.Cyan.ToColor();
White = _fallBackColors.White.ToColor();
BrightBlack = _fallBackColors.BrightBlack.ToColor();
BrightRed = _fallBackColors.BrightRed.ToColor();
BrightGreen = _fallBackColors.BrightGreen.ToColor();
BrightYellow = _fallBackColors.BrightYellow.ToColor();
BrightBlue = _fallBackColors.BrightBlue.ToColor();
BrightMagenta = _fallBackColors.BrightMagenta.ToColor();
BrightCyan = _fallBackColors.BrightCyan.ToColor();
BrightWhite = _fallBackColors.BrightWhite.ToColor();
Background = _fallBackColors.Background.ToColor();
Foreground = _fallBackColors.Foreground.ToColor();
Cursor = _fallBackColors.Cursor.ToColor();
CursorAccent = _fallBackColors.CursorAccent.ToColor();
Selection = _fallBackColors.Selection.FromString();
Name = _fallBackName;
Author = _fallBackAuthor;
BackgroundOpacity = _fallBackBackgroundOpacity;
InEditMode = false;
}
}
private bool CanDelete()
{
return !_theme.PreInstalled;
}
private bool CanEdit()
{
return !_theme.PreInstalled;
}
private async Task Delete()
{
var result = await _dialogService.ShowDialogAsnyc("Please confirm", "Are you sure you want to delete this theme?", DialogButton.OK, DialogButton.Cancel);
if (result == DialogButton.OK)
{
Deleted?.Invoke(this, EventArgs.Empty);
}
}
private void Edit()
{
_fallBackColors = new TerminalColors(_theme.Colors);
_fallBackName = Name;
_fallBackAuthor = Author;
_fallBackBackgroundOpacity = BackgroundOpacity;
InEditMode = true;
}
private void SetActive()
{
Activated?.Invoke(this, EventArgs.Empty);
}
}
}
@@ -0,0 +1,70 @@
using Windows.UI;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace FluentTerminal.App.Views
{
public sealed class BindableColorsTitleBar : Control
{
private ApplicationViewTitleBar _titleBar;
private Color? _buttonForeground;
private Color? _buttonHoverBackground;
private Color? _buttonPressedBackground;
private Color? _buttonHoverForeground;
private Color? _buttonPressedForeground;
private Color? _inactiveForeground;
public BindableColorsTitleBar()
{
DefaultStyleKey = typeof(BindableColorsTitleBar);
_titleBar = ApplicationView.GetForCurrentView().TitleBar;
_buttonHoverBackground = _titleBar.ButtonHoverBackgroundColor = Color.FromArgb(24, 255, 255, 255);
_buttonPressedBackground = _titleBar.ButtonPressedBackgroundColor = Color.FromArgb(48, 255, 255, 255);
}
public Color TitleBarForeground
{
get { return (Color)GetValue(TitleBarForegroundProperty); }
set { SetValue(TitleBarForegroundProperty, value); }
}
public static readonly DependencyProperty TitleBarForegroundProperty =
DependencyProperty.Register(nameof(TitleBarForeground), typeof(Color), typeof(BindableColorsTitleBar), new PropertyMetadata(Colors.Transparent, TitleBarForegroundChanged));
private static void TitleBarForegroundChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
{
if (dependencyObject is BindableColorsTitleBar titleBarControl)
{
var color = (Color)args.NewValue;
titleBarControl._buttonForeground = titleBarControl._titleBar.ButtonForegroundColor = color;
titleBarControl._buttonPressedForeground = titleBarControl._titleBar.ButtonPressedForegroundColor = color;
titleBarControl._buttonHoverForeground = titleBarControl._titleBar.ButtonHoverForegroundColor = color;
titleBarControl._inactiveForeground = titleBarControl._titleBar.InactiveForegroundColor = Color.FromArgb(128, color.R, color.G, color.B);
}
}
public void RestoreColors()
{
_titleBar.ButtonForegroundColor = _buttonForeground;
_titleBar.ButtonHoverBackgroundColor = _buttonHoverBackground;
_titleBar.ButtonPressedBackgroundColor = _buttonPressedBackground;
_titleBar.ButtonPressedForegroundColor = _buttonPressedForeground;
_titleBar.ButtonHoverForegroundColor = _buttonHoverForeground;
_titleBar.InactiveForegroundColor = _inactiveForeground;
}
public void ResetTitleBar()
{
_titleBar.ButtonForegroundColor = (Color)this.Resources["SystemBaseHighColor"];
_titleBar.ButtonHoverBackgroundColor = null;
_titleBar.ButtonPressedBackgroundColor = null;
_titleBar.ButtonPressedForegroundColor = null;
_titleBar.ButtonHoverForegroundColor = null;
_titleBar.InactiveForegroundColor = null;
}
}
}
+24
View File
@@ -0,0 +1,24 @@
using FluentTerminal.Models;
using FluentTerminal.Models.Enums;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace FluentTerminal.App.Views
{
public interface ITerminalView
{
event EventHandler<TerminalSize> TerminalSizeChanged;
event EventHandler<string> TerminalTitleChanged;
event EventHandler<Command> KeyboardCommandReceived;
Task ChangeTheme(TerminalColors theme);
Task ChangeOptions(TerminalOptions options);
Task<TerminalSize> CreateTerminal(TerminalOptions options, TerminalColors theme, IEnumerable<KeyBinding> keyBindings);
Task ConnectToSocket(string url);
void Close();
Task FocusTerminal();
Task<string> GetSelection();
Task Write(string text);
}
}
+128 -26
View File
@@ -2,44 +2,146 @@
x:Class="FluentTerminal.App.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:behaviors="using:FluentTerminal.App.Behaviors"
xmlns:converters="using:FluentTerminal.App.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource SystemControlAcrylicWindowBrush}"
xmlns:viewmodels="using:FluentTerminal.App.ViewModels"
RequestedTheme="Dark"
mc:Ignorable="d">
<Page.Resources>
<converters:TerminalViewModelToViewConverter x:Key="TerminalViewModelToViewConverter" />
<converters:IntToVisibilityConverter
x:Key="OneToVisibleConverter"
Else="Collapsed"
If="1"
Then="Visible" />
<converters:IntToVisibilityConverter
x:Key="OneToCollapsedConverter"
Else="Visible"
If="1"
Then="Collapsed" />
</Page.Resources>
<Grid x:Name="Root">
<Grid.Background>
<AcrylicBrush
BackgroundSource="HostBackdrop"
FallbackColor="{x:Bind ViewModel.Background, Mode=OneWay}"
TintColor="{x:Bind ViewModel.Background, Mode=OneWay}"
TintOpacity="{x:Bind ViewModel.BackgroundOpacity, Mode=OneWay}" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Rectangle x:Name="TitleBar" Fill="Transparent" />
<Grid
Grid.Row="0"
Height="{Binding CoreTitleBarHeight, Mode=OneWay}"
Canvas.ZIndex="3">
<Rectangle x:Name="TitleBar" Fill="Transparent" />
<Grid Padding="{Binding CoreTitleBarPadding, Mode=OneWay}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Canvas.ZIndex="9"
Style="{StaticResource WindowTitleTextBlockStyle}"
Text="Fluent Terminal" />
<!--<Button
Grid.Column="2"
Click="OnSettingsButtonClick"
Style="{StaticResource TitleBarButtonStyle}">
<Viewbox Width="16" Height="16">
<SymbolIcon Symbol="Setting" />
</Viewbox>
</Button>-->
</Grid>
</Grid>
Margin="{Binding CoreTitleBarPadding, Mode=OneWay}"
SizeChanged="Grid_SizeChanged">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
IsHitTestVisible="False"
Style="{StaticResource WindowTitleTextBlockStyle}"
Text="{x:Bind ViewModel.Terminals[0].Title, Mode=OneWay}"
Visibility="{x:Bind ViewModel.Terminals.Count, Mode=OneWay, Converter={StaticResource OneToVisibleConverter}}" />
<ListView
x:Name="Tabs"
Grid.Column="0"
AllowDrop="True"
CanDragItems="True"
CanReorderItems="True"
ItemsSource="{x:Bind ViewModel.Terminals}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Auto"
SelectedItem="{x:Bind ViewModel.SelectedTerminal, Mode=TwoWay}"
Visibility="{x:Bind ViewModel.Terminals.Count, Mode=OneWay, Converter={StaticResource OneToCollapsedConverter}}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewmodels:TerminalViewModel">
<Grid
Height="32"
Margin="0"
VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Interactivity:Interaction.Behaviors>
<behaviors:MiddleClickBehavior>
<behaviors:MiddleClickBehavior.Actions>
<core:InvokeCommandAction Command="{x:Bind CloseCommand}" />
</behaviors:MiddleClickBehavior.Actions>
</behaviors:MiddleClickBehavior>
</Interactivity:Interaction.Behaviors>
<TextBlock
Grid.Column="0"
Margin="12,8,0,0"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind Title, Mode=OneWay}" />
<Button
Grid.Column="2"
Width="32"
Command="{x:Bind CloseCommand}"
Style="{StaticResource TitleBarButtonStyle}"
ToolTipService.ToolTip="Close">
<Viewbox Width="12" Height="12">
<SymbolIcon Symbol="Cancel" />
</Viewbox>
</Button>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="MinWidth" Value="24" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="Padding" Value="0" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<StackPanel
x:Name="TitleBarButtons"
Grid.Column="2"
Orientation="Horizontal">
<Button
Command="{x:Bind ViewModel.AddTerminalCommand}"
Style="{StaticResource TitleBarButtonStyle}"
ToolTipService.ToolTip="New Tab">
<Viewbox Width="12" Height="12">
<SymbolIcon Symbol="Add" />
</Viewbox>
</Button>
<Button
HorizontalAlignment="Right"
Command="{x:Bind ViewModel.ShowSettingsCommand}"
Style="{StaticResource TitleBarButtonStyle}"
ToolTipService.ToolTip="Settings">
<Viewbox Width="12" Height="12">
<SymbolIcon Symbol="Setting" />
</Viewbox>
</Button>
</StackPanel>
</Grid>
<Frame x:Name="RootFrame" Grid.Row="1" />
<ContentControl
x:Name="TerminalContainer"
Grid.Row="1"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Content="{x:Bind ViewModel.SelectedTerminal, Mode=OneWay, Converter={StaticResource TerminalViewModelToViewConverter}}" />
</Grid>
</Page>
+23 -5
View File
@@ -1,10 +1,13 @@
using System.ComponentModel;
using FluentTerminal.App.ViewModels;
using System.ComponentModel;
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Core.Preview;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FluentTerminal.App.Views
{
@@ -31,6 +34,8 @@ namespace FluentTerminal.App.Views
}
}
public MainViewModel ViewModel { get; private set; }
public MainPage()
{
InitializeComponent();
@@ -40,11 +45,22 @@ namespace FluentTerminal.App.Views
Loaded += OnLoaded;
Unloaded += OnUnloaded;
Window.Current.Activated += OnWindowActivated;
ApplicationView.PreferredLaunchViewSize = new Windows.Foundation.Size(800, 600);
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is MainViewModel viewModel)
{
ViewModel = viewModel;
}
}
private async void OnWindowActivated(object sender, WindowActivatedEventArgs e)
{
if (e.WindowActivationState != CoreWindowActivationState.Deactivated && RootFrame.Content is TerminalPage terminal)
if (e.WindowActivationState != CoreWindowActivationState.Deactivated && TerminalContainer.Content is TerminalView terminal)
{
await terminal.FocusWebView();
}
@@ -59,7 +75,6 @@ namespace FluentTerminal.App.Views
{
coreTitleBar.LayoutMetricsChanged += OnLayoutMetricsChanged;
UpdateLayoutMetrics();
RootFrame.Navigate(typeof(TerminalPage));
}
private void OnLayoutMetricsChanged(CoreApplicationViewTitleBar sender, object e)
@@ -89,9 +104,12 @@ namespace FluentTerminal.App.Views
}
}
private async void OnSettingsButtonClick(object sender, RoutedEventArgs e)
private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
await App.Instance.ShowSettings();
if (sender is Grid grid)
{
Tabs.MaxWidth = grid.ActualWidth - grid.ColumnDefinitions[2].ActualWidth;
}
}
}
}
+76 -5
View File
@@ -2,12 +2,83 @@
x:Class="FluentTerminal.App.Views.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:FluentTerminal.App.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:FluentTerminal.App.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Text="Settings" />
<Page.Resources>
<converters:TrueToVisibleConverter x:Key="TrueToVisibleConverter" />
<converters:FalseToVisibleConverter x:Key="FalseToVisibleConverter" />
</Page.Resources>
<Grid x:Name="Root" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock
x:Name="AppTitle"
Canvas.ZIndex="1"
IsHitTestVisible="False"
Style="{StaticResource CaptionTextBlockStyle}"
Text="Settings"
Visibility="{Binding IsPaneOpen, ElementName=NavigationView, Converter={StaticResource TrueToVisibleConverter}}" />
<NavigationView
x:Name="NavigationView"
AlwaysShowHeader="False"
Canvas.ZIndex="0"
CompactModeThresholdWidth="560"
ExpandedModeThresholdWidth="560"
IsSettingsVisible="False"
Loaded="NavigationView_Loaded"
OpenPaneLength="200"
SelectionChanged="NavigationView_SelectionChanged">
<NavigationView.MenuItems>
<NavigationViewItem Content="General" Tag="general">
<NavigationViewItem.Icon>
<FontIcon
FontFamily="/Assets/settingsicons.ttf#settingsicons"
Glyph="e"
ToolTipService.ToolTip="General" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Terminal" Tag="terminal">
<NavigationViewItem.Icon>
<FontIcon
FontFamily="/Assets/settingsicons.ttf#settingsicons"
Glyph="d"
ToolTipService.ToolTip="Terminal" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Shell" Tag="shell">
<NavigationViewItem.Icon>
<FontIcon
FontFamily="/Assets/settingsicons.ttf#settingsicons"
Glyph="a"
ToolTipService.ToolTip="Shell" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Keybindings" Tag="keyBindings">
<NavigationViewItem.Icon>
<FontIcon
FontFamily="/Assets/settingsicons.ttf#settingsicons"
Glyph="b"
ToolTipService.ToolTip="Keybindings" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Themes" Tag="themes">
<NavigationViewItem.Icon>
<FontIcon
FontFamily="/Assets/settingsicons.ttf#settingsicons"
Glyph="c"
ToolTipService.ToolTip="Themes" />
</NavigationViewItem.Icon>
</NavigationViewItem>
</NavigationView.MenuItems>
<Grid>
<Frame x:Name="ContentFrame" />
<TextBlock
Margin="12,8,0,0"
IsHitTestVisible="False"
Style="{StaticResource CaptionTextBlockStyle}"
Text="Settings"
Visibility="{Binding IsPaneOpen, ElementName=NavigationView, Converter={StaticResource FalseToVisibleConverter}}" />
</Grid>
</NavigationView>
</Grid>
</Page>
</Page>
+81 -2
View File
@@ -1,12 +1,91 @@
using Windows.UI.Xaml.Controls;
using FluentTerminal.App.ViewModels;
using FluentTerminal.App.Views.SettingsPages;
using System.Linq;
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.Core.Preview;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FluentTerminal.App.Views
{
public sealed partial class SettingsPage : Page
{
public double CoreTitleBarHeight { get; }
public SettingsViewModel ViewModel { get; private set; }
public SettingsPage()
{
this.InitializeComponent();
InitializeComponent();
Root.DataContext = this;
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
titleBar.ButtonForegroundColor = (Color)this.Resources["SystemBaseHighColor"];
ApplicationView.PreferredLaunchViewSize = new Windows.Foundation.Size(1024, 768);
ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
ApplicationView.GetForCurrentView().Title = "Settings";
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged;
CoreTitleBarHeight = coreTitleBar.Height;
SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += SettingsPage_CloseRequested;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is SettingsViewModel viewModel)
{
ViewModel = viewModel;
}
}
private void SettingsPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
{
App.Instance.SettingsWindowClosed();
}
private void TitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
{
AppTitle.Margin = new Thickness(CoreApplication.GetCurrentView().TitleBar.SystemOverlayLeftInset + 12, 8, 0, 0);
}
private void NavigationView_Loaded(object sender, RoutedEventArgs e)
{
NavigationView.SelectedItem = NavigationView.MenuItems.Cast<NavigationViewItemBase>().FirstOrDefault(m => m.Tag.ToString() == "general");
}
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
if (args.SelectedItem is NavigationViewItem item)
{
switch (item.Tag)
{
case "general":
ContentFrame.Navigate(typeof(GeneralSettings), ViewModel);
break;
case "shell":
ContentFrame.Navigate(typeof(ShellSettings), ViewModel);
break;
case "themes":
ContentFrame.Navigate(typeof(ThemeSettings), ViewModel);
break;
case "terminal":
ContentFrame.Navigate(typeof(TerminalSettings), ViewModel);
break;
case "keyBindings":
ContentFrame.Navigate(typeof(KeyBindingSettings), ViewModel);
break;
}
}
}
}
}
@@ -0,0 +1,49 @@
<Page
x:Class="FluentTerminal.App.Views.SettingsPages.GeneralSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
NavigationCacheMode="Required"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="1" Margin="24,00,0,24">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Margin="0,10,0,0"
VerticalAlignment="Center"
FontSize="28"
Style="{StaticResource TitleTextBlockStyle}"
Text="General" />
<CommandBar
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
DefaultLabelPosition="Right">
<AppBarButton
Command="{Binding ViewModel.RestoreDefaultsCommand}"
CommandParameter="general"
Icon="Undo"
Label="Restore Defaults" />
</CommandBar>
</Grid>
<StackPanel Grid.Row="2" Margin="24,0,0,0">
<ToggleSwitch
Margin="0,0,0,24"
Header="Ask before closing windows"
IsOn="{x:Bind ViewModel.ConfirmClosingWindows, Mode=TwoWay}" />
<ToggleSwitch Header="Ask before closing tabs" IsOn="{x:Bind ViewModel.ConfirmClosingTabs, Mode=TwoWay}" />
</StackPanel>
</Grid>
</Page>
@@ -0,0 +1,24 @@
using FluentTerminal.App.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FluentTerminal.App.Views.SettingsPages
{
public sealed partial class GeneralSettings : Page
{
public SettingsViewModel ViewModel { get; private set; }
public GeneralSettings()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is SettingsViewModel viewModel)
{
ViewModel = viewModel;
}
}
}
}
@@ -1,9 +1,11 @@
<Page
x:Class="FluentTerminal.App.Views.TerminalPage"
x:Class="FluentTerminal.App.Views.SettingsPages.KeyBindingSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:FluentTerminal.App.Views.SettingsPages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="WebViewContainer" Margin="12" />
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
</Page>
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// Die Elementvorlage "Leere Seite" wird unter https://go.microsoft.com/fwlink/?LinkId=234238 dokumentiert.
namespace FluentTerminal.App.Views.SettingsPages
{
/// <summary>
/// Eine leere Seite, die eigenständig verwendet oder zu der innerhalb eines Rahmens navigiert werden kann.
/// </summary>
public sealed partial class KeyBindingSettings : Page
{
public KeyBindingSettings()
{
this.InitializeComponent();
}
}
}
@@ -0,0 +1,86 @@
<Page
x:Class="FluentTerminal.App.Views.SettingsPages.ShellSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
NavigationCacheMode="Required"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="1" Margin="24,00,0,24">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Margin="0,10,0,0"
VerticalAlignment="Center"
FontSize="28"
Style="{StaticResource TitleTextBlockStyle}"
Text="Shell" />
<CommandBar
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
DefaultLabelPosition="Right">
<AppBarButton
Command="{Binding ViewModel.RestoreDefaultsCommand}"
CommandParameter="shell"
Icon="Undo"
Label="Restore Defaults" />
</CommandBar>
</Grid>
<StackPanel Grid.Row="2" Margin="24,0,0,0">
<TextBlock Margin="0,0,0,8" Text="Type" />
<RadioButton Content="PowerShell" IsChecked="{Binding ViewModel.PoweShellIsSelected, Mode=TwoWay}" />
<RadioButton Content="CMD" IsChecked="{Binding ViewModel.CMDIsSelected, Mode=TwoWay}" />
<RadioButton Content="Custom" IsChecked="{Binding ViewModel.CustomShellIsSelected, Mode=TwoWay}" />
<StackPanel Margin="0,24,0,0" Orientation="Horizontal">
<TextBox
Width="400"
Header="Custom Shell Location"
IsEnabled="{x:Bind ViewModel.CustomShellIsSelected, Mode=OneWay}"
IsSpellCheckEnabled="False"
Text="{x:Bind ViewModel.CustomShellLocation, Mode=TwoWay}" />
<Button
Margin="6,0,0,0"
VerticalAlignment="Bottom"
Command="{x:Bind ViewModel.BrowseForCustomShellCommand}"
Content="..."
IsEnabled="{x:Bind ViewModel.CustomShellIsSelected, Mode=OneWay}"
Style="{StaticResource ButtonRevealStyle}" />
</StackPanel>
<StackPanel Margin="0,24,0,0" Orientation="Horizontal">
<TextBox
Width="400"
Header="Working Directory"
IsSpellCheckEnabled="False"
Text="{x:Bind ViewModel.WorkingDirectory, Mode=TwoWay}" />
<Button
Margin="6,0,0,0"
VerticalAlignment="Bottom"
Command="{x:Bind ViewModel.BrowseForWorkingDirectoryCommand}"
Content="..."
Style="{StaticResource ButtonRevealStyle}" />
</StackPanel>
<TextBox
Width="400"
Margin="0,24,0,0"
HorizontalAlignment="Left"
Header="Arguments"
IsSpellCheckEnabled="False"
Text="{x:Bind ViewModel.Arguments, Mode=TwoWay}" />
</StackPanel>
</Grid>
</Page>
@@ -0,0 +1,24 @@
using FluentTerminal.App.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FluentTerminal.App.Views.SettingsPages
{
public sealed partial class ShellSettings : Page
{
public SettingsViewModel ViewModel { get; private set; }
public ShellSettings()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is SettingsViewModel viewModel)
{
ViewModel = viewModel;
}
}
}
}
@@ -0,0 +1,62 @@
<Page
x:Class="FluentTerminal.App.Views.SettingsPages.TerminalSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
NavigationCacheMode="Required"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="1" Margin="24,00,0,24">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Margin="0,10,0,0"
VerticalAlignment="Center"
FontSize="28"
Style="{StaticResource TitleTextBlockStyle}"
Text="Terminal" />
<CommandBar
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
DefaultLabelPosition="Right">
<AppBarButton
Command="{Binding ViewModel.RestoreDefaultsCommand}"
CommandParameter="terminal"
Icon="Undo"
Label="Restore Defaults" />
</CommandBar>
</Grid>
<StackPanel Grid.Row="2" Margin="24,0,0,0">
<ComboBox
Width="200"
Margin="0,0,0,24"
Header="Font Family"
ItemsSource="{x:Bind ViewModel.Fonts}"
SelectedValue="{x:Bind ViewModel.FontFamily, Mode=TwoWay}" />
<ComboBox
Width="200"
Margin="0,0,0,24"
Header="Font Size"
ItemsSource="{x:Bind ViewModel.Sizes}"
SelectedValue="{x:Bind ViewModel.FontSize, Mode=TwoWay}" />
<ToggleSwitch
Margin="0,0,0,24"
Header="Blinking Cursor"
IsOn="{x:Bind ViewModel.CursorBlink, Mode=TwoWay}" />
<TextBlock Margin="0,0,0,8" Text="Cursor Style" />
<RadioButton Content="Block" IsChecked="{Binding ViewModel.BlockIsSelected, Mode=TwoWay}" />
<RadioButton Content="Underline" IsChecked="{Binding ViewModel.UnderlineIsSelected, Mode=TwoWay}" />
<RadioButton Content="Bar" IsChecked="{Binding ViewModel.BarIsSelected, Mode=TwoWay}" />
</StackPanel>
</Grid>
</Page>
@@ -0,0 +1,24 @@
using FluentTerminal.App.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FluentTerminal.App.Views.SettingsPages
{
public sealed partial class TerminalSettings : Page
{
public TerminalSettings()
{
InitializeComponent();
}
public SettingsViewModel ViewModel { get; private set; }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is SettingsViewModel viewModel)
{
ViewModel = viewModel;
}
}
}
}
@@ -0,0 +1,306 @@
<Page
x:Class="FluentTerminal.App.Views.SettingsPages.ThemeSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:FluentTerminal.App.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodels="using:FluentTerminal.App.ViewModels"
xmlns:views="using:FluentTerminal.App.Views"
NavigationCacheMode="Required"
mc:Ignorable="d">
<Page.Resources>
<converters:NegateConverter x:Key="NegateConverter" />
<converters:FalseToVisibleConverter x:Key="FalseToVisibleConverter" />
<converters:TrueToVisibleConverter x:Key="TrueToVisibleConverter" />
</Page.Resources>
<Grid x:Name="Root">
<Grid.Background>
<AcrylicBrush
BackgroundSource="HostBackdrop"
FallbackColor="{x:Bind ViewModel.SelectedTheme.Background, Mode=OneWay}"
TintColor="{x:Bind ViewModel.SelectedTheme.Background, Mode=OneWay}"
TintOpacity="{x:Bind ViewModel.SelectedTheme.BackgroundOpacity, Mode=OneWay}" />
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<views:BindableColorsTitleBar x:Name="TitleBar" TitleBarForeground="White" />
<Border
Grid.RowSpan="3"
Grid.Column="0"
Background="{ThemeResource SystemControlAcrylicWindowBrush}" />
<Grid
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,0,0,24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="24,10,0,0"
VerticalAlignment="Center"
FontSize="28"
Style="{StaticResource TitleTextBlockStyle}"
Text="Themes" />
<CommandBar
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="Transparent"
DefaultLabelPosition="Right"
Visibility="{x:Bind ViewModel.SelectedTheme.InEditMode, Mode=OneWay, Converter={StaticResource FalseToVisibleConverter}}">
<AppBarButton
Command="{x:Bind ViewModel.SelectedTheme.SetActiveCommand, Mode=OneWay}"
Foreground="White"
Icon="Accept"
IsEnabled="{x:Bind ViewModel.SelectedTheme.IsActive, Mode=OneWay, Converter={StaticResource NegateConverter}}"
Label="Set Active"
Style="{StaticResource ThemeAppBarButtonStyle}" />
<AppBarButton
Command="{x:Bind ViewModel.SelectedTheme.EditCommand, Mode=OneWay}"
Foreground="White"
Icon="Edit"
Label="Edit"
Style="{StaticResource ThemeAppBarButtonStyle}" />
<AppBarButton
Command="{x:Bind ViewModel.SelectedTheme.DeleteCommand, Mode=OneWay}"
Foreground="White"
Icon="Delete"
Label="Delete"
Style="{StaticResource ThemeAppBarButtonStyle}" />
</CommandBar>
<CommandBar
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="Transparent"
DefaultLabelPosition="Right"
Visibility="{x:Bind ViewModel.SelectedTheme.InEditMode, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}">
<AppBarButton
Command="{x:Bind ViewModel.SelectedTheme.SaveChangesCommand, Mode=OneWay}"
Foreground="White"
Icon="Save"
Label="Save"
Style="{StaticResource ThemeAppBarButtonStyle}" />
<AppBarButton
Command="{x:Bind ViewModel.SelectedTheme.CancelEditCommand, Mode=OneWay}"
Foreground="White"
Icon="Cancel"
Label="Cancel"
Style="{StaticResource ThemeAppBarButtonStyle}" />
</CommandBar>
</Grid>
<StackPanel Grid.Row="2" Grid.Column="0">
<ListView ItemsSource="{x:Bind ViewModel.Themes}" SelectedItem="{x:Bind ViewModel.SelectedTheme, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewmodels:ThemeViewModel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{x:Bind Name, Mode=OneWay}" />
<Viewbox
Grid.Column="1"
Width="16"
Height="16"
HorizontalAlignment="Right">
<SymbolIcon Symbol="Accept" Visibility="{x:Bind IsActive, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}" />
</Viewbox>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
</ListView>
<Button
Height="48"
Margin="0,12,0,0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Background="Transparent"
Command="{x:Bind ViewModel.CreateThemeCommand}"
Style="{StaticResource ButtonRevealStyle}">
<Button.Content>
<StackPanel Orientation="Horizontal">
<Viewbox
Width="16"
Height="16"
Margin="0,0,6,0">
<SymbolIcon Symbol="Add" />
</Viewbox>
<TextBlock Text="Create New" />
</StackPanel>
</Button.Content>
</Button>
</StackPanel>
<ContentControl
Grid.Row="2"
Grid.Column="1"
Margin="24,0,0,0"
Content="{x:Bind ViewModel.SelectedTheme, Mode=TwoWay}">
<ContentControl.ContentTemplate>
<DataTemplate x:DataType="viewmodels:ThemeViewModel">
<StackPanel>
<TextBlock
Style="{StaticResource SubtitleTextBlockStyle}"
Text="{x:Bind Name, Mode=OneWay}"
Visibility="{x:Bind InEditMode, Mode=OneWay, Converter={StaticResource FalseToVisibleConverter}}">
<TextBlock.Foreground>
<SolidColorBrush Color="{x:Bind Foreground, Mode=OneWay}" />
</TextBlock.Foreground>
</TextBlock>
<TextBlock
Foreground="White"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind Author, Mode=OneWay}" />
<TextBox
Header="Name"
RequestedTheme="Dark"
Text="{x:Bind Name, Mode=TwoWay}"
Visibility="{x:Bind InEditMode, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}" />
<TextBox
Margin="0,24,0,0"
Header="Author"
RequestedTheme="Dark"
Text="{x:Bind Author, Mode=TwoWay}"
Visibility="{x:Bind InEditMode, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}" />
<Grid Margin="0,48,0,0">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="Border">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
</Style>
</Grid.Resources>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<views:TerminalColorPicker
ColorName="Black"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Black, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Red"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Red, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Green"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Green, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Yellow"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Yellow, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Blue"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Blue, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Magenta"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Magenta, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Cyan"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Cyan, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="White"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind White, Mode=TwoWay}" />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<views:TerminalColorPicker
ColorName="Bright Black"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightBlack, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright Red"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightRed, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright Green"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightGreen, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright Yellow"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightYellow, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright Blue"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightBlue, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright Magenta"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightMagenta, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright Cyan"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightCyan, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Bright White"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind BrightWhite, Mode=TwoWay}" />
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<views:TerminalColorPicker
ColorName="Foreground"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Foreground, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Background"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Background, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Cursor"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind Cursor, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Cursor Accent"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
SelectedColor="{x:Bind CursorAccent, Mode=TwoWay}" />
<views:TerminalColorPicker
ColorName="Selection"
EnableEditing="{x:Bind InEditMode, Mode=OneWay}"
IsAlphaEnabled="True"
SelectedColor="{x:Bind Selection, Mode=TwoWay}" />
</StackPanel>
<TextBlock
Grid.Row="3"
Margin="0,6,0,0"
Foreground="White"
Text="Click on a color to edit"
Visibility="{x:Bind InEditMode, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}" />
</Grid>
<Slider
Margin="0,24,0,0"
Header="Background Opacity"
Maximum="1"
Minimum="0"
RequestedTheme="Dark"
StepFrequency="0.01"
Visibility="{x:Bind InEditMode, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}"
Value="{x:Bind BackgroundOpacity, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</Grid>
</Page>
@@ -0,0 +1,32 @@
using FluentTerminal.App.ViewModels;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FluentTerminal.App.Views.SettingsPages
{
public sealed partial class ThemeSettings : Page
{
public SettingsViewModel ViewModel { get; private set; }
public ThemeSettings()
{
InitializeComponent();
Root.DataContext = this;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is SettingsViewModel viewModel)
{
ViewModel = viewModel;
}
TitleBar.RestoreColors();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
TitleBar.ResetTitleBar();
}
}
}
@@ -0,0 +1,34 @@
<UserControl
x:Class="FluentTerminal.App.Views.TerminalColorPicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
d:DesignHeight="24"
d:DesignWidth="24"
mc:Ignorable="d">
<Button
x:Name="Root"
IsEnabled="{x:Bind EnableEditing, Mode=OneWay}"
Style="{StaticResource ColorPreviewButtonStyle}"
ToolTipService.ToolTip="{x:Bind ColorName}">
<Button.Background>
<SolidColorBrush Color="{x:Bind SelectedColor, Mode=OneWay}" />
</Button.Background>
<Button.Flyout>
<Flyout>
<StackPanel>
<TextBlock
Margin="0,0,0,6"
Style="{StaticResource TitleTextBlockStyle}"
Text="{x:Bind ColorName}" />
<ColorPicker
x:Name="colorPicker"
ColorChanged="ColorPicker_ColorChanged"
IsAlphaEnabled="{x:Bind IsAlphaEnabled, Mode=OneWay}"
IsColorChannelTextInputVisible="False" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
</UserControl>
@@ -0,0 +1,62 @@
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace FluentTerminal.App.Views
{
public sealed partial class TerminalColorPicker : UserControl
{
public static readonly DependencyProperty ColorNameProperty =
DependencyProperty.Register(nameof(ColorName), typeof(string), typeof(TerminalColorPicker), new PropertyMetadata(null));
public static readonly DependencyProperty EnableEditingProperty =
DependencyProperty.Register(nameof(EnableEditing), typeof(bool), typeof(TerminalColorPicker), new PropertyMetadata(false));
public static readonly DependencyProperty IsAlphaEnabledProperty =
DependencyProperty.Register(nameof(IsAlphaEnabled), typeof(bool), typeof(TerminalColorPicker), new PropertyMetadata(false));
public static readonly DependencyProperty SelectedColorProperty =
DependencyProperty.Register(nameof(SelectedColor), typeof(Color), typeof(TerminalColorPicker), new PropertyMetadata(Colors.Transparent, (s, e) =>
{
if (s is TerminalColorPicker terminalColorPicker)
{
terminalColorPicker.colorPicker.Color = (Color)e.NewValue;
}
}));
public TerminalColorPicker()
{
InitializeComponent();
Root.DataContext = this;
}
public string ColorName
{
get { return (string)GetValue(ColorNameProperty); }
set { SetValue(ColorNameProperty, value); }
}
public bool EnableEditing
{
get { return (bool)GetValue(EnableEditingProperty); }
set { SetValue(EnableEditingProperty, value); }
}
public bool IsAlphaEnabled
{
get { return (bool)GetValue(IsAlphaEnabledProperty); }
set { SetValue(IsAlphaEnabledProperty, value); }
}
public Color SelectedColor
{
get { return (Color)GetValue(SelectedColorProperty); }
set { SetValue(SelectedColorProperty, value); }
}
private void ColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
{
SelectedColor = args.NewColor;
}
}
}
@@ -1,65 +0,0 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.UI;
using Windows.UI.Core.Preview;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace FluentTerminal.App.Views
{
public sealed partial class TerminalPage : Page
{
private WebView _webView;
public TerminalPage()
{
InitializeComponent();
Loaded += OnLoaded;
SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += OnCloseRequested;
}
public async Task FocusWebView()
{
if (_webView != null)
{
_webView.Focus(FocusState.Programmatic);
await ExecuteScriptAsync("document.focus();");
}
}
private void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
{
_webView.Navigate(new Uri("about:blank"));
_webView = null;
}
public Task<string> ExecuteScriptAsync(string script)
{
try
{
return _webView.InvokeScriptAsync("eval", new[]
{
"try {" + script + "} catch(error) {}"
}).AsTask();
}
catch (Exception e)
{
Debug.WriteLine($"Exception while running:\n \"{script}\"\n\n {e}");
}
return Task.FromResult(string.Empty);
}
private async void OnLoaded(object sender, RoutedEventArgs e)
{
_webView = new WebView(WebViewExecutionMode.SeparateThread)
{
DefaultBackgroundColor = Colors.Transparent
};
WebViewContainer.Children.Add(_webView);
_webView.Navigate(new Uri("http://localhost:9000/Client/index.html"));
_webView.Focus(FocusState.Programmatic);
}
}
}
@@ -0,0 +1,29 @@
<UserControl
x:Class="FluentTerminal.App.Views.TerminalView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:FluentTerminal.App.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:FluentTerminal.App.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">
<UserControl.Resources>
<converters:TrueToVisibleConverter x:Key="TrueToVisibleConverter" />
</UserControl.Resources>
<Grid>
<Grid x:Name="WebViewContainer" Margin="12" />
<Grid
Margin="12"
Padding="6"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Visibility="{x:Bind ViewModel.ShowResizeOverlay, Mode=OneWay, Converter={StaticResource TrueToVisibleConverter}}">
<Grid.Background>
<SolidColorBrush Color="{ThemeResource SystemAccentColor}" />
</Grid.Background>
<TextBlock Foreground="White" Text="{x:Bind ViewModel.ResizeOverlayContent, Mode=OneWay}" />
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,237 @@
using FluentTerminal.App.ViewModels;
using FluentTerminal.Models;
using FluentTerminal.Models.Enums;
using FluentTerminal.RuntimeComponent.Interfaces;
using FluentTerminal.RuntimeComponent.WebAllowedObjects;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace FluentTerminal.App.Views
{
public sealed partial class TerminalView : UserControl, ITerminalView, ITerminalEventListener
{
private MenuFlyoutItem _copyMenuItem;
private BlockingCollection<Action> _dispatcherJobs;
private SemaphoreSlim _loaded;
private MenuFlyoutItem _pasteMenuItem;
private WebView _webView;
public TerminalView(TerminalViewModel viewModel)
{
ViewModel = viewModel;
InitializeComponent();
Loaded += OnLoaded;
_loaded = new SemaphoreSlim(0, 1);
JsonConvert.DefaultSettings = () =>
{
var settings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
};
settings.Converters.Add(new StringEnumConverter(true));
return settings;
};
StartMediatorTask();
}
public event EventHandler<Command> KeyboardCommandReceived;
public event EventHandler<TerminalSize> TerminalSizeChanged;
public event EventHandler<string> TerminalTitleChanged;
public TerminalViewModel ViewModel { get; }
public Task ChangeOptions(TerminalOptions options)
{
var serialized = JsonConvert.SerializeObject(options);
return ExecuteScriptAsync($"changeOptions('{serialized}')");
}
public Task ChangeTheme(TerminalColors theme)
{
var serialized = JsonConvert.SerializeObject(theme);
return ExecuteScriptAsync($"changeTheme('{serialized}')");
}
public void Close()
{
_webView?.Navigate(new Uri("about:blank"));
_webView = null;
}
public Task ConnectToSocket(string url)
{
return ExecuteScriptAsync($"connectToWebSocket('{url}');");
}
public async Task<TerminalSize> CreateTerminal(TerminalOptions options, TerminalColors theme, IEnumerable<KeyBinding> keyBindings)
{
var serializedOptions = JsonConvert.SerializeObject(options);
var serializedTheme = JsonConvert.SerializeObject(theme);
var serializedKeyBindings = JsonConvert.SerializeObject(keyBindings);
var size = await ExecuteScriptAsync($"createTerminal('{serializedOptions}', '{serializedTheme}', '{serializedKeyBindings}')");
return JsonConvert.DeserializeObject<TerminalSize>(size);
}
public Task<string> ExecuteScriptAsync(string script)
{
try
{
return _webView.InvokeScriptAsync("eval", new[] { script }).AsTask();
}
catch (Exception e)
{
Debug.WriteLine($"Exception while running:\n \"{script}\"\n\n {e}");
}
return Task.FromResult(string.Empty);
}
public async Task FocusTerminal()
{
if (_webView != null)
{
_webView.Focus(FocusState.Programmatic);
await ExecuteScriptAsync("document.focus();");
}
}
public async Task FocusWebView()
{
if (_webView != null)
{
_webView.Focus(FocusState.Programmatic);
await ExecuteScriptAsync("document.focus();");
}
}
public Task<string> GetSelection()
{
return ExecuteScriptAsync("term.getSelection()");
}
public void OnKeyboardCommand(string command)
{
_dispatcherJobs.Add(() => KeyboardCommandReceived?.Invoke(this, Enum.Parse<Command>(command, true)));
}
public void OnTerminalResized(int columns, int rows)
{
_dispatcherJobs.Add(() => TerminalSizeChanged?.Invoke(this, new TerminalSize { Columns = columns, Rows = rows }));
}
public void OnTitleChanged(string title)
{
_dispatcherJobs.Add(() => TerminalTitleChanged?.Invoke(this, title));
}
public Task Write(string text)
{
text = Convert.ToBase64String(Encoding.UTF8.GetBytes(text));
return ExecuteScriptAsync($"paste('{text}')");
}
private void _webView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
_loaded.Release();
}
private void _webView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
var bridge = new TerminalBridge(this);
_webView.AddWebAllowedObject("terminalBridge", bridge);
}
private void Copy_Click(object sender, RoutedEventArgs e)
{
OnKeyboardCommand(Command.Copy.ToString());
}
private async void OnLoaded(object sender, RoutedEventArgs e)
{
if (WebViewContainer.Children.Any())
{
return;
}
_webView = new WebView(WebViewExecutionMode.SeparateThread)
{
DefaultBackgroundColor = Colors.Transparent
};
WebViewContainer.Children.Add(_webView);
_webView.NavigationCompleted += _webView_NavigationCompleted;
_webView.NavigationStarting += _webView_NavigationStarting;
_copyMenuItem = new MenuFlyoutItem { Text = "Copy" };
_copyMenuItem.Click += Copy_Click;
_pasteMenuItem = new MenuFlyoutItem { Text = "Paste" };
_pasteMenuItem.Click += Paste_Click;
_webView.ContextFlyout = new MenuFlyout
{
Items = { _copyMenuItem, _pasteMenuItem }
};
_webView.Navigate(new Uri("http://localhost:9000/Client/index.html"));
await _loaded.WaitAsync();
_webView.Focus(FocusState.Programmatic);
await ViewModel.OnViewIsReady(this);
}
public void OnRightClick(int x, int y, bool hasSelection)
{
_dispatcherJobs.Add(() =>
{
var flyout = (MenuFlyout)_webView.ContextFlyout;
_copyMenuItem.IsEnabled = hasSelection;
flyout.ShowAt(_webView, new Point(x, y));
});
}
private void Paste_Click(object sender, RoutedEventArgs e)
{
OnKeyboardCommand(Command.Paste.ToString());
}
private void StartMediatorTask()
{
_dispatcherJobs = new BlockingCollection<Action>();
var dispatcher = CoreApplication.GetCurrentView().CoreWindow.Dispatcher;
Task.Run(async () =>
{
foreach (var job in _dispatcherJobs.GetConsumingEnumerable())
{
try
{
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => job.Invoke());
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
});
}
}
}
+1
View File
@@ -1 +1,2 @@
node_modules/
dist/
File diff suppressed because it is too large. Load diff
-12
View File
@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="xterm.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="terminal-container"></div>
<script src="bundle.js"></script>
</body>
</html>
-125
View File
@@ -1,125 +0,0 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
* @license MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*/
/**
* Default styles for xterm.js
*/
.xterm {
font-family: courier-new, courier, monospace;
font-feature-settings: "liga" 0;
position: relative;
user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}
.xterm.focus,
.xterm:focus {
outline: none;
}
.xterm .xterm-helpers {
position: absolute;
top: 0;
/**
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 10;
}
.xterm .xterm-helper-textarea {
/*
* HACK: to fix IE's blinking cursor
* Move textarea out of the screen to the far left, so that the cursor is not visible.
*/
position: absolute;
opacity: 0;
left: -9999em;
top: 0;
width: 0;
height: 0;
z-index: -10;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
resize: none;
}
.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
color: #FFF;
display: none;
position: absolute;
white-space: nowrap;
z-index: 1;
}
.xterm .composition-view.active {
display: block;
}
.xterm .xterm-viewport {
/* On OS X this is required in order for the scroll bar to appear fully opaque */
background-color: #000;
overflow-y: scroll;
cursor: default;
}
.xterm canvas {
position: absolute;
left: 0;
top: 0;
}
.xterm .xterm-scroll-area {
visibility: hidden;
}
.xterm .xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
left: -9999em;
}
.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}
.xterm:not(.enable-mouse-events) {
cursor: text;
}
+5 -6
View File
@@ -2472,12 +2472,6 @@
"safe-buffer": "5.1.1"
}
},
"raw-loader": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz",
"integrity": "sha1-DD0L6u2KAclm2Xh793goElKpeao=",
"dev": true
},
"read-pkg": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
@@ -3018,6 +3012,11 @@
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
"dev": true
},
"xterm": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/xterm/-/xterm-3.1.0.tgz",
"integrity": "sha512-xv4QQQAu8PjAPZE7m0h+i9X9z3vR82wPe0H3g4D9CbyDuQDNt1e+lxeTrkLwuMH3jcxqfHayu3Mu+iyQh62ECg=="
},
"y18n": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
+4 -2
View File
@@ -5,12 +5,14 @@
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "xcopy /y /s ..\\xterm.js\\build\\xterm.css dist\\ && npx webpack --config webpack.config.js"
"build": "xcopy /y /s node_modules\\xterm\\dist\\xterm.css dist\\ && xcopy /y /s src\\style.css dist\\ && xcopy /y /s src\\index.html dist\\ && npx webpack --config webpack.config.js"
},
"author": "FS Apps",
"license": "GPL-3.0",
"dependencies": {},
"devDependencies": {
"webpack": "^3.10.0"
},
"dependencies": {
"xterm": "^3.1.0"
}
}
+15
View File
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="xterm.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="terminal-container"></div>
<script src="bundle.js"></script>
</body>
</html>
+111 -34
View File
@@ -1,58 +1,135 @@
import * as Terminal from '../../xterm.js/build/xterm';
import * as attach from '../../xterm.js/build/addons/attach/attach';
import * as fit from '../../xterm.js/build/addons/fit/fit';
import * as winptyCompat from '../../xterm.js/build/addons/winptyCompat/winptyCompat';
import * as Terminal from '../node_modules/xterm/dist/xterm';
import * as attach from '../node_modules/xterm/dist/addons/attach/attach';
import * as fit from '../node_modules/xterm/dist/addons/fit/fit';
import * as winptyCompat from '../node_modules/xterm/dist/addons/winptyCompat/winptyCompat';
Terminal.applyAddon(attach);
Terminal.applyAddon(fit);
Terminal.applyAddon(winptyCompat);
var term, protocol, socketURL, socket;
var term, socket;
var terminalContainer = document.getElementById('terminal-container');
createTerminal();
function createTerminal() {
function createTerminal(options, theme, keyBindings) {
while (terminalContainer.children.length) {
terminalContainer.removeChild(terminalContainer.children[0]);
}
term = new Terminal({
cursorBlink: true,
fontFamily: 'consolas',
fontSize: 13,
theme = JSON.parse(theme);
theme.background = 'transparent';
window.keyBindings = JSON.parse(keyBindings);
options = JSON.parse(options);
var terminalOptions = {
fontFamily: options.fontFamily,
fontSize: options.fontSize,
cursorStyle: options.cursorStyle,
cursorBlink: options.cursorBlink,
bellStyle: options.bellStyle,
allowTransparency: true,
theme: {
background: "transparent"
}
});
window.term = term; // Expose `term` to window for debugging purposes
theme: theme
};
term = new Terminal(terminalOptions);
window.term = term;
term.on('resize', function (size) {
if (!socketURL) {
return;
}
var cols = size.cols,
rows = size.rows,
url = 'http://localhost:9000/terminals/' + pid + '/size?cols=' + cols + '&rows=' + rows;
fetch(url, {method: 'POST'});
terminalBridge.notifySizeChanged(term.cols, term.rows);
});
term.on('title', function (title) {
terminalBridge.notifyTitleChanged(title);
});
protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
term.open(terminalContainer);
term.winptyCompatInit();
term.fit();
term.focus();
fetch('http://localhost:9000/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then(function (res) {
console.log("got response");
res.text().then(function (url) {
socketURL = JSON.parse(url);
socket = new WebSocket(socketURL);
socket.onopen = runRealTerminal;
});
});
var resizeTimeout;
window.onresize = function () {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(term.fit(), 500);
}
window.onmouseup = function (e) {
if (e.button == 2) {
terminalBridge.notifyRightClick(e.clientX, e.clientY, term.hasSelection());
}
}
term.attachCustomKeyEventHandler(function (e) {
for (var i = 0; i < window.keyBindings.length; i++) {
var keyBinding = window.keyBindings[i];
if (keyBinding.ctrl == e.ctrlKey
&& keyBinding.alt == e.altKey
&& keyBinding.meta == e.metaKey
&& keyBinding.shift == e.shiftKey
&& keyBinding.key == e.keyCode) {
if (document.visibilityState == 'visible') {
e.preventDefault();
terminalBridge.invokeCommand(keyBinding.command);
}
return false;
}
}
return true;
});
return JSON.stringify({
rows: term.rows,
columns: term.cols
});
}
function runRealTerminal() {
function attachTerminal() {
term.attach(socket);
term._initialized = true;
}
function connectToWebSocket(url) {
socket = new WebSocket(url);
socket.onopen = attachTerminal;
}
function changeTheme(theme) {
theme = JSON.parse(theme);
theme.background = 'transparent';
term.setOption('theme', theme);
}
function changeOptions(options) {
options = JSON.parse(options);
term.setOption('bellStyle', options.bellStyle);
term.setOption('cursorBlink', options.cursorBlink);
term.setOption('cursorStyle', options.cursorStyle);
term.setOption('fontFamily', options.fontFamily);
term.setOption('fontSize', options.fontSize);
}
function paste(content) {
content = b64DecodeUnicode(content);
term.send(content);
}
function b64DecodeUnicode(str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(''))
}
document.oncontextmenu = function () {
return false;
};
window.createTerminal = createTerminal;
window.connectToWebSocket = connectToWebSocket;
window.changeTheme = changeTheme;
window.changeOptions = changeOptions;
window.paste = paste;
@@ -21,4 +21,4 @@ body {
.terminal {
background: transparent !important;
}
}
@@ -0,0 +1,8 @@
namespace FluentTerminal.Models
{
public class ApplicationSettings
{
public bool ConfirmClosingTabs { get; set; }
public bool ConfirmClosingWindows { get; set; }
}
}
@@ -0,0 +1,8 @@
namespace FluentTerminal.Models
{
public class CreateTerminalRequest
{
public TerminalSize Size { get; set; }
public ShellConfiguration Configuration { get; set; }
}
}
@@ -0,0 +1,11 @@
namespace FluentTerminal.Models
{
public class CreateTerminalResponse
{
public int Id { get; set; }
public bool Success { get; set; }
public string WebSocketUrl { get; set; }
public string Error { get; set; }
public string ShellExecutableName { get; set; }
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace FluentTerminal.Models.Enums
{
public enum BellStyle
{
None,
Sound
}
}
+15
View File
@@ -0,0 +1,15 @@
namespace FluentTerminal.Models.Enums
{
public enum Command
{
ToggleWindow,
NextTab,
PreviousTab,
NewTab,
CloseTab,
NewWindow,
ShowSettings,
Copy,
Paste
}
}
@@ -0,0 +1,9 @@
namespace FluentTerminal.Models.Enums
{
public enum CursorStyle
{
Block,
Underline,
Bar
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace FluentTerminal.Models.Enums
{
public enum ShellType
{
CMD,
PowerShell,
Custom
}
}
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="Windows">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
</Reference>
</ItemGroup>
</Project>
+15
View File
@@ -0,0 +1,15 @@
using FluentTerminal.Models.Enums;
using Windows.System;
namespace FluentTerminal.Models
{
public class KeyBinding
{
public Command Command { get; set; }
public int Key { get; set; }
public bool Ctrl { get; set; }
public bool Alt { get; set; }
public bool Meta { get; set; }
public bool Shift { get; set; }
}
}
@@ -0,0 +1,12 @@
using FluentTerminal.Models.Enums;
namespace FluentTerminal.Models
{
public class ShellConfiguration
{
public string Arguments { get; set; }
public ShellType Shell { get; set; }
public string CustomShellLocation { get; set; }
public string WorkingDirectory { get; set; }
}
}
+61
View File
@@ -0,0 +1,61 @@
namespace FluentTerminal.Models
{
public class TerminalColors
{
public string Foreground { get; set; }
public string Background { get; set; }
public string Cursor { get; set; }
public string CursorAccent { get; set; }
public string Selection { get; set; }
public string Black { get; set; }
public string Red { get; set; }
public string Green { get; set; }
public string Yellow { get; set; }
public string Blue { get; set; }
public string Magenta { get; set; }
public string Cyan { get; set; }
public string White { get; set; }
public string BrightBlack { get; set; }
public string BrightRed { get; set; }
public string BrightGreen { get; set; }
public string BrightYellow { get; set; }
public string BrightBlue { get; set; }
public string BrightMagenta { get; set; }
public string BrightCyan { get; set; }
public string BrightWhite { get; set; }
public TerminalColors()
{
}
public TerminalColors(TerminalColors other)
{
Foreground = other.Foreground;
Background = other.Background;
Cursor = other.Cursor;
CursorAccent = other.CursorAccent;
Selection = other.Selection;
Black = other.Black;
Red = other.Red;
Green = other.Green;
Yellow = other.Yellow;
Blue = other.Blue;
Magenta = other.Magenta;
Cyan = other.Cyan;
White = other.White;
BrightBlack = other.BrightBlack;
BrightRed = other.BrightRed;
BrightGreen = other.BrightGreen;
BrightYellow = other.BrightYellow;
BrightBlue = other.BrightBlue;
BrightMagenta = other.BrightMagenta;
BrightCyan = other.BrightCyan;
BrightWhite = other.BrightWhite;
}
}
}
+17
View File
@@ -0,0 +1,17 @@
using FluentTerminal.Models.Enums;
namespace FluentTerminal.Models
{
public class TerminalOptions
{
public string FontFamily { get; set; }
public int FontSize { get; set; }
public CursorStyle CursorStyle { get; set; }
public bool CursorBlink { get; set; }
public BellStyle BellStyle { get; set; }
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace FluentTerminal.Models
{
public class TerminalSize
{
public int Columns { get; set; }
public int Rows { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
namespace FluentTerminal.Models
{
public class TerminalTheme
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public bool PreInstalled { get; set; }
public double BackgroundOpacity { get; set; }
public TerminalColors Colors { get; set; }
}
}
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BAAE6239-343F-454C-977F-F81F91715961}</ProjectGuid>
<OutputType>winmdobj</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FluentTerminal.RuntimeComponent</RootNamespace>
<AssemblyName>FluentTerminal.RuntimeComponent</AssemblyName>
<DefaultLanguage>de-DE</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="Interfaces\ITerminalEventListener.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WebAllowedObjects\TerminalBridge.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.0.6</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,13 @@
namespace FluentTerminal.RuntimeComponent.Interfaces
{
public interface ITerminalEventListener
{
void OnTerminalResized(int columns, int rows);
void OnTitleChanged(string title);
void OnKeyboardCommand(string command);
void OnRightClick(int x, int y, bool hasSelection);
}
}
@@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FluentTerminal.RuntimeComponent")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FluentTerminal.RuntimeComponent")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
@@ -0,0 +1,36 @@
using FluentTerminal.RuntimeComponent.Interfaces;
using Windows.Foundation.Metadata;
namespace FluentTerminal.RuntimeComponent.WebAllowedObjects
{
[AllowForWeb]
public sealed class TerminalBridge
{
private readonly ITerminalEventListener _terminalEventListener;
public TerminalBridge(ITerminalEventListener terminalEventListener)
{
_terminalEventListener = terminalEventListener;
}
public void NotifySizeChanged(int columns, int rows)
{
_terminalEventListener.OnTerminalResized(columns, rows);
}
public void NotifyTitleChanged(string title)
{
_terminalEventListener.OnTitleChanged(title);
}
public void InvokeCommand(string command)
{
_terminalEventListener.OnKeyboardCommand(command);
}
public void NotifyRightClick(int x, int y, bool hasSelection)
{
_terminalEventListener.OnRightClick(x, y, hasSelection);
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="xterm.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="terminal-container"></div>
<script src="bundle.js"></script>
</body>
</html>
@@ -1,24 +0,0 @@
* {
margin: 0;
}
html {
-ms-overflow-style: none;
background: transparent;
height: 100%;
}
body {
background: transparent;
height: 100%;
}
#terminal-container {
width: 100%;
height: 100%;
margin: 0;
}
.terminal {
background: transparent !important;
}
-125
View File
@@ -1,125 +0,0 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
* @license MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*/
/**
* Default styles for xterm.js
*/
.xterm {
font-family: courier-new, courier, monospace;
font-feature-settings: "liga" 0;
position: relative;
user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}
.xterm.focus,
.xterm:focus {
outline: none;
}
.xterm .xterm-helpers {
position: absolute;
top: 0;
/**
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 10;
}
.xterm .xterm-helper-textarea {
/*
* HACK: to fix IE's blinking cursor
* Move textarea out of the screen to the far left, so that the cursor is not visible.
*/
position: absolute;
opacity: 0;
left: -9999em;
top: 0;
width: 0;
height: 0;
z-index: -10;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
resize: none;
}
.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
color: #FFF;
display: none;
position: absolute;
white-space: nowrap;
z-index: 1;
}
.xterm .composition-view.active {
display: block;
}
.xterm .xterm-viewport {
/* On OS X this is required in order for the scroll bar to appear fully opaque */
background-color: #000;
overflow-y: scroll;
cursor: default;
}
.xterm canvas {
position: absolute;
left: 0;
top: 0;
}
.xterm .xterm-scroll-area {
visibility: hidden;
}
.xterm .xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
left: -9999em;
}
.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}
.xterm:not(.enable-mouse-events) {
cursor: text;
}
@@ -1,8 +1,6 @@
using FluentTerminal.SystemTray.DataTransferObjects;
using FluentTerminal.Models;
using FluentTerminal.SystemTray.Services;
using System;
using System.Linq;
using System.Net.Http;
using System.Web.Http;
namespace FluentTerminal.SystemTray.Controllers
@@ -17,17 +15,17 @@ namespace FluentTerminal.SystemTray.Controllers
}
[HttpPost]
[Route("terminals")]
public string Post()
[Route("terminals/{id}/resize")]
public void Resize(int id, [FromBody]TerminalSize size)
{
var cols = int.Parse(this.Request.GetQueryNameValuePairs().SingleOrDefault(q => q.Key == "cols").Value);
var rows = int.Parse(this.Request.GetQueryNameValuePairs().SingleOrDefault(q => q.Key == "rows").Value);
var options = new TerminalOptions
{
Columns = cols,
Rows = rows
};
return _terminalsManager.CreateTerminal(options);
_terminalsManager.ResizeTerminal(id, size);
}
[HttpPost]
[Route("terminals")]
public CreateTerminalResponse Create([FromBody]CreateTerminalRequest request)
{
return _terminalsManager.CreateTerminal(request);
}
}
}
@@ -1,10 +0,0 @@
namespace FluentTerminal.SystemTray.DataTransferObjects
{
public class TerminalOptions
{
public int Rows { get; set; }
public int Columns { get; set; }
public string PWD { get; set; }
public string ShellExecutable { get; set; }
}
}
@@ -113,11 +113,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\TerminalsController.cs" />
<Compile Include="DataTransferObjects\TerminalOptions.cs" />
<Compile Include="LoopbackEnabler.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\Terminal.cs" />
<Compile Include="Services\TerminalSession.cs" />
<Compile Include="Services\TerminalsManager.cs" />
<Compile Include="Startup.cs" />
<Compile Include="SystemTrayApplicationContext.cs" />
@@ -153,6 +152,9 @@
<PackageReference Include="Fleck">
<Version>0.14.0.59</Version>
</PackageReference>
<PackageReference Include="GlobalHotKey">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.AspNet.WebApi.OwinSelfHost">
<Version>5.2.3</Version>
</PackageReference>
@@ -186,7 +188,12 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\FluentTerminal.Models\FluentTerminal.Models.csproj">
<Project>{5EA40453-A0AA-449E-8406-D6EA51D7E70E}</Project>
<Name>FluentTerminal.Models</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy /y "$(ProjectDir)BinaryDependencies\$(PlatformName)" "$(ProjectDir)bin\$(PlatformName)\$(ConfigurationName)"
Loaded 100 of 372 files, more files were not shown because too many files have changed in this diff. Show more