diff --git a/.github/actions/spell-check/dictionary/apis.txt b/.github/actions/spell-check/dictionary/apis.txt index 6e450ee12bb..d2386de1cf5 100644 --- a/.github/actions/spell-check/dictionary/apis.txt +++ b/.github/actions/spell-check/dictionary/apis.txt @@ -44,12 +44,17 @@ RSHIFT rx serializer SIZENS +snprintf spsc STDCPP +Subheader +Subpage syscall tmp +tolower tx userenv +wcsstr wcstoui XDocument XElement diff --git a/.github/actions/spell-check/dictionary/microsoft.txt b/.github/actions/spell-check/dictionary/microsoft.txt index a5d56bf5bc8..df286478679 100644 --- a/.github/actions/spell-check/dictionary/microsoft.txt +++ b/.github/actions/spell-check/dictionary/microsoft.txt @@ -12,6 +12,7 @@ LKG mfcribbon microsoft microsoftonline +muxc netcore osgvsowi pgc diff --git a/OpenConsole.sln b/OpenConsole.sln index 82ab30fdc5a..f6f92f66537 100644 --- a/OpenConsole.sln +++ b/OpenConsole.sln @@ -307,6 +307,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTerminalTestNetCore", "s EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wt", "src\cascadia\wt\wt.vcxproj", "{506FD703-BAA7-4F6E-9361-64F550EC8FCA}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TerminalSettingsEditor", "src\cascadia\TerminalSettingsEditor\TerminalSettingsEditor.vcxproj", "{CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AuditMode|Any CPU = AuditMode|Any CPU @@ -1986,6 +1988,44 @@ Global {506FD703-BAA7-4F6E-9361-64F550EC8FCA}.Release|x64.Build.0 = Release|x64 {506FD703-BAA7-4F6E-9361-64F550EC8FCA}.Release|x86.ActiveCfg = Release|Win32 {506FD703-BAA7-4F6E-9361-64F550EC8FCA}.Release|x86.Build.0 = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|Any CPU.ActiveCfg = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|Any CPU.Build.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|Any CPU.Deploy.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|ARM64.ActiveCfg = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|ARM64.Build.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|ARM64.Deploy.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|DotNet_x64Test.ActiveCfg = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|DotNet_x64Test.Build.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|DotNet_x64Test.Deploy.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|DotNet_x86Test.ActiveCfg = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|DotNet_x86Test.Build.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|DotNet_x86Test.Deploy.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x64.ActiveCfg = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x64.Build.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x64.Deploy.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x86.ActiveCfg = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x86.Build.0 = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.AuditMode|x86.Deploy.0 = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|ARM64.ActiveCfg = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|DotNet_x64Test.ActiveCfg = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|DotNet_x86Test.ActiveCfg = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x64.ActiveCfg = Debug|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x64.Build.0 = Debug|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x64.Deploy.0 = Debug|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x86.ActiveCfg = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x86.Build.0 = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Debug|x86.Deploy.0 = Debug|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|Any CPU.ActiveCfg = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|ARM64.ActiveCfg = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|DotNet_x64Test.ActiveCfg = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|DotNet_x86Test.ActiveCfg = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x64.ActiveCfg = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x64.Build.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x64.Deploy.0 = Release|x64 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x86.ActiveCfg = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x86.Build.0 = Release|Win32 + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32}.Release|x86.Deploy.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2066,6 +2106,7 @@ Global {6BAE5851-50D5-4934-8D5E-30361A8A40F3} = {81C352DB-1818-45B7-A284-18E259F1CC87} {1588FD7C-241E-4E7D-9113-43735F3E6BAD} = {59840756-302F-44DF-AA47-441A9D673202} {506FD703-BAA7-4F6E-9361-64F550EC8FCA} = {59840756-302F-44DF-AA47-441A9D673202} + {CA5CAD1A-0B5E-45C3-96A8-BB496BFE4E32} = {59840756-302F-44DF-AA47-441A9D673202} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3140B1B7-C8EE-43D1-A772-D82A7061A271} diff --git a/src/cascadia/TerminalSettingsEditor/AddProfile.cpp b/src/cascadia/TerminalSettingsEditor/AddProfile.cpp new file mode 100644 index 00000000000..9139a8d9623 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/AddProfile.cpp @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "AddProfile.h" +#include "AddProfile.g.cpp" + +using namespace winrt; +using namespace winrt::Windows::UI::Xaml; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + AddProfile::AddProfile() + { + InitializeComponent(); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/AddProfile.h b/src/cascadia/TerminalSettingsEditor/AddProfile.h new file mode 100644 index 00000000000..d27f3e6f553 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/AddProfile.h @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "AddProfile.g.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct AddProfile : AddProfileT + { + AddProfile(); + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(AddProfile); +} diff --git a/src/cascadia/TerminalSettingsEditor/AddProfile.idl b/src/cascadia/TerminalSettingsEditor/AddProfile.idl new file mode 100644 index 00000000000..de959cdaf93 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/AddProfile.idl @@ -0,0 +1,7 @@ +namespace Microsoft.Terminal.Settings.Editor +{ + [default_interface] runtimeclass AddProfile : Windows.UI.Xaml.Controls.Page + { + AddProfile(); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/AddProfile.xaml b/src/cascadia/TerminalSettingsEditor/AddProfile.xaml new file mode 100644 index 00000000000..d535ef218b5 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/AddProfile.xaml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp new file mode 100644 index 00000000000..ce45faf73b0 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "GlobalAppearance.h" +#include "GlobalAppearance.g.cpp" +#include + +using namespace winrt; +using namespace winrt::Windows::UI::Xaml; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + GlobalAppearance::GlobalAppearance() + { + m_globalSettingsModel = winrt::make(); + InitializeComponent(); + } + + Model::GlobalSettingsModel GlobalAppearance::GlobalSettingsModel() + { + return m_globalSettingsModel; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h new file mode 100644 index 00000000000..cd1419c327b --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "GlobalAppearance.g.h" +#include "ObjectModel/GlobalSettingsModel.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct GlobalAppearance : GlobalAppearanceT + { + GlobalAppearance(); + + Model::GlobalSettingsModel GlobalSettingsModel(); + + private: + Model::GlobalSettingsModel m_globalSettingsModel{ nullptr }; + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(GlobalAppearance); +} diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl new file mode 100644 index 00000000000..8b346a09368 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import "ObjectModel/GlobalSettingsModel.idl"; + +namespace Microsoft.Terminal.Settings.Editor +{ + [default_interface] runtimeclass GlobalAppearance : Windows.UI.Xaml.Controls.Page + { + GlobalAppearance(); + Microsoft.Terminal.Settings.Model.GlobalSettingsModel GlobalSettingsModel { get; }; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml new file mode 100644 index 00000000000..ef56a8f45a1 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/GlobalSettings.idl b/src/cascadia/TerminalSettingsEditor/GlobalSettings.idl new file mode 100644 index 00000000000..fffe555a6c1 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/GlobalSettings.idl @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import "SettingsTypes.idl"; + +namespace SettingsControl +{ + [default_interface] runtimeclass GlobalSettings { + GlobalSettings(); + + String UnparsedDefaultProfile(); + + Guid DefaultProfile; + Int32 InitialRows; + Int32 InitialCols; + Boolean AlwaysShowTabs; + Boolean ShowTitleInTitlebar; + Boolean ConfirmCloseAllTabs; + Windows.UI.Xaml.ElementTheme Theme; + TabWidthMode TabWidth; + Boolean ShowTabsInTitlebar; + String WordDelimiters; + Boolean CopyOnSelect; + Boolean CopyFormatting; + Boolean WarnAboutLargePaste; + Boolean WarnAboutMultiLinePaste; + Boolean SnapToGridOnResize; + Boolean ForceFullRepaintRendering; + Boolean SoftwareRendering; + Boolean ForceVTInput; + Boolean DebugFeaturesEnabled; + Boolean StartOnUserLogin; + Boolean AlwaysOnTop; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Globals.cpp b/src/cascadia/TerminalSettingsEditor/Globals.cpp new file mode 100644 index 00000000000..38257dd5a5a --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Globals.cpp @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "Globals.h" +#include "Globals.g.cpp" + +using namespace winrt; +using namespace winrt::Windows::UI::Xaml; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + Globals::Globals() + { + InitializeComponent(); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Globals.h b/src/cascadia/TerminalSettingsEditor/Globals.h new file mode 100644 index 00000000000..e1a6683a25d --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Globals.h @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "Globals.g.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct Globals : GlobalsT + { + Globals(); + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(Globals); +} diff --git a/src/cascadia/TerminalSettingsEditor/Globals.idl b/src/cascadia/TerminalSettingsEditor/Globals.idl new file mode 100644 index 00000000000..3c3abbc93d4 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Globals.idl @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.Terminal.Settings.Editor +{ + [default_interface] + runtimeclass Globals : Windows.UI.Xaml.Controls.Page + { + Globals(); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Globals.xaml b/src/cascadia/TerminalSettingsEditor/Globals.xaml new file mode 100644 index 00000000000..756d0b713f1 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Globals.xaml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Home.cpp b/src/cascadia/TerminalSettingsEditor/Home.cpp new file mode 100644 index 00000000000..2728f0ce98e --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Home.cpp @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "Home.h" +#include "Home.g.cpp" +#include "MainPage.h" + +using namespace winrt; +using namespace winrt::Windows::UI::Xaml; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + Home::Home() + { + m_homeViewModel = winrt::make(); + InitializeComponent(); + + HomeViewModel().HomeGridItems().Append(winrt::make(L"Startup", L"Launch_Nav")); + HomeViewModel().HomeGridItems().Append(winrt::make(L"Interaction", L"Interaction_Nav")); + HomeViewModel().HomeGridItems().Append(winrt::make(L"Rendering", L"Rendering_Nav")); + HomeViewModel().HomeGridItems().Append(winrt::make(L"Global appearance", L"GlobalAppearance_Nav")); + HomeViewModel().HomeGridItems().Append(winrt::make(L"Color schemes", L"ColorSchemes_Nav")); + HomeViewModel().HomeGridItems().Append(winrt::make(L"Global profile settings", L"GlobalProfile_Nav")); + HomeViewModel().HomeGridItems().Append(winrt::make(L"Keyboard", L"Keyboard_Nav")); + } + + void Home::HomeGridItemClickHandler(IInspectable const&, Controls::ItemClickEventArgs const& args) + { + auto clickedItemContainer = args.ClickedItem().as(); + hstring tag = clickedItemContainer->PageTag(); + MainPage mainPage; + mainPage.Navigate(frame(), tag); + } + + Editor::SettingsEditorViewModel Home::HomeViewModel() + { + return m_homeViewModel; + } + +} diff --git a/src/cascadia/TerminalSettingsEditor/Home.h b/src/cascadia/TerminalSettingsEditor/Home.h new file mode 100644 index 00000000000..bb67143dca6 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Home.h @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "Home.g.h" +#include "SettingsEditorViewModel.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct Home : HomeT + { + Home(); + + Editor::SettingsEditorViewModel HomeViewModel(); + + void HomeGridItemClickHandler(Windows::Foundation::IInspectable const&, Windows::UI::Xaml::Controls::ItemClickEventArgs const& args); + + private: + Editor::SettingsEditorViewModel m_homeViewModel{ nullptr }; + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(Home); +} diff --git a/src/cascadia/TerminalSettingsEditor/Home.idl b/src/cascadia/TerminalSettingsEditor/Home.idl new file mode 100644 index 00000000000..e275d44c1c4 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Home.idl @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import "SettingsEditorViewModel.idl"; + +namespace Microsoft.Terminal.Settings.Editor +{ + runtimeclass Home : Windows.UI.Xaml.Controls.Page + { + Home(); + SettingsEditorViewModel HomeViewModel{ get; }; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Home.xaml b/src/cascadia/TerminalSettingsEditor/Home.xaml new file mode 100644 index 00000000000..f6e428f0996 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Home.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/HomeGridItem.cpp b/src/cascadia/TerminalSettingsEditor/HomeGridItem.cpp new file mode 100644 index 00000000000..248cb5d6c86 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/HomeGridItem.cpp @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "HomeGridItem.h" +#include "HomeGridItem.g.cpp" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + HomeGridItem::HomeGridItem(hstring const& title, hstring const& pageTag) : + _Title{ title }, + _PageTag{ pageTag } + { + } +} diff --git a/src/cascadia/TerminalSettingsEditor/HomeGridItem.h b/src/cascadia/TerminalSettingsEditor/HomeGridItem.h new file mode 100644 index 00000000000..9b7a0e10f42 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/HomeGridItem.h @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once +#include "HomeGridItem.g.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct HomeGridItem : HomeGridItemT + { + HomeGridItem() = delete; + HomeGridItem(hstring const& title, hstring const& pageTag); + + WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); + OBSERVABLE_GETSET_PROPERTY(hstring, Title, _PropertyChangedHandlers); + OBSERVABLE_GETSET_PROPERTY(hstring, PageTag, _PropertyChangedHandlers); + }; +} diff --git a/src/cascadia/TerminalSettingsEditor/HomeGridItem.idl b/src/cascadia/TerminalSettingsEditor/HomeGridItem.idl new file mode 100644 index 00000000000..935be521f2f --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/HomeGridItem.idl @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.Terminal.Settings.Editor +{ + runtimeclass HomeGridItem : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + String Title; + String PageTag; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Interaction.cpp b/src/cascadia/TerminalSettingsEditor/Interaction.cpp new file mode 100644 index 00000000000..69c75b2dc56 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Interaction.cpp @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "Interaction.h" +#include "Interaction.g.cpp" +#include + +using namespace winrt; +using namespace winrt::Windows::UI::Xaml; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + Interaction::Interaction() + { + m_globalSettingsModel = winrt::make(); + InitializeComponent(); + } + + Model::GlobalSettingsModel Interaction::GlobalSettingsModel() + { + return m_globalSettingsModel; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Interaction.h b/src/cascadia/TerminalSettingsEditor/Interaction.h new file mode 100644 index 00000000000..73d90c24f8b --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Interaction.h @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "Interaction.g.h" +#include "ObjectModel/GlobalSettingsModel.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct Interaction : InteractionT + { + Interaction(); + + Model::GlobalSettingsModel GlobalSettingsModel(); + + private: + Model::GlobalSettingsModel m_globalSettingsModel{ nullptr }; + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(Interaction); +} diff --git a/src/cascadia/TerminalSettingsEditor/Interaction.idl b/src/cascadia/TerminalSettingsEditor/Interaction.idl new file mode 100644 index 00000000000..342730d7ae0 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Interaction.idl @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import "ObjectModel/GlobalSettingsModel.idl"; + +namespace Microsoft.Terminal.Settings.Editor +{ + [default_interface] runtimeclass Interaction : Windows.UI.Xaml.Controls.Page + { + Interaction(); + + Microsoft.Terminal.Settings.Model.GlobalSettingsModel GlobalSettingsModel { get; }; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Interaction.xaml b/src/cascadia/TerminalSettingsEditor/Interaction.xaml new file mode 100644 index 00000000000..f30d8303e3b --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Interaction.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/KeyBindingsPage.xaml b/src/cascadia/TerminalSettingsEditor/KeyBindingsPage.xaml new file mode 100644 index 00000000000..0e3b8b639a1 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/KeyBindingsPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Keybindings.cpp b/src/cascadia/TerminalSettingsEditor/Keybindings.cpp new file mode 100644 index 00000000000..6c2c5183ef8 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Keybindings.cpp @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "Keybindings.h" +#include "Keybindings.g.cpp" + +#include "Utils.h" + +using namespace winrt; +using namespace winrt::Windows::Foundation; +using namespace winrt::Windows::UI::Xaml; +using namespace winrt::Windows::UI::Xaml::Input; +using namespace winrt::Windows::UI::Xaml::Controls::Primitives; +using namespace winrt::Windows::System; +using namespace winrt::Microsoft::Terminal::Settings; + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + Keybindings::Keybindings() + { + InitializeComponent(); + + m_optionalSettingsPanel = FindName(L"OptionalSettingsPanel").as(); + m_addNewButton = FindName(L"AddNewLink").as(); + + Controls::TextBox tb = FindName(L"KeyBindTextBox").as(); + tb.KeyDown({ this, &Keybindings::KeyDown }); + } + + void Keybindings::Button_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/) + { + Popup popup = FindName(L"StandardPopup").as(); + + if (!popup.IsOpen()) + { + popup.IsOpen(true); + } + } + + void Keybindings::AddNewButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& /*e*/) + { + hstring setting = GetSelectedItemTag(FindName(L"CommandComboBox")); + + Controls::StackPanel panel{}; + + if (setting == c_moveFocusTag || setting == c_resizePaneTag) + { + panel = FindName(L"moveResizeFocusOptionPanel").as(); + panel.Visibility(Visibility::Visible); + } + else + { + panel = FindName(setting + L"OptionPanel").as(); + bool panelWasVisible = (panel.Visibility() == Visibility::Visible); + panel.Visibility(Visibility::Visible); + m_lastOpenedArgsPanel = panel; + + Controls::HyperlinkButton button = sender.as(); + if (setting == c_splitPaneTag) + { + if (panelWasVisible) + { + panel.Children().Append(SplitPaneOptionPanelControl()); + } + button.Visibility(Visibility::Visible); + } + else if (setting == c_newTabTag) + { + panel.Children().Append(NewTabOptionPanelControl()); + button.Visibility(Visibility::Visible); + } + else + { + button.Visibility(Visibility::Collapsed); + } + } + + m_lastOpenedArgsPanel = panel; + } + + hstring Keybindings::GetKeyListString() + { + hstring generatedString = L""; + boolean lastKeyWasModifier{}; + + if (m_keysInBind.find(VirtualKey::Control) != m_keysInBind.end()) + { + generatedString = generatedString + KeyToString(VirtualKey::Control); + lastKeyWasModifier = true; + } + + if (m_keysInBind.find(VirtualKey::Shift) != m_keysInBind.end()) + { + generatedString = generatedString + KeyToString(VirtualKey::Shift); + lastKeyWasModifier = true; + } + + if (m_keysInBind.find(VirtualKey::Menu) != m_keysInBind.end()) + { + generatedString = generatedString + KeyToString(VirtualKey::Menu); + lastKeyWasModifier = true; + } + + for (const auto& key : m_keysInBind) + { + if (key != VirtualKey::Control && key != VirtualKey::Shift && key != VirtualKey::Menu) + { + hstring keyString = KeyToString(key); + + if (!keyString.empty()) + { + if (!generatedString.empty() && !lastKeyWasModifier) + { + generatedString = generatedString + L"+"; + } + generatedString = generatedString + KeyToString(key); + lastKeyWasModifier = false; + } + } + } + + return generatedString; + } + + void Keybindings::KeyDown(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e) + { + Controls::TextBox textBox = sender.as(); + + if (e.Key() == VirtualKey::Back) + { + m_keysInBind.clear(); + } + else + { + m_keysInBind.insert(e.Key()); + if (textBox != nullptr) + { + textBox.Text(GetKeyListString()); + } + } + + e.Handled(true); + } + + void Keybindings::KeyBindTextBox_TextChanging(winrt::Windows::UI::Xaml::Controls::TextBox const& sender, winrt::Windows::UI::Xaml::Controls::TextBoxTextChangingEventArgs const& /*args*/) + { + hstring currText = sender.Text(); + hstring newText = hstring(currText.data(), currText.size()); + + sender.Text(newText); + } + + void Keybindings::ShowOptionsButtonIfRequired(hstring tag) + { + std::set settingsWithOptions; + settingsWithOptions.insert(c_openSettingsTag); + settingsWithOptions.insert(c_newTabTag); + settingsWithOptions.insert(c_switchToTabTag); + settingsWithOptions.insert(c_renameTabTag); + settingsWithOptions.insert(c_setTabColorTag); + settingsWithOptions.insert(c_moveFocusTag); + settingsWithOptions.insert(c_resizePaneTag); + settingsWithOptions.insert(c_splitPaneTag); + settingsWithOptions.insert(c_copyTag); + + Windows::UI::Xaml::Visibility expectedVisibility = Visibility::Collapsed; + if (settingsWithOptions.find(tag) != settingsWithOptions.end()) + { + expectedVisibility = Visibility::Visible; + } + m_optionalSettingsPanel.Visibility(expectedVisibility); + m_addNewButton.Visibility(expectedVisibility); + if (m_lastOpenedArgsPanel != nullptr) + { + m_lastOpenedArgsPanel.Visibility(Visibility::Collapsed); + } + } + + void Keybindings::CommandComboBox_SelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& /*e*/) + { + hstring selectedItemTag = GetSelectedItemTag(sender); + ShowOptionsButtonIfRequired(selectedItemTag); + } + + void Keybindings::SaveButton_Click(winrt::Windows::Foundation::IInspectable const& /*sender*/, winrt::Windows::UI::Xaml::RoutedEventArgs const& /*e*/) + { + // Collect the information here + winrt::Windows::UI::Popups::MessageDialog msg{ CollectInputData() }; + msg.ShowAsync(); + } + + hstring Keybindings::TraversePanel(const Controls::Panel& panel) + { + hstring fullInfo; + + for (const auto panelChild : panel.Children()) + { + if (Controls::ComboBox childComboBox = panelChild.try_as()) + { + fullInfo = fullInfo + childComboBox.Name() + L":" + GetSelectedItemTag(childComboBox); + } + else if (Controls::TextBox childTextBox = panelChild.try_as()) + { + fullInfo = fullInfo + childTextBox.Name() + L":" + childTextBox.Text(); + } + else if (Editor::NewTabOptionPanelControl ntOptionPanel = panelChild.try_as()) + { + fullInfo = fullInfo + ntOptionPanel.Argument() + L":" + ntOptionPanel.InputValue(); + } + else if (Editor::SplitPaneOptionPanelControl spOptionPanel = panelChild.try_as()) + { + fullInfo = fullInfo + spOptionPanel.Argument() + L":" + spOptionPanel.InputValue(); + } + else if (Controls::Grid grid = panelChild.try_as()) + { + fullInfo = fullInfo + TraversePanel(grid); + } + fullInfo = fullInfo + L"\n"; + } + + return fullInfo; + } + + hstring Keybindings::CollectInputData() + { + hstring fullInfo; + + Controls::ComboBox comboBox = FindName(L"CommandComboBox").as(); + fullInfo = fullInfo + comboBox.Name() + L":" + GetSelectedItemTag(comboBox) + L"\n"; + + Controls::TextBox textBox = FindName(L"KeyBindTextBox").as(); + fullInfo = fullInfo + textBox.Name() + L":" + textBox.Text() + L"\n"; + + fullInfo = fullInfo + TraversePanel(m_lastOpenedArgsPanel); + + return fullInfo; + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Keybindings.h b/src/cascadia/TerminalSettingsEditor/Keybindings.h new file mode 100644 index 00000000000..548fbb8a8a4 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Keybindings.h @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "Keybindings.g.h" +#include "Utils.h" + +namespace winrt::Microsoft::Terminal::Settings::Editor::implementation +{ + struct Keybindings : KeybindingsT + { + Keybindings(); + + void Button_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e); + void AddNewButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e); + void KeyDown(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e); + void KeyBindTextBox_TextChanging(winrt::Windows::UI::Xaml::Controls::TextBox const& sender, winrt::Windows::UI::Xaml::Controls::TextBoxTextChangingEventArgs const& args); + void CommandComboBox_SelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& e); + void SaveButton_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e); + + private: + hstring GetKeyListString(); + void ShowOptionsButtonIfRequired(hstring tag); + hstring CollectInputData(); + hstring TraversePanel(const winrt::Windows::UI::Xaml::Controls::Panel& panel); + + const hstring c_openSettingsTag = L"openSettings"; + const hstring c_newTabTag = L"newTab"; + const hstring c_switchToTabTag = L"switchToTab"; + const hstring c_renameTabTag = L"renameTab"; + const hstring c_setTabColorTag = L"setTabColor"; + const hstring c_moveFocusTag = L"moveFocus"; + const hstring c_resizePaneTag = L"resizePane"; + const hstring c_splitPaneTag = L"splitPane"; + const hstring c_copyTag = L"copy"; + + winrt::Windows::UI::Xaml::Controls::StackPanel m_lastOpenedArgsPanel{}; + winrt::Windows::UI::Xaml::Controls::StackPanel m_optionalSettingsPanel{}; + winrt::Windows::UI::Xaml::Controls::HyperlinkButton m_addNewButton{}; + + std::set m_keysInBind; + }; +} + +namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation +{ + BASIC_FACTORY(Keybindings); +} diff --git a/src/cascadia/TerminalSettingsEditor/Keybindings.idl b/src/cascadia/TerminalSettingsEditor/Keybindings.idl new file mode 100644 index 00000000000..4627c3d329e --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Keybindings.idl @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.Terminal.Settings.Editor +{ + [default_interface] + runtimeclass Keybindings : Windows.UI.Xaml.Controls.Page + { + Keybindings(); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Keybindings.xaml b/src/cascadia/TerminalSettingsEditor/Keybindings.xaml new file mode 100644 index 00000000000..fc1a4b7f642 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Keybindings.xaml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +