mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Rename the [Ee]xts dir to ext (#38852)
**WARNING:** This PR will probably blow up all in-flight PRs at some point in the early days of CmdPal, two of us created seperate `Exts` and `exts` dirs. Depending on what the casing was on the branch that you checked one of those out from, it'd get stuck like that on your PC forever. Windows didn't care, so we never noticed. But GitHub does care, and now browsing the source on GitHub is basically impossible. Closes #38081
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 503 B |
Binary file not shown.
|
After Width: | Height: | Size: 484 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,89 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 4.33333H5.33333V2H0.666667C0.3 2 0 2.3 0 2.66667V4.33333Z" fill="#CCCCCC"/>
|
||||
<path d="M10.6663 2H5.33301V4.33333H10.6663V2Z" fill="#999999"/>
|
||||
<path d="M16.0003 4.33333H10.667V2H15.3337C15.7003 2 16.0003 2.3 16.0003 2.66667V4.33333Z" fill="#666666"/>
|
||||
<path d="M15.3333 14H0.666667C0.3 14 0 13.7 0 13.3333V4H16V13.3333C16 13.7 15.7 14 15.3333 14Z" fill="url(#paint0_linear_1825_17865)"/>
|
||||
<g filter="url(#filter0_dd_1825_17865)">
|
||||
<path d="M5.06614 8.1L2.13281 11.0333C1.96615 11.2 1.96615 11.4333 2.13281 11.5667L2.73281 12.1667C2.89948 12.3333 3.13281 12.3333 3.26615 12.1667L6.19948 9.23333C6.36615 9.06666 6.36615 8.83333 6.19948 8.7L5.59948 8.1C5.46615 7.96667 5.19948 7.96667 5.06614 8.1Z" fill="url(#paint1_linear_1825_17865)"/>
|
||||
<mask id="mask0_1825_17865" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="2" y="8" width="5" height="5">
|
||||
<path d="M5.06614 8.1L2.13281 11.0333C1.96615 11.2 1.96615 11.4333 2.13281 11.5667L2.73281 12.1667C2.89948 12.3333 3.13281 12.3333 3.26615 12.1667L6.19948 9.23333C6.36615 9.06666 6.36615 8.83333 6.19948 8.7L5.59948 8.1C5.46615 7.96667 5.19948 7.96667 5.06614 8.1Z" fill="url(#paint2_linear_1825_17865)"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_1825_17865)">
|
||||
<g filter="url(#filter1_dd_1825_17865)">
|
||||
<path d="M3.26517 5.76602L6.1985 8.69935C6.36517 8.86602 6.36517 9.09935 6.1985 9.23268L5.5985 9.83268C5.43184 9.99935 5.1985 9.99935 5.06517 9.83268L2.13184 6.89935C1.96517 6.73268 1.96517 6.49935 2.13184 6.36602L2.73183 5.76602C2.86517 5.63268 3.13184 5.63268 3.26517 5.76602Z" fill="url(#paint3_linear_1825_17865)"/>
|
||||
</g>
|
||||
</g>
|
||||
<path d="M3.26712 5.76602L6.20045 8.69935C6.36712 8.86602 6.36712 9.09935 6.20045 9.23268L5.60046 9.83268C5.43379 9.99935 5.20045 9.99935 5.06712 9.83268L2.13379 6.89935C1.96712 6.73268 1.96712 6.49935 2.13379 6.36602L2.73379 5.76602C2.86712 5.63268 3.13379 5.63268 3.26712 5.76602Z" fill="url(#paint4_linear_1825_17865)"/>
|
||||
</g>
|
||||
<g filter="url(#filter2_dd_1825_17865)">
|
||||
<path d="M13.3337 10.666H8.00033C7.80033 10.666 7.66699 10.7993 7.66699 10.9993V11.9993C7.66699 12.1993 7.80033 12.3327 8.00033 12.3327H13.3337C13.5337 12.3327 13.667 12.1993 13.667 11.9993V10.9993C13.667 10.7993 13.5337 10.666 13.3337 10.666Z" fill="url(#paint5_linear_1825_17865)"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_dd_1825_17865" x="0.674479" y="4.66602" width="6.98405" height="9.29167" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="0.333333"/>
|
||||
<feGaussianBlur stdDeviation="0.666667"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1825_17865"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="0.333333"/>
|
||||
<feGaussianBlur stdDeviation="0.666667"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="effect1_dropShadow_1825_17865" result="effect2_dropShadow_1825_17865"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_1825_17865" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter1_dd_1825_17865" x="0.673503" y="4.66602" width="6.98307" height="6.95768" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="0.333333"/>
|
||||
<feGaussianBlur stdDeviation="0.666667"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1825_17865"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="0.333333"/>
|
||||
<feGaussianBlur stdDeviation="0.666667"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="effect1_dropShadow_1825_17865" result="effect2_dropShadow_1825_17865"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_1825_17865" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter2_dd_1825_17865" x="6.33366" y="9.66602" width="8.66667" height="4.33268" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="0.333333"/>
|
||||
<feGaussianBlur stdDeviation="0.666667"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1825_17865"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dy="0.333333"/>
|
||||
<feGaussianBlur stdDeviation="0.666667"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="effect1_dropShadow_1825_17865" result="effect2_dropShadow_1825_17865"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect2_dropShadow_1825_17865" result="shape"/>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_1825_17865" x1="12.1487" y1="15.9419" x2="3.94057" y2="1.72493" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#333333"/>
|
||||
<stop offset="1" stop-color="#4D4D4D"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_1825_17865" x1="4.84201" y1="11.332" x2="3.49418" y2="8.99747" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999999"/>
|
||||
<stop offset="1" stop-color="#B3B3B3"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_1825_17865" x1="4.84201" y1="11.332" x2="3.49418" y2="8.99747" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#999999"/>
|
||||
<stop offset="1" stop-color="#B3B3B3"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_1825_17865" x1="5.4234" y1="10.0105" x2="2.91084" y2="5.65872" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#CCCCCC"/>
|
||||
<stop offset="1" stop-color="#E6E6E6"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_1825_17865" x1="5.42535" y1="10.0105" x2="2.91279" y2="5.65872" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#CCCCCC"/>
|
||||
<stop offset="1" stop-color="#E6E6E6"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_1825_17865" x1="11.7169" y1="13.3178" x2="9.61713" y2="9.68092" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#CCCCCC"/>
|
||||
<stop offset="1" stop-color="#E6E6E6"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.6 KiB |
@@ -0,0 +1,101 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Windows.UI;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Commands;
|
||||
|
||||
internal sealed partial class LaunchProfileAsAdminCommand : InvokableCommand
|
||||
{
|
||||
private readonly string _id;
|
||||
private readonly string _profile;
|
||||
private readonly bool _openNewTab;
|
||||
private readonly bool _openQuake;
|
||||
|
||||
internal LaunchProfileAsAdminCommand(string id, string profile, bool openNewTab, bool openQuake)
|
||||
{
|
||||
this._id = id;
|
||||
this._profile = profile;
|
||||
this._openNewTab = openNewTab;
|
||||
this._openQuake = openQuake;
|
||||
|
||||
this.Name = Resources.launch_profile_as_admin;
|
||||
this.Icon = new IconInfo("\xE7EF"); // Admin icon
|
||||
}
|
||||
|
||||
private void LaunchElevated(string id, string profile)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = "shell:AppsFolder\\" + id;
|
||||
var arguments = TerminalHelper.GetArguments(profile, _openNewTab, _openQuake);
|
||||
|
||||
var startInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = path,
|
||||
Arguments = arguments,
|
||||
UseShellExecute = true,
|
||||
Verb = "runas",
|
||||
};
|
||||
|
||||
System.Diagnostics.Process.Start(startInfo);
|
||||
}
|
||||
#pragma warning disable IDE0059, CS0168, SA1005
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO GH #108 We need to figure out some logging
|
||||
//var name = "Plugin: " + Resources.plugin_name;
|
||||
//var message = Resources.run_terminal_failed;
|
||||
//Log.Exception("Failed to open Windows Terminal", ex, GetType());
|
||||
//_context.API.ShowMsg(name, message, string.Empty);
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0059, CS0168, SA1005
|
||||
|
||||
private void Launch(string id, string profile)
|
||||
{
|
||||
var appManager = new ApplicationActivationManager();
|
||||
const ActivateOptions noFlags = ActivateOptions.None;
|
||||
var queryArguments = TerminalHelper.GetArguments(profile, _openNewTab, _openQuake);
|
||||
try
|
||||
{
|
||||
appManager.ActivateApplication(id, queryArguments, noFlags, out var unusedPid);
|
||||
}
|
||||
#pragma warning disable IDE0059, CS0168
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO GH #108 We need to figure out some logging
|
||||
// var name = "Plugin: " + Resources.plugin_name;
|
||||
// var message = Resources.run_terminal_failed;
|
||||
// Log.Exception("Failed to open Windows Terminal", ex, GetType());
|
||||
// _context.API.ShowMsg(name, message, string.Empty);
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0059, CS0168
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
try
|
||||
{
|
||||
LaunchElevated(_id, _profile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO GH #108 We need to figure out some logging
|
||||
}
|
||||
|
||||
return CommandResult.Dismiss();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Windows.UI;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Commands;
|
||||
|
||||
internal sealed partial class LaunchProfileCommand : InvokableCommand
|
||||
{
|
||||
private readonly string _id;
|
||||
private readonly string _profile;
|
||||
private readonly bool _openNewTab;
|
||||
private readonly bool _openQuake;
|
||||
|
||||
internal LaunchProfileCommand(string id, string profile, string iconPath, bool openNewTab, bool openQuake)
|
||||
{
|
||||
this._id = id;
|
||||
this._profile = profile;
|
||||
this._openNewTab = openNewTab;
|
||||
this._openQuake = openQuake;
|
||||
|
||||
this.Name = Resources.launch_profile;
|
||||
this.Icon = new IconInfo(iconPath);
|
||||
}
|
||||
|
||||
private void Launch(string id, string profile)
|
||||
{
|
||||
var appManager = new ApplicationActivationManager();
|
||||
const ActivateOptions noFlags = ActivateOptions.None;
|
||||
var queryArguments = TerminalHelper.GetArguments(profile, _openNewTab, _openQuake);
|
||||
try
|
||||
{
|
||||
appManager.ActivateApplication(id, queryArguments, noFlags, out var unusedPid);
|
||||
}
|
||||
#pragma warning disable IDE0059, CS0168
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO GH #108 We need to figure out some logging
|
||||
// var name = "Plugin: " + Resources.plugin_name;
|
||||
// var message = Resources.run_terminal_failed;
|
||||
// Log.Exception("Failed to open Windows Terminal", ex, GetType());
|
||||
// _context.API.ShowMsg(name, message, string.Empty);
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0059, CS0168
|
||||
|
||||
public override CommandResult Invoke()
|
||||
{
|
||||
try
|
||||
{
|
||||
Launch(_id, _profile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO GH #108 We need to figure out some logging
|
||||
}
|
||||
|
||||
return CommandResult.Dismiss();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
|
||||
// Application Activation Manager Class
|
||||
[ComImport]
|
||||
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
|
||||
public class ApplicationActivationManager : IApplicationActivationManager
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
|
||||
public extern IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
public extern IntPtr ActivateForFile([In] string appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] string verb, [Out] out uint processId);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||
public extern IntPtr ActivateForProtocol([In] string appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out uint processId);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
|
||||
// Reference : https://github.com/MicrosoftEdge/edge-launcher/blob/108e63df0b4cb5cd9d5e45aa7a264690851ec51d/MIcrosoftEdgeLauncherCsharp/Program.cs
|
||||
[Flags]
|
||||
public enum ActivateOptions
|
||||
{
|
||||
None = 0x00000000,
|
||||
DesignMode = 0x00000001,
|
||||
NoErrorUI = 0x00000002,
|
||||
NoSplashScreen = 0x00000004,
|
||||
}
|
||||
|
||||
// ApplicationActivationManager
|
||||
[ComImport]
|
||||
[Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IApplicationActivationManager
|
||||
{
|
||||
IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);
|
||||
|
||||
IntPtr ActivateForFile([In] string appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] string verb, [Out] out uint processId);
|
||||
|
||||
IntPtr ActivateForProtocol([In] string appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out uint processId);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
|
||||
public interface ITerminalQuery
|
||||
{
|
||||
IEnumerable<TerminalProfile> GetProfiles();
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
|
||||
public class SettingsManager : JsonSettingsManager
|
||||
{
|
||||
private static readonly string _namespace = "wt";
|
||||
|
||||
private static string Namespaced(string propertyName) => $"{_namespace}.{propertyName}";
|
||||
|
||||
private readonly ToggleSetting _showHiddenProfiles = new(
|
||||
Namespaced(nameof(ShowHiddenProfiles)),
|
||||
Resources.show_hidden_profiles,
|
||||
Resources.show_hidden_profiles,
|
||||
false);
|
||||
|
||||
private readonly ToggleSetting _openNewTab = new(
|
||||
Namespaced(nameof(OpenNewTab)),
|
||||
Resources.open_new_tab,
|
||||
Resources.open_new_tab,
|
||||
false);
|
||||
|
||||
private readonly ToggleSetting _openQuake = new(
|
||||
Namespaced(nameof(OpenQuake)),
|
||||
Resources.open_quake,
|
||||
Resources.open_quake_description,
|
||||
false);
|
||||
|
||||
public bool ShowHiddenProfiles => _showHiddenProfiles.Value;
|
||||
|
||||
public bool OpenNewTab => _openNewTab.Value;
|
||||
|
||||
public bool OpenQuake => _openQuake.Value;
|
||||
|
||||
internal static string SettingsJsonPath()
|
||||
{
|
||||
var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
// now, the state is just next to the exe
|
||||
return Path.Combine(directory, "settings.json");
|
||||
}
|
||||
|
||||
public SettingsManager()
|
||||
{
|
||||
FilePath = SettingsJsonPath();
|
||||
|
||||
Settings.Add(_showHiddenProfiles);
|
||||
Settings.Add(_openNewTab);
|
||||
Settings.Add(_openQuake);
|
||||
|
||||
// Load settings from file upon initialization
|
||||
LoadSettings();
|
||||
|
||||
Settings.SettingsChanged += (s, a) => this.SaveSettings();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
|
||||
public static class TerminalHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the arguments for launch Windows Terminal
|
||||
/// </summary>
|
||||
/// <param name="profileName">Name of the Terminal profile</param>
|
||||
/// <param name="openNewTab">Whether to launch the profile in a new tab</param>
|
||||
/// <param name="openQuake">Whether to launch the profile in the quake window</param>
|
||||
public static string GetArguments(string profileName, bool openNewTab, bool openQuake)
|
||||
{
|
||||
var argsPrefix = string.Empty;
|
||||
if (openQuake)
|
||||
{
|
||||
// It does not matter whether we add the "nt" argument here; when specifying the
|
||||
// _quake window explicitly, Windows Terminal will always open a new tab when the
|
||||
// window exists, or open a new window when it does not yet.
|
||||
argsPrefix = "--window _quake";
|
||||
}
|
||||
else if (openNewTab)
|
||||
{
|
||||
argsPrefix = "--window 0 nt";
|
||||
}
|
||||
|
||||
return $"{argsPrefix} --profile \"{profileName}\"";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of profiles for the Windows Terminal
|
||||
/// </summary>
|
||||
/// <param name="terminal">Windows Terminal package</param>
|
||||
/// <param name="settingsJson">Content of the settings JSON file of the Terminal</param>
|
||||
public static List<TerminalProfile> ParseSettings(TerminalPackage terminal, string settingsJson)
|
||||
{
|
||||
var profiles = new List<TerminalProfile>();
|
||||
|
||||
var options = new JsonDocumentOptions
|
||||
{
|
||||
CommentHandling = JsonCommentHandling.Skip,
|
||||
AllowTrailingCommas = true,
|
||||
};
|
||||
|
||||
var json = JsonDocument.Parse(settingsJson, options);
|
||||
JsonElement profilesList;
|
||||
|
||||
json.RootElement.TryGetProperty("profiles", out var profilesElement);
|
||||
if (profilesElement.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
profilesElement.TryGetProperty("list", out profilesList);
|
||||
if (profilesList.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
else if (profilesElement.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
profilesList = profilesElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
return profiles;
|
||||
}
|
||||
|
||||
foreach (var profile in profilesList.EnumerateArray())
|
||||
{
|
||||
profiles.Add(ParseProfile(terminal, profile));
|
||||
}
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a profile for the Windows Terminal
|
||||
/// </summary>
|
||||
/// <param name="terminal">Windows Terminal package</param>
|
||||
/// <param name="profileElement">Profile from the settings JSON file</param>
|
||||
public static TerminalProfile ParseProfile(TerminalPackage terminal, JsonElement profileElement)
|
||||
{
|
||||
profileElement.TryGetProperty("name", out var nameElement);
|
||||
var name = nameElement.ValueKind == JsonValueKind.String ? nameElement.GetString() : null;
|
||||
|
||||
profileElement.TryGetProperty("hidden", out var hiddenElement);
|
||||
var hidden = (hiddenElement.ValueKind == JsonValueKind.False || hiddenElement.ValueKind == JsonValueKind.True) && hiddenElement.GetBoolean();
|
||||
|
||||
profileElement.TryGetProperty("guid", out var guidElement);
|
||||
var guid = guidElement.ValueKind == JsonValueKind.String ? Guid.Parse(guidElement.GetString()) : null as Guid?;
|
||||
|
||||
profileElement.TryGetProperty("icon", out var iconElement);
|
||||
var icon = iconElement.ValueKind == JsonValueKind.String ? iconElement.GetString() : null;
|
||||
|
||||
return new TerminalProfile(terminal, name, guid, hidden, icon);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
|
||||
using Windows.Management.Deployment;
|
||||
|
||||
// using Wox.Plugin.Logger;
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
|
||||
public class TerminalQuery : ITerminalQuery
|
||||
{
|
||||
private readonly PackageManager _packageManager;
|
||||
|
||||
// Static list of all Windows Terminal packages.
|
||||
private static ReadOnlyCollection<string> Packages => new List<string>
|
||||
{
|
||||
"Microsoft.WindowsTerminal",
|
||||
"Microsoft.WindowsTerminalPreview",
|
||||
"Microsoft.WindowsTerminalCanary",
|
||||
}.AsReadOnly();
|
||||
|
||||
private IEnumerable<TerminalPackage> Terminals => GetTerminals();
|
||||
|
||||
public TerminalQuery()
|
||||
{
|
||||
_packageManager = new PackageManager();
|
||||
}
|
||||
|
||||
public IEnumerable<TerminalProfile> GetProfiles()
|
||||
{
|
||||
var profiles = new List<TerminalProfile>();
|
||||
|
||||
if (!Terminals.Any())
|
||||
{
|
||||
// TODO: what kind of logging should we do?
|
||||
// Log.Warn($"No Windows Terminal packages installed", typeof(TerminalQuery));
|
||||
}
|
||||
|
||||
foreach (var terminal in Terminals)
|
||||
{
|
||||
if (!File.Exists(terminal.SettingsPath))
|
||||
{
|
||||
// TODO: what kind of logging should we do?
|
||||
// Log.Warn($"Failed to find settings file {terminal.SettingsPath}", typeof(TerminalQuery));
|
||||
continue;
|
||||
}
|
||||
|
||||
var settingsJson = File.ReadAllText(terminal.SettingsPath);
|
||||
profiles.AddRange(TerminalHelper.ParseSettings(terminal, settingsJson));
|
||||
}
|
||||
|
||||
return profiles.OrderBy(p => p.Name);
|
||||
}
|
||||
|
||||
private IEnumerable<TerminalPackage> GetTerminals()
|
||||
{
|
||||
var user = WindowsIdentity.GetCurrent().User;
|
||||
var localAppDataPath = Environment.GetEnvironmentVariable("LOCALAPPDATA");
|
||||
|
||||
foreach (var p in _packageManager.FindPackagesForUser(user.Value).Where(p => Packages.Contains(p.Id.Name)))
|
||||
{
|
||||
var appListEntries = p.GetAppListEntries();
|
||||
|
||||
var aumid = appListEntries.Single().AppUserModelId;
|
||||
var version = new Version(p.Id.Version.Major, p.Id.Version.Minor, p.Id.Version.Build, p.Id.Version.Revision);
|
||||
var settingsPath = Path.Combine(localAppDataPath, "Packages", p.Id.FamilyName, "LocalState", "settings.json");
|
||||
yield return new TerminalPackage(aumid, version, p.DisplayName, settingsPath, p.Logo.LocalPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\..\..\Common.Dotnet.CsWinRT.props" />
|
||||
<Import Project="..\..\Microsoft.CmdPal.UI\CmdPal.pre.props" />
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Microsoft.CmdPal.Ext.WindowsTerminal</RootNamespace>
|
||||
<!-- <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutputPath> -->
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<!-- MRT from windows app sdk will search for a pri file with the same name of the module before defaulting to resources.pri -->
|
||||
<ProjectPriFileName>Microsoft.CmdPal.Ext.WindowsTerminal.pri</ProjectPriFileName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\WindowsTerminal.svg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Assets\WindowsTerminal.dark.png" />
|
||||
<Content Remove="Assets\WindowsTerminal.dark.png" />
|
||||
<Content Remove="Assets\WindowsTerminal.light.png" />
|
||||
<Content Remove="Assets\WindowsTerminal.light.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Update="Assets\WindowsTerminal.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="Assets\WindowsTerminal.svg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,86 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Commands;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Pages;
|
||||
|
||||
internal sealed partial class ProfilesListPage : ListPage
|
||||
{
|
||||
private readonly TerminalQuery _terminalQuery = new();
|
||||
private readonly SettingsManager _terminalSettings;
|
||||
private readonly Dictionary<string, BitmapImage> _logoCache = [];
|
||||
|
||||
private bool showHiddenProfiles;
|
||||
private bool openNewTab;
|
||||
private bool openQuake;
|
||||
|
||||
public ProfilesListPage(SettingsManager terminalSettings)
|
||||
{
|
||||
Icon = WindowsTerminalCommandsProvider.TerminalIcon;
|
||||
Name = Resources.profiles_list_page_name;
|
||||
_terminalSettings = terminalSettings;
|
||||
}
|
||||
|
||||
#pragma warning disable SA1108
|
||||
public List<ListItem> Query()
|
||||
{
|
||||
showHiddenProfiles = _terminalSettings.ShowHiddenProfiles;
|
||||
openNewTab = _terminalSettings.OpenNewTab;
|
||||
openQuake = _terminalSettings.OpenQuake;
|
||||
|
||||
var profiles = _terminalQuery.GetProfiles();
|
||||
|
||||
var result = new List<ListItem>();
|
||||
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
if (profile.Hidden && !showHiddenProfiles)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Add(new ListItem(new LaunchProfileCommand(profile.Terminal.AppUserModelId, profile.Name, profile.Terminal.LogoPath, openNewTab, openQuake))
|
||||
{
|
||||
Title = profile.Name,
|
||||
Subtitle = profile.Terminal.DisplayName,
|
||||
MoreCommands = [
|
||||
new CommandContextItem(new LaunchProfileAsAdminCommand(profile.Terminal.AppUserModelId, profile.Name, openNewTab, openQuake)),
|
||||
],
|
||||
|
||||
// Icon = () => GetLogo(profile.Terminal),
|
||||
// Action = _ =>
|
||||
// {
|
||||
// Launch(profile.Terminal.AppUserModelId, profile.Name);
|
||||
// return true;
|
||||
// },
|
||||
// ContextData = profile,
|
||||
#pragma warning restore SA1108
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override IListItem[] GetItems() => Query().ToArray();
|
||||
|
||||
private BitmapImage GetLogo(TerminalPackage terminal)
|
||||
{
|
||||
var aumid = terminal.AppUserModelId;
|
||||
|
||||
if (!_logoCache.TryGetValue(aumid, out var value))
|
||||
{
|
||||
value = terminal.GetLogo();
|
||||
_logoCache.Add(aumid, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
180
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Properties/Resources.Designer.cs
generated
Normal file
180
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,180 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CmdPal.Ext.WindowsTerminal.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Windows Terminal Profiles.
|
||||
/// </summary>
|
||||
internal static string extension_name {
|
||||
get {
|
||||
return ResourceManager.GetString("extension_name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Launch profile.
|
||||
/// </summary>
|
||||
internal static string launch_profile {
|
||||
get {
|
||||
return ResourceManager.GetString("launch_profile", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Launch profile as administrator.
|
||||
/// </summary>
|
||||
internal static string launch_profile_as_admin {
|
||||
get {
|
||||
return ResourceManager.GetString("launch_profile_as_admin", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open Windows Terminal Profiles.
|
||||
/// </summary>
|
||||
internal static string list_item_title {
|
||||
get {
|
||||
return ResourceManager.GetString("list_item_title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open profiles in a new tab.
|
||||
/// </summary>
|
||||
internal static string open_new_tab {
|
||||
get {
|
||||
return ResourceManager.GetString("open_new_tab", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open profiles in the quake window.
|
||||
/// </summary>
|
||||
internal static string open_quake {
|
||||
get {
|
||||
return ResourceManager.GetString("open_quake", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Windows Terminal supports a "quake" feature where a terminal window is accessible using a global hotkey. Enable this option to open profiles in a new tab in this window..
|
||||
/// </summary>
|
||||
internal static string open_quake_description {
|
||||
get {
|
||||
return ResourceManager.GetString("open_quake_description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Opens Windows Terminal profiles.
|
||||
/// </summary>
|
||||
internal static string plugin_description {
|
||||
get {
|
||||
return ResourceManager.GetString("plugin_description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Windows Terminal Profiles.
|
||||
/// </summary>
|
||||
internal static string profiles_list_page_name {
|
||||
get {
|
||||
return ResourceManager.GetString("profiles_list_page_name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Run as administrator (Ctrl+Shift+Enter).
|
||||
/// </summary>
|
||||
internal static string run_as_administrator {
|
||||
get {
|
||||
return ResourceManager.GetString("run_as_administrator", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to open Windows Terminal.
|
||||
/// </summary>
|
||||
internal static string run_terminal_failed {
|
||||
get {
|
||||
return ResourceManager.GetString("run_terminal_failed", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Settings.
|
||||
/// </summary>
|
||||
internal static string settings_page_name {
|
||||
get {
|
||||
return ResourceManager.GetString("settings_page_name", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show hidden profiles.
|
||||
/// </summary>
|
||||
internal static string show_hidden_profiles {
|
||||
get {
|
||||
return ResourceManager.GetString("show_hidden_profiles", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="open_new_tab" xml:space="preserve">
|
||||
<value>Open profiles in a new tab</value>
|
||||
</data>
|
||||
<data name="open_quake" xml:space="preserve">
|
||||
<value>Open profiles in the quake window</value>
|
||||
<comment>Quake is a well-known computer game. Don't localize. See https://en.wikipedia.org/wiki/Quake_(video_game)</comment>
|
||||
</data>
|
||||
<data name="open_quake_description" xml:space="preserve">
|
||||
<value>Windows Terminal supports a "quake" feature where a terminal window is accessible using a global hotkey. Enable this option to open profiles in a new tab in this window.</value>
|
||||
<comment>Quake is a well-known computer game. Don't localize. See https://en.wikipedia.org/wiki/Quake_(video_game)</comment>
|
||||
</data>
|
||||
<data name="plugin_description" xml:space="preserve">
|
||||
<value>Opens Windows Terminal profiles</value>
|
||||
</data>
|
||||
<data name="extension_name" xml:space="preserve">
|
||||
<value>Windows Terminal Profiles</value>
|
||||
</data>
|
||||
<data name="run_as_administrator" xml:space="preserve">
|
||||
<value>Run as administrator (Ctrl+Shift+Enter)</value>
|
||||
</data>
|
||||
<data name="run_terminal_failed" xml:space="preserve">
|
||||
<value>Failed to open Windows Terminal</value>
|
||||
</data>
|
||||
<data name="show_hidden_profiles" xml:space="preserve">
|
||||
<value>Show hidden profiles</value>
|
||||
</data>
|
||||
<data name="launch_profile" xml:space="preserve">
|
||||
<value>Launch profile</value>
|
||||
</data>
|
||||
<data name="launch_profile_as_admin" xml:space="preserve">
|
||||
<value>Launch profile as administrator</value>
|
||||
</data>
|
||||
<data name="profiles_list_page_name" xml:space="preserve">
|
||||
<value>Windows Terminal Profiles</value>
|
||||
</data>
|
||||
<data name="settings_page_name" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name="list_item_title" xml:space="preserve">
|
||||
<value>Open Windows Terminal Profiles</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
|
||||
// using Wox.Infrastructure.Image;
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal;
|
||||
|
||||
public class TerminalPackage
|
||||
{
|
||||
public string AppUserModelId { get; }
|
||||
|
||||
public Version Version { get; }
|
||||
|
||||
public string DisplayName { get; }
|
||||
|
||||
public string SettingsPath { get; }
|
||||
|
||||
public string LogoPath { get; }
|
||||
|
||||
public TerminalPackage(string appUserModelId, Version version, string displayName, string settingsPath, string logoPath)
|
||||
{
|
||||
AppUserModelId = appUserModelId;
|
||||
Version = version;
|
||||
DisplayName = displayName;
|
||||
SettingsPath = settingsPath;
|
||||
LogoPath = logoPath;
|
||||
}
|
||||
|
||||
public BitmapImage GetLogo()
|
||||
{
|
||||
var image = new BitmapImage();
|
||||
|
||||
if (File.Exists(LogoPath))
|
||||
{
|
||||
using var fileStream = File.OpenRead(LogoPath);
|
||||
image.SetSource(fileStream.AsRandomAccessStream());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not using wox anymore, TODO: find the right new way to handle this
|
||||
// image.UriSource = new Uri(ImageLoader.ErrorIconPath);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal;
|
||||
|
||||
public class TerminalProfile
|
||||
{
|
||||
public TerminalPackage Terminal { get; }
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public Guid? Identifier { get; }
|
||||
|
||||
public bool Hidden { get; }
|
||||
|
||||
public string Icon { get; }
|
||||
|
||||
public TerminalProfile(TerminalPackage terminal, string name, Guid? identifier, bool hidden, string icon)
|
||||
{
|
||||
Terminal = terminal;
|
||||
Name = name;
|
||||
Identifier = identifier;
|
||||
Hidden = hidden;
|
||||
Icon = icon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Pages;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal;
|
||||
|
||||
public partial class TerminalTopLevelCommandItem : CommandItem
|
||||
{
|
||||
public TerminalTopLevelCommandItem(SettingsManager settingsManager)
|
||||
: base(new ProfilesListPage(settingsManager))
|
||||
{
|
||||
Icon = WindowsTerminalCommandsProvider.TerminalIcon;
|
||||
Title = Resources.list_item_title;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowsTerminal;
|
||||
|
||||
public partial class WindowsTerminalCommandsProvider : CommandProvider
|
||||
{
|
||||
private readonly TerminalTopLevelCommandItem _terminalCommand;
|
||||
private readonly SettingsManager _settingsManager = new();
|
||||
|
||||
public static IconInfo TerminalIcon { get; } = IconHelpers.FromRelativePath("Assets\\WindowsTerminal.svg");
|
||||
|
||||
public WindowsTerminalCommandsProvider()
|
||||
{
|
||||
Id = "WindowsTerminalProfiles";
|
||||
DisplayName = Resources.extension_name;
|
||||
Icon = TerminalIcon;
|
||||
Settings = _settingsManager.Settings;
|
||||
|
||||
_terminalCommand = new TerminalTopLevelCommandItem(_settingsManager)
|
||||
{
|
||||
MoreCommands = [
|
||||
new CommandContextItem(Settings.SettingsPage),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
public override ICommandItem[] TopLevelCommands() => [_terminalCommand];
|
||||
}
|
||||
Reference in New Issue
Block a user