[PTRun][Shell]Shell selection and combobox improvements (#28972)

* Make combobox items sortable

* Update plugin settings

* settings description

* fix settings hang on outdated plugin code

* spell fixes, shell implementation, translation improvements

* rename property

* backward compatibility

* comment changes

* comment changes

* review feedback 1

* review feedback 2

* Code clean up
This commit is contained in:
Heiko
2023-10-11 14:54:49 +02:00
committed by GitHub
parent 5d669df21a
commit 19827d0093
7 changed files with 175 additions and 49 deletions

View File

@@ -43,24 +43,28 @@ namespace Microsoft.Plugin.Shell
{
new PluginAdditionalOption()
{
Key = "LeaveShellOpen",
DisplayLabel = Resources.wox_leave_shell_open,
Value = _settings.LeaveShellOpen,
Key = "ShellCommandExecution",
DisplayLabel = Resources.wox_shell_command_execution,
DisplayDescription = Resources.wox_shell_command_execution_description,
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Combobox,
ComboBoxItems = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(Resources.find_executable_file_and_run_it, "2"),
new KeyValuePair<string, string>(Resources.run_command_in_command_prompt, "0"),
new KeyValuePair<string, string>(Resources.run_command_in_powershell, "1"),
new KeyValuePair<string, string>(Resources.run_command_in_powershell_seven, "6"),
new KeyValuePair<string, string>(Resources.run_command_in_windows_terminal_cmd, "5"),
new KeyValuePair<string, string>(Resources.run_command_in_windows_terminal_powershell, "3"),
new KeyValuePair<string, string>(Resources.run_command_in_windows_terminal_powershell_seven, "4"),
},
ComboBoxValue = (int)_settings.Shell,
},
new PluginAdditionalOption()
{
Key = "ShellCommandExecution",
DisplayLabel = Resources.wox_shell_command_execution,
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Combobox,
ComboBoxOptions = new List<string>
{
Resources.run_command_in_command_prompt,
Resources.run_command_in_powershell,
Resources.find_executable_file_and_run_it,
Resources.run_command_in_windows_terminal,
},
ComboBoxValue = (int)_settings.Shell,
Key = "LeaveShellOpen",
DisplayLabel = Resources.wox_leave_shell_open,
Value = _settings.LeaveShellOpen,
},
};
@@ -212,21 +216,63 @@ namespace Microsoft.Plugin.Shell
}
else
{
arguments = $"\"{command} ; Read-Host -Prompt \\\"Press Enter to continue\\\"\"";
arguments = $"\"{command} ; Read-Host -Prompt \\\"{Resources.run_plugin_cmd_wait_message}\\\"\"";
}
info = ShellCommand.SetProcessStartInfo("powershell.exe", workingDirectory, arguments, runAsVerbArg);
}
else if (_settings.Shell == ExecutionShell.WindowsTerminal)
else if (_settings.Shell == ExecutionShell.PowerShellSeven)
{
string arguments;
if (_settings.LeaveShellOpen)
{
arguments = $"powershell -NoExit \"{command}\"";
arguments = $"-NoExit -C \"{command}\"";
}
else
{
arguments = $"powershell \"{command}\"";
arguments = $"-C \"{command} ; Read-Host -Prompt \\\"{Resources.run_plugin_cmd_wait_message}\\\"\"";
}
info = ShellCommand.SetProcessStartInfo("pwsh.exe", workingDirectory, arguments, runAsVerbArg);
}
else if (_settings.Shell == ExecutionShell.WindowsTerminalCmd)
{
string arguments;
if (_settings.LeaveShellOpen)
{
arguments = $"cmd.exe /k \"{command}\"";
}
else
{
arguments = $"cmd.exe /c \"{command}\" & pause";
}
info = ShellCommand.SetProcessStartInfo("wt.exe", workingDirectory, arguments, runAsVerbArg);
}
else if (_settings.Shell == ExecutionShell.WindowsTerminalPowerShell)
{
string arguments;
if (_settings.LeaveShellOpen)
{
arguments = $"powershell -NoExit -C \"{command}\"";
}
else
{
arguments = $"powershell -C \"{command}\"";
}
info = ShellCommand.SetProcessStartInfo("wt.exe", workingDirectory, arguments, runAsVerbArg);
}
else if (_settings.Shell == ExecutionShell.WindowsTerminalPowerShellSeven)
{
string arguments;
if (_settings.LeaveShellOpen)
{
arguments = $"pwsh.exe -NoExit -C \"{command}\"";
}
else
{
arguments = $"pwsh.exe -C \"{command}\"";
}
info = ShellCommand.SetProcessStartInfo("wt.exe", workingDirectory, arguments, runAsVerbArg);

View File

@@ -61,7 +61,7 @@ namespace Microsoft.Plugin.Shell.Properties {
}
/// <summary>
/// Looks up a localized string similar to Find executable file and run it.
/// Looks up a localized string similar to Find and run executable file.
/// </summary>
public static string find_executable_file_and_run_it {
get {
@@ -70,7 +70,7 @@ namespace Microsoft.Plugin.Shell.Properties {
}
/// <summary>
/// Looks up a localized string similar to Run command in Command Prompt (cmd.exe).
/// Looks up a localized string similar to Run in Command Prompt (cmd.exe).
/// </summary>
public static string run_command_in_command_prompt {
get {
@@ -79,7 +79,7 @@ namespace Microsoft.Plugin.Shell.Properties {
}
/// <summary>
/// Looks up a localized string similar to Run command in PowerShell (PowerShell.exe).
/// Looks up a localized string similar to Run in PowerShell (PowerShell.exe).
/// </summary>
public static string run_command_in_powershell {
get {
@@ -88,11 +88,47 @@ namespace Microsoft.Plugin.Shell.Properties {
}
/// <summary>
/// Looks up a localized string similar to Run command in Windows Terminal (wt.exe).
/// Looks up a localized string similar to Run in PowerShell 7 (pwsh.exe).
/// </summary>
public static string run_command_in_windows_terminal {
public static string run_command_in_powershell_seven {
get {
return ResourceManager.GetString("run_command_in_windows_terminal", resourceCulture);
return ResourceManager.GetString("run_command_in_powershell_seven", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run in Command Prompt (cmd.exe) using Windows Terminal.
/// </summary>
public static string run_command_in_windows_terminal_cmd {
get {
return ResourceManager.GetString("run_command_in_windows_terminal_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run in PowerShell (PowerShell.exe) using Windows Terminal.
/// </summary>
public static string run_command_in_windows_terminal_powershell {
get {
return ResourceManager.GetString("run_command_in_windows_terminal_powershell", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run in PowerShell 7 (pwsh.exe) using Windows Terminal.
/// </summary>
public static string run_command_in_windows_terminal_powershell_seven {
get {
return ResourceManager.GetString("run_command_in_windows_terminal_powershell_seven", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Press Enter to continue.
/// </summary>
public static string run_plugin_cmd_wait_message {
get {
return ResourceManager.GetString("run_plugin_cmd_wait_message", resourceCulture);
}
}
@@ -178,12 +214,21 @@ namespace Microsoft.Plugin.Shell.Properties {
}
/// <summary>
/// Looks up a localized string similar to Shell command execution.
/// Looks up a localized string similar to Command execution.
/// </summary>
public static string wox_shell_command_execution {
get {
return ResourceManager.GetString("wox_shell_command_execution", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All entries that using the Windows Terminal forcing the Windows Terminal as console host regardless of the system setting.
/// </summary>
public static string wox_shell_command_execution_description {
get {
return ResourceManager.GetString("wox_shell_command_execution_description", resourceCulture);
}
}
}
}

View File

@@ -145,18 +145,34 @@
<value>Keep shell open</value>
</data>
<data name="wox_shell_command_execution" xml:space="preserve">
<value>Shell command execution</value>
<value>Command execution</value>
</data>
<data name="run_command_in_command_prompt" xml:space="preserve">
<value>Run command in Command Prompt (cmd.exe)</value>
<value>Run in Command Prompt (cmd.exe)</value>
</data>
<data name="run_command_in_powershell" xml:space="preserve">
<value>Run command in PowerShell (PowerShell.exe)</value>
<value>Run in PowerShell (PowerShell.exe)</value>
</data>
<data name="find_executable_file_and_run_it" xml:space="preserve">
<value>Find executable file and run it</value>
<value>Find and run the executable file</value>
</data>
<data name="run_command_in_windows_terminal" xml:space="preserve">
<value>Run command in Windows Terminal (wt.exe)</value>
<data name="run_command_in_powershell_seven" xml:space="preserve">
<value>Run in PowerShell 7 (pwsh.exe)</value>
</data>
<data name="run_command_in_windows_terminal_cmd" xml:space="preserve">
<value>Run in Command Prompt (cmd.exe) using Windows Terminal</value>
</data>
<data name="run_command_in_windows_terminal_powershell" xml:space="preserve">
<value>Run in PowerShell (PowerShell.exe) using Windows Terminal</value>
</data>
<data name="run_command_in_windows_terminal_powershell_seven" xml:space="preserve">
<value>Run in PowerShell 7 (pwsh.exe) using Windows Terminal</value>
</data>
<data name="run_plugin_cmd_wait_message" xml:space="preserve">
<value>Press Enter to continue</value>
<comment>"Enter" means the Enter key on the keyboard.</comment>
</data>
<data name="wox_shell_command_execution_description" xml:space="preserve">
<value>All entries using the Windows Terminal force the Windows Terminal as the console host regardless of the system settings</value>
</data>
</root>

View File

@@ -41,6 +41,9 @@ namespace Microsoft.Plugin.Shell
Cmd = 0,
Powershell = 1,
RunCommand = 2,
WindowsTerminal = 3,
WindowsTerminalPowerShell = 3,
WindowsTerminalPowerShellSeven = 4,
WindowsTerminalCmd = 5,
PowerShellSeven = 6,
}
}