From d6eeb6f0a8e4ae5f03a757cc39a5e65bfe2db46e Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 12 Mar 2024 18:13:45 -0500 Subject: [PATCH] How much faster is the build if we don't have 100 idl files? --- .../Microsoft.Terminal.Settings.Editor.idl | 591 +++++++++ ...Microsoft.Terminal.Settings.Editor.vcxproj | 85 +- .../TerminalSettingsModel/EnumMappings.h | 2 +- .../Microsoft.Terminal.Settings.Model.idl | 1155 +++++++++++++++++ ...crosoft.Terminal.Settings.ModelLib.vcxproj | 69 +- 5 files changed, 1749 insertions(+), 153 deletions(-) create mode 100644 src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.idl create mode 100644 src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.Model.idl diff --git a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.idl b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.idl new file mode 100644 index 0000000000..9fd302f861 --- /dev/null +++ b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.idl @@ -0,0 +1,591 @@ +#include "ViewModelHelpers.idl.h" + +#define OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Type, Name) \ + OBSERVABLE_PROJECTED_SETTING(Type, Name); \ + Object Name##OverrideSource { get; } + +#define OBSERVABLE_PROJECTED_PROFILE_SETTING(Type, Name) \ + OBSERVABLE_PROJECTED_SETTING(Type, Name); \ + Object Name##OverrideSource { get; } + +#define COMMA , + +namespace Microsoft.Terminal.Settings.Editor +{ + [default_interface] runtimeclass Actions : Windows.UI.Xaml.Controls.Page + { + Actions(); + ActionsViewModel ViewModel { get; }; + } + + runtimeclass ModifyKeyBindingEventArgs + { + Microsoft.Terminal.Control.KeyChord OldKeys { get; }; + Microsoft.Terminal.Control.KeyChord NewKeys { get; }; + String OldActionName { get; }; + String NewActionName { get; }; + } + + runtimeclass KeyBindingViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + // Settings Model side + String Name { get; }; + String KeyChordText { get; }; + + // UI side + Boolean ShowEditButton { get; }; + Boolean IsInEditMode { get; }; + Boolean IsNewlyAdded { get; }; + Microsoft.Terminal.Control.KeyChord ProposedKeys; + Object ProposedAction; + Windows.UI.Xaml.Controls.Flyout AcceptChangesFlyout; + String EditButtonName { get; }; + String CancelButtonName { get; }; + String AcceptButtonName { get; }; + String DeleteButtonName { get; }; + Windows.UI.Xaml.Media.Brush ContainerBackground { get; }; + + void EnterHoverMode(); + void ExitHoverMode(); + void ActionGotFocus(); + void ActionLostFocus(); + void EditButtonGettingFocus(); + void EditButtonLosingFocus(); + IObservableVector AvailableActions { get; }; + void ToggleEditMode(); + void AttemptAcceptChanges(); + void CancelChanges(); + void DeleteKeyBinding(); + + event Windows.Foundation.TypedEventHandler ModifyKeyBindingRequested; + event Windows.Foundation.TypedEventHandler DeleteKeyBindingRequested; + } + + runtimeclass ActionsViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + ActionsViewModel(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + + void OnAutomationPeerAttached(); + void AddNewKeybinding(); + + IObservableVector KeyBindingList { get; }; + event Windows.Foundation.TypedEventHandler FocusContainer; + event Windows.Foundation.TypedEventHandler UpdateBackground; + } + + delegate void AddNewArgs(Guid profile); + + runtimeclass AddProfilePageNavigationState + { + Microsoft.Terminal.Settings.Model.CascadiaSettings Settings; + void RequestAddNew(); + void RequestDuplicate(Guid profile); + event AddNewArgs AddNew; + }; + + [default_interface] runtimeclass AddProfile : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + AddProfile(); + AddProfilePageNavigationState State { get; }; + Boolean IsProfileSelected { get; }; + } + + runtimeclass Font : Windows.Foundation.IStringable + { + String Name { get; }; + String LocalizedName { get; }; + Boolean HasPowerlineCharacters { get; }; + Windows.Foundation.Collections.IMap FontAxesTagsAndNames { get; }; + Windows.Foundation.Collections.IMap FontFeaturesTagsAndNames { get; }; + } + + // We have to make this because we cannot bind an IObservableMap to a ListView in XAML (in c++) + // So instead we make an IObservableVector of these AxisKeyValuePair objects + runtimeclass AxisKeyValuePair : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + AxisKeyValuePair(String axisKey, Single axisValue, Windows.Foundation.Collections.IMap baseMap, Windows.Foundation.Collections.IMap tagToNameMap); + String AxisKey; + Single AxisValue; + Int32 AxisIndex; + } + + runtimeclass FeatureKeyValuePair : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + FeatureKeyValuePair(String featureKey, UInt32 featureValue, Windows.Foundation.Collections.IMap baseMap, Windows.Foundation.Collections.IMap tagToNameMap); + String FeatureKey; + UInt32 FeatureValue; + Int32 FeatureIndex; + } + + runtimeclass AppearanceViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + Boolean IsDefault; + + void SetFontWeightFromDouble(Double fontWeight); + void SetBackgroundImageOpacityFromPercentageValue(Double percentageValue); + void SetBackgroundImagePath(String path); + + Boolean UseDesktopBGImage; + Boolean BackgroundImageSettingsVisible { get; }; + + void ClearColorScheme(); + ColorSchemeViewModel CurrentColorScheme; + Windows.Foundation.Collections.IObservableVector SchemesList; + + void AddNewAxisKeyValuePair(); + void DeleteAxisKeyValuePair(String key); + void InitializeFontAxesVector(); + Boolean AreFontAxesAvailable { get; }; + Boolean CanFontAxesBeAdded { get; }; + Windows.Foundation.Collections.IObservableVector FontAxesVector; + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.Foundation.Collections.IMap, FontAxes); + + void AddNewFeatureKeyValuePair(); + void DeleteFeatureKeyValuePair(String key); + void InitializeFontFeaturesVector(); + Boolean AreFontFeaturesAvailable { get; }; + Boolean CanFontFeaturesBeAdded { get; }; + Windows.Foundation.Collections.IObservableVector FontFeaturesVector; + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.Foundation.Collections.IMap, FontFeatures); + + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, FontFace); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Single, FontSize); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Double, LineHeight); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.UI.Text.FontWeight, FontWeight); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Boolean, EnableBuiltinGlyphs); + + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, DarkColorSchemeName); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, LightColorSchemeName); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Boolean, RetroTerminalEffect); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Core.CursorStyle, CursorShape); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(UInt32, CursorHeight); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, BackgroundImagePath); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Double, BackgroundImageOpacity); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.UI.Xaml.Media.Stretch, BackgroundImageStretchMode); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.ConvergedAlignment, BackgroundImageAlignment); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.IntenseStyle, IntenseTextStyle); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Core.AdjustTextMode, AdjustIndistinguishableColors); + } + + [default_interface] runtimeclass Appearances : Windows.UI.Xaml.Controls.UserControl, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + Appearances(); + AppearanceViewModel Appearance; + ProfileViewModel SourceProfile; + IHostedInWindow WindowRoot; + static Windows.UI.Xaml.DependencyProperty AppearanceProperty { get; }; + + Boolean UsingMonospaceFont { get; }; + Boolean ShowAllFonts; + Boolean ShowProportionalFontWarning; + + IInspectable CurrentCursorShape; + Boolean IsVintageCursor { get; }; + Windows.Foundation.Collections.IObservableVector CursorShapeList { get; }; + + IInspectable CurrentAdjustIndistinguishableColors; + Windows.Foundation.Collections.IObservableVector AdjustIndistinguishableColorsList { get; }; + + IInspectable CurrentBackgroundImageStretchMode; + Windows.Foundation.Collections.IObservableVector BackgroundImageStretchModeList { get; }; + + IInspectable CurrentFontWeight; + Boolean IsCustomFontWeight { get; }; + Windows.Foundation.Collections.IObservableVector FontWeightList { get; }; + + IInspectable CurrentFontFace { get; }; + Windows.UI.Xaml.Controls.Slider BIOpacitySlider { get; }; + + IInspectable CurrentIntenseTextStyle; + Windows.Foundation.Collections.IObservableVector IntenseTextStyleList { get; }; + } + + [default_interface] runtimeclass ColorSchemes : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + ColorSchemes(); + + ColorSchemesPageViewModel ViewModel { get; }; + } + + enum ColorSchemesSubPage + { + Base = 0, + EditColorScheme = 1 + }; + + runtimeclass ColorSchemesPageViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + ColorSchemesPageViewModel(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + void UpdateSettings(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + + ColorSchemeViewModel RequestAddNew(); + Boolean RequestRenameCurrentScheme(String newName); + void RequestDeleteCurrentScheme(); + void RequestDuplicateCurrentScheme(); + void RequestEditSelectedScheme(); + void RequestSetSelectedSchemeAsDefault(); + + ColorSchemeViewModel CurrentScheme; + Boolean HasCurrentScheme { get; }; + Boolean CanDeleteCurrentScheme { get; }; + ColorSchemesSubPage CurrentPage; + Windows.Foundation.Collections.IObservableVector AllColorSchemes { get; }; + + void SchemeListItemClicked(IInspectable sender, Windows.UI.Xaml.Controls.ItemClickEventArgs args); + } + + runtimeclass ColorSchemeViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged, Windows.Foundation.IStringable + { + String Name; + Boolean IsEditable { get; }; + Boolean IsDefaultScheme { get; }; + + Boolean RequestRename(String newName); + + // Terminal Colors + Windows.Foundation.Collections.IVector NonBrightColorTable; + Windows.Foundation.Collections.IVector BrightColorTable; + + ColorTableEntry ColorEntryAt(UInt32 Index); + + // System Colors + ColorTableEntry ForegroundColor; + ColorTableEntry BackgroundColor; + ColorTableEntry CursorColor; + ColorTableEntry SelectionBackgroundColor; + + void DeleteConfirmation_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args); + void SetAsDefault_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args); + void Duplicate_Click(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args); + } + + [default_interface] runtimeclass ColorTableEntry : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + String Name { get; }; + IInspectable Tag; + Windows.UI.Color Color; + String AccessibleName { get; }; + } + + [default_interface] runtimeclass EditColorScheme : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + EditColorScheme(); + + ColorSchemeViewModel ViewModel { get; }; + } + + [default_interface] runtimeclass EnumEntry : Windows.UI.Xaml.Data.INotifyPropertyChanged, Windows.Foundation.IStringable + { + String EnumName { get; }; + IInspectable EnumValue { get; }; + } + + [default_interface] runtimeclass GlobalAppearance : Windows.UI.Xaml.Controls.Page + { + GlobalAppearance(); + GlobalAppearanceViewModel ViewModel { get; }; + } + + runtimeclass GlobalAppearanceViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + GlobalAppearanceViewModel(Microsoft.Terminal.Settings.Model.GlobalAppSettings globalSettings); + + static String LanguageDisplayConverter(String tag); + Boolean LanguageSelectorAvailable { get; }; + Windows.Foundation.Collections.IObservableVector LanguageList { get; }; + IInspectable CurrentLanguage; + + IInspectable CurrentTheme; + static String ThemeNameConverter(Microsoft.Terminal.Settings.Model.Theme theme); + Windows.Foundation.Collections.IObservableVector ThemeList { get; }; + + IInspectable CurrentNewTabPosition; + Windows.Foundation.Collections.IObservableVector NewTabPositionList { get; }; + + IInspectable CurrentTabWidthMode; + Windows.Foundation.Collections.IObservableVector TabWidthModeList { get; }; + + Boolean InvertedDisableAnimations; + + void ShowTitlebarToggled(IInspectable sender, Windows.UI.Xaml.RoutedEventArgs args); + + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysShowTabs); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTabsInTitlebar); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, UseAcrylicInTabRow); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTitleInTitlebar); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysOnTop); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AutoHideWindow); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysShowNotificationIcon); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, MinimizeToNotificationArea); + } + + [default_interface] runtimeclass Interaction : Windows.UI.Xaml.Controls.Page + { + Interaction(); + InteractionViewModel ViewModel { get; }; + } + + runtimeclass InteractionViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + InteractionViewModel(Microsoft.Terminal.Settings.Model.GlobalAppSettings globalSettings); + + IInspectable CurrentTabSwitcherMode; + Windows.Foundation.Collections.IObservableVector TabSwitcherModeList { get; }; + + IInspectable CurrentCopyFormat; + Windows.Foundation.Collections.IObservableVector CopyFormatList { get; }; + + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, CopyOnSelect); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, TrimBlockSelection); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, TrimPaste); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, SnapToGridOnResize); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, FocusFollowMouse); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DetectURLs); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, WordDelimiters); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ConfirmCloseAllTabs); + } + + [default_interface] runtimeclass KeyChordListener : Windows.UI.Xaml.Controls.UserControl + { + KeyChordListener(); + + Microsoft.Terminal.Control.KeyChord Keys; + static Windows.UI.Xaml.DependencyProperty KeysProperty { get; }; + } + + [default_interface] runtimeclass Launch : Windows.UI.Xaml.Controls.Page + { + Launch(); + LaunchViewModel ViewModel { get; }; + } + + runtimeclass LaunchViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + LaunchViewModel(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + + String LaunchParametersCurrentValue { get; }; + Double InitialPosX; + Double InitialPosY; + Boolean UseDefaultLaunchPosition; + + IInspectable CurrentDefaultProfile; + IObservableVector DefaultProfiles { get; }; + + IInspectable CurrentDefaultTerminal; + IObservableVector DefaultTerminals { get; }; + + IInspectable CurrentFirstWindowPreference; + IObservableVector FirstWindowPreferenceList { get; }; + + IInspectable CurrentLaunchMode; + IObservableVector LaunchModeList { get; }; + + IInspectable CurrentWindowingBehavior; + IObservableVector WindowingBehaviorList { get; }; + + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, CenterOnLaunch); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, StartOnUserLogin); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Int32, InitialRows); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Int32, InitialCols); + } + + // Due to a XAML Compiler bug, it is hard for us to propagate an HWND into a XAML-using runtimeclass. + // To work around that, we'll only propagate the HWND (when we need to) into the settings' toplevel page + // and use IHostedInWindow to hide the implementation detail where we use IInitializeWithWindow (shobjidl_core) + // https://github.com/microsoft/microsoft-ui-xaml/issues/3331 + interface IHostedInWindow + { + Boolean TryPropagateHostingWindow(IInspectable i); + UInt64 GetHostingWindow(); + } + + enum BreadcrumbSubPage + { + None = 0, + Profile_Appearance, + Profile_Advanced, + ColorSchemes_Edit + }; + + runtimeclass Breadcrumb : Windows.Foundation.IStringable + { + IInspectable Tag; + String Label; + BreadcrumbSubPage SubPage; + } + + [default_interface] runtimeclass MainPage : Windows.UI.Xaml.Controls.Page, IHostedInWindow + { + MainPage(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + + void UpdateSettings(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + event Windows.Foundation.TypedEventHandler OpenJson; + + // Due to the aforementioned bug, we can't use IInitializeWithWindow _here_ either. + // Let's just smuggle the HWND in as a UInt64 :| + void SetHostingWindow(UInt64 window); + + Windows.Foundation.Collections.IObservableVector Breadcrumbs { get; }; + + Windows.UI.Xaml.Media.Brush BackgroundBrush { get; }; + } + + [default_interface] runtimeclass Profiles_Advanced : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + Profiles_Advanced(); + ProfileViewModel Profile { get; }; + } + + [default_interface] runtimeclass Profiles_Appearance : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + Profiles_Appearance(); + ProfileViewModel Profile { get; }; + IHostedInWindow WindowRoot { get; }; + + Windows.UI.Xaml.Controls.Slider OpacitySlider { get; }; + } + + [default_interface] runtimeclass Profiles_Base : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged + { + Profiles_Base(); + ProfileViewModel Profile { get; }; + } + + runtimeclass NavigateToProfileArgs + { + ProfileViewModel Profile { get; }; + IHostedInWindow WindowRoot { get; }; + } + + runtimeclass DeleteProfileEventArgs + { + Guid ProfileGuid { get; }; + } + + enum ProfileSubPage + { + Base = 0, + Appearance = 1, + Advanced = 2 + }; + + runtimeclass ProfileViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + static Windows.Foundation.Collections.IObservableVector CompleteFontList { get; }; + static Windows.Foundation.Collections.IObservableVector MonospaceFontList { get; }; + static Font FindFontWithLocalizedName(String name); + + Microsoft.Terminal.Settings.Model.TerminalSettings TermSettings { get; }; + + event Windows.Foundation.TypedEventHandler DeleteProfile; + + void SetupAppearances(Windows.Foundation.Collections.IObservableVector schemesList); + + void SetAcrylicOpacityPercentageValue(Double value); + void SetPadding(Double value); + + Boolean IsBellStyleFlagSet(UInt32 flag); + void SetBellStyleAudible(Windows.Foundation.IReference on); + void SetBellStyleWindow(Windows.Foundation.IReference on); + void SetBellStyleTaskbar(Windows.Foundation.IReference on); + + IInspectable CurrentAntiAliasingMode; + Windows.Foundation.Collections.IObservableVector AntiAliasingModeList { get; }; + + IInspectable CurrentCloseOnExitMode; + Windows.Foundation.Collections.IObservableVector CloseOnExitModeList { get; }; + + IInspectable CurrentScrollState; + Windows.Foundation.Collections.IObservableVector ScrollStateList { get; }; + + Boolean CanDeleteProfile { get; }; + Boolean FocusDeleteButton; + Boolean IsBaseLayer; + ProfileSubPage CurrentPage; + Boolean UseParentProcessDirectory; + Boolean UseCustomStartingDirectory { get; }; + Boolean HideIcon; + AppearanceViewModel DefaultAppearance { get; }; + Guid OriginalProfileGuid { get; }; + Boolean HasUnfocusedAppearance { get; }; + Boolean EditableUnfocusedAppearance { get; }; + Boolean ShowUnfocusedAppearance { get; }; + AppearanceViewModel UnfocusedAppearance { get; }; + Boolean VtPassthroughAvailable { get; }; + + String EvaluatedIcon { get; }; + + void CreateUnfocusedAppearance(); + void DeleteUnfocusedAppearance(); + + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, Name); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Guid, Guid); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, Source); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Guid, ConnectionType); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, Hidden); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, Icon); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Settings.Model.CloseOnExitMode, CloseOnExit); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, TabTitle); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Windows.Foundation.IReference, TabColor); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, SuppressApplicationTitle); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, UseAcrylic); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Double, Opacity); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.ScrollbarState, ScrollState); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, Padding); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, Commandline); + OBSERVABLE_PROJECTED_PROFILE_SETTING(String, StartingDirectory); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.TextAntialiasingMode, AntialiasingMode); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Windows.Foundation.IReference, Foreground); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Windows.Foundation.IReference, Background); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Windows.Foundation.IReference, SelectionBackground); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Windows.Foundation.IReference, CursorColor); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Int32, HistorySize); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, SnapOnInput); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AltGrAliasing); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Settings.Model.BellStyle, BellStyle); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, Elevate); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, VtPassthrough); + OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ReloadEnvironmentVariables); + } + + [default_interface] runtimeclass Rendering : Windows.UI.Xaml.Controls.Page + { + Rendering(); + RenderingViewModel ViewModel { get; }; + } + + runtimeclass RenderingViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged + { + RenderingViewModel(Microsoft.Terminal.Settings.Model.CascadiaSettings settings); + + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ForceFullRepaintRendering); + PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, SoftwareRendering); + } + + [default_interface] runtimeclass SettingContainer : Windows.UI.Xaml.Controls.ContentControl + { + SettingContainer(); + + void SetExpanded(Boolean expanded); + + IInspectable Header; + static Windows.UI.Xaml.DependencyProperty HeaderProperty { get; }; + + String HelpText; + static Windows.UI.Xaml.DependencyProperty HelpTextProperty { get; }; + + String CurrentValue; + static Windows.UI.Xaml.DependencyProperty CurrentValueProperty { get; }; + + Boolean HasSettingValue; + static Windows.UI.Xaml.DependencyProperty HasSettingValueProperty { get; }; + + IInspectable SettingOverrideSource; + static Windows.UI.Xaml.DependencyProperty SettingOverrideSourceProperty { get; }; + + Boolean StartExpanded; + static Windows.UI.Xaml.DependencyProperty StartExpandedProperty { get; }; + + event Windows.Foundation.TypedEventHandler ClearSettingValue; + }; +} diff --git a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj index 836ec79a90..4b10476f8f 100644 --- a/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj +++ b/src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj @@ -48,7 +48,6 @@ AddProfile.xaml - EnumEntry.idl GlobalAppearance.xaml @@ -75,35 +74,27 @@ MainPage.xaml - ProfileViewModel.idl Code - ActionsViewModel.idl Code - ColorSchemeViewModel.idl Code - ColorSchemesPageViewModel.idl Code - RenderingViewModel.idl Code - InteractionViewModel.idl Code - GlobalAppearanceViewModel.idl Code - LaunchViewModel.idl Code @@ -126,7 +117,6 @@ Rendering.xaml - SettingContainer.idl @@ -218,35 +208,27 @@ - ProfileViewModel.idl Code - ActionsViewModel.idl Code - ColorSchemeViewModel.idl Code - ColorSchemesPageViewModel.idl Code - RenderingViewModel.idl Code - InteractionViewModel.idl Code - GlobalAppearanceViewModel.idl Code - LaunchViewModel.idl Code @@ -269,7 +251,6 @@ Rendering.xaml - SettingContainer.idl @@ -278,71 +259,7 @@ - - Actions.xaml - Code - - - AddProfile.xaml - Code - - - - GlobalAppearance.xaml - Code - - - ColorSchemes.xaml - Code - - - EditColorScheme.xaml - Code - - - KeyChordListener.xaml - Code - - - Launch.xaml - Code - - - Interaction.xaml - Code - - - Rendering.xaml - Code - - - MainPage.xaml - - - - - - - - - - - Profiles_Base.xaml - Code - - - Profiles_Advanced.xaml - Code - - - Profiles_Appearance.xaml - Code - - - Appearances.xaml - Code - - + Code diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.h b/src/cascadia/TerminalSettingsModel/EnumMappings.h index dfdd6c4650..4d25fe434a 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.h +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.h @@ -20,7 +20,7 @@ Author(s): namespace winrt::Microsoft::Terminal::Settings::Model::implementation { - struct EnumMappings : EnumMappingsT + struct EnumMappings { public: EnumMappings() = default; diff --git a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.Model.idl b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.Model.idl new file mode 100644 index 0000000000..5b71a8e2f5 --- /dev/null +++ b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.Model.idl @@ -0,0 +1,1155 @@ +#include "AllShortcutActions.h" +#include "IInheritable.idl.h" + +#define INHERITABLE_FONT_SETTING(Type, Name) \ + _BASE_INHERITABLE_SETTING(Type, Name); \ + Microsoft.Terminal.Settings.Model.FontConfig Name##OverrideSource { get; } + +#define INHERITABLE_APPEARANCE_SETTING(Type, Name) \ + _BASE_INHERITABLE_SETTING(Type, Name); \ + Microsoft.Terminal.Settings.Model.IAppearanceConfig Name##OverrideSource { get; } + +#define INHERITABLE_PROFILE_SETTING(Type, Name) \ + _BASE_INHERITABLE_SETTING(Type, Name); \ + Microsoft.Terminal.Settings.Model.Profile Name##OverrideSource { get; } + +#define COMMA , + +namespace Microsoft.Terminal.Settings.Model +{ + runtimeclass Command; + + // MIDL 3 allows for structs to hold nullable types + // Though IReference is a WinRT object, MIDL 3 + // handles all of the ownership logic for us. + // Docs: https://docs.microsoft.com/en-us/uwp/midl-3/intro#types + struct LaunchPosition + { + Windows.Foundation.IReference X; + Windows.Foundation.IReference Y; + }; + + [flags] + enum LaunchMode + { + DefaultMode = 0, + MaximizedMode = 1, + FullscreenMode = 2, + FocusMode = 4, + MaximizedFocusMode = 5 + }; + + enum WindowingMode + { + UseNew, + UseAnyExisting, + UseExisting, + }; + + enum FirstWindowPreference + { + DefaultProfile, + PersistedWindowLayout, + }; + + enum NewTabPosition + { + AfterLastTab, + AfterCurrentTab, + }; + + + interface IActionArgs + { + Boolean Equals(IActionArgs other); + String GenerateName(); + IActionArgs Copy(); + UInt64 Hash(); + }; + + interface IActionEventArgs + { + Boolean Handled; + IActionArgs ActionArgs { get; }; + }; + + enum ResizeDirection + { + None = 0, + Left, + Right, + Up, + Down + }; + + enum FocusDirection + { + None = 0, + Left, + Right, + Up, + Down, + Previous, + PreviousInOrder, + NextInOrder, + First, + Parent, + Child + }; + + enum SplitDirection + { + Automatic = 0, + Up, + Right, + Down, + Left + }; + + enum SplitType + { + Manual = 0, + Duplicate = 1 + }; + + enum SettingsTarget + { + SettingsFile = 0, + DefaultsFile, + AllFiles, + SettingsUI + }; + + enum MoveTabDirection + { + None = 0, + Forward, + Backward + }; + + enum FindMatchDirection + { + None = 0, + Next, + Previous + }; + + enum SelectOutputDirection + { + Previous = 0, + Next, + }; + + enum CommandPaletteLaunchMode + { + Action = 0, + CommandLine + }; + + enum TabSwitcherMode + { + MostRecentlyUsed, + InOrder, + Disabled, + }; + + enum DesktopBehavior + { + Any, + ToCurrent, + OnCurrent, + }; + + enum MonitorBehavior + { + Any, + ToCurrent, + ToMouse, + }; + + [flags] + enum SuggestionsSource + { + Tasks = 0x1, + CommandHistory = 0x2, + DirectoryHistory = 0x4, + All = 0xffffffff, + }; + + runtimeclass NewTerminalArgs { + NewTerminalArgs(); + NewTerminalArgs(Int32 profileIndex); + NewTerminalArgs Copy(); + + String Commandline; + String StartingDirectory; + String TabTitle; + Windows.Foundation.IReference TabColor; + String Profile; // Either a GUID or a profile's name if the GUID isn't a match + Boolean AppendCommandLine; + + // We use IReference<> to treat some args as nullable where null means + // "use the inherited value". See ProfileIndex, + // SuppressApplicationTitle, Elevate. Strings that behave this way just + // use `null` as "use the inherited value". + + // ProfileIndex can be null (for "use the default"), so this needs to be + // a IReference, so it's nullable + Windows.Foundation.IReference ProfileIndex { get; }; + Windows.Foundation.IReference SuppressApplicationTitle; + String ColorScheme; + // This needs to be an optional so that the default value (null) does + // not modify whatever the profile's value is (either true or false) + Windows.Foundation.IReference Elevate; + // Similarly with ReloadEnvironmentVariables + Windows.Foundation.IReference ReloadEnvironmentVariables; + + UInt64 ContentId{ get; set; }; + + Boolean Equals(NewTerminalArgs other); + String GenerateName(); + String ToCommandline(); + UInt64 Hash(); + }; + + [default_interface] runtimeclass ActionEventArgs : IActionEventArgs + { + ActionEventArgs(); + ActionEventArgs(IActionArgs args); + }; + + [default_interface] runtimeclass CopyTextArgs : IActionArgs + { + CopyTextArgs(); + Boolean DismissSelection { get; }; + Boolean SingleLine { get; }; + Windows.Foundation.IReference CopyFormatting { get; }; + }; + + [default_interface] runtimeclass NewTabArgs : IActionArgs + { + NewTabArgs(NewTerminalArgs terminalArgs); + NewTerminalArgs TerminalArgs { get; }; + }; + + [default_interface] runtimeclass MovePaneArgs : IActionArgs + { + MovePaneArgs(UInt32 tabIndex, String Window); + UInt32 TabIndex; + String Window; + }; + + [default_interface] runtimeclass SwitchToTabArgs : IActionArgs + { + SwitchToTabArgs(UInt32 tabIndex); + UInt32 TabIndex; + }; + + [default_interface] runtimeclass ResizePaneArgs : IActionArgs + { + ResizeDirection ResizeDirection { get; }; + }; + + [default_interface] runtimeclass MoveFocusArgs : IActionArgs + { + MoveFocusArgs(FocusDirection direction); + FocusDirection FocusDirection { get; }; + }; + + [default_interface] runtimeclass SwapPaneArgs : IActionArgs + { + SwapPaneArgs(FocusDirection direction); + FocusDirection Direction { get; }; + }; + + [default_interface] runtimeclass AdjustFontSizeArgs : IActionArgs + { + Single Delta { get; }; + }; + + [default_interface] runtimeclass SendInputArgs : IActionArgs + { + String Input { get; }; + }; + + [default_interface] runtimeclass SplitPaneArgs : IActionArgs + { + SplitPaneArgs(SplitType splitMode, SplitDirection split, Double size, NewTerminalArgs terminalArgs); + SplitPaneArgs(SplitDirection split, Double size, NewTerminalArgs terminalArgs); + SplitPaneArgs(SplitDirection split, NewTerminalArgs terminalArgs); + SplitPaneArgs(SplitType splitMode); + + SplitDirection SplitDirection { get; }; + NewTerminalArgs TerminalArgs { get; }; + SplitType SplitMode { get; }; + Double SplitSize { get; }; + }; + + [default_interface] runtimeclass OpenSettingsArgs : IActionArgs + { + OpenSettingsArgs(SettingsTarget target); + SettingsTarget Target { get; }; + }; + + [default_interface] runtimeclass SetFocusModeArgs : IActionArgs + { + SetFocusModeArgs(Boolean isFocusMode); + Boolean IsFocusMode { get; }; + }; + + [default_interface] runtimeclass SetFullScreenArgs : IActionArgs + { + SetFullScreenArgs(Boolean isFullScreen); + Boolean IsFullScreen { get; }; + }; + + [default_interface] runtimeclass SetMaximizedArgs : IActionArgs + { + SetMaximizedArgs(Boolean isMaximized); + Boolean IsMaximized { get; }; + }; + + [default_interface] runtimeclass SetColorSchemeArgs : IActionArgs + { + SetColorSchemeArgs(String name); + String SchemeName { get; }; + }; + + [default_interface] runtimeclass SetTabColorArgs : IActionArgs + { + SetTabColorArgs(Windows.UI.Color tabColor); + Windows.Foundation.IReference TabColor { get; }; + }; + + [default_interface] runtimeclass RenameTabArgs : IActionArgs + { + RenameTabArgs(String title); + String Title { get; }; + }; + + [default_interface] runtimeclass ExecuteCommandlineArgs : IActionArgs + { + ExecuteCommandlineArgs(String commandline); + String Commandline; + }; + + [default_interface] runtimeclass CloseOtherTabsArgs : IActionArgs + { + CloseOtherTabsArgs(UInt32 tabIndex); + Windows.Foundation.IReference Index { get; }; + }; + + [default_interface] runtimeclass CloseTabsAfterArgs : IActionArgs + { + CloseTabsAfterArgs(UInt32 tabIndex); + Windows.Foundation.IReference Index { get; }; + }; + + [default_interface] runtimeclass CloseTabArgs : IActionArgs + { + CloseTabArgs(UInt32 tabIndex); + Windows.Foundation.IReference Index { get; }; + }; + + [default_interface] runtimeclass MoveTabArgs : IActionArgs + { + MoveTabArgs(String window, MoveTabDirection direction); + MoveTabDirection Direction { get; }; + String Window { get; }; + }; + + [default_interface] runtimeclass ScrollUpArgs : IActionArgs + { + Windows.Foundation.IReference RowsToScroll { get; }; + }; + + [default_interface] runtimeclass ScrollDownArgs : IActionArgs + { + Windows.Foundation.IReference RowsToScroll { get; }; + }; + + + [default_interface] runtimeclass ScrollToMarkArgs : IActionArgs + { + Microsoft.Terminal.Control.ScrollToMarkDirection Direction { get; }; + }; + + [default_interface] runtimeclass AddMarkArgs : IActionArgs + { + Windows.Foundation.IReference Color { get; }; + }; + + [default_interface] runtimeclass ToggleCommandPaletteArgs : IActionArgs + { + CommandPaletteLaunchMode LaunchMode { get; }; + }; + + [default_interface] runtimeclass SuggestionsArgs : IActionArgs + { + SuggestionsArgs(); + SuggestionsArgs(SuggestionsSource source, Boolean useCommandline); + SuggestionsSource Source { get; }; + Boolean UseCommandline { get; }; + }; + + [default_interface] runtimeclass FindMatchArgs : IActionArgs + { + FindMatchArgs(FindMatchDirection direction); + FindMatchDirection Direction { get; }; + }; + + [default_interface] runtimeclass NewWindowArgs : IActionArgs + { + NewWindowArgs(NewTerminalArgs terminalArgs); + NewTerminalArgs TerminalArgs { get; }; + }; + + [default_interface] runtimeclass PrevTabArgs : IActionArgs + { + PrevTabArgs(); + PrevTabArgs(TabSwitcherMode SwitcherMode); + Windows.Foundation.IReference SwitcherMode; + }; + + [default_interface] runtimeclass NextTabArgs : IActionArgs + { + NextTabArgs(); + NextTabArgs(TabSwitcherMode SwitcherMode); + Windows.Foundation.IReference SwitcherMode; + }; + + [default_interface] runtimeclass RenameWindowArgs : IActionArgs + { + RenameWindowArgs(String name); + String Name { get; }; + }; + + [default_interface] runtimeclass SearchForTextArgs : IActionArgs + { + String QueryUrl { get; }; + }; + + [default_interface] runtimeclass GlobalSummonArgs : IActionArgs + { + String Name { get; }; + DesktopBehavior Desktop { get; }; + MonitorBehavior Monitor { get; }; + Boolean ToggleVisibility { get; }; + UInt32 DropdownDuration { get; }; + }; + + [default_interface] runtimeclass FocusPaneArgs : IActionArgs + { + FocusPaneArgs(UInt32 Id); + UInt32 Id { get; }; + }; + + [default_interface] runtimeclass ExportBufferArgs : IActionArgs + { + ExportBufferArgs(String path); + String Path { get; }; + }; + + [default_interface] runtimeclass ClearBufferArgs : IActionArgs + { + ClearBufferArgs(Microsoft.Terminal.Control.ClearBufferType clear); + Microsoft.Terminal.Control.ClearBufferType Clear { get; }; + }; + + [default_interface] runtimeclass MultipleActionsArgs : IActionArgs + { + MultipleActionsArgs(); + Windows.Foundation.Collections.IVector Actions; + }; + + [default_interface] runtimeclass AdjustOpacityArgs : IActionArgs + { + AdjustOpacityArgs(); + Int32 Opacity { get; }; + Boolean Relative { get; }; + }; + + [default_interface] runtimeclass ColorSelectionArgs : IActionArgs + { + Microsoft.Terminal.Control.SelectionColor Foreground; + Microsoft.Terminal.Control.SelectionColor Background; + Microsoft.Terminal.Core.MatchMode MatchMode { get; }; + }; + + [default_interface] runtimeclass SelectCommandArgs : IActionArgs + { + SelectCommandArgs(SelectOutputDirection direction); + SelectOutputDirection Direction { get; }; + } + [default_interface] runtimeclass SelectOutputArgs : IActionArgs + { + SelectOutputArgs(SelectOutputDirection direction); + SelectOutputDirection Direction { get; }; + } + + // This interface ensures that no changes are made to ActionMap + interface IActionMapView + { + Boolean IsKeyChordExplicitlyUnbound(Microsoft.Terminal.Control.KeyChord keys); + + Command GetActionByKeyChord(Microsoft.Terminal.Control.KeyChord keys); + + Microsoft.Terminal.Control.KeyChord GetKeyBindingForAction(ShortcutAction action); + [method_name("GetKeyBindingForActionWithArgs")] Microsoft.Terminal.Control.KeyChord GetKeyBindingForAction(ShortcutAction action, IActionArgs actionArgs); + + Windows.Foundation.Collections.IMapView AvailableActions { get; }; + + Windows.Foundation.Collections.IMapView NameMap { get; }; + Windows.Foundation.Collections.IMapView KeyBindings { get; }; + Windows.Foundation.Collections.IMapView GlobalHotkeys { get; }; + + IVector ExpandedCommands { get; }; + + IVector FilterToSendInput(String CurrentCommandline); + }; + + [default_interface] runtimeclass ActionMap : IActionMapView + { + void RebindKeys(Microsoft.Terminal.Control.KeyChord oldKeys, Microsoft.Terminal.Control.KeyChord newKeys); + void DeleteKeyBinding(Microsoft.Terminal.Control.KeyChord keys); + + void RegisterKeyBinding(Microsoft.Terminal.Control.KeyChord keys, ActionAndArgs action); + } + + runtimeclass AppearanceConfig : [default] IAppearanceConfig { + } + + enum InfoBarMessage + { + CloseOnExitInfo = 0, + KeyboardServiceWarning, + SetAsDefault, + }; + + runtimeclass WindowLayout + { + WindowLayout(); + + static String ToJson(WindowLayout layout); + static WindowLayout FromJson(String json); + + Windows.Foundation.Collections.IVector TabLayout; + Windows.Foundation.IReference InitialPosition; + Windows.Foundation.IReference InitialSize; + Windows.Foundation.IReference LaunchMode; + }; + + runtimeclass ApplicationState { + static ApplicationState SharedInstance(); + + void Flush(); + void Reset(); + + String SettingsHash; + Windows.Foundation.Collections.IVector PersistedWindowLayouts; + Windows.Foundation.Collections.IVector RecentCommands; + Windows.Foundation.Collections.IVector DismissedMessages; + Windows.Foundation.Collections.IVector AllowedCommandlines; + } + + runtimeclass CascadiaSettings { + static CascadiaSettings LoadDefaults(); + static CascadiaSettings LoadAll(); + + static String SettingsPath { get; }; + static String DefaultSettingsPath { get; }; + static Boolean IsPortableMode { get; }; + + static String ApplicationDisplayName { get; }; + static String ApplicationVersion { get; }; + + static void ExportFile(String path, String content); + + CascadiaSettings(String userJSON, String inboxJSON); + + CascadiaSettings Copy(); + void WriteSettingsToDisk(); + + String Hash { get; }; + + GlobalAppSettings GlobalSettings { get; }; + + Profile ProfileDefaults { get; }; + + IObservableVector AllProfiles { get; }; + IObservableVector ActiveProfiles { get; }; + + Profile DuplicateProfile(Profile sourceProfile); + + ActionMap ActionMap { get; }; + + IVectorView Warnings { get; }; + Windows.Foundation.IReference GetLoadingError { get; }; + String GetSerializationErrorMessage { get; }; + + Profile CreateNewProfile(); + Profile FindProfile(Guid profileGuid); + void UpdateColorSchemeReferences(String oldName, String newName); + + Profile GetProfileForArgs(NewTerminalArgs newTerminalArgs); + + static Boolean IsDefaultTerminalAvailable { get; }; + static Boolean IsDefaultTerminalSet { get; }; + IObservableVector DefaultTerminals { get; }; + DefaultTerminal CurrentDefaultTerminal; + + void ExpandCommands(); + } + + runtimeclass ColorScheme : Windows.Foundation.IStringable, ISettingsModelObject { + ColorScheme(); + ColorScheme(String name); + + String Name; + + Microsoft.Terminal.Core.Color Foreground; + Microsoft.Terminal.Core.Color Background; + Microsoft.Terminal.Core.Color SelectionBackground; + Microsoft.Terminal.Core.Color CursorColor; + + // winrt::com_arrays prevent data binding. + // Instead of representing Table as a property, + // we expose the getter as a function. + Microsoft.Terminal.Core.Color[] Table(); + void SetColorTableEntry(UInt8 index, Microsoft.Terminal.Core.Color value); + + Microsoft.Terminal.Core.Scheme ToCoreScheme(); + } + + enum ShortcutAction + { + Invalid = 0, // treat Invalid as unbound actions + + // When adding a new action, add them to AllShortcutActions.h! + #define ON_ALL_ACTIONS(action) action, + ALL_SHORTCUT_ACTIONS + #undef ON_ALL_ACTIONS + }; + + runtimeclass ActionAndArgs { + ActionAndArgs(); + ActionAndArgs(ShortcutAction action, IActionArgs args); + + static String Serialize(IVector args); + static IVector Deserialize(String content); + + IActionArgs Args; + ShortcutAction Action; + }; + + runtimeclass Command + { + Command(); + + String Name { get; }; + ActionAndArgs ActionAndArgs { get; }; + Microsoft.Terminal.Control.KeyChord Keys { get; }; + void RegisterKey(Microsoft.Terminal.Control.KeyChord keys); + String KeyChordText { get; }; + + String IconPath; + + Boolean HasNestedCommands { get; }; + Windows.Foundation.Collections.IMapView NestedCommands { get; }; + + static IVector ParsePowerShellMenuComplete(String json, Int32 replaceLength); + static IVector HistoryToCommands(IVector commandHistory, String commandline, Boolean directories); + + } + + runtimeclass DefaultTerminal : Windows.Foundation.IStringable + { + String Name { get; }; + String Author { get; }; + String Version { get; }; + String Icon { get; }; + } + + runtimeclass EnumMappings { + // Global Settings + static Windows.Foundation.Collections.IMap ElementTheme { get; }; + static Windows.Foundation.Collections.IMap NewTabPosition { get; }; + static Windows.Foundation.Collections.IMap TabViewWidthMode { get; }; + static Windows.Foundation.Collections.IMap FirstWindowPreference { get; }; + static Windows.Foundation.Collections.IMap LaunchMode { get; }; + static Windows.Foundation.Collections.IMap TabSwitcherMode { get; }; + static Windows.Foundation.Collections.IMap CopyFormat { get; }; + static Windows.Foundation.Collections.IMap WindowingMode { get; }; + static Windows.Foundation.Collections.IMap MatchMode { get; }; + + // Profile Settings + static Windows.Foundation.Collections.IMap CloseOnExitMode { get; }; + static Windows.Foundation.Collections.IMap ScrollbarState { get; }; + static Windows.Foundation.Collections.IMap BackgroundImageStretchMode { get; }; + static Windows.Foundation.Collections.IMap TextAntialiasingMode { get; }; + static Windows.Foundation.Collections.IMap CursorStyle { get; }; + static Windows.Foundation.Collections.IMap AdjustIndistinguishableColors { get; }; + static Windows.Foundation.Collections.IMap FontWeight { get; }; + static Windows.Foundation.Collections.IMap IntenseTextStyle { get; }; + } + + runtimeclass FontConfig { + Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; }; + + INHERITABLE_FONT_SETTING(String, FontFace); + INHERITABLE_FONT_SETTING(Single, FontSize); + INHERITABLE_FONT_SETTING(Windows.UI.Text.FontWeight, FontWeight); + INHERITABLE_FONT_SETTING(Windows.Foundation.Collections.IMap, FontFeatures); + INHERITABLE_FONT_SETTING(Windows.Foundation.Collections.IMap, FontAxes); + INHERITABLE_FONT_SETTING(Boolean, EnableBuiltinGlyphs); + INHERITABLE_FONT_SETTING(String, CellWidth); + INHERITABLE_FONT_SETTING(String, CellHeight); + } + + runtimeclass GlobalAppSettings { + Guid DefaultProfile; + + INHERITABLE_SETTING(String, UnparsedDefaultProfile); + + INHERITABLE_SETTING(Int32, InitialRows); + INHERITABLE_SETTING(Int32, InitialCols); + INHERITABLE_SETTING(Boolean, AlwaysShowTabs); + INHERITABLE_SETTING(NewTabPosition, NewTabPosition); + INHERITABLE_SETTING(Boolean, ShowTitleInTitlebar); + INHERITABLE_SETTING(Boolean, ConfirmCloseAllTabs); + INHERITABLE_SETTING(String, Language); + INHERITABLE_SETTING(Microsoft.UI.Xaml.Controls.TabViewWidthMode, TabWidthMode); + INHERITABLE_SETTING(Boolean, UseAcrylicInTabRow); + INHERITABLE_SETTING(Boolean, ShowTabsInTitlebar); + INHERITABLE_SETTING(String, WordDelimiters); + INHERITABLE_SETTING(Boolean, CopyOnSelect); + INHERITABLE_SETTING(Boolean, InputServiceWarning); + INHERITABLE_SETTING(Microsoft.Terminal.Control.CopyFormat, CopyFormatting); + INHERITABLE_SETTING(Boolean, WarnAboutLargePaste); + INHERITABLE_SETTING(Boolean, WarnAboutMultiLinePaste); + INHERITABLE_SETTING(Boolean, TrimPaste); + INHERITABLE_SETTING(LaunchPosition, InitialPosition); + INHERITABLE_SETTING(Boolean, CenterOnLaunch); + INHERITABLE_SETTING(FirstWindowPreference, FirstWindowPreference); + INHERITABLE_SETTING(LaunchMode, LaunchMode); + INHERITABLE_SETTING(Boolean, SnapToGridOnResize); + INHERITABLE_SETTING(Boolean, ForceFullRepaintRendering); + INHERITABLE_SETTING(Boolean, SoftwareRendering); + INHERITABLE_SETTING(Boolean, UseBackgroundImageForWindow); + INHERITABLE_SETTING(Boolean, ForceVTInput); + INHERITABLE_SETTING(Boolean, DebugFeaturesEnabled); + INHERITABLE_SETTING(Boolean, StartOnUserLogin); + INHERITABLE_SETTING(Boolean, AlwaysOnTop); + INHERITABLE_SETTING(Boolean, AutoHideWindow); + INHERITABLE_SETTING(TabSwitcherMode, TabSwitcherMode); + INHERITABLE_SETTING(Boolean, DisableAnimations); + INHERITABLE_SETTING(String, StartupActions); + INHERITABLE_SETTING(Boolean, FocusFollowMouse); + INHERITABLE_SETTING(WindowingMode, WindowingBehavior); + INHERITABLE_SETTING(Boolean, TrimBlockSelection); + INHERITABLE_SETTING(Boolean, DetectURLs); + INHERITABLE_SETTING(Boolean, MinimizeToNotificationArea); + INHERITABLE_SETTING(Boolean, AlwaysShowNotificationIcon); + INHERITABLE_SETTING(IVector, DisabledProfileSources); + INHERITABLE_SETTING(Boolean, ShowAdminShield); + INHERITABLE_SETTING(IVector, NewTabMenu); + INHERITABLE_SETTING(Boolean, EnableColorSelection); + INHERITABLE_SETTING(Boolean, EnableShellCompletionMenu); + INHERITABLE_SETTING(Boolean, EnableUnfocusedAcrylic); + INHERITABLE_SETTING(Boolean, IsolatedMode); + INHERITABLE_SETTING(Boolean, AllowHeadless); + INHERITABLE_SETTING(String, SearchWebDefaultQueryUrl); + + Windows.Foundation.Collections.IMapView ColorSchemes(); + void AddColorScheme(ColorScheme scheme); + void RemoveColorScheme(String schemeName); + ColorScheme DuplicateColorScheme(ColorScheme scheme); + + ActionMap ActionMap { get; }; + + Windows.Foundation.Collections.IMapView Themes(); + void AddTheme(Theme theme); + INHERITABLE_SETTING(ThemePair, Theme); + Theme CurrentTheme { get; }; + + Boolean ShouldUsePersistedLayout(); + } + + [flags] enum ConvergedAlignment { + // low 4 bits are the horizontal + Horizontal_Center = 0x00, + Horizontal_Left = 0x01, + Horizontal_Right = 0x02, + + // high 4 bits are the vertical + Vertical_Center = 0x00, + Vertical_Top = 0x10, + Vertical_Bottom = 0x20 + }; + + [flags] enum IntenseStyle { + Bold = 0x1, + Bright = 0x2, + All = 0xffffffff + }; + + interface IAppearanceConfig + { + Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; }; + + INHERITABLE_APPEARANCE_SETTING(String, DarkColorSchemeName); + INHERITABLE_APPEARANCE_SETTING(String, LightColorSchemeName); + + INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, Foreground); + INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, Background); + INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, SelectionBackground); + INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, CursorColor); + INHERITABLE_APPEARANCE_SETTING(Microsoft.Terminal.Core.CursorStyle, CursorShape); + INHERITABLE_APPEARANCE_SETTING(UInt32, CursorHeight); + + INHERITABLE_APPEARANCE_SETTING(String, BackgroundImagePath); + String ExpandedBackgroundImagePath { get; }; + + INHERITABLE_APPEARANCE_SETTING(Double, BackgroundImageOpacity); + INHERITABLE_APPEARANCE_SETTING(Windows.UI.Xaml.Media.Stretch, BackgroundImageStretchMode); + INHERITABLE_APPEARANCE_SETTING(ConvergedAlignment, BackgroundImageAlignment); + + INHERITABLE_APPEARANCE_SETTING(Boolean, RetroTerminalEffect); + INHERITABLE_APPEARANCE_SETTING(String, PixelShaderPath); + INHERITABLE_APPEARANCE_SETTING(String, PixelShaderImagePath); + INHERITABLE_APPEARANCE_SETTING(IntenseStyle, IntenseTextStyle); + INHERITABLE_APPEARANCE_SETTING(Microsoft.Terminal.Core.AdjustTextMode, AdjustIndistinguishableColors); + INHERITABLE_APPEARANCE_SETTING(Double, Opacity); + INHERITABLE_APPEARANCE_SETTING(Boolean, UseAcrylic); + }; + + // This tag is used to identify the context in which this object was created + enum OriginTag + { + None = 0, + User, + InBox, + Generated, + Fragment, + ProfilesDefaults + }; + + interface ISettingsModelObject { + OriginTag Origin { get; }; + } + + static runtimeclass KeyChordSerialization + { + static Microsoft.Terminal.Control.KeyChord FromString(String str); + static String ToString(Microsoft.Terminal.Control.KeyChord chord); + } + + enum NewTabMenuEntryType + { + Invalid = 0, + Profile, + Separator, + Folder, + RemainingProfiles, + MatchProfiles + }; + + unsealed runtimeclass NewTabMenuEntry + { + NewTabMenuEntryType Type; + } + + [default_interface] runtimeclass SeparatorEntry : NewTabMenuEntry + { + SeparatorEntry(); + } + + runtimeclass ProfileEntry : NewTabMenuEntry + { + ProfileEntry(); + ProfileEntry(String profile); + + Profile Profile; + Int32 ProfileIndex; + } + + enum FolderEntryInlining + { + Never = 0, + Auto + }; + + runtimeclass FolderEntry : NewTabMenuEntry + { + FolderEntry(); + FolderEntry(String name); + + String Name; + String Icon; + FolderEntryInlining Inlining; + Boolean AllowEmpty; + + IVector Entries(); + } + + unsealed runtimeclass ProfileCollectionEntry : NewTabMenuEntry + { + IMap Profiles; + } + + [default_interface] runtimeclass RemainingProfilesEntry : ProfileCollectionEntry + { + RemainingProfilesEntry(); + } + + runtimeclass MatchProfilesEntry : ProfileCollectionEntry + { + MatchProfilesEntry(); + + String Name; + String Commandline; + String Source; + } + + enum CloseOnExitMode + { + Never = 0, + Graceful, + Always, + Automatic + }; + + [flags] + enum BellStyle + { + // !! If you update this, you must update the values in TerminalSettingsEditor/Profiles.xaml + Audible = 0x1, + Window = 0x2, + Taskbar = 0x4, + All = 0xffffffff + }; + + runtimeclass Profile : Windows.Foundation.IStringable, ISettingsModelObject { + Profile(); + Profile(Guid guid); + + void CreateUnfocusedAppearance(); + void DeleteUnfocusedAppearance(); + + // True if the user explicitly removed this Profile from settings.json. + Boolean Deleted { get; }; + + // Helper for magically using a commandline for an icon for a profile + // without an explicit icon. + String EvaluatedIcon { get; }; + + INHERITABLE_PROFILE_SETTING(Guid, Guid); + INHERITABLE_PROFILE_SETTING(String, Name); + INHERITABLE_PROFILE_SETTING(String, Source); + INHERITABLE_PROFILE_SETTING(Boolean, Hidden); + INHERITABLE_PROFILE_SETTING(Guid, ConnectionType); + INHERITABLE_PROFILE_SETTING(String, Icon); + INHERITABLE_PROFILE_SETTING(CloseOnExitMode, CloseOnExit); + INHERITABLE_PROFILE_SETTING(String, TabTitle); + INHERITABLE_PROFILE_SETTING(Windows.Foundation.IReference, TabColor); + INHERITABLE_PROFILE_SETTING(Boolean, SuppressApplicationTitle); + INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.ScrollbarState, ScrollState); + INHERITABLE_PROFILE_SETTING(String, Padding); + INHERITABLE_PROFILE_SETTING(String, Commandline); + INHERITABLE_PROFILE_SETTING(Boolean, VtPassthrough); + + INHERITABLE_PROFILE_SETTING(String, StartingDirectory); + String EvaluatedStartingDirectory { get; }; + + FontConfig FontInfo { get; }; + + IAppearanceConfig DefaultAppearance { get; }; + INHERITABLE_PROFILE_SETTING(IAppearanceConfig, UnfocusedAppearance); + + INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.TextAntialiasingMode, AntialiasingMode); + + INHERITABLE_PROFILE_SETTING(Int32, HistorySize); + INHERITABLE_PROFILE_SETTING(Boolean, SnapOnInput); + INHERITABLE_PROFILE_SETTING(Boolean, AltGrAliasing); + INHERITABLE_PROFILE_SETTING(BellStyle, BellStyle); + + INHERITABLE_PROFILE_SETTING(Windows.Foundation.Collections.IMap, EnvironmentVariables); + + INHERITABLE_PROFILE_SETTING(Windows.Foundation.Collections.IVector, BellSound); + + INHERITABLE_PROFILE_SETTING(Boolean, Elevate); + INHERITABLE_PROFILE_SETTING(Boolean, AutoMarkPrompts); + INHERITABLE_PROFILE_SETTING(Boolean, ShowMarks); + + INHERITABLE_PROFILE_SETTING(Boolean, RightClickContextMenu); + INHERITABLE_PROFILE_SETTING(Boolean, RepositionCursorWithMouse); + + INHERITABLE_PROFILE_SETTING(Boolean, ReloadEnvironmentVariables); + + } + + runtimeclass TerminalSettingsCreateResult + { + TerminalSettingsCreateResult(TerminalSettings defaultSettings); + TerminalSettings DefaultSettings { get; }; + TerminalSettings UnfocusedSettings { get; }; + } + + // Class Description: + // TerminalSettings encapsulates all settings that control the + // TermControl's behavior. In these settings there is both the entirety + // of the Core ICoreSettings properties and the IControlSettings + // properties. It's the Profile's responsibility to build this from + // settings it contains, in combination with the global settings. + // The TerminalControl will pull settings it requires from this object, + // and pass along the Core properties to the terminal core. + [default_interface] + runtimeclass TerminalSettings : Microsoft.Terminal.Core.ICoreSettings, + Microsoft.Terminal.Control.IControlSettings + { + TerminalSettings(); + + Windows.Foundation.Collections.IMap EnvironmentVariables; + + static TerminalSettings CreateForPreview(CascadiaSettings appSettings, Profile profile); + static TerminalSettingsCreateResult CreateWithProfile(CascadiaSettings appSettings, Profile profile, Microsoft.Terminal.Control.IKeyBindings keybindings); + static TerminalSettingsCreateResult CreateWithNewTerminalArgs(CascadiaSettings appSettings, NewTerminalArgs newTerminalArgs, Microsoft.Terminal.Control.IKeyBindings keybindings); + + void ApplyColorScheme(ColorScheme scheme); + + ColorScheme AppliedColorScheme; + + // The getters for these are already defined in IControlSettings. So + // we're just adding the setters here, because TerminalApp likes to be + // able to change these at runtime (e.g. when duplicating a pane). + String Commandline { set; }; + String StartingDirectory { set; }; + + Boolean Elevate; + Boolean ReloadEnvironmentVariables; + }; + + // SettingsLoadWarnings are scenarios where the settings contained + // information we knew was invalid, but we could recover from. + enum SettingsLoadWarnings + { + MissingDefaultProfile = 0, + DuplicateProfile, + UnknownColorScheme, + InvalidBackgroundImage, + InvalidIcon, + AtLeastOneKeybindingWarning, + TooManyKeysForChord, + MissingRequiredParameter, + FailedToParseCommandJson, + FailedToWriteToSettings, + InvalidColorSchemeInCmd, + InvalidSplitSize, + FailedToParseStartupActions, + InvalidProfileEnvironmentVariables, + FailedToParseSubCommands, + UnknownTheme, + DuplicateRemainingProfilesEntry, + InvalidUseOfContent, + WARNINGS_SIZE // IMPORTANT: This MUST be the last value in this enum. It's an unused placeholder. + }; + + // SettingsLoadWarnings are scenarios where the settings had invalid state + // that we could not recover from. + enum SettingsLoadErrors + { + NoProfiles = 0, + AllProfilesHidden = 1, + ERRORS_SIZE // IMPORTANT: This MUST be the last value in this enum. It's an unused placeholder. + }; + + enum IconStyle + { + Default, + Hidden, + Monochrome + }; + + enum ThemeColorType + { + Accent, + Color, + TerminalBackground + }; + + enum TabCloseButtonVisibility + { + Always, + Hover, + Never, + ActiveOnly + }; + + runtimeclass ThemePair + { + ThemePair(); + ThemePair(String name); + ThemePair(String darkName, String lightName); + + String DarkName; + String LightName; + }; + + runtimeclass ThemeColor + { + ThemeColor(); + static ThemeColor FromColor(Microsoft.Terminal.Core.Color color); + static ThemeColor FromAccent(); + static ThemeColor FromTerminalBackground(); + + Microsoft.Terminal.Core.Color Color { get; }; + ThemeColorType ColorType; + + static Microsoft.Terminal.Core.Color ColorFromBrush(Windows.UI.Xaml.Media.Brush brush); + Windows.UI.Xaml.Media.Brush Evaluate(Windows.UI.Xaml.ResourceDictionary res, + Windows.UI.Xaml.Media.Brush terminalBackground, + Boolean forTitlebar); + UInt8 UnfocusedTabOpacity { get; }; + } + + runtimeclass WindowTheme { + Windows.UI.Xaml.ElementTheme RequestedTheme { get; }; + Boolean UseMica { get; }; + Boolean RainbowFrame { get; }; + ThemeColor Frame { get; }; + ThemeColor UnfocusedFrame { get; }; + } + + runtimeclass TabRowTheme { + ThemeColor Background { get; }; + ThemeColor UnfocusedBackground { get; }; + } + + runtimeclass TabTheme { + ThemeColor Background { get; }; + ThemeColor UnfocusedBackground { get; }; + TabCloseButtonVisibility ShowCloseButton { get; }; + IconStyle IconStyle { get; }; + } + + runtimeclass Theme : Windows.Foundation.IStringable { + Theme(); + Theme(Windows.UI.Xaml.ElementTheme requestedTheme); + + String Name; + + // window.* Namespace + WindowTheme Window { get; }; + + // tabRow.* Namespace + TabRowTheme TabRow { get; }; + + // tab.* Namespace + TabTheme Tab { get; }; + + // A helper for retrieving the RequestedTheme out of the window property + Windows.UI.Xaml.ElementTheme RequestedTheme { get; }; + static Boolean IsSystemInDarkTheme(); + + } +} diff --git a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj index 7175aa6e67..cf5f37e9c8 100644 --- a/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj +++ b/src/cascadia/TerminalSettingsModel/Microsoft.Terminal.Settings.ModelLib.vcxproj @@ -22,60 +22,43 @@ - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - DefaultTerminal.idl - ActionArgs.idl - ActionArgs.idl - ActionMap.idl - ApplicationState.idl - CascadiaSettings.idl - ColorScheme.idl - Theme.idl - Command.idl - GlobalAppSettings.idl @@ -83,28 +66,21 @@ - KeyChordSerialization.idl - Profile.idl - AppearanceConfig.idl - FontConfig.idl - EnumMappings.idl - TerminalSettings.idl - TerminalWarnings.idl @@ -117,87 +93,62 @@ - DefaultTerminal.idl Create - ActionArgs.idl - ActionArgs.idl - ActionMap.idl - ActionMap.idl - ApplicationState.idl - CascadiaSettings.idl - CascadiaSettings.idl - ColorScheme.idl - Theme.idl - Command.idl - GlobalAppSettings.idl - KeyChordSerialization.idl - Profile.idl - AppearanceConfig.idl - FontConfig.idl - TerminalSettings.idl - EnumMappings.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl - NewTabMenuEntry.idl @@ -213,25 +164,7 @@ - - - - - - - - - - - - - - - - - - - +