├── .gitignore ├── .gitmodules ├── Build.ps1 ├── CONTRIBUTING.md ├── Microsoft.Terminal.Control.Projection ├── ITextProviderMethods.cs ├── IXamlMetadataProviderMethods.cs └── Microsoft.Terminal.Control.Projection.csproj ├── Microsoft.Terminal.Settings.Model.Projection ├── IValueConverterMethods.cs └── Microsoft.Terminal.Settings.Model.Projection.csproj ├── Microsoft.Terminal.TerminalConnection.Projection └── Microsoft.Terminal.TerminalConnection.Projection.csproj ├── NuGet ├── WindowsTerminal.WinUI3.Control.nuspec ├── WindowsTerminal.WinUI3.Settings.Model.nuspec └── build │ └── net6.0-windows10.0.18362.0 │ ├── WindowsTerminal.WinUI3.Control.targets │ └── WindowsTerminal.WinUI3.Settings.Model.targets ├── OpenConsole ├── Microsoft.Terminal.Control │ ├── ControlAppearance.h │ ├── ControlCore.cpp │ ├── ControlCore.h │ ├── ControlCore.idl │ ├── ControlInteractivity.cpp │ ├── ControlInteractivity.h │ ├── ControlInteractivity.idl │ ├── ControlSettings.h │ ├── EventArgs.cpp │ ├── EventArgs.h │ ├── EventArgs.idl │ ├── IControlAppearance.idl │ ├── IControlSettings.idl │ ├── ICoreState.idl │ ├── IDirectKeyListener.idl │ ├── IKeyBindings.idl │ ├── IMouseWheelListener.idl │ ├── InteractivityAutomationPeer.cpp │ ├── InteractivityAutomationPeer.h │ ├── InteractivityAutomationPeer.idl │ ├── KeyChord.cpp │ ├── KeyChord.h │ ├── KeyChord.idl │ ├── Microsoft.Terminal.Control.def │ ├── Microsoft.Terminal.Control.vcxproj │ ├── Microsoft.Terminal.Control.vcxproj.filters │ ├── Resources │ │ └── en-US │ │ │ └── Resources.resw │ ├── SearchBoxControl.cpp │ ├── SearchBoxControl.h │ ├── SearchBoxControl.idl │ ├── SearchBoxControl.xaml │ ├── TSFInputControl.cpp │ ├── TSFInputControl.h │ ├── TSFInputControl.idl │ ├── TSFInputControl.xaml │ ├── TermControl.cpp │ ├── TermControl.h │ ├── TermControl.idl │ ├── TermControl.xaml │ ├── TermControlAutomationPeer.cpp │ ├── TermControlAutomationPeer.h │ ├── TermControlAutomationPeer.idl │ ├── Themes │ │ └── Generic.xaml │ ├── VersionInfo.rc │ ├── XamlLights.cpp │ ├── XamlLights.h │ ├── XamlLights.idl │ ├── XamlUiaTextRange.cpp │ ├── XamlUiaTextRange.h │ ├── init.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── readme.txt │ └── resource.h ├── Microsoft.Terminal.Settings.Model │ ├── ActionAndArgs.cpp │ ├── ActionAndArgs.h │ ├── ActionArgs.cpp │ ├── ActionArgs.h │ ├── ActionArgs.idl │ ├── ActionArgsMagic.h │ ├── ActionMap.cpp │ ├── ActionMap.h │ ├── ActionMap.idl │ ├── ActionMapSerialization.cpp │ ├── AllShortcutActions.h │ ├── AppearanceConfig.cpp │ ├── AppearanceConfig.h │ ├── AppearanceConfig.idl │ ├── ApplicationState.cpp │ ├── ApplicationState.h │ ├── ApplicationState.idl │ ├── AzureCloudShellGenerator.cpp │ ├── AzureCloudShellGenerator.h │ ├── CascadiaSettings.cpp │ ├── CascadiaSettings.h │ ├── CascadiaSettings.idl │ ├── CascadiaSettingsSerialization.cpp │ ├── ColorScheme.cpp │ ├── ColorScheme.h │ ├── ColorScheme.idl │ ├── Command.cpp │ ├── Command.h │ ├── Command.idl │ ├── DefaultTerminal.cpp │ ├── DefaultTerminal.h │ ├── DefaultTerminal.idl │ ├── DynamicProfileUtils.cpp │ ├── DynamicProfileUtils.h │ ├── EnumMappings.cpp │ ├── EnumMappings.h │ ├── EnumMappings.idl │ ├── FileUtils.cpp │ ├── FileUtils.h │ ├── FontConfig.cpp │ ├── FontConfig.h │ ├── FontConfig.idl │ ├── GlobalAppSettings.cpp │ ├── GlobalAppSettings.h │ ├── GlobalAppSettings.idl │ ├── HashUtils.h │ ├── IAppearanceConfig.idl │ ├── IDynamicProfileGenerator.h │ ├── IInheritable.h │ ├── IInheritable.idl.h │ ├── IconPathConverter.cpp │ ├── IconPathConverter.h │ ├── IconPathConverter.idl │ ├── JsonUtils.h │ ├── KeyChordSerialization.cpp │ ├── KeyChordSerialization.h │ ├── KeyChordSerialization.idl │ ├── LegacyProfileGeneratorNamespaces.h │ ├── MTSMSettings.h │ ├── Microsoft.Terminal.Settings.Model.vcxproj │ ├── Microsoft.Terminal.Settings.Model.vcxproj.filters │ ├── Microsoft_Terminal_Settings_Model.def │ ├── PowershellCoreProfileGenerator.cpp │ ├── PowershellCoreProfileGenerator.h │ ├── Profile.cpp │ ├── Profile.h │ ├── Profile.idl │ ├── Resources │ │ └── en-US │ │ │ └── Resources.resw │ ├── SettingsTypes.h │ ├── TerminalSettings.cpp │ ├── TerminalSettings.h │ ├── TerminalSettings.idl │ ├── TerminalSettingsSerializationHelpers.h │ ├── TerminalWarnings.h │ ├── TerminalWarnings.idl │ ├── VersionInfo.rc │ ├── VisualStudioGenerator.cpp │ ├── VisualStudioGenerator.h │ ├── VsDevCmdGenerator.cpp │ ├── VsDevCmdGenerator.h │ ├── VsDevShellGenerator.cpp │ ├── VsDevShellGenerator.h │ ├── VsSetupConfiguration.cpp │ ├── VsSetupConfiguration.h │ ├── WslDistroGenerator.cpp │ ├── WslDistroGenerator.h │ ├── defaults-universal.json │ ├── defaults.json │ ├── init.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── readme.txt │ ├── resource.h │ └── userDefaults.json ├── Microsoft.Terminal.TerminalConnection │ ├── AzureClient.h │ ├── AzureClientID.h │ ├── AzureConnection.cpp │ ├── AzureConnection.h │ ├── AzureConnection.idl │ ├── CTerminalHandoff.cpp │ ├── CTerminalHandoff.h │ ├── ConnectionInformation.cpp │ ├── ConnectionInformation.h │ ├── ConnectionInformation.idl │ ├── ConnectionStateHolder.h │ ├── ConptyConnection.cpp │ ├── ConptyConnection.h │ ├── ConptyConnection.idl │ ├── EchoConnection.cpp │ ├── EchoConnection.h │ ├── EchoConnection.idl │ ├── ITerminalConnection.idl │ ├── Microsoft.Terminal.TerminalConnection.def │ ├── Microsoft.Terminal.TerminalConnection.filters │ ├── Microsoft.Terminal.TerminalConnection.vcxproj │ ├── PassThroughConnection.cpp │ ├── PassThroughConnection.h │ ├── PassThroughConnection.idl │ ├── Resources │ │ └── en-US │ │ │ └── Resources.resw │ ├── VersionInfo.rc │ ├── init.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── readme.txt │ └── resource.h ├── TerminalCore │ ├── ControlKeyStates.hpp │ ├── ICoreAppearance.idl │ ├── ICoreSettings.idl │ ├── ITerminalInput.hpp │ ├── Terminal.cpp │ ├── Terminal.hpp │ ├── TerminalApi.cpp │ ├── TerminalCore.def │ ├── TerminalCore.vcxproj │ ├── TerminalCore.vcxproj.filters │ ├── TerminalSelection.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── readme.txt │ └── terminalrenderdata.cpp ├── WinRTUtils │ ├── LibraryResources.cpp │ ├── ScopedResourceLoader.cpp │ ├── Utils.cpp │ ├── WinRTUtils.vcxproj │ ├── WinRTUtils.vcxproj.filters │ ├── inc │ │ ├── LibraryResources.h │ │ ├── ScopedResourceLoader.h │ │ ├── ThrottledFunc.h │ │ ├── Utils.h │ │ └── WtExeUtils.h │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ └── readme.txt ├── inc │ └── ControlProperties.h ├── packages.config └── patches │ ├── ActionMap.h │ ├── ControlCore.cpp │ ├── DxRenderer.cpp │ ├── KeyChord.cpp │ ├── KeyChord.h │ ├── KeyChord.idl │ └── TerminalSettings.cpp ├── PatchOpenConsole.ps1 ├── README.md ├── SampleApp ├── README.md ├── SampleApp (Package) │ ├── Images │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ ├── Package.appxmanifest │ └── SampleApp (Package).wapproj └── SampleApp │ ├── App.xaml │ ├── App.xaml.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── SampleApp.csproj │ └── app.manifest ├── SampleAppUnpackaged ├── Program.cs ├── SampleAppUnpackaged.csproj └── app.manifest ├── Tools └── AnyCpuGenerator │ ├── AnyCpuGenerator.csproj │ └── Program.cs ├── UpdateOpenConsoleCppWinRT.ps1 └── WindowsTerminal.sln /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/terminal"] 2 | path = external/terminal 3 | url = https://github.com/microsoft/terminal.git 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Terminal Contributor's Guide 2 | 3 | Below is our guidance for how to report issues, propose new features, and submit contributions via Pull Requests (PRs). 4 | 5 | ## Issues with Windows Terminal 6 | 7 | Bugs, security issues, new features, etc that affect the Windows Terminal logic should be submitted to the official Windows Terminal team. Anything PR's 'that affect how Windows Terminal has been ported to WinUI3, or the ways in which it can be embedded, should be submitted here. -------------------------------------------------------------------------------- /Microsoft.Terminal.Control.Projection/ITextProviderMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using WinRT; 7 | 8 | namespace ABI.Microsoft.UI.Xaml.Automation.Provider 9 | { 10 | internal static class ITextProviderMethods 11 | { 12 | public static global::Microsoft.UI.Xaml.Automation.Provider.ITextRangeProvider[] GetSelection(IObjectReference obj) 13 | { 14 | var textProvider = obj.AsInterface(); 15 | 16 | if(textProvider != null) 17 | { 18 | return textProvider.GetSelection(); 19 | } 20 | 21 | throw new NotSupportedException(); 22 | } 23 | 24 | public static global::Microsoft.UI.Xaml.Automation.Provider.ITextRangeProvider[] GetVisibleRanges(IObjectReference obj) 25 | { 26 | var textProvider = obj.AsInterface(); 27 | 28 | if(textProvider != null) 29 | { 30 | return textProvider.GetVisibleRanges(); 31 | } 32 | 33 | throw new NotSupportedException(); 34 | } 35 | 36 | public static global::Microsoft.UI.Xaml.Automation.Provider.ITextRangeProvider RangeFromChild(IObjectReference obj, global::Microsoft.UI.Xaml.Automation.Provider.IRawElementProviderSimple childElement) 37 | { 38 | var textProvider = obj.AsInterface(); 39 | 40 | if(textProvider != null) 41 | { 42 | return textProvider.RangeFromChild(childElement); 43 | } 44 | 45 | throw new NotSupportedException(); 46 | } 47 | 48 | public static global::Microsoft.UI.Xaml.Automation.Provider.ITextRangeProvider RangeFromPoint(IObjectReference obj, global::Windows.Foundation.Point screenLocation) 49 | { 50 | var textProvider = obj.AsInterface(); 51 | 52 | if(textProvider != null) 53 | { 54 | return textProvider.RangeFromPoint(screenLocation); 55 | } 56 | 57 | throw new NotSupportedException(); 58 | } 59 | 60 | public static global::Microsoft.UI.Xaml.Automation.Provider.ITextRangeProvider get_DocumentRange(IObjectReference obj) 61 | { 62 | var textProvider = obj.AsInterface(); 63 | 64 | if(textProvider != null) 65 | { 66 | return textProvider.DocumentRange; 67 | } 68 | 69 | throw new NotSupportedException(); 70 | } 71 | 72 | public static global::Microsoft.UI.Xaml.Automation.SupportedTextSelection get_SupportedTextSelection(IObjectReference obj) 73 | { 74 | var textProvider = obj.AsInterface(); 75 | 76 | if(textProvider != null) 77 | { 78 | return textProvider.SupportedTextSelection; 79 | } 80 | 81 | throw new NotSupportedException(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Microsoft.Terminal.Control.Projection/IXamlMetadataProviderMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using WinRT; 8 | 9 | namespace ABI.Microsoft.UI.Xaml.Markup 10 | { 11 | internal static class IXamlMetadataProviderMethods 12 | { 13 | public static global::Microsoft.UI.Xaml.Markup.IXamlType GetXamlType(IObjectReference obj, global::System.Type type) 14 | { 15 | var xamlMetadatProvider = obj.AsInterface(); 16 | 17 | if(xamlMetadatProvider != null) 18 | { 19 | return xamlMetadatProvider.GetXamlType(type); 20 | } 21 | 22 | throw new NotSupportedException(); 23 | } 24 | 25 | public static global::Microsoft.UI.Xaml.Markup.IXamlType GetXamlType(IObjectReference obj, string fullName) 26 | { 27 | var xamlMetadatProvider = obj.AsInterface(); 28 | 29 | if(xamlMetadatProvider != null) 30 | { 31 | return xamlMetadatProvider.GetXamlType(fullName); 32 | } 33 | 34 | throw new NotSupportedException(); 35 | } 36 | 37 | public static global::Microsoft.UI.Xaml.Markup.XmlnsDefinition[] GetXmlnsDefinitions(IObjectReference obj) 38 | { 39 | var xamlMetadatProvider = obj.AsInterface(); 40 | 41 | if(xamlMetadatProvider != null) 42 | { 43 | return xamlMetadatProvider.GetXmlnsDefinitions(); 44 | } 45 | 46 | throw new NotSupportedException(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Microsoft.Terminal.Settings.Model.Projection/IValueConverterMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using WinRT; 7 | 8 | namespace ABI.Microsoft.UI.Xaml.Data 9 | { 10 | internal static class IValueConverterMethods 11 | { 12 | public static object Convert(IObjectReference obj, object value, global::System.Type targetType, object parameter, string language) 13 | { 14 | var converter = obj.AsInterface(); 15 | 16 | if(converter != null) 17 | { 18 | return converter.Convert(value, targetType, parameter, language); 19 | } 20 | 21 | throw new NotSupportedException(); 22 | } 23 | 24 | public static object ConvertBack(IObjectReference obj, object value, global::System.Type targetType, object parameter, string language) 25 | { 26 | var converter = obj.AsInterface(); 27 | 28 | if(converter != null) 29 | { 30 | return converter.Convert(value, targetType, parameter, language); 31 | } 32 | 33 | throw new NotSupportedException(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Microsoft.Terminal.TerminalConnection.Projection/Microsoft.Terminal.TerminalConnection.Projection.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0-windows10.0.19041.0 5 | enable 6 | enable 7 | AnyCPU;x64;x86;ARM64 8 | 10.0.18362.0 9 | 1.11.3471 10 | https://github.com/Corillian/WindowsTerminal 11 | https://github.com/Corillian/WindowsTerminal 12 | A WinUI3 abstraction for Windows Terminal connections. The root namespace is Microsoft.Terminal.TerminalConnection. 13 | Keith Newton 14 | WindowsTerminal.WinUI3.TerminalConnection 15 | Windows;Terminal;WinUI 16 | 17 | 18 | 19 | $([MSBuild]::NormalizeDirectory('$(SolutionDir)', '_build', '$(Platform)', '$(Configuration)')) 20 | $([MSBuild]::NormalizeDirectory('$(BuildOutDir)', '$(MSBuildProjectName)', 'bin')) 21 | $([MSBuild]::NormalizeDirectory('$(BuildOutDir)', '$(MSBuildProjectName)', 'obj')) 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | high 34 | sdk 35 | Microsoft.Terminal.TerminalConnection 36 | $(OutDir) 37 | 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /NuGet/build/net6.0-windows10.0.18362.0/WindowsTerminal.WinUI3.Control.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | PreserveNewest 6 | false 7 | 8 | 12 | 13 | PreserveNewest 14 | false 15 | true 16 | 17 | 18 | PreserveNewest 19 | false 20 | 21 | 22 | PreserveNewest 23 | false 24 | true 25 | 26 | 27 | PreserveNewest 28 | false 29 | 30 | 31 | 32 | 38 | 39 | 40 | 46 | -------------------------------------------------------------------------------- /NuGet/build/net6.0-windows10.0.18362.0/WindowsTerminal.WinUI3.Settings.Model.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | PreserveNewest 6 | false 7 | 8 | 12 | 13 | PreserveNewest 14 | false 15 | 16 | 17 | 18 | 19 | 25 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/ControlAppearance.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | --*/ 5 | #pragma once 6 | #include 7 | #include "../inc/ControlProperties.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace winrt::Microsoft::Terminal::Control::implementation 13 | { 14 | struct ControlAppearance : public winrt::implements 15 | { 16 | #define SETTINGS_GEN(type, name, ...) WINRT_PROPERTY(type, name, __VA_ARGS__); 17 | CORE_APPEARANCE_SETTINGS(SETTINGS_GEN) 18 | CONTROL_APPEARANCE_SETTINGS(SETTINGS_GEN) 19 | #undef SETTINGS_GEN 20 | 21 | private: 22 | // Color Table is special because it's an array 23 | std::array _ColorTable; 24 | 25 | public: 26 | winrt::Microsoft::Terminal::Core::Color GetColorTableEntry(int32_t index) noexcept 27 | { 28 | return _ColorTable.at(index); 29 | } 30 | void SetColorTableEntry(int32_t index, 31 | winrt::Microsoft::Terminal::Core::Color color) noexcept 32 | { 33 | _ColorTable.at(index) = color; 34 | } 35 | 36 | ControlAppearance(Control::IControlAppearance appearance) 37 | { 38 | #define COPY_SETTING(type, name, ...) _##name = appearance.name(); 39 | CORE_APPEARANCE_SETTINGS(COPY_SETTING) 40 | CONTROL_APPEARANCE_SETTINGS(COPY_SETTING) 41 | #undef COPY_SETTING 42 | 43 | for (size_t i = 0; i < _ColorTable.size(); i++) 44 | { 45 | _ColorTable[i] = appearance.GetColorTableEntry(static_cast(i)); 46 | } 47 | } 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/ControlInteractivity.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "ICoreState.idl"; 5 | import "IControlSettings.idl"; 6 | import "ControlCore.idl"; 7 | import "EventArgs.idl"; 8 | import "InteractivityAutomationPeer.idl"; 9 | 10 | 11 | namespace Microsoft.Terminal.Control 12 | { 13 | 14 | [default_interface] runtimeclass ControlInteractivity 15 | { 16 | ControlInteractivity(IControlSettings settings, 17 | IControlAppearance unfocusedAppearance, 18 | Microsoft.Terminal.TerminalConnection.ITerminalConnection connection); 19 | 20 | ControlCore Core { get; }; 21 | void UpdateSettings(); 22 | void Initialize(); 23 | void GotFocus(); 24 | void LostFocus(); 25 | 26 | InteractivityAutomationPeer OnCreateAutomationPeer(); 27 | 28 | Boolean CopySelectionToClipboard(Boolean singleLine, Windows.Foundation.IReference formats); 29 | void RequestPasteTextFromClipboard(); 30 | void SetEndSelectionPoint(Microsoft.Terminal.Core.Point point); 31 | 32 | void PointerPressed(MouseButtonState buttonState, 33 | UInt32 pointerUpdateKind, 34 | UInt64 timestamp, 35 | Microsoft.Terminal.Core.ControlKeyStates modifiers, 36 | Microsoft.Terminal.Core.Point pixelPosition); 37 | void TouchPressed(Microsoft.Terminal.Core.Point contactPoint); 38 | 39 | void PointerMoved(MouseButtonState buttonState, 40 | UInt32 pointerUpdateKind, 41 | Microsoft.Terminal.Core.ControlKeyStates modifiers, 42 | Boolean focused, 43 | Microsoft.Terminal.Core.Point pixelPosition, 44 | Boolean pointerPressedInBounds); 45 | 46 | void TouchMoved(Microsoft.Terminal.Core.Point newTouchPoint, 47 | Boolean focused); 48 | 49 | void PointerReleased(MouseButtonState buttonState, 50 | UInt32 pointerUpdateKind, 51 | Microsoft.Terminal.Core.ControlKeyStates modifiers, 52 | Microsoft.Terminal.Core.Point pixelPosition); 53 | void TouchReleased(); 54 | 55 | Boolean MouseWheel(Microsoft.Terminal.Core.ControlKeyStates modifiers, 56 | Int32 delta, 57 | Microsoft.Terminal.Core.Point pixelPosition, 58 | MouseButtonState state); 59 | 60 | void UpdateScrollbar(Double newValue); 61 | 62 | Boolean ManglePathsForWsl { get; }; 63 | 64 | event Windows.Foundation.TypedEventHandler OpenHyperlink; 65 | event Windows.Foundation.TypedEventHandler ScrollPositionChanged; 66 | event Windows.Foundation.TypedEventHandler PasteFromClipboard; 67 | 68 | 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/EventArgs.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "EventArgs.h" 6 | #include "TitleChangedEventArgs.g.cpp" 7 | #include "CopyToClipboardEventArgs.g.cpp" 8 | #include "PasteFromClipboardEventArgs.g.cpp" 9 | #include "OpenHyperlinkEventArgs.g.cpp" 10 | #include "NoticeEventArgs.g.cpp" 11 | #include "ScrollPositionChangedArgs.g.cpp" 12 | #include "RendererWarningArgs.g.cpp" 13 | #include "TransparencyChangedEventArgs.g.cpp" 14 | #include "FoundResultsArgs.g.cpp" 15 | #include "ShowWindowArgs.g.cpp" 16 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/EventArgs.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | delegate void FontSizeChangedEventArgs(Int32 width, Int32 height, Boolean isInitialChange); 7 | delegate void ScrollPositionChangedEventArgs(Int32 viewTop, Int32 viewHeight, Int32 bufferLength); 8 | 9 | [flags] 10 | enum CopyFormat 11 | { 12 | HTML = 0x1, 13 | RTF = 0x2, 14 | All = 0xffffffff 15 | }; 16 | 17 | runtimeclass CopyToClipboardEventArgs 18 | { 19 | String Text { get; }; 20 | String Html { get; }; 21 | String Rtf { get; }; 22 | Windows.Foundation.IReference Formats { get; }; 23 | } 24 | 25 | runtimeclass TitleChangedEventArgs 26 | { 27 | String Title; 28 | } 29 | 30 | runtimeclass PasteFromClipboardEventArgs 31 | { 32 | void HandleClipboardData(String data); 33 | Boolean BracketedPasteEnabled { get; }; 34 | } 35 | 36 | runtimeclass OpenHyperlinkEventArgs 37 | { 38 | String Uri { get; }; 39 | } 40 | 41 | enum NoticeLevel 42 | { 43 | Debug = 10, 44 | Info = 20, 45 | Warning = 30, 46 | Error = 40, 47 | }; 48 | 49 | runtimeclass NoticeEventArgs 50 | { 51 | NoticeLevel Level { get; }; 52 | String Message { get; }; 53 | } 54 | 55 | runtimeclass ScrollPositionChangedArgs 56 | { 57 | Int32 ViewTop { get; }; 58 | Int32 ViewHeight { get; }; 59 | Int32 BufferSize { get; }; 60 | } 61 | 62 | runtimeclass RendererWarningArgs 63 | { 64 | UInt64 Result { get; }; 65 | } 66 | 67 | runtimeclass TransparencyChangedEventArgs 68 | { 69 | Double Opacity { get; }; 70 | } 71 | 72 | 73 | runtimeclass FoundResultsArgs 74 | { 75 | Boolean FoundMatch { get; }; 76 | } 77 | 78 | runtimeclass ShowWindowArgs 79 | { 80 | Boolean ShowOrHide { get; }; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/IControlAppearance.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | interface IControlAppearance requires Microsoft.Terminal.Core.ICoreAppearance 7 | { 8 | Microsoft.Terminal.Core.Color SelectionBackground { get; }; 9 | String BackgroundImage { get; }; 10 | Double BackgroundImageOpacity { get; }; 11 | Microsoft.UI.Xaml.Media.Stretch BackgroundImageStretchMode { get; }; 12 | Microsoft.UI.Xaml.HorizontalAlignment BackgroundImageHorizontalAlignment { get; }; 13 | Microsoft.UI.Xaml.VerticalAlignment BackgroundImageVerticalAlignment { get; }; 14 | // IntenseIsBold and IntenseIsBright are in Core Appearance 15 | Double Opacity { get; }; 16 | 17 | // Experimental settings 18 | Boolean RetroTerminalEffect { get; }; 19 | String PixelShaderPath { get; }; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/IControlSettings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "IKeyBindings.idl"; 5 | import "IControlAppearance.idl"; 6 | 7 | namespace Microsoft.Terminal.Control 8 | { 9 | enum ScrollbarState 10 | { 11 | Visible = 0, 12 | Hidden 13 | }; 14 | 15 | enum TextAntialiasingMode 16 | { 17 | Grayscale = 0, 18 | Cleartype, 19 | Aliased 20 | }; 21 | 22 | // Class Description: 23 | // TerminalSettings encapsulates all settings that control the 24 | // TermControl's behavior. In these settings there is both the entirety 25 | // of the Core ITerminalSettings interface, and any additional settings 26 | // for specifically the control. 27 | interface IControlSettings requires Microsoft.Terminal.Core.ICoreSettings, Microsoft.Terminal.Control.IControlAppearance 28 | { 29 | String ProfileName; 30 | String ProfileSource; 31 | 32 | Boolean UseAcrylic { get; }; 33 | ScrollbarState ScrollState { get; }; 34 | 35 | Boolean UseAtlasEngine { get; }; 36 | 37 | String FontFace { get; }; 38 | Int32 FontSize { get; }; 39 | Windows.UI.Text.FontWeight FontWeight { get; }; 40 | String Padding { get; }; 41 | Windows.Foundation.Collections.IMap FontFeatures { get; }; 42 | Windows.Foundation.Collections.IMap FontAxes { get; }; 43 | 44 | Microsoft.Terminal.Control.IKeyBindings KeyBindings { get; }; 45 | 46 | Boolean CopyOnSelect { get; }; 47 | Boolean FocusFollowMouse { get; }; 48 | 49 | String Commandline { get; }; 50 | String StartingDirectory { get; }; 51 | String EnvironmentVariables { get; }; 52 | 53 | TextAntialiasingMode AntialiasingMode { get; }; 54 | 55 | // Experimental Settings 56 | Boolean ForceFullRepaintRendering { get; }; 57 | Boolean SoftwareRendering { get; }; 58 | Boolean UseBackgroundImageForWindow { get; }; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/ICoreState.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | // These are properties of the TerminalCore that should be queryable by the 7 | // rest of the app. 8 | interface ICoreState 9 | { 10 | String Title { get; }; 11 | UInt64 TaskbarState { get; }; 12 | UInt64 TaskbarProgress { get; }; 13 | 14 | String WorkingDirectory { get; }; 15 | 16 | Windows.Foundation.IReference TabColor { get; }; 17 | 18 | Int32 ScrollOffset { get; }; 19 | Int32 ViewHeight { get; }; 20 | Int32 BufferHeight { get; }; 21 | 22 | Boolean BracketedPasteEnabled { get; }; 23 | 24 | Microsoft.Terminal.TerminalConnection.ConnectionState ConnectionState { get; }; 25 | 26 | Microsoft.Terminal.Core.Scheme ColorScheme { get; set; }; 27 | 28 | UInt64 OwningHwnd; 29 | 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/IDirectKeyListener.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | // C++/winrt makes it difficult to share this idl between two projects, 7 | // Instead, we just pin the uuid and include it in both TermControl and App 8 | // If you update this one, please update TerminalApp\IDirectKeyListener.idl. 9 | // If you change this interface, please update the guid. 10 | // If you press F7 or Alt and get a runtime error, go make sure both copies are the same. 11 | [uuid("0ddf4edc-3fda-4dee-97ca-a417ee3dd510")] interface IDirectKeyListener { 12 | Boolean OnDirectKeyEvent(UInt32 vkey, UInt8 scanCode, Boolean down); 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/IKeyBindings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "KeyChord.idl"; 5 | 6 | namespace Microsoft.Terminal.Control 7 | { 8 | // [default_interface] 9 | interface IKeyBindings 10 | { 11 | Boolean TryKeyChord(KeyChord kc); 12 | Boolean IsKeyChordExplicitlyUnbound(KeyChord kc); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/IMouseWheelListener.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | 7 | // This interface is a hack for GH#979. Controls should implement this 8 | // interface to be able to be notified of mousewheel events even on devices 9 | // who's trackpads won't scroll inactive windows. 10 | 11 | [uuid("65b8b8c5-988f-43ff-aba9-e89368da1598")] 12 | interface IMouseWheelListener 13 | { 14 | Boolean OnMouseWheel(Windows.Foundation.Point coord, Int32 delta, Boolean leftButtonDown, Boolean midButtonDown, Boolean rightButtonDown); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/InteractivityAutomationPeer.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | namespace Microsoft.Terminal.Control 4 | { 5 | [default_interface] runtimeclass InteractivityAutomationPeer : 6 | Microsoft.UI.Xaml.Automation.Peers.AutomationPeer, 7 | Microsoft.UI.Xaml.Automation.Provider.ITextProvider 8 | { 9 | 10 | void SetControlBounds(Windows.Foundation.Rect bounds); 11 | void SetControlPadding(Microsoft.Terminal.Core.Padding padding); 12 | void ParentProvider(Microsoft.UI.Xaml.Automation.Peers.AutomationPeer parentProvider); 13 | 14 | event Windows.Foundation.TypedEventHandler SelectionChanged; 15 | event Windows.Foundation.TypedEventHandler TextChanged; 16 | event Windows.Foundation.TypedEventHandler CursorChanged; 17 | event Windows.Foundation.TypedEventHandler NewOutput; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/KeyChord.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "KeyChord.g.h" 7 | 8 | namespace winrt::Microsoft::Terminal::Control::implementation 9 | { 10 | struct KeyChord : KeyChordT 11 | { 12 | KeyChord() noexcept = default; 13 | KeyChord(const VkModifiers modifiers, int32_t vkey, int32_t scanCode) noexcept; 14 | KeyChord(bool ctrl, bool alt, bool shift, bool win, int32_t vkey, int32_t scanCode) noexcept; 15 | 16 | uint64_t Hash() const noexcept; 17 | bool DeepEquals(const Control::KeyChord& other) const noexcept; 18 | 19 | VkModifiers Modifiers() const noexcept; 20 | void Modifiers(const VkModifiers value) noexcept; 21 | int32_t Vkey() const noexcept; 22 | void Vkey(int32_t value) noexcept; 23 | int32_t ScanCode() const noexcept; 24 | void ScanCode(int32_t value) noexcept; 25 | 26 | private: 27 | VkModifiers _modifiers{}; 28 | int32_t _vkey{}; 29 | int32_t _scanCode{}; 30 | }; 31 | } 32 | 33 | namespace winrt::Microsoft::Terminal::Control::factory_implementation 34 | { 35 | struct KeyChord : KeyChordT 36 | { 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/KeyChord.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | [flags] 7 | enum VkModifiers 8 | { 9 | None = 0, 10 | Control = 1, 11 | Menu = 2, 12 | Shift = 4, 13 | Windows = 8, 14 | }; 15 | 16 | [default_interface] 17 | runtimeclass KeyChord 18 | { 19 | KeyChord(); 20 | KeyChord(VkModifiers modifiers, Int32 vkey, Int32 scanCode); 21 | KeyChord(Boolean ctrl, Boolean alt, Boolean shift, Boolean win, Int32 vkey, Int32 scanCode); 22 | 23 | UInt64 Hash(); 24 | 25 | // Due to a bug in CsWinRT (https://github.com/microsoft/CsWinRT/issues/864) this is modified 26 | Boolean DeepEquals(KeyChord other); 27 | 28 | VkModifiers Modifiers; 29 | Int32 Vkey; 30 | Int32 ScanCode; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/Microsoft.Terminal.Control.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/Microsoft.Terminal.Control.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | {1a066865-7e48-4173-a971-ed7d0b8c46a9} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | Resources 73 | 74 | 75 | 76 | 77 | Resources\en-US 78 | 79 | 80 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/SearchBoxControl.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - SearchBoxControl.cpp 7 | 8 | Abstract: 9 | - the search dialog component used in Terminal Search 10 | 11 | Author(s): 12 | - Kaiyu Wang (kawa) 11-27-2019 13 | 14 | --*/ 15 | 16 | #pragma once 17 | 18 | #include "winrt/Microsoft.UI.Xaml.h" 19 | #include "winrt/Microsoft.UI.Xaml.Markup.h" 20 | #include "winrt/Microsoft.UI.Xaml.Controls.Primitives.h" 21 | #include "winrt/Microsoft.UI.Xaml.Controls.h" 22 | #include "winrt/Microsoft.UI.Xaml.Input.h" 23 | #include "SearchBoxControl.g.h" 24 | #include 25 | 26 | namespace winrt::Microsoft::Terminal::Control::implementation 27 | { 28 | struct SearchBoxControl : SearchBoxControlT 29 | { 30 | SearchBoxControl(); 31 | 32 | void TextBoxKeyDown(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::Microsoft::UI::Xaml::Input::KeyRoutedEventArgs& e); 33 | 34 | void SetFocusOnTextbox(); 35 | void PopulateTextbox(const winrt::hstring& text); 36 | bool ContainsFocus(); 37 | 38 | void GoBackwardClicked(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::Microsoft::UI::Xaml::RoutedEventArgs& /*e*/); 39 | void GoForwardClicked(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::Microsoft::UI::Xaml::RoutedEventArgs& /*e*/); 40 | void CloseClick(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::Microsoft::UI::Xaml::RoutedEventArgs& e); 41 | 42 | WINRT_CALLBACK(Search, SearchHandler); 43 | TYPED_EVENT(Closed, Control::SearchBoxControl, Microsoft::UI::Xaml::RoutedEventArgs); 44 | 45 | private: 46 | std::unordered_set _focusableElements; 47 | 48 | bool _GoForward(); 49 | bool _CaseSensitive(); 50 | void _KeyDownHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Microsoft::UI::Xaml::Input::KeyRoutedEventArgs& e); 51 | void _CharacterHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/, const winrt::Microsoft::UI::Xaml::Input::CharacterReceivedRoutedEventArgs& e); 52 | }; 53 | } 54 | 55 | namespace winrt::Microsoft::Terminal::Control::factory_implementation 56 | { 57 | BASIC_FACTORY(SearchBoxControl); 58 | } 59 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/SearchBoxControl.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | delegate void SearchHandler(String query, Boolean goForward, Boolean isCaseSensitive); 7 | 8 | [default_interface] 9 | runtimeclass SearchBoxControl : Microsoft.UI.Xaml.Controls.UserControl 10 | { 11 | SearchBoxControl(); 12 | void SetFocusOnTextbox(); 13 | void PopulateTextbox(String text); 14 | Boolean ContainsFocus(); 15 | 16 | event SearchHandler Search; 17 | event Windows.Foundation.TypedEventHandler Closed; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/TSFInputControl.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | delegate void CompositionCompletedEventArgs(String text); 7 | 8 | runtimeclass CursorPositionEventArgs 9 | { 10 | Windows.Foundation.Point CurrentPosition { get; set; }; 11 | } 12 | 13 | runtimeclass FontInfoEventArgs 14 | { 15 | String FontFace { get; set; }; 16 | Windows.Foundation.Size FontSize { get; set; }; 17 | Windows.UI.Text.FontWeight FontWeight { get; set; }; 18 | } 19 | 20 | [default_interface] 21 | runtimeclass TSFInputControl : Microsoft.UI.Xaml.Controls.UserControl 22 | { 23 | TSFInputControl(); 24 | 25 | event CompositionCompletedEventArgs CompositionCompleted; 26 | event Windows.Foundation.TypedEventHandler CurrentCursorPosition; 27 | event Windows.Foundation.TypedEventHandler CurrentFontInfo; 28 | 29 | void NotifyFocusEnter(); 30 | void NotifyFocusLeave(); 31 | void ClearBuffer(); 32 | void TryRedrawCanvas(); 33 | 34 | void Close(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/TSFInputControl.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/TermControlAutomationPeer.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "TermControl.idl"; 5 | 6 | namespace Microsoft.Terminal.Control 7 | { 8 | [default_interface] runtimeclass TermControlAutomationPeer : 9 | Microsoft.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer, 10 | Microsoft.UI.Xaml.Automation.Provider.ITextProvider 11 | { 12 | 13 | void UpdateControlBounds(); 14 | void SetControlPadding(Microsoft.Terminal.Core.Padding padding); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/VersionInfo.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Version 51 | // 52 | 53 | VS_VERSION_INFO VERSIONINFO 54 | FILEVERSION 1,11,3471,0 55 | PRODUCTVERSION 1,11,3471,0 56 | FILEFLAGSMASK 0x3fL 57 | #ifdef _DEBUG 58 | FILEFLAGS 0x1L 59 | #else 60 | FILEFLAGS 0x0L 61 | #endif 62 | FILEOS 0x40004L 63 | FILETYPE 0x2L 64 | FILESUBTYPE 0x0L 65 | BEGIN 66 | BLOCK "StringFileInfo" 67 | BEGIN 68 | BLOCK "040904b0" 69 | BEGIN 70 | VALUE "FileDescription", "Windows Terminal" 71 | VALUE "FileVersion", "1.11.3471.0" 72 | VALUE "InternalName", "Microsoft.Terminal.Control" 73 | VALUE "LegalCopyright", "Copyright (C) 2022" 74 | VALUE "OriginalFilename", "Microsoft.Terminal.Control" 75 | VALUE "ProductName", "Windows Terminal" 76 | VALUE "ProductVersion", "1.11.3471.0" 77 | END 78 | END 79 | BLOCK "VarFileInfo" 80 | BEGIN 81 | VALUE "Translation", 0x409, 1200 82 | END 83 | END 84 | 85 | #endif // English (United States) resources 86 | ///////////////////////////////////////////////////////////////////////////// 87 | 88 | 89 | 90 | #ifndef APSTUDIO_INVOKED 91 | ///////////////////////////////////////////////////////////////////////////// 92 | // 93 | // Generated from the TEXTINCLUDE 3 resource. 94 | // 95 | 96 | 97 | ///////////////////////////////////////////////////////////////////////////// 98 | #endif // not APSTUDIO_INVOKED 99 | 100 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/XamlLights.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "cppwinrt_utils.h" 7 | #include "VisualBellLight.g.h" 8 | 9 | namespace winrt::Microsoft::Terminal::Control::implementation 10 | { 11 | struct VisualBellLight : VisualBellLightT 12 | { 13 | VisualBellLight(); 14 | 15 | winrt::hstring GetId(); 16 | 17 | static Microsoft::UI::Xaml::DependencyProperty IsTargetProperty() { return _IsTargetProperty; } 18 | 19 | static bool GetIsTarget(const Microsoft::UI::Xaml::DependencyObject& target) 20 | { 21 | return winrt::unbox_value(target.GetValue(_IsTargetProperty)); 22 | } 23 | 24 | static void SetIsTarget(const Microsoft::UI::Xaml::DependencyObject& target, bool value) 25 | { 26 | target.SetValue(_IsTargetProperty, winrt::box_value(value)); 27 | } 28 | 29 | void OnConnected(const Microsoft::UI::Xaml::UIElement& newElement); 30 | void OnDisconnected(const Microsoft::UI::Xaml::UIElement& oldElement); 31 | 32 | static void OnIsTargetChanged(const Microsoft::UI::Xaml::DependencyObject& d, Microsoft::UI::Xaml::DependencyPropertyChangedEventArgs const& e); 33 | 34 | inline static winrt::hstring GetIdStatic() 35 | { 36 | // This specifies the unique name of the light. In most cases you should use the type's full name. 37 | return winrt::xaml_typename().Name; 38 | } 39 | 40 | private: 41 | static void _InitializeProperties(); 42 | static Microsoft::UI::Xaml::DependencyProperty _IsTargetProperty; 43 | }; 44 | } 45 | 46 | namespace winrt::Microsoft::Terminal::Control::factory_implementation 47 | { 48 | BASIC_FACTORY(VisualBellLight); 49 | } 50 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/XamlLights.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | [default_interface] runtimeclass VisualBellLight : Microsoft.UI.Xaml.Media.XamlLight 7 | { 8 | VisualBellLight(); 9 | static Microsoft.UI.Xaml.DependencyProperty IsTargetProperty { get; }; 10 | static Boolean GetIsTarget(Microsoft.UI.Xaml.DependencyObject target); 11 | static void SetIsTarget(Microsoft.UI.Xaml.DependencyObject target, Boolean value); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/init.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | 4 | 5 | BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/) 6 | { 7 | switch (reason) 8 | { 9 | case DLL_PROCESS_ATTACH: 10 | DisableThreadLibraryCalls(hInstDll); 11 | break; 12 | case DLL_PROCESS_DETACH: 13 | break; 14 | } 15 | 16 | return TRUE; 17 | } 18 | 19 | UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(L"Microsoft.Terminal.Control/Resources"); 20 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #define NOMCX 5 | #define NOHELP 6 | #define NOCOMM 7 | 8 | // Manually include til after we include Windows.Foundation to give it winrt superpowers 9 | #define BLOCK_TIL 10 | #include 11 | 12 | // This is inexplicable, but for whatever reason, cppwinrt conflicts with the 13 | // SDK definition of this function, so the only fix is to undef it. 14 | // from WinBase.h 15 | // Windows::UI::Xaml::Media::Animation::IStoryboard::GetCurrentTime 16 | #ifdef GetCurrentTime 17 | #undef GetCurrentTime 18 | #endif 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | #include 41 | 42 | #include "../inc/ThrottledFunc.h" 43 | 44 | inline winrt::Windows::UI::Color toWinUIColor(const til::color clr) noexcept 45 | { 46 | return { clr.a, clr.r, clr.g, clr.b }; 47 | } 48 | 49 | //inline winrt::Microsoft::Terminal::Core::Point toTerminalPoint(const til::point& pt) noexcept 50 | //{ 51 | // return { static_cast(pt.x()), static_cast(pt.y()) }; 52 | //} -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | Microsoft.Terminal.Control Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the Windows App SDK and 7 | C++/WinRT packages to generate implementation headers from interface 8 | (IDL) files. The generated Windows Runtime component binary and WinMD 9 | files should then be bundled with the app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about Windows App SDK here: 22 | https://docs.microsoft.com/windows/apps/windows-app-sdk/ 23 | Learn more about WinUI3 here: 24 | https://docs.microsoft.com/windows/apps/winui/winui3/ 25 | Learn more about C++/WinRT here: 26 | http://aka.ms/cppwinrt/ 27 | ======================================================================== 28 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Control/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by VersionInfo.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/ActionAndArgs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "ActionAndArgs.g.h" 7 | #include "ActionArgs.h" 8 | #include "TerminalWarnings.h" 9 | 10 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 11 | { 12 | struct ActionAndArgs : public ActionAndArgsT 13 | { 14 | static const std::map> ActionKeyNamesMap; 15 | static winrt::com_ptr FromJson(const Json::Value& json, 16 | std::vector& warnings); 17 | static Json::Value ToJson(const Model::ActionAndArgs& val); 18 | 19 | ActionAndArgs() = default; 20 | ActionAndArgs(ShortcutAction action); 21 | ActionAndArgs(ShortcutAction action, IActionArgs args) : 22 | _Action{ action }, 23 | _Args{ args } {}; 24 | com_ptr Copy() const; 25 | 26 | hstring GenerateName() const; 27 | 28 | WINRT_PROPERTY(ShortcutAction, Action, ShortcutAction::Invalid); 29 | WINRT_PROPERTY(IActionArgs, Args, nullptr); 30 | }; 31 | } 32 | 33 | namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation 34 | { 35 | BASIC_FACTORY(ActionAndArgs); 36 | } 37 | 38 | namespace Microsoft::Terminal::Settings::Model::JsonUtils 39 | { 40 | using namespace winrt::Microsoft::Terminal::Settings::Model; 41 | 42 | template<> 43 | struct ConversionTrait 44 | { 45 | ActionAndArgs FromJson(const Json::Value& json) 46 | { 47 | std::vector v; 48 | return *implementation::ActionAndArgs::FromJson(json, v); 49 | } 50 | 51 | bool CanConvert(const Json::Value& json) const 52 | { 53 | // commands without args might just be a string 54 | return json.isString() || json.isObject(); 55 | } 56 | 57 | Json::Value ToJson(const ActionAndArgs& val) 58 | { 59 | return implementation::ActionAndArgs::ToJson(val); 60 | } 61 | 62 | std::string TypeDescription() const 63 | { 64 | return "ActionAndArgs"; 65 | } 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/ActionMap.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "Command.idl"; 5 | 6 | namespace Microsoft.Terminal.Settings.Model 7 | { 8 | // This interface ensures that no changes are made to ActionMap 9 | interface IActionMapView 10 | { 11 | Boolean IsKeyChordExplicitlyUnbound(Microsoft.Terminal.Control.KeyChord keys); 12 | 13 | Command GetActionByKeyChord(Microsoft.Terminal.Control.KeyChord keys); 14 | 15 | Microsoft.Terminal.Control.KeyChord GetKeyBindingForAction(ShortcutAction action); 16 | [method_name("GetKeyBindingForActionWithArgs")] Microsoft.Terminal.Control.KeyChord GetKeyBindingForAction(ShortcutAction action, IActionArgs actionArgs); 17 | 18 | Windows.Foundation.Collections.IMapView AvailableActions { get; }; 19 | 20 | Windows.Foundation.Collections.IMapView NameMap { get; }; 21 | Windows.Foundation.Collections.IMapView KeyBindings { get; }; 22 | Windows.Foundation.Collections.IMapView GlobalHotkeys { get; }; 23 | }; 24 | 25 | [default_interface] runtimeclass ActionMap : IActionMapView 26 | { 27 | void RebindKeys(Microsoft.Terminal.Control.KeyChord oldKeys, Microsoft.Terminal.Control.KeyChord newKeys); 28 | void DeleteKeyBinding(Microsoft.Terminal.Control.KeyChord keys); 29 | 30 | void RegisterKeyBinding(Microsoft.Terminal.Control.KeyChord keys, ActionAndArgs action); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/AppearanceConfig.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - AppearanceConfig 7 | 8 | Abstract: 9 | - The implementation of the AppearanceConfig winrt class. Provides settings related 10 | to the appearance of the terminal, in both terminal control and terminal core. 11 | 12 | Author(s): 13 | - Pankaj Bhojwani - Nov 2020 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #include "AppearanceConfig.g.h" 20 | #include "JsonUtils.h" 21 | #include "IInheritable.h" 22 | #include "MTSMSettings.h" 23 | #include 24 | 25 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 26 | { 27 | struct AppearanceConfig : AppearanceConfigT, IInheritable 28 | { 29 | public: 30 | AppearanceConfig(winrt::weak_ref sourceProfile); 31 | static winrt::com_ptr CopyAppearance(const AppearanceConfig* source, winrt::weak_ref sourceProfile); 32 | Json::Value ToJson() const; 33 | void LayerJson(const Json::Value& json); 34 | 35 | Model::Profile SourceProfile(); 36 | 37 | winrt::hstring ExpandedBackgroundImagePath(); 38 | 39 | INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Foreground, nullptr); 40 | INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, Background, nullptr); 41 | INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, SelectionBackground, nullptr); 42 | INHERITABLE_NULLABLE_SETTING(Model::IAppearanceConfig, Microsoft::Terminal::Core::Color, CursorColor, nullptr); 43 | INHERITABLE_SETTING(Model::IAppearanceConfig, double, Opacity, 1.0); 44 | 45 | #define APPEARANCE_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ 46 | INHERITABLE_SETTING(Model::IAppearanceConfig, type, name, ##__VA_ARGS__) 47 | MTSM_APPEARANCE_SETTINGS(APPEARANCE_SETTINGS_INITIALIZE) 48 | #undef APPEARANCE_SETTINGS_INITIALIZE 49 | 50 | private: 51 | winrt::weak_ref _sourceProfile; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/AppearanceConfig.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "IAppearanceConfig.idl"; 5 | 6 | namespace Microsoft.Terminal.Settings.Model 7 | { 8 | [default_interface] runtimeclass AppearanceConfig : IAppearanceConfig { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/ApplicationState.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | import "Command.idl"; 4 | import "GlobalAppSettings.idl"; 5 | 6 | namespace Microsoft.Terminal.Settings.Model 7 | { 8 | enum InfoBarMessage 9 | { 10 | CloseOnExitInfo = 0, 11 | KeyboardServiceWarning, 12 | SetAsDefault, 13 | }; 14 | 15 | runtimeclass WindowLayout 16 | { 17 | WindowLayout(); 18 | 19 | static String ToJson(WindowLayout layout); 20 | static WindowLayout FromJson(String json); 21 | 22 | Windows.Foundation.Collections.IVector TabLayout; 23 | Windows.Foundation.IReference InitialPosition; 24 | Windows.Foundation.IReference InitialSize; 25 | Windows.Foundation.IReference LaunchMode; 26 | }; 27 | 28 | [default_interface] runtimeclass ApplicationState { 29 | static ApplicationState SharedInstance(); 30 | 31 | void Reload(); 32 | void Reset(); 33 | 34 | Boolean IsStatePath(String filename); 35 | 36 | Windows.Foundation.Collections.IVector PersistedWindowLayouts { get; set; }; 37 | 38 | Windows.Foundation.Collections.IVector RecentCommands { get; set; }; 39 | 40 | Windows.Foundation.Collections.IVector DismissedMessages { get; set; }; 41 | 42 | Windows.Foundation.Collections.IVector AllowedCommandlines { get; set; }; 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/AzureCloudShellGenerator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | 6 | #include "AzureCloudShellGenerator.h" 7 | #include "LegacyProfileGeneratorNamespaces.h" 8 | 9 | #include "../../types/inc/utils.hpp" 10 | #include "../../inc/DefaultSettings.h" 11 | #include "DynamicProfileUtils.h" 12 | 13 | using namespace ::Microsoft::Terminal::Settings::Model; 14 | using namespace winrt::Microsoft::Terminal::Settings::Model; 15 | using namespace winrt::Microsoft::Terminal::TerminalConnection; 16 | 17 | std::wstring_view AzureCloudShellGenerator::GetNamespace() const noexcept 18 | { 19 | return AzureGeneratorNamespace; 20 | } 21 | 22 | // Method Description: 23 | // - Checks if the Azure Cloud shell is available on this platform, and if it 24 | // is, creates a profile to be able to launch it. 25 | // Arguments: 26 | // - 27 | // Return Value: 28 | // - a vector with the Azure Cloud Shell connection profile, if available. 29 | void AzureCloudShellGenerator::GenerateProfiles(std::vector>& profiles) const 30 | { 31 | if (AzureConnection::IsAzureConnectionAvailable()) 32 | { 33 | auto azureCloudShellProfile{ CreateDynamicProfile(L"Azure Cloud Shell") }; 34 | azureCloudShellProfile->StartingDirectory(winrt::hstring{ DEFAULT_STARTING_DIRECTORY }); 35 | azureCloudShellProfile->DefaultAppearance().ColorSchemeName(L"Vintage"); 36 | azureCloudShellProfile->ConnectionType(AzureConnection::ConnectionType()); 37 | profiles.emplace_back(std::move(azureCloudShellProfile)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/AzureCloudShellGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - AzureCloudShellGenerator 7 | 8 | Abstract: 9 | - This is the dynamic profile generator for the azure cloud shell connector. 10 | Checks if the Azure Cloud shell is available on this platform, and if it is, 11 | creates a profile to be able to launch it. 12 | 13 | Author(s): 14 | - Mike Griese - August 2019 15 | 16 | --*/ 17 | 18 | #pragma once 19 | 20 | #include "IDynamicProfileGenerator.h" 21 | 22 | namespace winrt::Microsoft::Terminal::Settings::Model 23 | { 24 | class AzureCloudShellGenerator final : public IDynamicProfileGenerator 25 | { 26 | public: 27 | std::wstring_view GetNamespace() const noexcept override; 28 | void GenerateProfiles(std::vector>& profiles) const override; 29 | }; 30 | }; 31 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/CascadiaSettings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "GlobalAppSettings.idl"; 5 | import "Profile.idl"; 6 | import "TerminalWarnings.idl"; 7 | import "DefaultTerminal.idl"; 8 | 9 | namespace Microsoft.Terminal.Settings.Model 10 | { 11 | [default_interface] runtimeclass CascadiaSettings { 12 | static CascadiaSettings LoadDefaults(); 13 | static CascadiaSettings LoadAll(); 14 | static CascadiaSettings LoadUniversal(); 15 | 16 | static String SettingsPath { get; }; 17 | static String DefaultSettingsPath { get; }; 18 | 19 | static String ApplicationDisplayName { get; }; 20 | static String ApplicationVersion { get; }; 21 | 22 | static void ExportFile(String path, String content); 23 | 24 | CascadiaSettings(String userJSON, String inboxJSON); 25 | 26 | CascadiaSettings Copy(); 27 | void WriteSettingsToDisk(); 28 | 29 | GlobalAppSettings GlobalSettings { get; }; 30 | 31 | Profile ProfileDefaults { get; }; 32 | 33 | IObservableVector AllProfiles { get; }; 34 | IObservableVector ActiveProfiles { get; }; 35 | 36 | Profile DuplicateProfile(Profile sourceProfile); 37 | 38 | ActionMap ActionMap { get; }; 39 | 40 | IVectorView Warnings { get; }; 41 | Windows.Foundation.IReference GetLoadingError { get; }; 42 | String GetSerializationErrorMessage { get; }; 43 | 44 | Profile CreateNewProfile(); 45 | Profile FindProfile(Guid profileGuid); 46 | ColorScheme GetColorSchemeForProfile(Profile profile); 47 | void UpdateColorSchemeReferences(String oldName, String newName); 48 | 49 | Profile GetProfileForArgs(NewTerminalArgs newTerminalArgs); 50 | 51 | static Boolean IsDefaultTerminalAvailable { get; }; 52 | static Boolean IsDefaultTerminalSet { get; }; 53 | IObservableVector DefaultTerminals { get; }; 54 | DefaultTerminal CurrentDefaultTerminal; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/ColorScheme.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - ColorScheme.hpp 7 | 8 | Abstract: 9 | - A color scheme is a single set of colors to use as the terminal colors. These 10 | schemes are named, and can be used to quickly change all the colors of the 11 | terminal to another scheme. 12 | 13 | Author(s): 14 | - Mike Griese - March 2019 15 | 16 | --*/ 17 | #pragma once 18 | #include 19 | #include 20 | #include "DefaultSettings.h" 21 | 22 | #include "ColorScheme.g.h" 23 | 24 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 25 | { 26 | struct ColorScheme : ColorSchemeT 27 | { 28 | // A ColorScheme constructed with uninitialized_t 29 | // leaves _table uninitialized. 30 | struct uninitialized_t 31 | { 32 | }; 33 | 34 | public: 35 | ColorScheme() noexcept; 36 | explicit ColorScheme(uninitialized_t) noexcept {} 37 | explicit ColorScheme(const winrt::hstring& name) noexcept; 38 | 39 | com_ptr Copy() const; 40 | 41 | hstring ToString() 42 | { 43 | return Name(); 44 | } 45 | 46 | static com_ptr FromJson(const Json::Value& json); 47 | Json::Value ToJson() const; 48 | 49 | winrt::Microsoft::Terminal::Core::Scheme ToCoreScheme() const noexcept; 50 | 51 | com_array Table() const noexcept; 52 | void SetColorTableEntry(uint8_t index, const Core::Color& value) noexcept; 53 | 54 | WINRT_PROPERTY(winrt::hstring, Name); 55 | WINRT_PROPERTY(Core::Color, Foreground, static_cast(DEFAULT_FOREGROUND)); 56 | WINRT_PROPERTY(Core::Color, Background, static_cast(DEFAULT_BACKGROUND)); 57 | WINRT_PROPERTY(Core::Color, SelectionBackground, static_cast(DEFAULT_FOREGROUND)); 58 | WINRT_PROPERTY(Core::Color, CursorColor, static_cast(DEFAULT_CURSOR_COLOR)); 59 | 60 | private: 61 | bool _layerJson(const Json::Value& json); 62 | 63 | std::array _table; 64 | }; 65 | } 66 | 67 | namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation 68 | { 69 | BASIC_FACTORY(ColorScheme); 70 | } 71 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/ColorScheme.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Settings.Model 5 | { 6 | [default_interface] runtimeclass ColorScheme : Windows.Foundation.IStringable { 7 | ColorScheme(); 8 | ColorScheme(String name); 9 | 10 | String Name; 11 | 12 | Microsoft.Terminal.Core.Color Foreground; 13 | Microsoft.Terminal.Core.Color Background; 14 | Microsoft.Terminal.Core.Color SelectionBackground; 15 | Microsoft.Terminal.Core.Color CursorColor; 16 | 17 | // winrt::com_arrays prevent data binding. 18 | // Instead of representing Table as a property, 19 | // we expose the getter as a function. 20 | Microsoft.Terminal.Core.Color[] Table(); 21 | void SetColorTableEntry(UInt8 index, Microsoft.Terminal.Core.Color value); 22 | 23 | Microsoft.Terminal.Core.Scheme ToCoreScheme(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/Command.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "AllShortcutActions.h" 5 | 6 | import "ActionArgs.idl"; 7 | import "Profile.idl"; 8 | import "ColorScheme.idl"; 9 | import "TerminalWarnings.idl"; 10 | 11 | namespace Microsoft.Terminal.Settings.Model 12 | { 13 | enum ShortcutAction 14 | { 15 | Invalid = 0, // treat Invalid as unbound actions 16 | 17 | // When adding a new action, add them to AllShortcutActions.h! 18 | #define ON_ALL_ACTIONS(action) action, 19 | ALL_SHORTCUT_ACTIONS 20 | #undef ON_ALL_ACTIONS 21 | }; 22 | 23 | [default_interface] runtimeclass ActionAndArgs { 24 | ActionAndArgs(); 25 | ActionAndArgs(ShortcutAction action, IActionArgs args); 26 | 27 | IActionArgs Args; 28 | ShortcutAction Action; 29 | }; 30 | 31 | [default_interface] runtimeclass Command : Microsoft.UI.Xaml.Data.INotifyPropertyChanged 32 | { 33 | Command(); 34 | 35 | String Name { get; }; 36 | ActionAndArgs ActionAndArgs { get; }; 37 | Microsoft.Terminal.Control.KeyChord Keys { get; }; 38 | void RegisterKey(Microsoft.Terminal.Control.KeyChord keys); 39 | String KeyChordText { get; }; 40 | 41 | String IconPath; 42 | 43 | Boolean HasNestedCommands { get; }; 44 | Windows.Foundation.Collections.IMapView NestedCommands { get; }; 45 | 46 | static void ExpandCommands(Windows.Foundation.Collections.IMap commands, 47 | Windows.Foundation.Collections.IVectorView profiles, 48 | Windows.Foundation.Collections.IVectorView schemes, 49 | Windows.Foundation.Collections.IVector warnings); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/DefaultTerminal.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - DefaultTerminal.h 7 | 8 | Abstract: 9 | - A Default Terminal is an application that can register 10 | as the handler window or "terminal" for a command-line 11 | application. This class is the model for presenting 12 | handler options in the Windows Terminal Settings UI. 13 | 14 | Author(s): 15 | - Michael Niksa - 20-Apr-2021 16 | 17 | --*/ 18 | 19 | #pragma once 20 | 21 | #include "DefaultTerminal.g.h" 22 | 23 | #include "../../propslib/DelegationConfig.hpp" 24 | 25 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 26 | { 27 | struct DefaultTerminal : public DefaultTerminalT 28 | { 29 | explicit DefaultTerminal(DelegationConfig::DelegationPackage&& pkg); 30 | 31 | hstring ToString() 32 | { 33 | return hstring{ fmt::format(L"{}, {}, {}", Name(), Author(), Version()) }; 34 | } 35 | 36 | hstring Name() const; 37 | hstring Author() const; 38 | hstring Version() const; 39 | hstring Icon() const; 40 | 41 | static std::pair, Model::DefaultTerminal> Available(); 42 | static bool HasCurrent(); 43 | static void Current(const Model::DefaultTerminal& term); 44 | 45 | private: 46 | DelegationConfig::DelegationPackage _pkg; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/DefaultTerminal.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Settings.Model 5 | { 6 | runtimeclass DefaultTerminal : Windows.Foundation.IStringable 7 | { 8 | String Name { get; }; 9 | String Author { get; }; 10 | String Version { get; }; 11 | String Icon { get; }; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/DynamicProfileUtils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "DynamicProfileUtils.h" 6 | #include "../../types/inc/utils.hpp" 7 | 8 | static constexpr std::wstring_view PACKAGED_PROFILE_ICON_PATH{ L"ms-appx:///ProfileIcons/" }; 9 | static constexpr std::wstring_view PACKAGED_PROFILE_ICON_EXTENSION{ L".png" }; 10 | 11 | // Method Description: 12 | // - Helper function for creating a skeleton default profile with a pre-populated 13 | // guid and name. 14 | // Arguments: 15 | // - name: the name of the new profile. 16 | // Return Value: 17 | // - A Profile, ready to be filled in 18 | winrt::com_ptr CreateDynamicProfile(const std::wstring_view& name) 19 | { 20 | const auto profileGuid = Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, gsl::as_bytes(gsl::make_span(name))); 21 | 22 | std::wstring iconPath{ PACKAGED_PROFILE_ICON_PATH }; 23 | iconPath.append(Microsoft::Console::Utils::GuidToString(profileGuid)); 24 | iconPath.append(PACKAGED_PROFILE_ICON_EXTENSION); 25 | 26 | auto profile = winrt::make_self(profileGuid); 27 | profile->Name(winrt::hstring{ name }); 28 | profile->Icon(winrt::hstring{ iconPath }); 29 | return profile; 30 | } 31 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/DynamicProfileUtils.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Abstract: 6 | - This header stores our default namespace guid. This is used in the creation of 7 | default and in-box dynamic profiles. It also provides a helper function for 8 | creating a "default" profile. Prior to GH#754, this was used to create the 9 | cmd, powershell, wsl, pwsh, and azure profiles. Now, this helper is used for 10 | any of the in-box dynamic profile generators. 11 | 12 | Author(s): 13 | - Mike Griese - August 2019 14 | -- */ 15 | #pragma once 16 | 17 | #include "Profile.h" 18 | 19 | // !!! LOAD-BEARING 20 | // If you change or delete this GUID, all dynamic profiles 21 | // will become disconnected from user settings. 22 | // {2bde4a90-d05f-401c-9492-e40884ead1d8} 23 | // uuidv5 properties: name format is UTF-16LE bytes 24 | static constexpr GUID TERMINAL_PROFILE_NAMESPACE_GUID = { 0x2bde4a90, 0xd05f, 0x401c, { 0x94, 0x92, 0xe4, 0x8, 0x84, 0xea, 0xd1, 0xd8 } }; 25 | 26 | winrt::com_ptr CreateDynamicProfile(const std::wstring_view& name); 27 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/EnumMappings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "ActionAndArgs.h" 6 | #include "JsonUtils.h" 7 | #include "TerminalSettingsSerializationHelpers.h" 8 | 9 | #include "EnumMappings.h" 10 | #include "EnumMappings.g.cpp" 11 | 12 | using namespace winrt; 13 | using namespace winrt::Windows::Foundation::Collections; 14 | using namespace ::Microsoft::Terminal::Settings::Model; 15 | 16 | #define DEFINE_ENUM_MAP(type, name) \ 17 | winrt::Windows::Foundation::Collections::IMap EnumMappings::name() \ 18 | { \ 19 | static IMap enumMap = []() { \ 20 | auto map = single_threaded_map(); \ 21 | for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) \ 22 | { \ 23 | map.Insert(winrt::to_hstring(enumStr), enumVal); \ 24 | } \ 25 | return map; \ 26 | }(); \ 27 | return enumMap; \ 28 | } 29 | 30 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 31 | { 32 | // Global Settings 33 | DEFINE_ENUM_MAP(winrt::Microsoft::UI::Xaml::ElementTheme, ElementTheme); 34 | DEFINE_ENUM_MAP(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabViewWidthMode); 35 | DEFINE_ENUM_MAP(Model::FirstWindowPreference, FirstWindowPreference); 36 | DEFINE_ENUM_MAP(Model::LaunchMode, LaunchMode); 37 | DEFINE_ENUM_MAP(Model::TabSwitcherMode, TabSwitcherMode); 38 | DEFINE_ENUM_MAP(Microsoft::Terminal::Control::CopyFormat, CopyFormat); 39 | DEFINE_ENUM_MAP(Model::WindowingMode, WindowingMode); 40 | 41 | // Profile Settings 42 | DEFINE_ENUM_MAP(Model::CloseOnExitMode, CloseOnExitMode); 43 | DEFINE_ENUM_MAP(Microsoft::Terminal::Control::ScrollbarState, ScrollbarState); 44 | DEFINE_ENUM_MAP(Microsoft::UI::Xaml::Media::Stretch, BackgroundImageStretchMode); 45 | DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextAntialiasingMode, TextAntialiasingMode); 46 | DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); 47 | DEFINE_ENUM_MAP(Microsoft::Terminal::Settings::Model::IntenseStyle, IntenseTextStyle); 48 | 49 | // FontWeight is special because the JsonUtils::ConversionTrait for it 50 | // creates a FontWeight object, but we need to use the uint16_t value. 51 | winrt::Windows::Foundation::Collections::IMap EnumMappings::FontWeight() 52 | { 53 | static auto enumMap = []() { 54 | auto map = single_threaded_map(); 55 | for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) 56 | { 57 | map.Insert(winrt::to_hstring(enumStr), enumVal); 58 | } 59 | return map; 60 | }(); 61 | return enumMap; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/EnumMappings.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - EnumMappings.h 7 | 8 | Abstract: 9 | - Contains mappings from enum name to enum value for the enum types used in our settings. 10 | These are mainly used in the settings UI for data binding so that we can display 11 | all possible choices in the UI for each setting/enum. 12 | 13 | Author(s): 14 | - Leon Liang - October 2020 15 | 16 | --*/ 17 | #pragma once 18 | 19 | #include "EnumMappings.g.h" 20 | 21 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 22 | { 23 | struct EnumMappings : EnumMappingsT 24 | { 25 | public: 26 | EnumMappings() = default; 27 | 28 | // Global Settings 29 | static winrt::Windows::Foundation::Collections::IMap ElementTheme(); 30 | static winrt::Windows::Foundation::Collections::IMap TabViewWidthMode(); 31 | static winrt::Windows::Foundation::Collections::IMap FirstWindowPreference(); 32 | static winrt::Windows::Foundation::Collections::IMap LaunchMode(); 33 | static winrt::Windows::Foundation::Collections::IMap TabSwitcherMode(); 34 | static winrt::Windows::Foundation::Collections::IMap CopyFormat(); 35 | static winrt::Windows::Foundation::Collections::IMap WindowingMode(); 36 | 37 | // Profile Settings 38 | static winrt::Windows::Foundation::Collections::IMap CloseOnExitMode(); 39 | static winrt::Windows::Foundation::Collections::IMap ScrollbarState(); 40 | static winrt::Windows::Foundation::Collections::IMap BackgroundImageStretchMode(); 41 | static winrt::Windows::Foundation::Collections::IMap TextAntialiasingMode(); 42 | static winrt::Windows::Foundation::Collections::IMap CursorStyle(); 43 | static winrt::Windows::Foundation::Collections::IMap FontWeight(); 44 | static winrt::Windows::Foundation::Collections::IMap IntenseTextStyle(); 45 | }; 46 | } 47 | 48 | namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation 49 | { 50 | BASIC_FACTORY(EnumMappings); 51 | } 52 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/EnumMappings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // Licensed under the MIT license. 3 | 4 | import "GlobalAppSettings.idl"; 5 | import "Profile.idl"; 6 | 7 | namespace Microsoft.Terminal.Settings.Model 8 | { 9 | [default_interface] runtimeclass EnumMappings { 10 | // Global Settings 11 | static Windows.Foundation.Collections.IMap ElementTheme { get; }; 12 | static Windows.Foundation.Collections.IMap TabViewWidthMode { get; }; 13 | static Windows.Foundation.Collections.IMap FirstWindowPreference { get; }; 14 | static Windows.Foundation.Collections.IMap LaunchMode { get; }; 15 | static Windows.Foundation.Collections.IMap TabSwitcherMode { get; }; 16 | static Windows.Foundation.Collections.IMap CopyFormat { get; }; 17 | static Windows.Foundation.Collections.IMap WindowingMode { get; }; 18 | 19 | // Profile Settings 20 | static Windows.Foundation.Collections.IMap CloseOnExitMode { get; }; 21 | static Windows.Foundation.Collections.IMap ScrollbarState { get; }; 22 | static Windows.Foundation.Collections.IMap BackgroundImageStretchMode { get; }; 23 | static Windows.Foundation.Collections.IMap TextAntialiasingMode { get; }; 24 | static Windows.Foundation.Collections.IMap CursorStyle { get; }; 25 | static Windows.Foundation.Collections.IMap FontWeight { get; }; 26 | static Windows.Foundation.Collections.IMap IntenseTextStyle { get; }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/FileUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace winrt::Microsoft::Terminal::Settings::Model 5 | { 6 | std::filesystem::path GetBaseSettingsPath(); 7 | std::string ReadUTF8File(const std::filesystem::path& path, const bool elevatedOnly = false); 8 | std::optional ReadUTF8FileIfExists(const std::filesystem::path& path, const bool elevatedOnly = false); 9 | void WriteUTF8File(const std::filesystem::path& path, const std::string_view& content, const bool elevatedOnly = false); 10 | void WriteUTF8FileAtomic(const std::filesystem::path& path, const std::string_view& content); 11 | } 12 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/FontConfig.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "FontConfig.h" 6 | #include "FontConfig.g.cpp" 7 | 8 | #include "TerminalSettingsSerializationHelpers.h" 9 | #include "JsonUtils.h" 10 | 11 | using namespace Microsoft::Terminal::Settings::Model; 12 | using namespace winrt::Microsoft::Terminal::Settings::Model::implementation; 13 | 14 | static constexpr std::string_view FontInfoKey{ "font" }; 15 | static constexpr std::string_view LegacyFontFaceKey{ "fontFace" }; 16 | static constexpr std::string_view LegacyFontSizeKey{ "fontSize" }; 17 | static constexpr std::string_view LegacyFontWeightKey{ "fontWeight" }; 18 | 19 | winrt::Microsoft::Terminal::Settings::Model::implementation::FontConfig::FontConfig(winrt::weak_ref sourceProfile) : 20 | _sourceProfile(std::move(sourceProfile)) 21 | { 22 | } 23 | 24 | winrt::com_ptr FontConfig::CopyFontInfo(const FontConfig* source, winrt::weak_ref sourceProfile) 25 | { 26 | auto fontInfo{ winrt::make_self(std::move(sourceProfile)) }; 27 | 28 | #define FONT_SETTINGS_COPY(type, name, jsonKey, ...) \ 29 | fontInfo->_##name = source->_##name; 30 | MTSM_FONT_SETTINGS(FONT_SETTINGS_COPY) 31 | #undef FONT_SETTINGS_COPY 32 | 33 | return fontInfo; 34 | } 35 | 36 | Json::Value FontConfig::ToJson() const 37 | { 38 | Json::Value json{ Json::ValueType::objectValue }; 39 | 40 | #define FONT_SETTINGS_TO_JSON(type, name, jsonKey, ...) \ 41 | JsonUtils::SetValueForKey(json, jsonKey, _##name); 42 | MTSM_FONT_SETTINGS(FONT_SETTINGS_TO_JSON) 43 | #undef FONT_SETTINGS_TO_JSON 44 | 45 | return json; 46 | } 47 | 48 | // Method Description: 49 | // - Layer values from the given json object on top of the existing properties 50 | // of this object. For any keys we're expecting to be able to parse in the 51 | // given object, we'll parse them and replace our settings with values from 52 | // the new json object. Properties that _aren't_ in the json object will _not_ 53 | // be replaced. 54 | // - Optional values that are set to `null` in the json object 55 | // will be set to nullopt. 56 | // - This is similar to Profile::LayerJson but for FontConfig 57 | // Arguments: 58 | // - json: an object which should be a partial serialization of a FontConfig object. 59 | void FontConfig::LayerJson(const Json::Value& json) 60 | { 61 | // Legacy users may not have a font object defined in their profile, 62 | // so check for that before we decide how to parse this 63 | if (json.isMember(JsonKey(FontInfoKey))) 64 | { 65 | // A font object is defined, use that 66 | const auto fontInfoJson = json[JsonKey(FontInfoKey)]; 67 | #define FONT_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \ 68 | JsonUtils::GetValueForKey(fontInfoJson, jsonKey, _##name); 69 | MTSM_FONT_SETTINGS(FONT_SETTINGS_LAYER_JSON) 70 | #undef FONT_SETTINGS_LAYER_JSON 71 | } 72 | else 73 | { 74 | // No font object is defined 75 | JsonUtils::GetValueForKey(json, LegacyFontFaceKey, _FontFace); 76 | JsonUtils::GetValueForKey(json, LegacyFontSizeKey, _FontSize); 77 | JsonUtils::GetValueForKey(json, LegacyFontWeightKey, _FontWeight); 78 | } 79 | } 80 | 81 | bool FontConfig::HasAnyOptionSet() const 82 | { 83 | return HasFontFace() || HasFontSize() || HasFontWeight(); 84 | } 85 | 86 | winrt::Microsoft::Terminal::Settings::Model::Profile FontConfig::SourceProfile() 87 | { 88 | return _sourceProfile.get(); 89 | } 90 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/FontConfig.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - FontConfig 7 | 8 | Abstract: 9 | - The implementation of the FontConfig winrt class. Provides settings related 10 | to the font settings of the terminal, for the terminal control. 11 | 12 | Author(s): 13 | - Pankaj Bhojwani - June 2021 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #include "pch.h" 20 | #include "FontConfig.g.h" 21 | #include "JsonUtils.h" 22 | #include "MTSMSettings.h" 23 | #include "IInheritable.h" 24 | #include 25 | 26 | using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap; 27 | using IFontFeatureMap = winrt::Windows::Foundation::Collections::IMap; 28 | 29 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 30 | { 31 | struct FontConfig : FontConfigT, IInheritable 32 | { 33 | public: 34 | FontConfig(winrt::weak_ref sourceProfile); 35 | static winrt::com_ptr CopyFontInfo(const FontConfig* source, winrt::weak_ref sourceProfile); 36 | Json::Value ToJson() const; 37 | void LayerJson(const Json::Value& json); 38 | bool HasAnyOptionSet() const; 39 | 40 | Model::Profile SourceProfile(); 41 | 42 | #define FONT_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ 43 | INHERITABLE_SETTING(Model::FontConfig, type, name, ##__VA_ARGS__) 44 | MTSM_FONT_SETTINGS(FONT_SETTINGS_INITIALIZE) 45 | #undef FONT_SETTINGS_INITIALIZE 46 | 47 | private: 48 | winrt::weak_ref _sourceProfile; 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/FontConfig.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "Profile.idl"; 5 | #include "IInheritable.idl.h" 6 | 7 | #define INHERITABLE_FONT_SETTING(Type, Name) \ 8 | _BASE_INHERITABLE_SETTING(Type, Name); \ 9 | Microsoft.Terminal.Settings.Model.FontConfig Name##OverrideSource { get; } 10 | 11 | #define COMMA , 12 | 13 | namespace Microsoft.Terminal.Settings.Model 14 | { 15 | [default_interface] runtimeclass FontConfig { 16 | Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; }; 17 | 18 | INHERITABLE_FONT_SETTING(String, FontFace); 19 | INHERITABLE_FONT_SETTING(Int32, FontSize); 20 | INHERITABLE_FONT_SETTING(Windows.UI.Text.FontWeight, FontWeight); 21 | 22 | INHERITABLE_FONT_SETTING(Windows.Foundation.Collections.IMap, FontFeatures); 23 | INHERITABLE_FONT_SETTING(Windows.Foundation.Collections.IMap, FontAxes); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/GlobalAppSettings.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - GlobalAppSettings.h 7 | 8 | Abstract: 9 | - This class encapsulates all of the settings that are global to the app, and 10 | not a part of any particular profile. 11 | 12 | Author(s): 13 | - Mike Griese - March 2019 14 | 15 | --*/ 16 | #pragma once 17 | 18 | #include "GlobalAppSettings.g.h" 19 | #include "IInheritable.h" 20 | #include "MTSMSettings.h" 21 | 22 | #include "ActionMap.h" 23 | #include "Command.h" 24 | #include "ColorScheme.h" 25 | 26 | // fwdecl unittest classes 27 | namespace SettingsModelLocalTests 28 | { 29 | class DeserializationTests; 30 | class ColorSchemeTests; 31 | }; 32 | 33 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 34 | { 35 | struct GlobalAppSettings : GlobalAppSettingsT, IInheritable 36 | { 37 | public: 38 | void _FinalizeInheritance() override; 39 | com_ptr Copy() const; 40 | 41 | Windows::Foundation::Collections::IMapView ColorSchemes() noexcept; 42 | void AddColorScheme(const Model::ColorScheme& scheme); 43 | void RemoveColorScheme(hstring schemeName); 44 | 45 | Model::ActionMap ActionMap() const noexcept; 46 | 47 | static com_ptr FromJson(const Json::Value& json); 48 | void LayerJson(const Json::Value& json); 49 | 50 | Json::Value ToJson() const; 51 | 52 | const std::vector& KeybindingsWarnings() const; 53 | 54 | // This DefaultProfile() setter is called by CascadiaSettings, 55 | // when it parses UnparsedDefaultProfile in _finalizeSettings(). 56 | void DefaultProfile(const guid& defaultProfile) noexcept; 57 | guid DefaultProfile() const; 58 | 59 | // TODO GH#9207: Remove this once we have a GlobalAppSettingsViewModel in TerminalSettingsEditor 60 | void SetInvertedDisableAnimationsValue(bool invertedDisableAnimationsValue) 61 | { 62 | DisableAnimations(!invertedDisableAnimationsValue); 63 | } 64 | 65 | INHERITABLE_SETTING(Model::GlobalAppSettings, hstring, UnparsedDefaultProfile, L""); 66 | 67 | #define GLOBAL_SETTINGS_INITIALIZE(type, name, jsonKey, ...) \ 68 | INHERITABLE_SETTING(Model::GlobalAppSettings, type, name, ##__VA_ARGS__) 69 | MTSM_GLOBAL_SETTINGS(GLOBAL_SETTINGS_INITIALIZE) 70 | #undef GLOBAL_SETTINGS_INITIALIZE 71 | 72 | private: 73 | #ifdef NDEBUG 74 | static constexpr bool debugFeaturesDefault{ false }; 75 | #else 76 | static constexpr bool debugFeaturesDefault{ true }; 77 | #endif 78 | 79 | winrt::guid _defaultProfile; 80 | winrt::com_ptr _actionMap{ winrt::make_self() }; 81 | std::vector _keybindingsWarnings; 82 | Windows::Foundation::Collections::IMap _colorSchemes{ winrt::single_threaded_map() }; 83 | }; 84 | } 85 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/HashUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | /*++ 5 | Module Name: 6 | - HashUtils.h 7 | 8 | Abstract: 9 | - This module is used for hashing data consistently 10 | 11 | Author(s): 12 | - Carlos Zamora (CaZamor) 15-Apr-2021 13 | 14 | Revision History: 15 | - N/A 16 | --*/ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace til 23 | { 24 | template 25 | struct hash_trait> 26 | { 27 | constexpr void operator()(hasher& h, const winrt::Windows::Foundation::IReference& v) const noexcept 28 | { 29 | if (v) 30 | { 31 | h.write(v.Value()); 32 | } 33 | } 34 | }; 35 | 36 | template<> 37 | struct hash_trait 38 | { 39 | void operator()(hasher& h, const winrt::hstring& value) const noexcept 40 | { 41 | h.write(reinterpret_cast(value.data()), value.size() * sizeof(wchar_t)); 42 | } 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/IAppearanceConfig.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "Profile.idl"; 5 | #include "IInheritable.idl.h" 6 | 7 | #define INHERITABLE_APPEARANCE_SETTING(Type, Name) \ 8 | _BASE_INHERITABLE_SETTING(Type, Name); \ 9 | Microsoft.Terminal.Settings.Model.IAppearanceConfig Name##OverrideSource { get; } 10 | 11 | namespace Microsoft.Terminal.Settings.Model 12 | { 13 | [flags] enum ConvergedAlignment { 14 | // low 4 bits are the horizontal 15 | Horizontal_Center = 0x00, 16 | Horizontal_Left = 0x01, 17 | Horizontal_Right = 0x02, 18 | 19 | // high 4 bits are the vertical 20 | Vertical_Center = 0x00, 21 | Vertical_Top = 0x10, 22 | Vertical_Bottom = 0x20 23 | }; 24 | 25 | [flags] 26 | enum IntenseStyle 27 | { 28 | Bold = 0x1, 29 | Bright = 0x2, 30 | All = 0xffffffff 31 | }; 32 | 33 | interface IAppearanceConfig 34 | { 35 | Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; }; 36 | INHERITABLE_APPEARANCE_SETTING(String, ColorSchemeName); 37 | INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, Foreground); 38 | INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, Background); 39 | INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, SelectionBackground); 40 | INHERITABLE_APPEARANCE_SETTING(Windows.Foundation.IReference, CursorColor); 41 | INHERITABLE_APPEARANCE_SETTING(Microsoft.Terminal.Core.CursorStyle, CursorShape); 42 | INHERITABLE_APPEARANCE_SETTING(UInt32, CursorHeight); 43 | 44 | INHERITABLE_APPEARANCE_SETTING(String, BackgroundImagePath); 45 | String ExpandedBackgroundImagePath { get; }; 46 | 47 | INHERITABLE_APPEARANCE_SETTING(Double, BackgroundImageOpacity); 48 | INHERITABLE_APPEARANCE_SETTING(Microsoft.UI.Xaml.Media.Stretch, BackgroundImageStretchMode); 49 | INHERITABLE_APPEARANCE_SETTING(ConvergedAlignment, BackgroundImageAlignment); 50 | 51 | INHERITABLE_APPEARANCE_SETTING(Boolean, RetroTerminalEffect); 52 | INHERITABLE_APPEARANCE_SETTING(String, PixelShaderPath); 53 | INHERITABLE_APPEARANCE_SETTING(IntenseStyle, IntenseTextStyle); 54 | INHERITABLE_APPEARANCE_SETTING(Boolean, AdjustIndistinguishableColors); 55 | INHERITABLE_APPEARANCE_SETTING(Double, Opacity); 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/IDynamicProfileGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - IDynamicProfileGenerator 7 | 8 | Abstract: 9 | - The DynamicProfileGenerator interface. A dynamic profile generator is a object 10 | that can synthesize a list of profiles based on some arbitrary, typically 11 | external criteria. Profiles from dynamic sources are only available in the 12 | user's profiles if the generator actually ran and created the profile. 13 | - Each DPG must have a unique namespace to associate with itself. If the 14 | namespace is not unique, the generator risks affecting profiles from 15 | conflicting generators. 16 | 17 | Author(s): 18 | - Mike Griese - August 2019 19 | 20 | --*/ 21 | 22 | #pragma once 23 | 24 | #include "Profile.h" 25 | 26 | namespace winrt::Microsoft::Terminal::Settings::Model 27 | { 28 | class IDynamicProfileGenerator 29 | { 30 | public: 31 | virtual ~IDynamicProfileGenerator(){}; 32 | virtual std::wstring_view GetNamespace() const noexcept = 0; 33 | virtual void GenerateProfiles(std::vector>& profiles) const = 0; 34 | }; 35 | }; 36 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/IInheritable.idl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #define _BASE_INHERITABLE_SETTING(Type, Name) \ 7 | Type Name \ 8 | { \ 9 | get; \ 10 | set; \ 11 | }; \ 12 | Boolean Has##Name { get; }; \ 13 | void Clear##Name() 14 | 15 | #define INHERITABLE_SETTING(Type, Name) \ 16 | _BASE_INHERITABLE_SETTING(Type, Name) 17 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/IconPathConverter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IconPathConverter.g.h" 4 | 5 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 6 | { 7 | struct IconPathConverter : IconPathConverterT 8 | { 9 | IconPathConverter() = default; 10 | 11 | Windows::Foundation::IInspectable Convert(const Windows::Foundation::IInspectable& value, 12 | const Windows::UI::Xaml::Interop::TypeName& targetType, 13 | const Windows::Foundation::IInspectable& parameter, 14 | const hstring& language); 15 | 16 | Windows::Foundation::IInspectable ConvertBack(const Windows::Foundation::IInspectable& value, 17 | const Windows::UI::Xaml::Interop::TypeName& targetType, 18 | const Windows::Foundation::IInspectable& parameter, 19 | const hstring& language); 20 | 21 | //static Windows::UI::Xaml::Controls::IconSource IconSourceWUX(hstring path); 22 | static Microsoft::UI::Xaml::Controls::IconSource IconSourceMUX(hstring path); 23 | }; 24 | } 25 | 26 | namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation 27 | { 28 | BASIC_FACTORY(IconPathConverter); 29 | } 30 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/IconPathConverter.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Settings.Model 5 | { 6 | // See https://docs.microsoft.com/en-us/windows/uwp/data-binding/data-binding-quickstart 7 | 8 | // We use the default attribute to declare IValueConverter as the default 9 | // interface. In the listing, IconPathConverter has only a 10 | // constructor, and no methods, so no default interface is generated for it. 11 | // The default attribute is optimal if you won't be adding instance members 12 | // to IconPathConverter, because no QueryInterface will be 13 | // required to call the IValueConverter methods 14 | runtimeclass IconPathConverter : [default] Microsoft.UI.Xaml.Data.IValueConverter 15 | { 16 | IconPathConverter(); 17 | 18 | //static Windows.UI.Xaml.Controls.IconSource IconSourceWUX(String path); 19 | static Microsoft.UI.Xaml.Controls.IconSource IconSourceMUX(String path); 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/KeyChordSerialization.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "KeyChordSerialization.g.h" 7 | #include "JsonUtils.h" 8 | 9 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 10 | { 11 | struct KeyChordSerialization 12 | { 13 | KeyChordSerialization() = default; 14 | 15 | static winrt::Microsoft::Terminal::Control::KeyChord FromString(const winrt::hstring& str); 16 | static winrt::hstring ToString(const winrt::Microsoft::Terminal::Control::KeyChord& chord); 17 | }; 18 | } 19 | 20 | template<> 21 | struct Microsoft::Terminal::Settings::Model::JsonUtils::ConversionTrait 22 | { 23 | winrt::Microsoft::Terminal::Control::KeyChord FromJson(const Json::Value& json); 24 | bool CanConvert(const Json::Value& json); 25 | Json::Value ToJson(const winrt::Microsoft::Terminal::Control::KeyChord& val); 26 | std::string TypeDescription() const; 27 | }; 28 | 29 | namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation 30 | { 31 | // C++/WinRT generates a constructor even though one is not specified in the IDL 32 | BASIC_FACTORY(KeyChordSerialization); 33 | } 34 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/KeyChordSerialization.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Settings.Model 5 | { 6 | static runtimeclass KeyChordSerialization 7 | { 8 | static Microsoft.Terminal.Control.KeyChord FromString(String str); 9 | static String ToString(Microsoft.Terminal.Control.KeyChord chord); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/LegacyProfileGeneratorNamespaces.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Abstract: 6 | - This header simply contains all the namespaces of the "legacy" dynamic profile 7 | generators. These generators were built-in to the code before we had a proper 8 | concept of a dynamic profile source. As such, these profiles will exist in 9 | user's settings without a `source` attribute, and we'll need to make sure to 10 | handle layering them specially. 11 | 12 | Author(s): 13 | - Mike Griese - August 2019 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | static constexpr std::wstring_view WslGeneratorNamespace{ L"Windows.Terminal.Wsl" }; 20 | static constexpr std::wstring_view AzureGeneratorNamespace{ L"Windows.Terminal.Azure" }; 21 | static constexpr std::wstring_view PowershellCoreGeneratorNamespace{ L"Windows.Terminal.PowershellCore" }; 22 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/Microsoft_Terminal_Settings_Model.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/PowershellCoreProfileGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - PowershellCoreProfileGenerator 7 | 8 | Abstract: 9 | - This is the dynamic profile generator for PowerShell Core. Checks if pwsh is 10 | installed, and if it is, creates a profile to launch it. 11 | 12 | Author(s): 13 | - Mike Griese - August 2019 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #include "IDynamicProfileGenerator.h" 20 | 21 | namespace winrt::Microsoft::Terminal::Settings::Model 22 | { 23 | class PowershellCoreProfileGenerator final : public IDynamicProfileGenerator 24 | { 25 | public: 26 | static const std::wstring_view GetPreferredPowershellProfileName(); 27 | 28 | std::wstring_view GetNamespace() const noexcept override; 29 | void GenerateProfiles(std::vector>& profiles) const override; 30 | }; 31 | }; 32 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/Profile.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "IAppearanceConfig.idl"; 5 | import "FontConfig.idl"; 6 | #include "IInheritable.idl.h" 7 | 8 | #define INHERITABLE_PROFILE_SETTING(Type, Name) \ 9 | _BASE_INHERITABLE_SETTING(Type, Name); \ 10 | Microsoft.Terminal.Settings.Model.Profile Name##OverrideSource { get; } 11 | 12 | namespace Microsoft.Terminal.Settings.Model 13 | { 14 | // This tag is used to identify the context in which the Profile was created 15 | enum OriginTag 16 | { 17 | None = 0, 18 | User, 19 | InBox, 20 | Generated, 21 | Fragment, 22 | ProfilesDefaults 23 | }; 24 | 25 | enum CloseOnExitMode 26 | { 27 | Never = 0, 28 | Graceful, 29 | Always 30 | }; 31 | 32 | [flags] 33 | enum BellStyle 34 | { 35 | // !! If you update this, you must update the values in TerminalSettingsEditor/Profiles.xaml 36 | Audible = 0x1, 37 | Window = 0x2, 38 | Taskbar = 0x4, 39 | All = 0xffffffff 40 | }; 41 | 42 | [default_interface] runtimeclass Profile : Windows.Foundation.IStringable { 43 | Profile(); 44 | Profile(Guid guid); 45 | 46 | void CreateUnfocusedAppearance(); 47 | void DeleteUnfocusedAppearance(); 48 | 49 | // True if the user explicitly removed this Profile from settings.json. 50 | Boolean Deleted { get; }; 51 | OriginTag Origin { get; }; 52 | 53 | INHERITABLE_PROFILE_SETTING(Guid, Guid); 54 | INHERITABLE_PROFILE_SETTING(String, Name); 55 | INHERITABLE_PROFILE_SETTING(String, Source); 56 | INHERITABLE_PROFILE_SETTING(Boolean, Hidden); 57 | INHERITABLE_PROFILE_SETTING(Guid, ConnectionType); 58 | INHERITABLE_PROFILE_SETTING(String, Icon); 59 | INHERITABLE_PROFILE_SETTING(CloseOnExitMode, CloseOnExit); 60 | INHERITABLE_PROFILE_SETTING(String, TabTitle); 61 | INHERITABLE_PROFILE_SETTING(Windows.Foundation.IReference, TabColor); 62 | INHERITABLE_PROFILE_SETTING(Boolean, SuppressApplicationTitle); 63 | INHERITABLE_PROFILE_SETTING(Boolean, UseAcrylic); 64 | INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.ScrollbarState, ScrollState); 65 | INHERITABLE_PROFILE_SETTING(String, Padding); 66 | INHERITABLE_PROFILE_SETTING(String, Commandline); 67 | INHERITABLE_PROFILE_SETTING(Boolean, VtPassthrough); 68 | 69 | INHERITABLE_PROFILE_SETTING(String, StartingDirectory); 70 | String EvaluatedStartingDirectory { get; }; 71 | 72 | FontConfig FontInfo { get; }; 73 | 74 | IAppearanceConfig DefaultAppearance { get; }; 75 | INHERITABLE_PROFILE_SETTING(IAppearanceConfig, UnfocusedAppearance); 76 | 77 | INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.TextAntialiasingMode, AntialiasingMode); 78 | 79 | INHERITABLE_PROFILE_SETTING(Int32, HistorySize); 80 | INHERITABLE_PROFILE_SETTING(Boolean, SnapOnInput); 81 | INHERITABLE_PROFILE_SETTING(Boolean, AltGrAliasing); 82 | INHERITABLE_PROFILE_SETTING(BellStyle, BellStyle); 83 | INHERITABLE_PROFILE_SETTING(Boolean, UseAtlasEngine); 84 | INHERITABLE_PROFILE_SETTING(Windows.Foundation.Collections.IVector, BellSound); 85 | 86 | INHERITABLE_PROFILE_SETTING(Boolean, Elevate); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/SettingsTypes.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - SettingsTypes.h 7 | 8 | Abstract: 9 | - Types used in the settings model (non-exported) 10 | --*/ 11 | 12 | #pragma once 13 | 14 | namespace winrt::Microsoft::Terminal::Settings::Model 15 | { 16 | enum class ExpandCommandType : uint32_t 17 | { 18 | None = 0, 19 | Profiles, 20 | ColorSchemes 21 | }; 22 | }; 23 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/TerminalSettings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "CascadiaSettings.idl"; 5 | 6 | namespace Microsoft.Terminal.Settings.Model 7 | { 8 | runtimeclass TerminalSettingsCreateResult 9 | { 10 | TerminalSettingsCreateResult(TerminalSettings defaultSettings); 11 | TerminalSettings DefaultSettings { get; }; 12 | TerminalSettings UnfocusedSettings { get; }; 13 | } 14 | 15 | // Class Description: 16 | // TerminalSettings encapsulates all settings that control the 17 | // TermControl's behavior. In these settings there is both the entirety 18 | // of the Core ICoreSettings properties and the IControlSettings 19 | // properties. It's the Profile's responsibility to build this from 20 | // settings it contains, in combination with the global settings. 21 | // The TerminalControl will pull settings it requires from this object, 22 | // and pass along the Core properties to the terminal core. 23 | [default_interface] 24 | runtimeclass TerminalSettings : Microsoft.Terminal.Core.ICoreSettings, 25 | Microsoft.Terminal.Control.IControlSettings 26 | { 27 | TerminalSettings(); 28 | 29 | static TerminalSettings CreateForPreview(CascadiaSettings appSettings, Profile profile); 30 | static TerminalSettingsCreateResult CreateWithProfile(CascadiaSettings appSettings, Profile profile, Microsoft.Terminal.Control.IKeyBindings keybindings); 31 | static TerminalSettingsCreateResult CreateWithNewTerminalArgs(CascadiaSettings appSettings, NewTerminalArgs newTerminalArgs, Microsoft.Terminal.Control.IKeyBindings keybindings); 32 | 33 | void ApplyColorScheme(ColorScheme scheme); 34 | 35 | ColorScheme AppliedColorScheme; 36 | 37 | // The getters for these are already defined in IControlSettings. So 38 | // we're just adding the setters here, because TerminalApp likes to be 39 | // able to change these at runtime (e.g. when duplicating a pane). 40 | String Commandline { set; }; 41 | String StartingDirectory { set; }; 42 | String EnvironmentVariables { set; }; 43 | 44 | Boolean Elevate; 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/TerminalWarnings.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - TerminalWarnings.h 7 | 8 | Abstract: 9 | - This file contains definitions for warnings, errors and exceptions used by the 10 | Windows Terminal 11 | 12 | Author(s): 13 | - Mike Griese - August 2019 14 | 15 | --*/ 16 | #pragma once 17 | 18 | namespace winrt::Microsoft::Terminal::Settings::Model::implementation 19 | { 20 | // This is a helper class to wrap up a SettingsLoadErrors into a proper 21 | // exception type. 22 | class SettingsException : public std::runtime_error 23 | { 24 | public: 25 | explicit SettingsException(const SettingsLoadErrors& error) : 26 | std::runtime_error{ nullptr }, 27 | _error{ error } {}; 28 | 29 | // We don't use the what() method - we want to be able to display 30 | // localizable error messages. Catchers of this exception should use 31 | // _GetErrorText (in App.cpp) to get the localized exception string. 32 | const char* what() const override 33 | { 34 | return "Exception while loading or validating Terminal settings"; 35 | }; 36 | 37 | SettingsLoadErrors Error() const noexcept { return _error; }; 38 | 39 | private: 40 | const SettingsLoadErrors _error; 41 | }; 42 | }; 43 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/TerminalWarnings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Settings.Model 5 | { 6 | // SettingsLoadWarnings are scenarios where the settings contained 7 | // information we knew was invalid, but we could recover from. 8 | enum SettingsLoadWarnings 9 | { 10 | MissingDefaultProfile = 0, 11 | DuplicateProfile, 12 | UnknownColorScheme, 13 | InvalidBackgroundImage, 14 | InvalidIcon, 15 | AtLeastOneKeybindingWarning, 16 | TooManyKeysForChord, 17 | MissingRequiredParameter, 18 | FailedToParseCommandJson, 19 | FailedToWriteToSettings, 20 | InvalidColorSchemeInCmd, 21 | InvalidSplitSize, 22 | FailedToParseStartupActions, 23 | FailedToParseSubCommands, 24 | WARNINGS_SIZE // IMPORTANT: This MUST be the last value in this enum. It's an unused placeholder. 25 | }; 26 | 27 | // SettingsLoadWarnings are scenarios where the settings had invalid state 28 | // that we could not recover from. 29 | enum SettingsLoadErrors 30 | { 31 | NoProfiles = 0, 32 | AllProfilesHidden = 1, 33 | ERRORS_SIZE // IMPORTANT: This MUST be the last value in this enum. It's an unused placeholder. 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VersionInfo.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Version 51 | // 52 | 53 | VS_VERSION_INFO VERSIONINFO 54 | FILEVERSION 1,11,3471,0 55 | PRODUCTVERSION 1,11,3471,0 56 | FILEFLAGSMASK 0x3fL 57 | #ifdef _DEBUG 58 | FILEFLAGS 0x1L 59 | #else 60 | FILEFLAGS 0x0L 61 | #endif 62 | FILEOS 0x40004L 63 | FILETYPE 0x2L 64 | FILESUBTYPE 0x0L 65 | BEGIN 66 | BLOCK "StringFileInfo" 67 | BEGIN 68 | BLOCK "040904b0" 69 | BEGIN 70 | VALUE "FileDescription", "Windows Terminal Settings" 71 | VALUE "FileVersion", "1.11.3471.0" 72 | VALUE "InternalName", "Microsoft.Terminal.Settings.Model" 73 | VALUE "LegalCopyright", "Copyright (C) 2022" 74 | VALUE "OriginalFilename", "Microsoft.Terminal.Settings.Model" 75 | VALUE "ProductName", "Windows Terminal" 76 | VALUE "ProductVersion", "1.11.3471.0" 77 | END 78 | END 79 | BLOCK "VarFileInfo" 80 | BEGIN 81 | VALUE "Translation", 0x409, 1200 82 | END 83 | END 84 | 85 | #endif // English (United States) resources 86 | ///////////////////////////////////////////////////////////////////////////// 87 | 88 | 89 | 90 | #ifndef APSTUDIO_INVOKED 91 | ///////////////////////////////////////////////////////////////////////////// 92 | // 93 | // Generated from the TEXTINCLUDE 3 resource. 94 | // 95 | 96 | 97 | ///////////////////////////////////////////////////////////////////////////// 98 | #endif // not APSTUDIO_INVOKED 99 | 100 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VisualStudioGenerator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "DynamicProfileUtils.h" 6 | #include "VisualStudioGenerator.h" 7 | #include "VsDevCmdGenerator.h" 8 | #include "VsDevShellGenerator.h" 9 | 10 | using namespace winrt::Microsoft::Terminal::Settings::Model; 11 | 12 | std::wstring_view VisualStudioGenerator::GetNamespace() const noexcept 13 | { 14 | return std::wstring_view{ L"Windows.Terminal.VisualStudio" }; 15 | } 16 | 17 | void VisualStudioGenerator::GenerateProfiles(std::vector>& profiles) const 18 | { 19 | const auto instances = VsSetupConfiguration::QueryInstances(); 20 | 21 | VsDevCmdGenerator devCmdGenerator; 22 | VsDevShellGenerator devShellGenerator; 23 | 24 | // Instances are ordered from latest to oldest. Hide all but the profiles for the latest instance. 25 | auto hidden = false; 26 | for (const auto& instance : instances) 27 | { 28 | devCmdGenerator.GenerateProfiles(instance, hidden, profiles); 29 | devShellGenerator.GenerateProfiles(instance, hidden, profiles); 30 | hidden = true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VisualStudioGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - VisualStudioGenerator 7 | 8 | Abstract: 9 | - Generator for Visual Studio shell profiles. Actual profile generation is delegated 10 | to separate classes that encapsulate different logic for cmd- and powershell-based shells, 11 | as well as VC startup scripts specific to the current processor architecture. 12 | 13 | Author(s): 14 | - Charles Willis - October 2020 15 | - Heath Stewart - September 2021 16 | 17 | --*/ 18 | 19 | #pragma once 20 | 21 | #include "IDynamicProfileGenerator.h" 22 | #include "VsSetupConfiguration.h" 23 | 24 | namespace winrt::Microsoft::Terminal::Settings::Model 25 | { 26 | class VisualStudioGenerator : public IDynamicProfileGenerator 27 | { 28 | public: 29 | std::wstring_view GetNamespace() const noexcept override; 30 | void GenerateProfiles(std::vector>& profiles) const override; 31 | 32 | class IVisualStudioProfileGenerator 33 | { 34 | public: 35 | virtual void GenerateProfiles(const VsSetupConfiguration::VsSetupInstance& instance, bool hidden, std::vector>& profiles) const = 0; 36 | }; 37 | }; 38 | }; 39 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VsDevCmdGenerator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "DynamicProfileUtils.h" 6 | #include "VsDevCmdGenerator.h" 7 | 8 | using namespace winrt::Microsoft::Terminal::Settings::Model; 9 | 10 | void VsDevCmdGenerator::GenerateProfiles(const VsSetupConfiguration::VsSetupInstance& instance, bool hidden, std::vector>& profiles) const 11 | { 12 | try 13 | { 14 | if (!IsInstanceValid(instance)) 15 | { 16 | return; 17 | } 18 | 19 | const auto seed = GetProfileGuidSeed(instance); 20 | const winrt::guid profileGuid{ ::Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, gsl::as_bytes(gsl::make_span(seed))) }; 21 | auto profile = winrt::make_self(profileGuid); 22 | profile->Name(winrt::hstring{ GetProfileName(instance) }); 23 | profile->Commandline(winrt::hstring{ GetProfileCommandLine(instance) }); 24 | profile->StartingDirectory(winrt::hstring{ instance.GetInstallationPath() }); 25 | profile->Icon(winrt::hstring{ GetProfileIconPath() }); 26 | profile->Hidden(hidden); 27 | profiles.emplace_back(std::move(profile)); 28 | } 29 | CATCH_LOG(); 30 | } 31 | 32 | std::wstring VsDevCmdGenerator::GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const 33 | { 34 | std::wstring name{ L"Developer Command Prompt for VS " }; 35 | name.append(instance.GetProfileNameSuffix()); 36 | return name; 37 | } 38 | 39 | std::wstring VsDevCmdGenerator::GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance& instance) const 40 | { 41 | std::wstring commandLine; 42 | commandLine.reserve(256); 43 | commandLine.append(LR"(cmd.exe /k ")"); 44 | commandLine.append(GetDevCmdScriptPath(instance)); 45 | #if defined(_M_ARM64) 46 | commandLine.append(LR"(" -arch=arm64 -host_arch=x64)"); 47 | #elif defined(_M_AMD64) 48 | commandLine.append(LR"(" -arch=x64 -host_arch=x64)"); 49 | #endif 50 | return commandLine; 51 | } 52 | 53 | std::wstring VsDevCmdGenerator::GetDevCmdScriptPath(const VsSetupConfiguration::VsSetupInstance& instance) const 54 | { 55 | return instance.ResolvePath(L"Common7\\Tools\\VsDevCmd.bat"); 56 | } 57 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VsDevCmdGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - VsDevCmdGenerator 7 | 8 | Abstract: 9 | - Dynamic profile generator for Visual Studio Developer Command Prompt 10 | 11 | Author(s): 12 | - Charles Willis - October 2020 13 | - Heath Stewart - September 2021 14 | 15 | --*/ 16 | 17 | #pragma once 18 | #include "VisualStudioGenerator.h" 19 | #include "VsSetupConfiguration.h" 20 | 21 | namespace winrt::Microsoft::Terminal::Settings::Model 22 | { 23 | class VsDevCmdGenerator final : public VisualStudioGenerator::IVisualStudioProfileGenerator 24 | { 25 | public: 26 | void GenerateProfiles(const VsSetupConfiguration::VsSetupInstance& instance, bool hidden, std::vector>& profiles) const override; 27 | 28 | private: 29 | bool IsInstanceValid(const VsSetupConfiguration::VsSetupInstance&) const 30 | { 31 | // We only support version of VS from 15.0. 32 | // Per heaths: The [ISetupConfiguration] COM server only supports Visual Studio 15.0 and newer anyway. 33 | // Eliding the version range will improve the discovery performance by not having to parse or compare the versions. 34 | return true; 35 | } 36 | 37 | std::wstring GetProfileGuidSeed(const VsSetupConfiguration::VsSetupInstance& instance) const 38 | { 39 | return L"VsDevCmd" + instance.GetInstanceId(); 40 | } 41 | 42 | std::wstring GetProfileIconPath() const 43 | { 44 | return L"ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png"; 45 | } 46 | 47 | std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const; 48 | std::wstring GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance& instance) const; 49 | std::wstring GetDevCmdScriptPath(const VsSetupConfiguration::VsSetupInstance& instance) const; 50 | }; 51 | }; 52 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VsDevShellGenerator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "DynamicProfileUtils.h" 6 | #include "VsDevShellGenerator.h" 7 | #include "VsSetupConfiguration.h" 8 | 9 | using namespace winrt::Microsoft::Terminal::Settings::Model; 10 | 11 | void VsDevShellGenerator::GenerateProfiles(const VsSetupConfiguration::VsSetupInstance& instance, bool hidden, std::vector>& profiles) const 12 | { 13 | try 14 | { 15 | if (!IsInstanceValid(instance)) 16 | { 17 | return; 18 | } 19 | 20 | const auto seed = GetProfileGuidSeed(instance); 21 | const winrt::guid profileGuid{ ::Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, gsl::as_bytes(gsl::make_span(seed))) }; 22 | auto profile = winrt::make_self(profileGuid); 23 | profile->Name(winrt::hstring{ GetProfileName(instance) }); 24 | profile->Commandline(winrt::hstring{ GetProfileCommandLine(instance) }); 25 | profile->StartingDirectory(winrt::hstring{ instance.GetInstallationPath() }); 26 | profile->Icon(winrt::hstring{ GetProfileIconPath() }); 27 | profile->Hidden(hidden); 28 | profiles.emplace_back(std::move(profile)); 29 | } 30 | CATCH_LOG(); 31 | } 32 | 33 | std::wstring VsDevShellGenerator::GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const 34 | { 35 | std::wstring name{ L"Developer PowerShell for VS " }; 36 | name.append(instance.GetProfileNameSuffix()); 37 | return name; 38 | } 39 | 40 | std::wstring VsDevShellGenerator::GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance& instance) const 41 | { 42 | // The triple-quotes are a PowerShell path escape sequence that can safely be stored in a JSON object. 43 | // The "SkipAutomaticLocation" parameter will prevent "Enter-VsDevShell" from automatically setting the shell path 44 | // so the path in the profile will be used instead. 45 | std::wstring commandLine; 46 | commandLine.reserve(256); 47 | commandLine.append(LR"(powershell.exe -NoExit -Command "&{Import-Module """)"); 48 | commandLine.append(GetDevShellModulePath(instance)); 49 | commandLine.append(LR"("""; Enter-VsDevShell )"); 50 | commandLine.append(instance.GetInstanceId()); 51 | #if defined(_M_ARM64) 52 | commandLine.append(LR"( -SkipAutomaticLocation -DevCmdArguments """-arch=arm64 -host_arch=x64"""}")"); 53 | #elif defined(_M_AMD64) 54 | commandLine.append(LR"( -SkipAutomaticLocation -DevCmdArguments """-arch=x64 -host_arch=x64"""}")"); 55 | #else 56 | commandLine.append(LR"( -SkipAutomaticLocation}")"); 57 | #endif 58 | 59 | return commandLine; 60 | } 61 | 62 | std::wstring VsDevShellGenerator::GetDevShellModulePath(const VsSetupConfiguration::VsSetupInstance& instance) const 63 | { 64 | // The path of Microsoft.VisualStudio.DevShell.dll changed in 16.3 65 | if (instance.VersionInRange(L"[16.3,")) 66 | { 67 | return instance.ResolvePath(L"Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll"); 68 | } 69 | 70 | return instance.ResolvePath(L"Common7\\Tools\\vsdevshell\\Microsoft.VisualStudio.DevShell.dll"); 71 | } 72 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/VsDevShellGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - VsDevShellGenerator 7 | 8 | Abstract: 9 | - Dynamic profile generator for Visual Studio Developer PowerShell 10 | 11 | Author(s): 12 | - Charles Willis - October 2020 13 | - Heath Stewart - September 2021 14 | 15 | --*/ 16 | 17 | #pragma once 18 | #include "VisualStudioGenerator.h" 19 | #include "VsSetupConfiguration.h" 20 | 21 | namespace winrt::Microsoft::Terminal::Settings::Model 22 | { 23 | class VsDevShellGenerator final : public VisualStudioGenerator::IVisualStudioProfileGenerator 24 | { 25 | public: 26 | void GenerateProfiles(const VsSetupConfiguration::VsSetupInstance& instance, bool hidden, std::vector>& profiles) const override; 27 | 28 | private: 29 | bool IsInstanceValid(const VsSetupConfiguration::VsSetupInstance& instance) const 30 | { 31 | return instance.VersionInRange(L"[16.2,)"); 32 | } 33 | 34 | std::wstring GetProfileGuidSeed(const VsSetupConfiguration::VsSetupInstance& instance) const 35 | { 36 | return L"VsDevShell" + instance.GetInstanceId(); 37 | } 38 | 39 | std::wstring GetProfileIconPath() const 40 | { 41 | return L"ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png"; 42 | } 43 | 44 | std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const; 45 | std::wstring GetProfileCommandLine(const VsSetupConfiguration::VsSetupInstance& instance) const; 46 | std::wstring GetDevShellModulePath(const VsSetupConfiguration::VsSetupInstance& instance) const; 47 | }; 48 | }; 49 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/WslDistroGenerator.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - WslDistroGenerator 7 | 8 | Abstract: 9 | - This is the dynamic profile generator for WSL distros. Enumerates all the 10 | installed WSL distros to create profiles for them. 11 | 12 | Author(s): 13 | - Mike Griese - August 2019 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #include "IDynamicProfileGenerator.h" 20 | 21 | namespace winrt::Microsoft::Terminal::Settings::Model 22 | { 23 | class WslDistroGenerator final : public IDynamicProfileGenerator 24 | { 25 | public: 26 | std::wstring_view GetNamespace() const noexcept override; 27 | void GenerateProfiles(std::vector>& profiles) const override; 28 | }; 29 | }; 30 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/init.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include 6 | 7 | BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/) 8 | { 9 | switch (reason) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | DisableThreadLibraryCalls(hInstDll); 13 | break; 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | } 17 | 18 | return TRUE; 19 | } 20 | 21 | namespace Microsoft::Console::Internal::DefaultApp 22 | { 23 | [[nodiscard]] HRESULT CheckShouldTerminalBeDefault(bool& isEnabled) noexcept 24 | { 25 | // False since setting Terminal as the default app is an OS feature and probably 26 | // should not be done in the open source conhost. We can always decide to turn it 27 | // on in the future though. 28 | isEnabled = false; 29 | return S_OK; 30 | } 31 | } 32 | 33 | UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(L"Microsoft.Terminal.Settings.Model/Resources") 34 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #define NOMCX 5 | #define NOHELP 6 | #define NOCOMM 7 | 8 | // Manually include til after we include Windows.Foundation to give it winrt superpowers 9 | #define BLOCK_TIL 10 | #include 11 | // This is inexplicable, but for whatever reason, cppwinrt conflicts with the 12 | // SDK definition of this function, so the only fix is to undef it. 13 | // from WinBase.h 14 | // Windows::UI::Xaml::Media::Animation::IStoryboard::GetCurrentTime 15 | #ifdef GetCurrentTime 16 | #undef GetCurrentTime 17 | #endif 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #include 42 | #include // must go after the CoreDispatcher type is defined -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | Microsoft.Terminal.Settings.Model Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the Windows App SDK and 7 | C++/WinRT packages to generate implementation headers from interface 8 | (IDL) files. The generated Windows Runtime component binary and WinMD 9 | files should then be bundled with the app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about Windows App SDK here: 22 | https://docs.microsoft.com/windows/apps/windows-app-sdk/ 23 | Learn more about WinUI3 here: 24 | https://docs.microsoft.com/windows/apps/winui/winui3/ 25 | Learn more about C++/WinRT here: 26 | http://aka.ms/cppwinrt/ 27 | ======================================================================== 28 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by VersionInfo.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.Settings.Model/userDefaults.json: -------------------------------------------------------------------------------- 1 | { 2 | // "defaultProfile" is filled in by CascadiaSettings, depending on 3 | // what dynamic profiles are present during the first launch. 4 | "copyOnSelect": false, 5 | "copyFormatting": false, 6 | "profiles": 7 | { 8 | "list": 9 | [ 10 | { 11 | "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", 12 | "name": "Windows PowerShell", 13 | "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", 14 | "hidden": false 15 | }, 16 | { 17 | // "name" is filled in by CascadiaSettings as a localized string. 18 | "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", 19 | "commandline": "%SystemRoot%\\System32\\cmd.exe", 20 | "hidden": false 21 | } 22 | ] 23 | }, 24 | "actions": 25 | [ 26 | { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }, 27 | { "command": "paste", "keys": "ctrl+v" }, 28 | { "command": "find", "keys": "ctrl+shift+f" }, 29 | { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/AzureClient.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "cpprest/json.h" 7 | 8 | namespace Microsoft::Terminal::Azure 9 | { 10 | class AzureException : public std::runtime_error 11 | { 12 | std::wstring _code; 13 | 14 | public: 15 | static bool IsErrorPayload(const web::json::value& errorObject) 16 | { 17 | return errorObject.has_string_field(L"error"); 18 | } 19 | 20 | AzureException(const web::json::value& errorObject) : 21 | runtime_error(til::u16u8(errorObject.at(L"error_description").as_string())), // surface the human-readable description as .what() 22 | _code(errorObject.at(L"error").as_string()) 23 | { 24 | } 25 | 26 | std::wstring_view GetCode() const noexcept 27 | { 28 | return _code; 29 | } 30 | }; 31 | 32 | namespace ErrorCodes 33 | { 34 | static constexpr std::wstring_view AuthorizationPending{ L"authorization_pending" }; 35 | static constexpr std::wstring_view InvalidGrant{ L"invalid_grant" }; 36 | } 37 | 38 | struct Tenant 39 | { 40 | std::wstring ID; 41 | std::optional DisplayName; 42 | std::optional DefaultDomain; 43 | }; 44 | } 45 | 46 | #define THROW_IF_AZURE_ERROR(payload) \ 47 | do \ 48 | { \ 49 | if (AzureException::IsErrorPayload((payload))) \ 50 | { \ 51 | throw AzureException((payload)); \ 52 | } \ 53 | } while (0) 54 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/AzureClientID.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | static constexpr std::wstring_view AzureClientID = L"0"; 7 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/AzureConnection.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "ITerminalConnection.idl"; 5 | 6 | namespace Microsoft.Terminal.TerminalConnection 7 | { 8 | [default_interface] runtimeclass AzureConnection : ITerminalConnection 9 | { 10 | static Guid ConnectionType { get; }; 11 | static Boolean IsAzureConnectionAvailable(); 12 | 13 | AzureConnection(); 14 | }; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/CTerminalHandoff.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Module Name: 6 | - CTerminalHandoff.h 7 | 8 | Abstract: 9 | - This module receives an incoming request to host a terminal UX 10 | for a console mode application already started and attached to a PTY. 11 | 12 | Author(s): 13 | - Michael Niksa (MiNiksa) 31-Aug-2020 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #include "ITerminalHandoff.h" 20 | 21 | #if defined(WT_BRANDING_RELEASE) 22 | #define __CLSID_CTerminalHandoff "E12CFF52-A866-4C77-9A90-F570A7AA2C6B" 23 | #elif defined(WT_BRANDING_PREVIEW) 24 | #define __CLSID_CTerminalHandoff "86633F1F-6454-40EC-89CE-DA4EBA977EE2" 25 | #else 26 | #define __CLSID_CTerminalHandoff "051F34EE-C1FD-4B19-AF75-9BA54648434C" 27 | #endif 28 | 29 | using NewHandoffFunction = HRESULT (*)(HANDLE, HANDLE, HANDLE, HANDLE, HANDLE, HANDLE); 30 | 31 | struct __declspec(uuid(__CLSID_CTerminalHandoff)) 32 | CTerminalHandoff : public Microsoft::WRL::RuntimeClass, ITerminalHandoff> 33 | { 34 | #pragma region ITerminalHandoff 35 | STDMETHODIMP EstablishPtyHandoff(HANDLE in, 36 | HANDLE out, 37 | HANDLE signal, 38 | HANDLE ref, 39 | HANDLE server, 40 | HANDLE client) override; 41 | 42 | #pragma endregion 43 | 44 | static HRESULT s_StartListening(NewHandoffFunction pfnHandoff); 45 | static HRESULT s_StopListening(); 46 | }; 47 | 48 | // Disable warnings from the CoCreatableClass macro as the value it provides for 49 | // automatic COM class registration is of much greater value than the nits from 50 | // the static analysis warnings. 51 | #pragma warning(push) 52 | 53 | #pragma warning(disable : 26477) // Macro uses 0/NULL over nullptr. 54 | #pragma warning(disable : 26476) // Macro uses naked union over variant. 55 | 56 | CoCreatableClass(CTerminalHandoff); 57 | 58 | #pragma warning(pop) 59 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/ConnectionInformation.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ConnectionInformation.h" 3 | #include "ConnectionInformation.g.cpp" 4 | 5 | namespace winrt::Microsoft::Terminal::TerminalConnection::implementation 6 | { 7 | ConnectionInformation::ConnectionInformation(const hstring& className, 8 | const Windows::Foundation::Collections::ValueSet& settings) : 9 | _ClassName{ className }, 10 | _Settings{ settings } 11 | { 12 | } 13 | 14 | // Function Description: 15 | // - Create an instance of the connection specified in the 16 | // ConnectionInformation, and Initialize it. 17 | // - This static method allows the content process to create a connection 18 | // from information that lives in the window process. 19 | // Arguments: 20 | // - info: A ConnectionInformation object that possibly lives out-of-proc, 21 | // containing the name of the WinRT class we should activate for this 22 | // connection, and a bag of setting to use to initialize that object. 23 | // Return Value: 24 | // - 25 | TerminalConnection::ITerminalConnection ConnectionInformation::CreateConnection(TerminalConnection::ConnectionInformation info) 26 | try 27 | { 28 | Windows::Foundation::IInspectable inspectable{}; 29 | 30 | const auto name = static_cast(winrt::get_abi(info.ClassName())); 31 | const auto pointer = winrt::put_abi(inspectable); 32 | 33 | #pragma warning(push) 34 | #pragma warning(disable : 26490) 35 | // C++/WinRT just loves it's void**, nothing we can do here _except_ reinterpret_cast 36 | auto raw = reinterpret_cast<::IInspectable**>(pointer); 37 | #pragma warning(pop) 38 | 39 | // RoActivateInstance() will try to create an instance of the object, 40 | // who's fully qualified name is the string in Name(). 41 | // 42 | // The class has to be activatable. For the Terminal, this is easy 43 | // enough - we're not hosting anything that's not already in our 44 | // manifest, or living as a .dll & .winmd SxS. 45 | // 46 | // When we get to extensions (GH#4000), we may want to revisit. 47 | if (LOG_IF_FAILED(RoActivateInstance(name, raw))) 48 | { 49 | return nullptr; 50 | } 51 | 52 | // Now that thing we made, make sure it's actually a ITerminalConnection 53 | if (const auto connection{ inspectable.try_as() }) 54 | { 55 | // Initialize it, and return it. 56 | connection.Initialize(info.Settings()); 57 | return connection; 58 | } 59 | return nullptr; 60 | } 61 | catch (...) 62 | { 63 | LOG_CAUGHT_EXCEPTION(); 64 | return nullptr; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/ConnectionInformation.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | Copyright (c) Microsoft Corporation 3 | Licensed under the MIT license. 4 | 5 | Class Name: 6 | - ConnectionInformation.h 7 | 8 | Abstract: 9 | - This is a helper object for storing both the name of a type of connection, and 10 | a bag of settings to use to initialize that connection. 11 | - This helper is used primarily in cross-proc scenarios, to allow the window 12 | process to tell the content process the name of the connection type it wants 13 | created, and how to set that connection up. This is done so the connection can 14 | live entirely in the content process, without having to go through the window 15 | process at all. 16 | --*/ 17 | 18 | #pragma once 19 | #include "ConnectionInformation.g.h" 20 | 21 | namespace winrt::Microsoft::Terminal::TerminalConnection::implementation 22 | { 23 | struct ConnectionInformation : ConnectionInformationT 24 | { 25 | ConnectionInformation(const hstring& className, 26 | const Windows::Foundation::Collections::ValueSet& settings); 27 | 28 | static TerminalConnection::ITerminalConnection CreateConnection(TerminalConnection::ConnectionInformation info); 29 | 30 | winrt::hstring ClassName() const { return _ClassName; } 31 | void ClassName(const winrt::hstring& value) { _ClassName = value; } 32 | 33 | WINRT_PROPERTY(Windows::Foundation::Collections::ValueSet, Settings); 34 | 35 | private: 36 | winrt::hstring _ClassName{}; 37 | }; 38 | } 39 | namespace winrt::Microsoft::Terminal::TerminalConnection::factory_implementation 40 | { 41 | BASIC_FACTORY(ConnectionInformation); 42 | } 43 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/ConnectionInformation.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "ITerminalConnection.idl"; 5 | 6 | namespace Microsoft.Terminal.TerminalConnection 7 | { 8 | [default_interface] runtimeclass ConnectionInformation 9 | { 10 | ConnectionInformation(String className, Windows.Foundation.Collections.ValueSet settings); 11 | String ClassName { get; }; 12 | Windows.Foundation.Collections.ValueSet Settings { get; }; 13 | 14 | static ITerminalConnection CreateConnection(ConnectionInformation info); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/ConptyConnection.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "ITerminalConnection.idl"; 5 | 6 | namespace Microsoft.Terminal.TerminalConnection 7 | { 8 | delegate void NewConnectionHandler(ConptyConnection connection); 9 | 10 | [default_interface] runtimeclass ConptyConnection : ITerminalConnection 11 | { 12 | ConptyConnection(); 13 | Guid Guid { get; }; 14 | String Commandline { get; }; 15 | 16 | void ClearBuffer(); 17 | 18 | void ShowHide(Boolean show); 19 | 20 | void ReparentWindow(UInt64 newParent); 21 | 22 | static event NewConnectionHandler NewConnection; 23 | static void StartInboundListener(); 24 | static void StopInboundListener(); 25 | 26 | static Windows.Foundation.Collections.ValueSet CreateSettings(String cmdline, 27 | String startingDirectory, 28 | String startingTitle, 29 | IMapView environment, 30 | UInt32 rows, 31 | UInt32 columns, 32 | Guid guid); 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/EchoConnection.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "EchoConnection.h" 6 | #include 7 | 8 | #include "EchoConnection.g.cpp" 9 | 10 | namespace winrt::Microsoft::Terminal::TerminalConnection::implementation 11 | { 12 | EchoConnection::EchoConnection() noexcept 13 | { 14 | } 15 | 16 | void EchoConnection::Start() noexcept 17 | { 18 | } 19 | 20 | void EchoConnection::WriteInput(const hstring& data) 21 | { 22 | std::wstringstream prettyPrint; 23 | for (const auto& wch : data) 24 | { 25 | if (wch < 0x20) 26 | { 27 | prettyPrint << L"^" << gsl::narrow_cast(wch + 0x40); 28 | } 29 | else if (wch == 0x7f) 30 | { 31 | prettyPrint << L"0x7f"; 32 | } 33 | else 34 | { 35 | prettyPrint << wch; 36 | } 37 | } 38 | _TerminalOutputHandlers(prettyPrint.str()); 39 | } 40 | 41 | void EchoConnection::Resize(uint32_t /*rows*/, uint32_t /*columns*/) noexcept 42 | { 43 | } 44 | 45 | void EchoConnection::Close() noexcept 46 | { 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/EchoConnection.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "EchoConnection.g.h" 7 | 8 | namespace winrt::Microsoft::Terminal::TerminalConnection::implementation 9 | { 10 | struct EchoConnection : EchoConnectionT 11 | { 12 | EchoConnection() noexcept; 13 | 14 | void Start() noexcept; 15 | void WriteInput(const hstring& data); 16 | void Resize(uint32_t rows, uint32_t columns) noexcept; 17 | void Close() noexcept; 18 | 19 | void Initialize(const Windows::Foundation::Collections::ValueSet& /*settings*/) const noexcept {}; 20 | 21 | ConnectionState State() const noexcept { return ConnectionState::Connected; } 22 | 23 | WINRT_CALLBACK(TerminalOutput, TerminalOutputHandler); 24 | TYPED_EVENT(StateChanged, ITerminalConnection, IInspectable); 25 | }; 26 | } 27 | 28 | namespace winrt::Microsoft::Terminal::TerminalConnection::factory_implementation 29 | { 30 | BASIC_FACTORY(EchoConnection); 31 | } 32 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/EchoConnection.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "ITerminalConnection.idl"; 5 | 6 | namespace Microsoft.Terminal.TerminalConnection 7 | { 8 | [default_interface] 9 | runtimeclass EchoConnection : ITerminalConnection 10 | { 11 | EchoConnection(); 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/ITerminalConnection.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.TerminalConnection 5 | { 6 | enum ConnectionState 7 | { 8 | NotConnected = 0, 9 | Connecting, 10 | Connected, 11 | Closing, 12 | Closed, 13 | Failed 14 | }; 15 | 16 | delegate void TerminalOutputHandler(String output); 17 | 18 | interface ITerminalConnection 19 | { 20 | void Initialize(Windows.Foundation.Collections.ValueSet settings); 21 | 22 | void Start(); 23 | void WriteInput(String data); 24 | void Resize(UInt32 rows, UInt32 columns); 25 | void Close(); 26 | 27 | event TerminalOutputHandler TerminalOutput; 28 | 29 | event Windows.Foundation.TypedEventHandler StateChanged; 30 | ConnectionState State { get; }; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/Microsoft.Terminal.TerminalConnection.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/Microsoft.Terminal.TerminalConnection.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/PassThroughConnection.h: -------------------------------------------------------------------------------- 1 | // Written by Corillian, NOT Microsoft 2 | // Unfortunately, the WinRT toolchain loudly complains 3 | // if I create a WinRT class under a namespace other 4 | // than the default namespace. I think this will likely 5 | // be something desired by a lot of users and I don't 6 | // think it makes sense to create a whole new assembly 7 | // for a single class so... this is why we can't have 8 | // nice things. 9 | 10 | #pragma once 11 | 12 | #include "PassThroughConnection.g.h" 13 | #include "../cascadia/inc/cppwinrt_utils.h" 14 | 15 | namespace winrt::Microsoft::Terminal::TerminalConnection::implementation 16 | { 17 | struct PassThroughConnection : PassThroughConnectionT 18 | { 19 | PassThroughConnection() noexcept; 20 | PassThroughConnection(const bool passThroughInput) noexcept; 21 | 22 | void Start() noexcept; 23 | void WriteInput(hstring const& data); 24 | void Resize(uint32_t rows, uint32_t columns) noexcept; 25 | void Close() noexcept; 26 | 27 | void Initialize(const Windows::Foundation::Collections::ValueSet& /*settings*/) const noexcept {}; 28 | 29 | void ClearBufferedData(); 30 | void WriteOutput(hstring const& data); 31 | void WriteLine(hstring const& data); 32 | 33 | ConnectionState State() const noexcept { return _connectionState.load(std::memory_order_acquire); } 34 | 35 | bool PassThroughInput() const noexcept; 36 | void PassThroughInput(const bool value) noexcept; 37 | 38 | WINRT_CALLBACK(TerminalOutput, TerminalOutputHandler); 39 | TYPED_EVENT(StateChanged, ITerminalConnection, IInspectable); 40 | 41 | private: 42 | std::unique_ptr> _bufferedData; 43 | std::mutex _bufferedDataMutex; 44 | std::atomic _connectionState{ ConnectionState::NotConnected }; 45 | std::atomic _passThroughInput; 46 | }; 47 | } 48 | 49 | namespace winrt::Microsoft::Terminal::TerminalConnection::factory_implementation 50 | { 51 | struct PassThroughConnection : PassThroughConnectionT 52 | { 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/PassThroughConnection.idl: -------------------------------------------------------------------------------- 1 | // Written by Corillian, NOT Microsoft 2 | // Unfortunately, the WinRT toolchain loudly complains 3 | // if I create a WinRT class under a namespace other 4 | // than the default namespace. I think this will likely 5 | // be something desired by a lot of users and I don't 6 | // think it makes sense to create a whole new assembly 7 | // for a single class so... this is why we can't have 8 | // nice things. 9 | 10 | import "ITerminalConnection.idl"; 11 | 12 | namespace Microsoft.Terminal.TerminalConnection 13 | { 14 | [default_interface] runtimeclass PassThroughConnection : ITerminalConnection 15 | { 16 | Boolean PassThroughInput; 17 | 18 | PassThroughConnection(); 19 | PassThroughConnection(Boolean passThroughInput); 20 | 21 | void WriteOutput(String data); 22 | void WriteLine(String data); 23 | void ClearBufferedData(); 24 | }; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/VersionInfo.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Version 51 | // 52 | 53 | VS_VERSION_INFO VERSIONINFO 54 | FILEVERSION 1,11,3471,0 55 | PRODUCTVERSION 1,11,3471,0 56 | FILEFLAGSMASK 0x3fL 57 | #ifdef _DEBUG 58 | FILEFLAGS 0x1L 59 | #else 60 | FILEFLAGS 0x0L 61 | #endif 62 | FILEOS 0x40004L 63 | FILETYPE 0x2L 64 | FILESUBTYPE 0x0L 65 | BEGIN 66 | BLOCK "StringFileInfo" 67 | BEGIN 68 | BLOCK "040904b0" 69 | BEGIN 70 | VALUE "FileDescription", "Windows Terminal Connection" 71 | VALUE "FileVersion", "1.11.3471.0" 72 | VALUE "InternalName", "Microsoft.Terminal.TerminalConnection" 73 | VALUE "LegalCopyright", "Copyright (C) 2022" 74 | VALUE "OriginalFilename", "Microsoft.Terminal.TerminalConnection" 75 | VALUE "ProductName", "Windows Terminal" 76 | VALUE "ProductVersion", "1.11.3471.0" 77 | END 78 | END 79 | BLOCK "VarFileInfo" 80 | BEGIN 81 | VALUE "Translation", 0x409, 1200 82 | END 83 | END 84 | 85 | #endif // English (United States) resources 86 | ///////////////////////////////////////////////////////////////////////////// 87 | 88 | 89 | 90 | #ifndef APSTUDIO_INVOKED 91 | ///////////////////////////////////////////////////////////////////////////// 92 | // 93 | // Generated from the TEXTINCLUDE 3 resource. 94 | // 95 | 96 | 97 | ///////////////////////////////////////////////////////////////////////////// 98 | #endif // not APSTUDIO_INVOKED 99 | 100 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/init.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include 6 | 7 | BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD reason, LPVOID /*reserved*/) 8 | { 9 | switch(reason) 10 | { 11 | case DLL_PROCESS_ATTACH: 12 | DisableThreadLibraryCalls(hInstDll); 13 | break; 14 | case DLL_PROCESS_DETACH: 15 | break; 16 | default: 17 | break; 18 | } 19 | 20 | return TRUE; 21 | } 22 | 23 | UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(L"Microsoft.Terminal.TerminalConnection/Resources"); 24 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Needs to be defined or we get redeclaration errors 4 | #define WIN32_LEAN_AND_MEAN 5 | #define NOMCX 6 | #define NOHELP 7 | #define NOCOMM 8 | 9 | // Manually include til after we include Windows.Foundation to give it winrt superpowers 10 | #define BLOCK_TIL 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | TerminalConnection Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the Windows App SDK and 7 | C++/WinRT packages to generate implementation headers from interface 8 | (IDL) files. The generated Windows Runtime component binary and WinMD 9 | files should then be bundled with the app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about Windows App SDK here: 22 | https://docs.microsoft.com/windows/apps/windows-app-sdk/ 23 | Learn more about WinUI3 here: 24 | https://docs.microsoft.com/windows/apps/winui/winui3/ 25 | Learn more about C++/WinRT here: 26 | http://aka.ms/cppwinrt/ 27 | ======================================================================== 28 | -------------------------------------------------------------------------------- /OpenConsole/Microsoft.Terminal.TerminalConnection/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by VersionInfo.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/ICoreSettings.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | import "ICoreAppearance.idl"; 5 | 6 | namespace Microsoft.Terminal.Core 7 | { 8 | interface ICoreSettings requires ICoreAppearance 9 | { 10 | // TODO:MSFT:20642297 - define a sentinel for Infinite Scrollback 11 | Int32 HistorySize; 12 | Int32 InitialRows; 13 | Int32 InitialCols; 14 | 15 | Boolean SnapOnInput; 16 | Boolean AltGrAliasing; 17 | 18 | String StartingTitle; 19 | Boolean SuppressApplicationTitle; 20 | String WordDelimiters; 21 | 22 | Boolean ForceVTInput; 23 | Boolean TrimBlockSelection; 24 | Boolean DetectURLs; 25 | Boolean VtPassthrough; 26 | 27 | Windows.Foundation.IReference TabColor; 28 | Windows.Foundation.IReference StartingTabColor; 29 | }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/ITerminalInput.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "ControlKeyStates.hpp" 7 | 8 | namespace Microsoft::Terminal::Core 9 | { 10 | class ITerminalInput 11 | { 12 | public: 13 | virtual ~ITerminalInput() {} 14 | ITerminalInput(const ITerminalInput&) = default; 15 | ITerminalInput(ITerminalInput&&) = default; 16 | ITerminalInput& operator=(const ITerminalInput&) = default; 17 | ITerminalInput& operator=(ITerminalInput&&) = default; 18 | 19 | virtual bool SendKeyEvent(const WORD vkey, const WORD scanCode, const ControlKeyStates states, const bool keyDown) = 0; 20 | virtual bool SendMouseEvent(const COORD viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const Microsoft::Console::VirtualTerminal::TerminalInput::MouseButtonState state) = 0; 21 | virtual bool SendCharEvent(const wchar_t ch, const WORD scanCode, const ControlKeyStates states) = 0; 22 | 23 | [[nodiscard]] virtual HRESULT UserResize(const COORD size) noexcept = 0; 24 | virtual void UserScrollViewport(const int viewTop) = 0; 25 | virtual int GetScrollOffset() = 0; 26 | 27 | virtual void TrySnapOnInput() = 0; 28 | 29 | virtual void FocusChanged(const bool focused) = 0; 30 | 31 | protected: 32 | ITerminalInput() = default; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/TerminalCore.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/TerminalCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | // We're suspending the inclusion of til here so that we can include 7 | // it after some of our C++/WinRT headers. 8 | #define BLOCK_TIL 9 | #include 10 | #include 11 | 12 | #include 13 | #include -------------------------------------------------------------------------------- /OpenConsole/TerminalCore/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | TerminalCore Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the Windows App SDK and 7 | C++/WinRT packages to generate implementation headers from interface 8 | (IDL) files. The generated Windows Runtime component binary and WinMD 9 | files should then be bundled with the app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about Windows App SDK here: 22 | https://docs.microsoft.com/windows/apps/windows-app-sdk/ 23 | Learn more about WinUI3 here: 24 | https://docs.microsoft.com/windows/apps/winui/winui3/ 25 | Learn more about C++/WinRT here: 26 | http://aka.ms/cppwinrt/ 27 | ======================================================================== 28 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/LibraryResources.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | #include "ScopedResourceLoader.h" 6 | #include "LibraryResources.h" 7 | 8 | /* 9 | CHECKED RESOURCES 10 | This is the support infrastructure for "checked resources", a system that lets 11 | us immediately failfast (on launch) when a library makes a static reference to 12 | a resource that doesn't exist at runtime. 13 | 14 | Resource checking relies on diligent use of USES_RESOURCE() and RS_() (which 15 | uses USES_RESOURCE), but can make sure we don't ship something that'll blow up 16 | at runtime. 17 | 18 | It works like this: 19 | ** IN DEBUG MODE ** 20 | - All resource names referenced through USES_RESOURCE() are emitted alongside 21 | their referencing filenames and line numbers into a static section of the 22 | binary. 23 | That section is named .util$res$m. 24 | 25 | - We emit two sentinel values into two different sections, .util$res$a and 26 | .util$res$z. 27 | 28 | - The linker sorts all sections alphabetically before crushing them together 29 | into the final binary. 30 | 31 | - When we first construct our library's scoped resource loader, we iterate over 32 | every resource reference between $a and $z and check residency. 33 | 34 | ** IN RELEASE MODE ** 35 | - All checked resource code is compiled out. 36 | */ 37 | 38 | extern const wchar_t* g_WinRTUtilsLibraryResourceScope; 39 | 40 | #ifdef _DEBUG 41 | #pragma detect_mismatch("winrt_utils_debug", "1") 42 | 43 | #pragma section(".util$res$a", read) 44 | #pragma section(".util$res$z", read) 45 | 46 | __declspec(allocate(".util$res$a")) static const ::Microsoft::Console::Utils::StaticResource* debugResFirst{ nullptr }; 47 | __declspec(allocate(".util$res$z")) static const ::Microsoft::Console::Utils::StaticResource* debugResLast{ nullptr }; 48 | 49 | static void EnsureAllResourcesArePresent(const ScopedResourceLoader& loader) 50 | { 51 | for (auto resp = &debugResFirst; resp != &debugResLast; ++resp) 52 | { 53 | if (*resp) 54 | { 55 | const auto& res = **resp; 56 | if (!loader.HasResourceWithName(res.resourceKey)) 57 | { 58 | auto filename = wcsrchr(res.filename, L'\\'); 59 | if (!filename) 60 | { 61 | filename = res.filename; 62 | } 63 | else 64 | { 65 | filename++; // skip the '\' 66 | } 67 | 68 | FAIL_FAST_MSG("Resource %ls not found in scope %ls (%ls:%u)", res.resourceKey, g_WinRTUtilsLibraryResourceScope, filename, res.line); 69 | } 70 | } 71 | } 72 | } 73 | #else // _DEBUG 74 | 75 | #pragma detect_mismatch("winrt_utils_debug", "0") 76 | 77 | #endif 78 | 79 | static ScopedResourceLoader GetLibraryResourceLoader() 80 | try 81 | { 82 | ScopedResourceLoader loader{ g_WinRTUtilsLibraryResourceScope }; 83 | #ifdef _DEBUG 84 | EnsureAllResourcesArePresent(loader); 85 | #endif 86 | return loader; 87 | } 88 | CATCH_FAIL_FAST() 89 | 90 | winrt::hstring GetLibraryResourceString(const std::wstring_view key) 91 | try 92 | { 93 | static auto loader{ GetLibraryResourceLoader() }; 94 | return loader.GetLocalizedString(key); 95 | } 96 | CATCH_FAIL_FAST() 97 | 98 | bool HasLibraryResourceWithName(const std::wstring_view key) 99 | try 100 | { 101 | static auto loader{ GetLibraryResourceLoader() }; 102 | return loader.HasResourceWithName(key); 103 | } 104 | CATCH_FAIL_FAST() 105 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/ScopedResourceLoader.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | 6 | #include "ScopedResourceLoader.h" 7 | 8 | using namespace ::winrt::Microsoft::Windows::ApplicationModel::Resources; 9 | 10 | ScopedResourceLoader::ScopedResourceLoader(const std::wstring_view resourceLocatorBase) : 11 | _resourceManager{}, 12 | _resourceMap{ _resourceManager.MainResourceMap().GetSubtree(resourceLocatorBase) }, 13 | _resourceContext{ _resourceManager.CreateResourceContext() } 14 | { 15 | } 16 | 17 | // Method Description: 18 | // - Gets the resource map associated with the scoped resource subcompartment. 19 | // Return Value: 20 | // - the resource map associated with the scoped resource subcompartment. 21 | ResourceMap ScopedResourceLoader::GetResourceMap() const noexcept 22 | { 23 | return _resourceMap; 24 | } 25 | 26 | // Method Description: 27 | // - Loads the localized string resource with the given key from the scoped 28 | // resource subcompartment. 29 | // - This resource loader is view-independent; it cannot take into account scale 30 | // factors and view themes. Strings should not vary based on those things. 31 | // Arguments: 32 | // - resourceName: the key up by which to look the resource 33 | // Return Value: 34 | // - The final localized string for the given key. 35 | winrt::hstring ScopedResourceLoader::GetLocalizedString(const std::wstring_view resourceName) const 36 | { 37 | return _resourceMap.GetValue(resourceName, _resourceContext).ValueAsString(); 38 | } 39 | 40 | // Method Description: 41 | // - Returns whether this resource loader can find a resource with the given key. 42 | // Arguments: 43 | // - resourceName: the key up by which to look the resource 44 | // Return Value: 45 | // - A boolean indicating whether the resource was found 46 | bool ScopedResourceLoader::HasResourceWithName(const std::wstring_view resourceName) const 47 | { 48 | return _resourceMap.TryGetValue(resourceName, _resourceContext).operator bool(); 49 | } 50 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/Utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "pch.h" 7 | #include "Utils.h" 8 | 9 | // Function Description: 10 | // - Helper that opens a file picker pre-seeded with image file types. 11 | winrt::Windows::Foundation::IAsyncOperation OpenImagePicker(HWND parentHwnd) 12 | { 13 | static constexpr COMDLG_FILTERSPEC supportedImageFileTypes[] = { 14 | { L"All Supported Bitmap Types (*.jpg, *.jpeg, *.png, *.bmp, *.gif, *.tiff, *.ico)", L"*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.tiff;*.ico" }, 15 | { L"All Files (*.*)", L"*.*" } 16 | }; 17 | 18 | static constexpr winrt::guid clientGuidImagePicker{ 0x55675F54, 0x74A1, 0x4552, { 0xA3, 0x9D, 0x94, 0xAE, 0x85, 0xD8, 0xF2, 0x7A } }; 19 | return OpenFilePicker(parentHwnd, [](auto&& dialog) { 20 | THROW_IF_FAILED(dialog->SetClientGuid(clientGuidImagePicker)); 21 | try 22 | { 23 | auto pictureFolderShellItem{ winrt::capture(&SHGetKnownFolderItem, FOLDERID_PicturesLibrary, KF_FLAG_DEFAULT, nullptr) }; 24 | dialog->SetDefaultFolder(pictureFolderShellItem.get()); 25 | } 26 | CATCH_LOG(); // non-fatal 27 | 28 | #pragma warning(suppress : 26485) // so we can pass in the supportedImageFileTypes without the analyzer complaining 29 | THROW_IF_FAILED(dialog->SetFileTypes(ARRAYSIZE(supportedImageFileTypes), supportedImageFileTypes)); 30 | THROW_IF_FAILED(dialog->SetFileTypeIndex(1)); // the array is 1-indexed 31 | THROW_IF_FAILED(dialog->SetDefaultExtension(L"jpg;jpeg;png;bmp;gif;tiff;ico")); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/WinRTUtils.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/inc/LibraryResources.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | /* 7 | USING RESOURCES 8 | To use PRI resources that are included alongside your library: 9 | - In one file, use 10 | UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(L"ResourceScope"). The 11 | provided scope will be used as the basename for all library 12 | resource lookups with RS_() or GetLibraryLocalizedString(). 13 | - Use RS_(L"ResourceName") for all statically-known resource 14 | names. 15 | - Use GetLibraryResourceString(string) for all resource lookups 16 | for keys known only at runtime. 17 | - For any static resource lookups that are deferred through 18 | another function call, use USES_RESOURCE(L"Key") to ensure the 19 | key is tracked. 20 | */ 21 | 22 | #ifdef _DEBUG 23 | 24 | /* 25 | The definitions in this section exist to support checked resources. 26 | Check out the comment in LibraryResources.cpp to learn more. 27 | */ 28 | 29 | // Don't let non-debug and debug builds live together. 30 | #pragma detect_mismatch("winrt_utils_debug", "1") 31 | 32 | #pragma section(".util$res$m", read) 33 | 34 | namespace Microsoft::Console::Utils 35 | { 36 | struct StaticResource 37 | { 38 | const wchar_t* resourceKey; 39 | const wchar_t* filename; 40 | unsigned int line; 41 | }; 42 | } 43 | 44 | #define USES_RESOURCE(x) ([]() { \ 45 | static const ::Microsoft::Console::Utils::StaticResource res{ \ 46 | (x), __FILEW__, __LINE__ \ 47 | }; \ 48 | __declspec(allocate(".util$res$m")) static auto pRes{ &res }; \ 49 | return pRes->resourceKey; \ 50 | }()) 51 | #define RS_(x) GetLibraryResourceString(USES_RESOURCE(x)) 52 | 53 | #else // _DEBUG 54 | 55 | #pragma detect_mismatch("winrt_utils_debug", "0") 56 | 57 | #define USES_RESOURCE(x) (x) 58 | #define RS_(x) GetLibraryResourceString((x)) 59 | 60 | #endif 61 | 62 | // For things that need UTF-8 strings 63 | #define RS_A(x) (winrt::to_string(RS_(x))) 64 | 65 | // Array-to-pointer decay might technically be avoidable, but this is elegant and clean. 66 | #define UTILS_DEFINE_LIBRARY_RESOURCE_SCOPE(x) \ 67 | __pragma(warning(suppress : 26485)); \ 68 | __declspec(selectany) extern const wchar_t* g_WinRTUtilsLibraryResourceScope{ (x) }; 69 | 70 | winrt::hstring GetLibraryResourceString(const std::wstring_view key); 71 | bool HasLibraryResourceWithName(const std::wstring_view key); 72 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/inc/ScopedResourceLoader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | class ScopedResourceLoader 9 | { 10 | public: 11 | ScopedResourceLoader(const std::wstring_view resourceLocatorBase); 12 | winrt::Microsoft::Windows::ApplicationModel::Resources::ResourceMap GetResourceMap() const noexcept; 13 | winrt::hstring GetLocalizedString(const std::wstring_view resourceName) const; 14 | bool HasResourceWithName(const std::wstring_view resourceName) const; 15 | 16 | private: 17 | winrt::Microsoft::Windows::ApplicationModel::Resources::ResourceManager _resourceManager; 18 | winrt::Microsoft::Windows::ApplicationModel::Resources::ResourceMap _resourceMap; 19 | winrt::Microsoft::Windows::ApplicationModel::Resources::ResourceContext _resourceContext; 20 | }; 21 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/inc/Utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | // Function Description: 7 | // - This function presents a File Open "common dialog" and returns its selected file asynchronously. 8 | // Parameters: 9 | // - customize: A lambda that receives an IFileDialog* to customize. 10 | // Return value: 11 | // (async) path to the selected item. 12 | template 13 | winrt::Windows::Foundation::IAsyncOperation FilePicker(HWND parentHwnd, bool saveDialog, TLambda&& customize) 14 | { 15 | auto fileDialog{ saveDialog ? winrt::create_instance(CLSID_FileSaveDialog) : 16 | winrt::create_instance(CLSID_FileOpenDialog) }; 17 | DWORD flags{}; 18 | THROW_IF_FAILED(fileDialog->GetOptions(&flags)); 19 | THROW_IF_FAILED(fileDialog->SetOptions(flags | FOS_FORCEFILESYSTEM | FOS_NOCHANGEDIR | FOS_DONTADDTORECENT)); // filesystem objects only; no recent places 20 | customize(fileDialog.get()); 21 | 22 | const auto hr{ fileDialog->Show(parentHwnd) }; 23 | if (!SUCCEEDED(hr)) 24 | { 25 | if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) 26 | { 27 | co_return winrt::hstring{}; 28 | } 29 | THROW_HR(hr); 30 | } 31 | 32 | winrt::com_ptr result; 33 | THROW_IF_FAILED(fileDialog->GetResult(result.put())); 34 | 35 | wil::unique_cotaskmem_string filePath; 36 | THROW_IF_FAILED(result->GetDisplayName(SIGDN_FILESYSPATH, &filePath)); 37 | 38 | co_return winrt::hstring{ filePath.get() }; 39 | } 40 | 41 | template 42 | winrt::Windows::Foundation::IAsyncOperation OpenFilePicker(HWND parentHwnd, TLambda&& customize) 43 | { 44 | return FilePicker(parentHwnd, false, customize); 45 | } 46 | template 47 | winrt::Windows::Foundation::IAsyncOperation SaveFilePicker(HWND parentHwnd, TLambda&& customize) 48 | { 49 | return FilePicker(parentHwnd, true, customize); 50 | } 51 | 52 | winrt::Windows::Foundation::IAsyncOperation OpenImagePicker(HWND parentHwnd); 53 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/pch.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #include "pch.h" 5 | -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/pch.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | // 4 | // pch.h 5 | // Header for platform projection include files 6 | // 7 | 8 | #pragma once 9 | 10 | #define WIN32_LEAN_AND_MEAN 11 | #define NOMCX 12 | #define NOHELP 13 | #define NOCOMM 14 | 15 | #include 16 | // This is inexplicable, but for whatever reason, cppwinrt conflicts with the 17 | // SDK definition of this function, so the only fix is to undef it. 18 | // from WinBase.h 19 | // Windows::UI::Xaml::Media::Animation::IStoryboard::GetCurrentTime 20 | #ifdef GetCurrentTime 21 | #undef GetCurrentTime 22 | #endif 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | #include -------------------------------------------------------------------------------- /OpenConsole/WinRTUtils/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | WinRTUtils Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the Windows App SDK and 7 | C++/WinRT packages to generate implementation headers from interface 8 | (IDL) files. The generated Windows Runtime component binary and WinMD 9 | files should then be bundled with the app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about Windows App SDK here: 22 | https://docs.microsoft.com/windows/apps/windows-app-sdk/ 23 | Learn more about WinUI3 here: 24 | https://docs.microsoft.com/windows/apps/winui/winui3/ 25 | Learn more about C++/WinRT here: 26 | http://aka.ms/cppwinrt/ 27 | ======================================================================== 28 | -------------------------------------------------------------------------------- /OpenConsole/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OpenConsole/patches/KeyChord.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | #pragma once 5 | 6 | #include "KeyChord.g.h" 7 | 8 | namespace winrt::Microsoft::Terminal::Control::implementation 9 | { 10 | struct KeyChord : KeyChordT 11 | { 12 | KeyChord() noexcept = default; 13 | KeyChord(const winrt::Windows::System::VirtualKeyModifiers modifiers, int32_t vkey, int32_t scanCode) noexcept; 14 | KeyChord(bool ctrl, bool alt, bool shift, bool win, int32_t vkey, int32_t scanCode) noexcept; 15 | 16 | uint64_t Hash() const noexcept; 17 | bool DeepEquals(const Control::KeyChord& other) const noexcept; 18 | 19 | winrt::Windows::System::VirtualKeyModifiers Modifiers() const noexcept; 20 | void Modifiers(const winrt::Windows::System::VirtualKeyModifiers value) noexcept; 21 | int32_t Vkey() const noexcept; 22 | void Vkey(int32_t value) noexcept; 23 | int32_t ScanCode() const noexcept; 24 | void ScanCode(int32_t value) noexcept; 25 | 26 | private: 27 | winrt::Windows::System::VirtualKeyModifiers _modifiers{}; 28 | int32_t _vkey{}; 29 | int32_t _scanCode{}; 30 | }; 31 | } 32 | 33 | namespace winrt::Microsoft::Terminal::Control::factory_implementation 34 | { 35 | struct KeyChord : KeyChordT 36 | { 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /OpenConsole/patches/KeyChord.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | namespace Microsoft.Terminal.Control 5 | { 6 | [default_interface] 7 | runtimeclass KeyChord 8 | { 9 | KeyChord(); 10 | KeyChord(Windows.System.VirtualKeyModifiers modifiers, Int32 vkey, Int32 scanCode); 11 | KeyChord(Boolean ctrl, Boolean alt, Boolean shift, Boolean win, Int32 vkey, Int32 scanCode); 12 | 13 | UInt64 Hash(); 14 | Boolean DeepEquals(KeyChord other); 15 | 16 | Windows.System.VirtualKeyModifiers Modifiers; 17 | Int32 Vkey; 18 | Int32 ScanCode; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SampleApp/README.md: -------------------------------------------------------------------------------- 1 | # SampleApp 2 | 3 | This is an example application showing a very simple integration of the Windows Terminal. It loads the global Windows Terminal settings, or uses defaults if they don't exist, and starts the default profile (PowerShell is the default). It does not register any of the command and event handlers, or do anything else, that a proper integration would do. You can look at [TerminalApp](https://github.com/microsoft/terminal/tree/main/src/cascadia/TerminalApp) to see how Windows Terminal actually works. -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/StoreLogo.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Images/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Corillian/WindowsTerminal/364883e6584288d6915ca1f83f8d9b362a61b769/SampleApp/SampleApp (Package)/Images/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /SampleApp/SampleApp (Package)/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | SampleApp (Package) 16 | Corillian 17 | Images\StoreLogo.png 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SampleApp/SampleApp/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /SampleApp/SampleApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | using Microsoft.UI.Xaml.Controls; 3 | using Microsoft.UI.Xaml.Controls.Primitives; 4 | using Microsoft.UI.Xaml.Data; 5 | using Microsoft.UI.Xaml.Input; 6 | using Microsoft.UI.Xaml.Media; 7 | using Microsoft.UI.Xaml.Navigation; 8 | using Microsoft.UI.Xaml.Shapes; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.IO; 12 | using System.Linq; 13 | using System.Runtime.InteropServices.WindowsRuntime; 14 | using Windows.ApplicationModel; 15 | using Windows.ApplicationModel.Activation; 16 | using Windows.Foundation; 17 | using Windows.Foundation.Collections; 18 | 19 | // To learn more about WinUI, the WinUI project structure, 20 | // and more about our project templates, see: http://aka.ms/winui-project-info. 21 | 22 | namespace SampleApp 23 | { 24 | /// 25 | /// Provides application-specific behavior to supplement the default Application class. 26 | /// 27 | public partial class App : Application 28 | { 29 | /// 30 | /// Initializes the singleton application object. This is the first line of authored code 31 | /// executed, and as such is the logical equivalent of main() or WinMain(). 32 | /// 33 | public App() 34 | { 35 | this.InitializeComponent(); 36 | } 37 | 38 | /// 39 | /// Invoked when the application is launched normally by the end user. Other entry points 40 | /// will be used such as when the application is launched to open a specific file. 41 | /// 42 | /// Details about the launch request and process. 43 | protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) 44 | { 45 | m_window = new MainWindow(); 46 | m_window.Activate(); 47 | } 48 | 49 | private Window m_window; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /SampleApp/SampleApp/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /SampleApp/SampleApp/SampleApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | WinExe 4 | net6.0-windows10.0.19041.0 5 | 10.0.17763.0 6 | SampleApp 7 | app.manifest 8 | x86;x64;arm64 9 | win10-x86;win10-x64;win10-arm64 10 | true 11 | 10.0.18362.0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SampleApp/SampleApp/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /SampleAppUnpackaged/SampleAppUnpackaged.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows10.0.19041.0 6 | 10.0.17763.0 7 | enable 8 | enable 9 | AnyCPU;x64;x86 10 | true 11 | app.manifest 12 | 10.0.18362.0 13 | win10-x86;win10-x64 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | False 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SampleAppUnpackaged/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 54 | 55 | 56 | 57 | true 58 | PerMonitorV2 59 | true 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Tools/AnyCpuGenerator/AnyCpuGenerator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | $([MSBuild]::NormalizeDirectory('$(SolutionDir)', '_build', '$(Platform)', '$(Configuration)')) 12 | $([MSBuild]::NormalizeDirectory('$(BuildOutDir)', '$(MSBuildProjectName)', 'bin')) 13 | $([MSBuild]::NormalizeDirectory('$(BuildOutDir)', '$(MSBuildProjectName)', 'obj')) 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Tools/AnyCpuGenerator/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace AnyCpuGenerator 4 | { 5 | public static class Program 6 | { 7 | [STAThread] 8 | public static int Main(string[] args) 9 | { 10 | if(args.Length < 2 || args.Length > 3) 11 | { 12 | Console.WriteLine("Usage: AnyCpuGenerator.exe "); 13 | return 1; 14 | } 15 | 16 | var sourcePath = Path.GetFullPath(args[0]); 17 | var destPath = Path.GetFullPath(args[1]); 18 | var keyPairPath = args.Length > 2 ? Path.GetFullPath(args[2]) : null; 19 | 20 | if(!File.Exists(args[0])) 21 | { 22 | Console.WriteLine($"Source assembly {args[0]} does not exist."); 23 | return 2; 24 | } 25 | 26 | if(sourcePath.Equals(destPath, System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) 27 | { 28 | Console.WriteLine("The source assembly and the destination assembly cannot be the same."); 29 | return 3; 30 | } 31 | 32 | if(keyPairPath != null && !File.Exists(keyPairPath)) 33 | { 34 | Console.WriteLine($"Invalid key pair: {keyPairPath}"); 35 | return 4; 36 | } 37 | 38 | Mono.Cecil.ReaderParameters parms = new(Mono.Cecil.ReadingMode.Immediate); 39 | using var module = Mono.Cecil.ModuleDefinition.ReadModule(sourcePath, parms); 40 | 41 | if((module.Attributes & Mono.Cecil.ModuleAttributes.ILOnly) == 0) 42 | { 43 | Console.WriteLine("Cannot convert assembly to 'AnyCPU' because it isn't IL Only."); 44 | return 5; 45 | } 46 | 47 | var destDir = Path.GetDirectoryName(destPath); 48 | 49 | if(destDir != null && !Directory.Exists(destDir)) 50 | { 51 | Directory.CreateDirectory(destDir); 52 | } 53 | 54 | // x64: Architecture = AMD64, Attributes = ILOnly 55 | // x86: Architecture = I386, Attributes = ILOnly | Required32Bit 56 | // MSIL: Architecture = I386, Attributes = ILOnly 57 | module.Architecture = Mono.Cecil.TargetArchitecture.I386; 58 | module.Attributes &= ~(Mono.Cecil.ModuleAttributes.Required32Bit | Mono.Cecil.ModuleAttributes.Preferred32Bit); 59 | 60 | if(keyPairPath != null) 61 | { 62 | var writeParms = new Mono.Cecil.WriterParameters() { StrongNameKeyContainer = keyPairPath }; 63 | 64 | if(!writeParms.HasStrongNameKey) 65 | { 66 | Console.WriteLine($"Failed to load the strong name key pair: {keyPairPath}"); 67 | return 6; 68 | } 69 | 70 | module.Attributes |= Mono.Cecil.ModuleAttributes.StrongNameSigned; 71 | module.Write(destPath, writeParms); 72 | } 73 | else 74 | { 75 | module.Attributes &= ~Mono.Cecil.ModuleAttributes.StrongNameSigned; 76 | module.Write(destPath); 77 | } 78 | 79 | return 0; 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /UpdateOpenConsoleCppWinRT.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$false)] 3 | [string] $winrtver = '2.0.220608.4' 4 | ) 5 | 6 | $rootDir = [System.IO.Path]::GetDirectoryName($PSCommandPath) 7 | $openConsolePath = [System.IO.Path]::Combine($rootDir, 'external', 'terminal') 8 | $oldVer = '2.0.210825.3' 9 | $nugetProps = [System.IO.Path]::Combine($openConsolePath, 'src', 'common.nugetversions.props') 10 | $nugetTargets = [System.IO.Path]::Combine($openConsolePath, 'src', 'common.nugetversions.targets') 11 | $nugetConfig = [System.IO.Path]::Combine($openConsolePath, 'NuGet.config') 12 | $configFiles = Get-ChildItem $openConsolePath packages.config -rec 13 | 14 | foreach ($file in $configFiles) 15 | { 16 | (Get-Content $file.PSPath) | 17 | Foreach-Object { $_ -replace $oldVer, $winrtver } | 18 | Set-Content $file.PSPath 19 | } 20 | 21 | (Get-Content $nugetProps).Replace($oldVer, $winrtver) | Set-Content $nugetProps 22 | (Get-Content $nugetTargets).Replace($oldVer, $winrtver) | Set-Content $nugetTargets 23 | (Get-Content $nugetConfig).Replace('https://pkgs.dev.azure.com/ms/terminal/_packaging/TerminalDependencies/nuget/v3/index.json', 'https://api.nuget.org/v3/index.json') | Set-Content $nugetConfig 24 | --------------------------------------------------------------------------------