Compare commits

..

1 Commits

Author SHA1 Message Date
David Federman
c77ac66c33 Re-enable MSBuildCache 2025-07-24 09:36:36 -07:00
70 changed files with 931 additions and 907 deletions

View File

@@ -115,6 +115,7 @@ BKCOLOR
BKGND
BKMK
Bksp
blds
Blt
blu
BLUESCROLL
@@ -180,6 +181,7 @@ CLIPCHILDREN
CLIPSIBLINGS
closetest
cloudconsole
CLOUDT
cloudvault
CLSCTX
clsids

View File

@@ -33,6 +33,17 @@
A:\;
E:\;
$(windir)\**;
$(MSBuildBinPath)\**;
$(MSBuildToolsPath32)\**;
</MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>
<!--
Unit tests may write to TEMP, but should not be considered outputs. However, $(Temp) is using the DOS path (C:\Users\CLOUDT~1\AppData\Local\Temp), which
isn't accounted for in these globs. So we're building up to TEMP using $(LOCALAPPDATA) instead.
-->
<MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>
$(MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns);
$(LOCALAPPDATA)\Temp\**;
</MSBuildCacheAllowFileAccessAfterProjectFinishFilePatterns>
<!--
@@ -46,6 +57,15 @@
-->
<MSBuildCacheIdenticalDuplicateOutputPatterns>$(MSBuildCacheIdenticalDuplicateOutputPatterns);obj\*\vcpkg\**</MSBuildCacheIdenticalDuplicateOutputPatterns>
<!--
Ensure the MSBuildCache ignores collecting outputs under vcpkg's build tree, which is a working directory used to build vcpkg packages and not intended to be consumed by anything else in the build.
Note: We cannot use $(VcpkgInstalledDir) directly since it differs between projects, so use a pattern which encompasses all possibilities.
-->
<MSBuildCacheIgnoredOutputPatterns>
$(MSBuildCacheIgnoredOutputPatterns);
$(SolutionDir)\obj\*\vcpkg*\vcpkg\blds\**;
</MSBuildCacheIgnoredOutputPatterns>
<!-- version of MSBuildCache is not part of the cache key -->
<PackagesConfigFile>$(MSBuildThisFileDirectory)\dep\nuget\packages.config</PackagesConfigFile>
<MSBuildCacheIgnoredInputPatterns>$(MSBuildCacheIgnoredInputPatterns);$(PackagesConfigFile)</MSBuildCacheIgnoredInputPatterns>

View File

@@ -14,21 +14,21 @@
<Package
Name="Microsoft.UI.Xaml.2.8"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="8.2306.22001.0"
Version="8.2305.5001.0"
ProcessorArchitecture="x64"
Uri="https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.5/Microsoft.UI.Xaml.2.8.x64.appx" />
Uri="https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.4/Microsoft.UI.Xaml.2.8.x64.appx" />
<Package
Name="Microsoft.UI.Xaml.2.8"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="8.2306.22001.0"
Version="8.2305.5001.0"
ProcessorArchitecture="x86"
Uri="https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.5/Microsoft.UI.Xaml.2.8.x86.appx" />
Uri="https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.4/Microsoft.UI.Xaml.2.8.x86.appx" />
<Package
Name="Microsoft.UI.Xaml.2.8"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="8.2306.22001.0"
Version="8.2305.5001.0"
ProcessorArchitecture="arm64"
Uri="https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.5/Microsoft.UI.Xaml.2.8.arm64.appx" />
Uri="https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.4/Microsoft.UI.Xaml.2.8.arm64.appx" />
</Dependencies>
<UpdateSettings>

View File

@@ -84,7 +84,7 @@ stages:
buildEverything: true
keepAllExpensiveBuildOutputs: false
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
enableCaching: true
enableMsBuildCaching: true
- ${{ if eq(parameters.runTests, true) }}:
- stage: Test_${{ platform }}

View File

@@ -25,6 +25,8 @@ pr:
variables:
- name: runCodesignValidationInjectionBG
value: false
- name: EnablePipelineCache
value: true
# 0.0.yyMM.dd##
# 0.0.1904.0900
@@ -45,6 +47,10 @@ parameters:
- x64
- x86
- arm64
- name: enableMsBuildCaching
type: boolean
displayName: "Enable MSBuild Caching"
default: true
stages:
- ${{ if eq(parameters.auditMode, true) }}:
@@ -87,6 +93,8 @@ stages:
buildConfigurations: [Release]
buildEverything: true
keepAllExpensiveBuildOutputs: false
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
enableMsBuildCaching: ${{ parameters.enableMsBuildCaching }}
- ${{ if eq(parameters.runTests, true) }}:
- stage: Test_${{ platform }}

View File

@@ -68,7 +68,7 @@ parameters:
- name: signingIdentity
type: object
default: {}
- name: enableCaching
- name: enableMsBuildCaching
type: boolean
default: false
@@ -144,7 +144,7 @@ jobs:
}
displayName: Prepare Build and Sign Targets
- ${{ if eq(parameters.enableCaching, true) }}:
- ${{ if eq(parameters.enableMsBuildCaching, true) }}:
- pwsh: |-
$MSBuildCacheParameters = ""
$MSBuildCacheParameters += " -graph"
@@ -183,7 +183,7 @@ jobs:
configuration: $(BuildConfiguration)
msbuildArchitecture: x64
maximumCpuCount: true
${{ if eq(parameters.enableCaching, true) }}:
${{ if eq(parameters.enableMsBuildCaching, true) }}:
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
@@ -192,7 +192,7 @@ jobs:
artifact: logs-$(BuildPlatform)-$(BuildConfiguration)${{ parameters.artifactStem }}
condition: always()
displayName: Publish Build Log
- ${{ if eq(parameters.enableCaching, true) }}:
- ${{ if eq(parameters.enableMsBuildCaching, true) }}:
- publish: $(Build.SourcesDirectory)\MSBuildCacheLogs
artifact: logs-msbuildcache-$(BuildPlatform)-$(BuildConfiguration)${{ parameters.artifactStem }}
condition: always()
@@ -203,7 +203,7 @@ jobs:
inputs:
contents: $(Build.SourcesDirectory)/msbuild.binlog
TargetFolder: $(Terminal.BinDir)
- ${{ if eq(parameters.enableCaching, true) }}:
- ${{ if eq(parameters.enableMsBuildCaching, true) }}:
- task: CopyFiles@2
displayName: Copy MSBuildCache Logs
inputs:

View File

@@ -20,7 +20,7 @@
<package id="Selenium.WebDriver" version="3.5.0" targetFramework="net45" />
<!-- MSBuildCache -->
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.283-preview" />
<package id="Microsoft.MSBuildCache.Local" version="0.1.283-preview" />
<package id="Microsoft.MSBuildCache.SharedCompilation" version="0.1.283-preview" />
<package id="Microsoft.MSBuildCache.AzurePipelines" version="0.1.318-preview" />
<package id="Microsoft.MSBuildCache.Local" version="0.1.318-preview" />
<package id="Microsoft.MSBuildCache.SharedCompilation" version="0.1.318-preview" />
</packages>

View File

@@ -21,7 +21,6 @@ namespace TerminalAppLocalTests
_value{ value } {}
winrt::hstring Name() { return _value; }
winrt::hstring Subtitle() { return {}; }
winrt::hstring KeyChordText() { return {}; }
winrt::hstring Icon() { return {}; }

View File

@@ -0,0 +1,267 @@
#include "ColorHelper.h"
using namespace winrt::TerminalApp;
// Method Description:
// Determines whether or not a given color is light
// Arguments:
// - color: this color is going to be examined whether it
// is light or not
// Return Value:
// - true if light, false if dark
bool ColorHelper::IsBrightColor(const winrt::Windows::UI::Color& color)
{
// https://www.w3.org/TR/AERT#color-contrast
auto brightness = (color.R * 299 + color.G * 587 + color.B * 114) / 1000.f;
return brightness > 128.f;
}
// Method Description:
// Converts a rgb color to an hsl one
// Arguments:
// - color: the rgb color, which is going to be converted
// Return Value:
// - a hsl color with the following ranges
// - H: [0.f -360.f]
// - L: [0.f - 1.f] (rounded to the third decimal place)
// - S: [0.f - 1.f] (rounded to the third decimal place)
HSL ColorHelper::RgbToHsl(const winrt::Windows::UI::Color& color)
{
// https://www.rapidtables.com/convert/color/rgb-to-hsl.html
auto epsilon = std::numeric_limits<float>::epsilon();
auto r = color.R / 255.f;
auto g = color.G / 255.f;
auto b = color.B / 255.f;
auto max = std::max(r, std::max(g, b));
auto min = std::min(r, std::min(g, b));
auto delta = max - min;
auto h = 0.f;
auto s = 0.f;
auto l = (max + min) / 2;
if (delta < epsilon || max < epsilon) /* delta == 0 || max == 0*/
{
l = std::roundf(l * 1000) / 1000;
return HSL{ h, s, l };
}
s = l > 0.5 ? delta / (2 - max - min) : delta / (max + min);
if (max - r < epsilon) // max == r
{
h = (g - b) / delta + (g < b ? 6 : 0);
}
else if (max - g < epsilon) // max == g
{
h = (b - r) / delta + 2;
}
else if (max - b < epsilon) // max == b
{
h = (r - g) / delta + 4;
}
// three decimal places after the comma ought
// to be enough for everybody - Bill Gates, 1981
auto finalH = std::roundf(h * 60);
auto finalS = std::roundf(s * 1000) / 1000;
auto finalL = std::roundf(l * 1000) / 1000;
return HSL{ finalH, finalS, finalL };
}
// Method Description:
// Converts a hsl color to rgb one
// Arguments:
// - color: the hsl color, which is going to be converted
// Return Value:
// - the rgb color (r,g,b - [0, 255] range)
winrt::Windows::UI::Color ColorHelper::HslToRgb(const HSL& color)
{
auto epsilon = std::numeric_limits<float>::epsilon();
auto h = (color.H - 1.f > epsilon) ? color.H / 360.f : color.H;
auto s = (color.S - 1.f > epsilon) ? color.S / 100.f : color.S;
auto l = (color.L - 1.f > epsilon) ? color.L / 100.f : color.L;
auto r = l;
auto g = l;
auto b = l;
if (s > epsilon)
{
auto q = l < 0.5 ? l * (1 + s) : l + s - l * s;
auto p = 2 * l - q;
r = HueToRgb(p, q, h + 1.f / 3.f);
g = HueToRgb(p, q, h);
b = HueToRgb(p, q, h - 1.f / 3.f);
}
auto finalR = static_cast<uint8_t>(std::roundf(r * 255));
auto finalG = static_cast<uint8_t>(std::roundf(g * 255));
auto finalB = static_cast<uint8_t>(std::roundf(b * 255));
uint8_t finalA = 255; //opaque
return winrt::Windows::UI::ColorHelper::FromArgb(finalA, finalR, finalG, finalB);
}
float ColorHelper::HueToRgb(float p, float q, float t)
{
auto epsilon = std::numeric_limits<float>::epsilon();
if (t < 0)
t += 1;
if (t > 1)
t -= 1;
if (t - (1.f / 6.f) < epsilon)
return p + (q - p) * 6 * t;
if (t - .5f < epsilon)
return q;
if (t - 2.f / 3.f < epsilon)
return p + (q - p) * (2.f / 3.f - t) * 6;
return p;
}
// Method Description:
// Lightens a color by a given amount
// Arguments:
// - color: the color which is going to be lightened
// - amount: the lighten amount (0-100)
// Return Value:
// - the lightened color in RGB format
winrt::Windows::UI::Color ColorHelper::Lighten(const winrt::Windows::UI::Color& color, float amount /* = 10.f*/)
{
auto hsl = RgbToHsl(color);
hsl.L += amount / 100;
hsl.L = std::clamp(hsl.L, 0.f, 1.f);
return HslToRgb(hsl);
}
// Method Description:
// Darkens a color by a given amount
// Arguments:
// - color: the color which is going to be darkened
// - amount: the darken amount (0-100)
// Return Value:
// - the darkened color in RGB format
winrt::Windows::UI::Color ColorHelper::Darken(const winrt::Windows::UI::Color& color, float amount /* = 10.f*/)
{
auto hsl = RgbToHsl(color);
hsl.L -= amount / 100;
hsl.L = std::clamp(hsl.L, 0.f, 1.f);
return HslToRgb(hsl);
}
// Method Description:
// Gets an accent color to a given color. Basically, generates
// 16 shades of the color and finds the first which has a good
// contrast according to https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
// Readability ratio of 3.5 seems to look quite nicely
// Arguments:
// - color: the color for which we need an accent
// Return Value:
// - the accent color in RGB format
winrt::Windows::UI::Color ColorHelper::GetAccentColor(const winrt::Windows::UI::Color& color)
{
auto accentColor = RgbToHsl(color);
if (accentColor.S < 0.15)
{
accentColor.S = 0.15f;
}
constexpr auto shadeCount = 16;
constexpr auto shadeStep = 1.f / shadeCount;
auto shades = std::map<float, HSL>();
for (auto i = 0; i < 15; i++)
{
auto shade = HSL{ accentColor.H, accentColor.S, i * shadeStep };
auto contrast = GetReadability(shade, accentColor);
shades.insert(std::make_pair(contrast, shade));
}
// 3f is quite nice if the whole non-client area is painted
constexpr auto readability = 1.75f;
for (auto shade : shades)
{
if (shade.first >= readability)
{
return HslToRgb(shade.second);
}
}
return HslToRgb(shades.end()->second);
}
// Method Description:
// Gets the readability of two colors according to
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
// Arguments:
// - firstColor: the first color for the readability check (hsl)
// - secondColor: the second color for the readability check (hsl)
// Return Value:
// - the readability of the colors according to (WCAG Version 2)
float ColorHelper::GetReadability(const HSL& first, const HSL& second)
{
return GetReadability(HslToRgb(first), HslToRgb(second));
}
// Method Description:
// Gets the readability of two colors according to
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
// Arguments:
// - firstColor: the first color for the readability check (rgb)
// - secondColor: the second color for the readability check (rgb)
// Return Value:
// - the readability of the colors according to (WCAG Version 2)
float ColorHelper::GetReadability(const winrt::Windows::UI::Color& first, const winrt::Windows::UI::Color& second)
{
auto l1 = GetLuminance(first);
auto l2 = GetLuminance(second);
return (std::max(l1, l2) + 0.05f) / std::min(l1, l2) + 0.05f;
}
// Method Description:
// Calculates the luminance of a given color according to
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
// Arguments:
// - color: its luminance is going to be calculated
// Return Value:
// - the luminance of the color
float ColorHelper::GetLuminance(const winrt::Windows::UI::Color& color)
{
auto epsilon = std::numeric_limits<float>::epsilon();
float R, G, B;
auto RsRGB = color.R / 255.f;
auto GsRGB = color.G / 255.f;
auto BsRGB = color.B / 255.f;
if (RsRGB - 0.03928f <= epsilon)
{
R = RsRGB / 12.92f;
}
else
{
R = std::pow(((RsRGB + 0.055f) / 1.055f), 2.4f);
}
if (GsRGB - 0.03928f <= epsilon)
{
G = GsRGB / 12.92f;
}
else
{
G = std::pow(((GsRGB + 0.055f) / 1.055f), 2.4f);
}
if (BsRGB - 0.03928f <= epsilon)
{
B = BsRGB / 12.92f;
}
else
{
B = std::pow(((BsRGB + 0.055f) / 1.055f), 2.4f);
}
auto luminance = (0.2126f * R) + (0.7152f * G) + (0.0722f * B);
return std::roundf(luminance * 10000) / 10000.f;
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include <winrt/Windows.UI.h>
namespace winrt::TerminalApp
{
class HSL
{
public:
float H;
float S;
float L;
};
class ColorHelper
{
public:
static bool IsBrightColor(const Windows::UI::Color& color);
static HSL RgbToHsl(const Windows::UI::Color& color);
static Windows::UI::Color HslToRgb(const HSL& color);
static Windows::UI::Color Lighten(const Windows::UI::Color& color, float amount = 10.f);
static Windows::UI::Color Darken(const Windows::UI::Color& color, float amount = 10.f);
static Windows::UI::Color GetAccentColor(const Windows::UI::Color& color);
static float GetLuminance(const Windows::UI::Color& color);
static float GetReadability(const Windows::UI::Color& first, const Windows::UI::Color& second);
static float GetReadability(const HSL& first, const HSL& second);
private:
static float HueToRgb(float p, float q, float t);
};
}

View File

@@ -44,12 +44,6 @@
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
</Style>
<Style x:Key="SubtitleTextStyle"
TargetType="TextBlock">
<Setter Property="FontSize" Value="10" />
<Setter Property="Foreground" Value="{ThemeResource SystemBaseMediumColor}" />
</Style>
<DataTemplate x:Key="ListItemTemplate"
x:DataType="local:FilteredCommand">
<ListViewItem HorizontalContentAlignment="Stretch"
@@ -77,19 +71,11 @@
Height="16"
Content="{x:Bind Item.ResolvedIcon, Mode=OneWay}" />
<StackPanel Grid.Column="1"
HorizontalAlignment="Left"
Orientation="Vertical">
<local:HighlightedTextControl HorizontalAlignment="Left"
HighlightedRuns="{x:Bind NameHighlights, Mode=OneWay}"
Text="{x:Bind Item.Name, Mode=OneWay}" />
<local:HighlightedTextControl HorizontalAlignment="Left"
HighlightedRuns="{x:Bind SubtitleHighlights, Mode=OneWay}"
Text="{x:Bind Item.Subtitle, Mode=OneWay}"
TextBlockStyle="{StaticResource SubtitleTextStyle}"
Visibility="{x:Bind HasSubtitle, Mode=OneWay}" />
<local:HighlightedTextControl Grid.Column="1"
HorizontalAlignment="Left"
HighlightedRuns="{x:Bind NameHighlights, Mode=OneWay}"
Text="{x:Bind Item.Name, Mode=OneWay}" />
</StackPanel>
<!--
The block for the key chord is only visible
when there's actual text set as the label.
@@ -136,19 +122,10 @@
Height="16"
Content="{x:Bind Item.ResolvedIcon, Mode=OneWay}" />
<StackPanel Grid.Column="1"
HorizontalAlignment="Left"
Orientation="Vertical">
<local:HighlightedTextControl HorizontalAlignment="Left"
HighlightedRuns="{x:Bind NameHighlights, Mode=OneWay}"
Text="{x:Bind Item.Name, Mode=OneWay}" />
<local:HighlightedTextControl HorizontalAlignment="Left"
HighlightedRuns="{x:Bind SubtitleHighlights, Mode=OneWay}"
Text="{x:Bind Item.Subtitle, Mode=OneWay}"
TextBlockStyle="{StaticResource SubtitleTextStyle}"
Visibility="{x:Bind HasSubtitle, Mode=OneWay}" />
</StackPanel>
<local:HighlightedTextControl Grid.Column="1"
HorizontalAlignment="Left"
HighlightedRuns="{x:Bind NameHighlights, Mode=OneWay}"
Text="{x:Bind Item.Name, Mode=OneWay}" />
<!--
The block for the key chord is only visible

View File

@@ -17,31 +17,6 @@ namespace winrt::TerminalApp::implementation
ActionPaletteItem(const Microsoft::Terminal::Settings::Model::Command& command, const winrt::hstring keyChordText) :
_Command{ command }, _name{ command.Name() }, _keyChordText{ keyChordText }
{
static bool shouldShowSubtitles = [] {
try
{
const auto context{ winrt::Windows::ApplicationModel::Resources::Core::ResourceContext::GetForViewIndependentUse() };
const auto qualifiers{ context.QualifierValues() };
if (const auto language{ qualifiers.TryLookup(L"language") })
{
return !til::starts_with_insensitive_ascii(*language, L"en-");
}
}
catch (...)
{
LOG_CAUGHT_EXCEPTION();
}
return false;
}();
if (shouldShowSubtitles)
{
const auto subtitle = _Command.LanguageNeutralName();
if (subtitle != _name)
{
_subtitle = std::move(subtitle);
}
}
}
winrt::hstring Name()
@@ -49,11 +24,6 @@ namespace winrt::TerminalApp::implementation
return _name;
}
winrt::hstring Subtitle()
{
return _subtitle;
}
winrt::hstring KeyChordText()
{
return _keyChordText;
@@ -69,7 +39,6 @@ namespace winrt::TerminalApp::implementation
private:
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _commandChangedRevoker;
winrt::hstring _name;
winrt::hstring _subtitle;
winrt::hstring _keyChordText;
};
@@ -85,11 +54,6 @@ namespace winrt::TerminalApp::implementation
return _CommandLine;
}
winrt::hstring Subtitle()
{
return {};
}
winrt::hstring KeyChordText()
{
return {};
@@ -123,11 +87,6 @@ namespace winrt::TerminalApp::implementation
return {};
}
winrt::hstring Subtitle()
{
return {};
}
winrt::hstring KeyChordText()
{
return {};

View File

@@ -26,16 +26,11 @@ namespace winrt::TerminalApp::implementation
{
// Recompute the highlighted name if the item name changes
// Our Item will not change, so we don't need to update the revoker if it does.
_itemChangedRevoker = _Item.as<winrt::Windows::UI::Xaml::Data::INotifyPropertyChanged>().PropertyChanged(winrt::auto_revoke, [=](auto& /*sender*/, auto& e) {
const auto property{ e.PropertyName() };
if (property == L"Name")
_itemChangedRevoker = _Item.as<winrt::Windows::UI::Xaml::Data::INotifyPropertyChanged>().PropertyChanged(winrt::auto_revoke, [weakThis{ get_weak() }](auto& /*sender*/, auto& e) {
auto filteredCommand{ weakThis.get() };
if (filteredCommand && e.PropertyName() == L"Name")
{
_update();
}
else if (property == L"Subtitle")
{
_update();
PropertyChanged.raise(*this, winrt::Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"HasSubtitle" });
filteredCommand->_update();
}
});
}
@@ -51,11 +46,6 @@ namespace winrt::TerminalApp::implementation
}
}
bool FilteredCommand::HasSubtitle()
{
return !_Item.Subtitle().empty();
}
static std::tuple<std::vector<winrt::TerminalApp::HighlightedRun>, int32_t> _matchedSegmentsAndWeight(const std::shared_ptr<fzf::matcher::Pattern>& pattern, const winrt::hstring& haystack)
{
std::vector<winrt::TerminalApp::HighlightedRun> segments;
@@ -78,17 +68,7 @@ namespace winrt::TerminalApp::implementation
void FilteredCommand::_update()
{
auto itemName = _Item.Name();
auto [segments, weight] = _matchedSegmentsAndWeight(_pattern, itemName);
decltype(segments) subtitleSegments;
if (HasSubtitle())
{
auto itemSubtitle = _Item.Subtitle();
int32_t subtitleWeight = 0;
std::tie(subtitleSegments, subtitleWeight) = _matchedSegmentsAndWeight(_pattern, itemSubtitle);
weight = std::max(weight, subtitleWeight);
}
auto [segments, weight] = _matchedSegmentsAndWeight(_pattern, _Item.Name());
if (segments.empty())
{
@@ -99,15 +79,6 @@ namespace winrt::TerminalApp::implementation
NameHighlights(winrt::single_threaded_vector(std::move(segments)));
}
if (subtitleSegments.empty())
{
SubtitleHighlights(nullptr);
}
else
{
SubtitleHighlights(winrt::single_threaded_vector(std::move(subtitleSegments)));
}
Weight(weight);
}

View File

@@ -24,12 +24,9 @@ namespace winrt::TerminalApp::implementation
static int Compare(const winrt::TerminalApp::FilteredCommand& first, const winrt::TerminalApp::FilteredCommand& second);
bool HasSubtitle();
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::TerminalApp::IPaletteItem, Item, PropertyChanged.raise, nullptr);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::Foundation::Collections::IVector<winrt::TerminalApp::HighlightedRun>, NameHighlights, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::Foundation::Collections::IVector<winrt::TerminalApp::HighlightedRun>, SubtitleHighlights, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(int, Weight, PropertyChanged.raise);
private:

View File

@@ -13,8 +13,6 @@ namespace TerminalApp
IPaletteItem Item { get; };
IVector<HighlightedRun> NameHighlights { get; };
IVector<HighlightedRun> SubtitleHighlights { get; };
Boolean HasSubtitle { get; };
Int32 Weight;
}
}

View File

@@ -16,7 +16,6 @@ namespace TerminalApp
{
PaletteItemType Type { get; };
String Name { get; };
String Subtitle { get; };
String KeyChordText { get; };
String Icon { get; };
Windows.UI.Xaml.Controls.IconElement ResolvedIcon { get; };

View File

@@ -8,8 +8,8 @@
#include "SettingsPaneContent.h"
#include "Tab.g.cpp"
#include "Utils.h"
#include "ColorHelper.h"
#include "AppLogic.h"
#include "../../types/inc/ColorFix.hpp"
using namespace winrt;
using namespace winrt::Windows::UI::Xaml;
@@ -2275,13 +2275,11 @@ namespace winrt::TerminalApp::implementation
// the background color
// - This method should only be called on the UI thread.
// Arguments:
// - uiColor: the color the user picked for their tab
// - color: the color the user picked for their tab
// Return Value:
// - <none>
void Tab::_ApplyTabColorOnUIThread(const winrt::Windows::UI::Color& uiColor)
void Tab::_ApplyTabColorOnUIThread(const winrt::Windows::UI::Color& color)
{
constexpr auto lightnessThreshold = 0.6f;
const til::color color{ uiColor };
Media::SolidColorBrush selectedTabBrush{};
Media::SolidColorBrush deselectedTabBrush{};
Media::SolidColorBrush fontBrush{};
@@ -2294,7 +2292,7 @@ namespace winrt::TerminalApp::implementation
// calculate the luminance of the current color and select a font
// color based on that
// see https://www.w3.org/TR/WCAG20/#relativeluminancedef
if (ColorFix::GetLightness(color) >= lightnessThreshold)
if (TerminalApp::ColorHelper::IsBrightColor(color))
{
auto subtleFillColorSecondary = winrt::Windows::UI::Colors::Black();
subtleFillColorSecondary.A = 0x09;
@@ -2314,8 +2312,8 @@ namespace winrt::TerminalApp::implementation
}
// The tab font should be based on the evaluated appearance of the tab color layered on tab row.
const auto layeredTabColor = color.layer_over(_tabRowColor);
if (ColorFix::GetLightness(layeredTabColor) >= lightnessThreshold)
const auto layeredTabColor = til::color{ color }.layer_over(_tabRowColor);
if (TerminalApp::ColorHelper::IsBrightColor(layeredTabColor))
{
fontBrush.Color(winrt::Windows::UI::Colors::Black());
auto secondaryFontColor = winrt::Windows::UI::Colors::Black();
@@ -2335,7 +2333,8 @@ namespace winrt::TerminalApp::implementation
selectedTabBrush.Color(color);
// Start with the current tab color, set to Opacity=.3
auto deselectedTabColor = color.with_alpha(77); // 255 * .3 = 77
til::color deselectedTabColor{ color };
deselectedTabColor = deselectedTabColor.with_alpha(77); // 255 * .3 = 77
// If we DON'T have a color set from the color picker, or the profile's
// tabColor, but we do have a unfocused color in the theme, use the
@@ -2377,7 +2376,7 @@ namespace winrt::TerminalApp::implementation
// We don't want that to result in white text on a white tab row for
// inactive tabs.
const auto deselectedActualColor = deselectedTabColor.layer_over(_tabRowColor);
if (ColorFix::GetLightness(deselectedActualColor) >= lightnessThreshold)
if (TerminalApp::ColorHelper::IsBrightColor(deselectedActualColor))
{
deselectedFontBrush.Color(winrt::Windows::UI::Colors::Black());
}

View File

@@ -18,6 +18,7 @@
#include <LibraryResources.h>
#include "TabRowControl.h"
#include "ColorHelper.h"
#include "DebugTapConnection.h"
#include "..\TerminalSettingsModel\FileUtils.h"

View File

@@ -134,6 +134,7 @@
<ClInclude Include="FilteredCommand.h" />
<ClInclude Include="Pane.h" />
<ClInclude Include="fzf/fzf.h" />
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="ShortcutActionDispatch.h">
<DependentUpon>ShortcutActionDispatch.idl</DependentUpon>
@@ -246,6 +247,9 @@
<ClCompile Include="FilteredCommand.cpp" />
<ClCompile Include="Pane.cpp" />
<ClCompile Include="Pane.LayoutSizeNode.cpp" />
<ClCompile Include="ColorHelper.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="DebugTapConnection.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>

View File

@@ -20,6 +20,7 @@
</ClCompile>
<ClCompile Include="AppCommandlineArgs.cpp" />
<ClCompile Include="Commandline.cpp" />
<ClCompile Include="ColorHelper.cpp" />
<ClCompile Include="DebugTapConnection.cpp" />
<ClCompile Include="Jumplist.cpp" />
<ClCompile Include="FilteredCommand.cpp">
@@ -47,6 +48,7 @@
<ClInclude Include="AppCommandlineArgs.h" />
<ClInclude Include="Commandline.h" />
<ClInclude Include="DebugTapConnection.h" />
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="Jumplist.h" />
<ClInclude Include="FilteredCommand.h">
<Filter>commandPalette</Filter>

View File

@@ -6,24 +6,24 @@
#include "TerminalPage.h"
#include <LibraryResources.h>
#include <Utils.h>
#include <TerminalCore/ControlKeyStates.hpp>
#include <Utils.h>
#include "App.h"
#include "DebugTapConnection.h"
#include "MarkdownPaneContent.h"
#include "Remoting.h"
#include "ScratchpadContent.h"
#include "SettingsPaneContent.h"
#include "SnippetsPaneContent.h"
#include "TabRowControl.h"
#include "../../types/inc/ColorFix.hpp"
#include "../../types/inc/utils.hpp"
#include "App.h"
#include "ColorHelper.h"
#include "DebugTapConnection.h"
#include "SettingsPaneContent.h"
#include "ScratchpadContent.h"
#include "SnippetsPaneContent.h"
#include "MarkdownPaneContent.h"
#include "TabRowControl.h"
#include "Remoting.h"
#include "LaunchPositionRequest.g.cpp"
#include "TerminalPage.g.cpp"
#include "RenameWindowRequestedArgs.g.cpp"
#include "RequestMoveContentArgs.g.cpp"
#include "TerminalPage.g.cpp"
#include "LaunchPositionRequest.g.cpp"
using namespace winrt;
using namespace winrt::Microsoft::Management::Deployment;
@@ -3904,18 +3904,36 @@ namespace winrt::TerminalApp::implementation
// and the non-client are behind it
// Return Value:
// - <none>
void TerminalPage::_SetNewTabButtonColor(const til::color color, const til::color accentColor)
void TerminalPage::_SetNewTabButtonColor(const Windows::UI::Color& color, const Windows::UI::Color& accentColor)
{
constexpr auto lightnessThreshold = 0.6f;
// TODO GH#3327: Look at what to do with the tab button when we have XAML theming
const auto IsBrightColor = ColorFix::GetLightness(color) >= lightnessThreshold;
const auto isLightAccentColor = ColorFix::GetLightness(accentColor) >= lightnessThreshold;
const auto hoverColorAdjustment = isLightAccentColor ? -0.05f : 0.05f;
const auto pressedColorAdjustment = isLightAccentColor ? -0.1f : 0.1f;
auto IsBrightColor = ColorHelper::IsBrightColor(color);
auto isLightAccentColor = ColorHelper::IsBrightColor(accentColor);
winrt::Windows::UI::Color pressedColor{};
winrt::Windows::UI::Color hoverColor{};
winrt::Windows::UI::Color foregroundColor{};
const auto hoverColorAdjustment = 5.f;
const auto pressedColorAdjustment = 7.f;
const auto foregroundColor = IsBrightColor ? Colors::Black() : Colors::White();
const auto hoverColor = til::color{ ColorFix::AdjustLightness(accentColor, hoverColorAdjustment) };
const auto pressedColor = til::color{ ColorFix::AdjustLightness(accentColor, pressedColorAdjustment) };
if (IsBrightColor)
{
foregroundColor = winrt::Windows::UI::Colors::Black();
}
else
{
foregroundColor = winrt::Windows::UI::Colors::White();
}
if (isLightAccentColor)
{
hoverColor = ColorHelper::Darken(accentColor, hoverColorAdjustment);
pressedColor = ColorHelper::Darken(accentColor, pressedColorAdjustment);
}
else
{
hoverColor = ColorHelper::Lighten(accentColor, hoverColorAdjustment);
pressedColor = ColorHelper::Lighten(accentColor, pressedColorAdjustment);
}
Media::SolidColorBrush backgroundBrush{ accentColor };
Media::SolidColorBrush backgroundHoverBrush{ hoverColor };

View File

@@ -463,7 +463,7 @@ namespace winrt::TerminalApp::implementation
void _RefreshUIForSettingsReload();
void _SetNewTabButtonColor(til::color color, til::color accentColor);
void _SetNewTabButtonColor(const Windows::UI::Color& color, const Windows::UI::Color& accentColor);
void _ClearNewTabButtonColor();
safe_void_coroutine _CompleteInitialization();

View File

@@ -7,7 +7,8 @@
#include "pch.h"
#include "TitlebarControl.h"
#include "../../types/inc/ColorFix.hpp"
#include "ColorHelper.h"
#include "TitlebarControl.g.cpp"
@@ -188,8 +189,7 @@ namespace winrt::TerminalApp::implementation
return;
}
constexpr auto lightnessThreshold = 0.6f;
const auto isBrightColor = ColorFix::GetLightness(c) >= lightnessThreshold;
const auto isBrightColor = ColorHelper::IsBrightColor(c);
MinMaxCloseControl().RequestedTheme(isBrightColor ? winrt::Windows::UI::Xaml::ElementTheme::Light :
winrt::Windows::UI::Xaml::ElementTheme::Dark);
}

View File

@@ -66,41 +66,10 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
// WSLENV is a colon-delimited list of environment variables (+flags) that should appear inside WSL
// https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/
// WSLENV.1: Get a handle to the WSLENV environment variable.
auto& wslEnv = environment.as_map()[L"WSLENV"];
std::wstring additionalWslEnv;
// WSLENV.2: Figure out what variables are already in WSLENV.
std::unordered_set<std::wstring_view> wslEnvVars;
for (const auto& part : til::split_iterator{ std::wstring_view{ wslEnv }, L':' })
{
// Each part may contain a variable name and flags (e.g., /p, /l, etc.)
// We only care about the variable name for WSLENV.
const auto key = til::safe_slice_len(part, 0, part.rfind(L'/'));
wslEnvVars.emplace(key);
}
// WSLENV.3: Add our terminal-specific environment variables to WSLENV.
static constexpr std::wstring_view builtinWslEnvVars[] = {
L"WT_SESSION",
L"WT_PROFILE_ID",
};
// Misdiagnosis in MSVC 14.44.35207. No pointer arithmetic in sight.
#pragma warning(suppress : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
for (const auto& key : builtinWslEnvVars)
{
if (wslEnvVars.emplace(key).second)
{
additionalWslEnv.append(key);
additionalWslEnv.push_back(L':');
}
}
std::wstring wslEnv{ L"WT_SESSION:WT_PROFILE_ID:" };
if (_environment)
{
// Order the environment variable names so that resolution order is consistent
// NOTE(lhecker): I'm like 99% sure that this is unnecessary.
std::set<std::wstring, til::env_key_sorter> keys{};
for (const auto item : _environment)
{
@@ -116,39 +85,18 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
const auto value = winrt::unbox_value<hstring>(_environment.Lookup(key));
environment.set_user_environment_var(key.c_str(), value.c_str());
// WSLENV.4: Add custom user environment variables to WSLENV.
if (wslEnvVars.emplace(key).second)
{
additionalWslEnv.append(key);
additionalWslEnv.push_back(L':');
}
// For each environment variable added to the environment, also add it to WSLENV
wslEnv += key + L":";
}
CATCH_LOG();
}
}
if (!additionalWslEnv.empty())
{
// WSLENV.5: In the next step we'll prepend `additionalWslEnv` to `wslEnv`,
// so make sure that we have a single colon in between them.
const auto hasColon = additionalWslEnv.ends_with(L':');
const auto needsColon = !wslEnv.starts_with(L':');
if (hasColon != needsColon)
{
if (hasColon)
{
additionalWslEnv.pop_back();
}
else
{
additionalWslEnv.push_back(L':');
}
}
// WSLENV.6: Prepend our additional environment variables to WSLENV.
wslEnv.insert(0, additionalWslEnv);
}
// We want to prepend new environment variables to WSLENV - that way if a variable already
// exists in WSLENV but with a flag, the flag will be respected.
// (This behaviour was empirically observed)
wslEnv += environment.as_map()[L"WSLENV"];
environment.as_map().insert_or_assign(L"WSLENV", wslEnv);
}
auto newEnvVars = environment.to_string();

View File

@@ -156,7 +156,6 @@ public:
bool IsVtInputEnabled() const noexcept override;
void NotifyAccessibilityChange(const til::rect& changedRect) noexcept override;
void NotifyBufferRotation(const int delta) override;
void NotifyShellIntegrationMark() override;
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;

View File

@@ -404,9 +404,3 @@ void Terminal::NotifyBufferRotation(const int delta)
_NotifyScrollEvent();
}
}
void Terminal::NotifyShellIntegrationMark()
{
// Notify the scrollbar that marks have been added so it can refresh the mark indicators
_NotifyScrollEvent();
}

View File

@@ -1736,14 +1736,6 @@
<value>Bereich automatisch mit dem Mauszeiger fokussieren</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Passen Sie die Schriftgröße des Terminals an, indem Sie die STRG-TASTE gedrückt halten und scrollen</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Passen Sie die Deckkraft des Terminals an, indem Sie scrollen, während Sie die STRG- und UMSCHALTTASTE gedrückt halten</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Bereichsanimationen</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Centrarse automáticamente en el panel al pasar el mouse</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Ajuste el tamaño de fuente del terminal desplazándose mientras mantiene presionada la tecla Ctrl</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ajuste la opacidad del terminal desplazándose mientras mantiene presionadas las teclas CTRL y Mayús</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Animaciones de panel</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Mise au point automatique du volet au survol de la souris</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Ajustez la taille de police du terminal en faisant défiler tout en maintenant la touche Ctrl enfoncée</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ajustez lopacité du terminal en faisant défiler tout en maintenant les touches Ctrl et Maj enfoncées</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Animations du volet</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Riquadro di messa a fuoco automatica al passaggio del mouse</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Regola le dimensioni del carattere del terminale scorrendo tenendo premuto il tasto CTRL</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Regola l'opacità del terminale scorrendo mentre tieni premuti i tasti CTRL e MAIUSC</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Riquadro animazioni</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>マウスをポイントしたときにフォーカス ウィンドウを自動的に表示する</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Ctrl キーを押しながらスクロールして、ターミナルのフォント サイズを調整します</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ctrl キーと Shift キーを押しながらスクロールして、ターミナルの不透明度を調整します</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>ウィンドウのアニメーション</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>마우스를 위에 가져다 대면 자동으로 포커스 창이 실행됨</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Ctrl 키를 누른 상태에서 스크롤하여 터미널 글꼴 크기 조정</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ctrl 키와 Shift 키를 누른 상태에서 스크롤하여 터미널 불투명도 조정</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>창 애니메이션</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Focalizar painel automaticamente ao passar o mouse</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Ajustar o tamanho da fonte do terminal rolando enquanto mantém a tecla Ctrl pressionada</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ajustar a opacidade do terminal ao rolar enquanto mantém as teclas Ctrl e Shift</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Animações do painel</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Áϋτомàţīćąłłý ƒόćŭś рåπę öń мõùšě ђöνëŗ !!! !!! !!! !!!</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Аδĵŭŝт ţєŗмιņăℓ ƒøпť ѕįżε вỳ şċѓοℓℓíńğ ẃħïĺє ĥöľδīйģ τђе €ŧřŀ ќëÿ !!! !!! !!! !!! !!! !!! !</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ąδĵüšţ ŧęřмìńąĺ ôрǻčĩτў ьγ šćřοļĺįήĝ ẅђϊłę ħōļδîʼnğ ťђз Çťгł àиδ Śђĭƒт ķęÿŝ !!! !!! !!! !!! !!! !!! !!! !</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Ρǻйě ǻйϊмäţіőηş !!! !</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Áϋτомàţīćąłłý ƒόćŭś рåπę öń мõùšě ђöνëŗ !!! !!! !!! !!!</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Аδĵŭŝт ţєŗмιņăℓ ƒøпť ѕįżε вỳ şċѓοℓℓíńğ ẃħïĺє ĥöľδīйģ τђе €ŧřŀ ќëÿ !!! !!! !!! !!! !!! !!! !</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ąδĵüšţ ŧęřмìńąĺ ôрǻčĩτў ьγ šćřοļĺįήĝ ẅђϊłę ħōļδîʼnğ ťђз Çťгł àиδ Śђĭƒт ķęÿŝ !!! !!! !!! !!! !!! !!! !!! !</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Ρǻйě ǻйϊмäţіőηş !!! !</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Áϋτомàţīćąłłý ƒόćŭś рåπę öń мõùšě ђöνëŗ !!! !!! !!! !!!</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Аδĵŭŝт ţєŗмιņăℓ ƒøпť ѕįżε вỳ şċѓοℓℓíńğ ẃħïĺє ĥöľδīйģ τђе €ŧřŀ ќëÿ !!! !!! !!! !!! !!! !!! !</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Ąδĵüšţ ŧęřмìńąĺ ôрǻčĩτў ьγ šćřοļĺįήĝ ẅђϊłę ħōļδîʼnğ ťђз Çťгł àиδ Śђĭƒт ķęÿŝ !!! !!! !!! !!! !!! !!! !!! !</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Ρǻйě ǻйϊмäţіőηş !!! !</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>Автоматически переводить фокус на панель при наведении указателя мыши</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>Изменение размера шрифта терминала с помощью прокрутки при удерживании клавиши CTRL</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Настройте прозрачность терминала путем прокрутки при нажатых клавишах CTRL и SHIFT</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Анимация панели</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>鼠标悬停时自动聚焦窗格</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>按住 Ctrl 键时通过滚动调整终端字体大小</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>按住 Ctrl 和 Shift 键的同时滚动来调整终端不透明度</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>窗格动画</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -1736,14 +1736,6 @@
<value>滑鼠暫留時自動聚焦窗格</value>
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
</data>
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
<value>按住 Ctrl 鍵的同時捲動來調整終端字體大小</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>按住 Ctrl 和 Shift 鍵的同時捲動來調整終端不透明度</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>窗格動畫</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@@ -9,7 +9,6 @@
#include <LibraryResources.h>
#include <til/static_map.h>
#include <ScopedResourceLoader.h>
static constexpr std::string_view AdjustFontSizeKey{ "adjustFontSize" };
static constexpr std::string_view CloseOtherPanesKey{ "closeOtherPanes" };
@@ -340,112 +339,112 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return copy;
}
winrt::hstring ActionAndArgs::GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext& context) const
winrt::hstring ActionAndArgs::GenerateName() const
{
// Sentinel used to indicate this command must ALWAYS be generated by GenerateName
static constexpr wil::zwstring_view MustGenerate{};
static const winrt::hstring MustGenerate;
// Use a magic static to initialize this map, because we won't be able
// to load the resources at _init_, only at runtime.
static const auto GeneratedActionNames = []() {
return std::unordered_map<ShortcutAction, wil::zwstring_view>{
{ ShortcutAction::AdjustFontSize, USES_RESOURCE(L"AdjustFontSizeCommandKey") },
{ ShortcutAction::CloseOtherPanes, USES_RESOURCE(L"CloseOtherPanesCommandKey") },
return std::unordered_map<ShortcutAction, winrt::hstring>{
{ ShortcutAction::AdjustFontSize, RS_(L"AdjustFontSizeCommandKey") },
{ ShortcutAction::CloseOtherPanes, RS_(L"CloseOtherPanesCommandKey") },
{ ShortcutAction::CloseOtherTabs, MustGenerate },
{ ShortcutAction::ClosePane, USES_RESOURCE(L"ClosePaneCommandKey") },
{ ShortcutAction::ClosePane, RS_(L"ClosePaneCommandKey") },
{ ShortcutAction::CloseTab, MustGenerate },
{ ShortcutAction::CloseTabsAfter, MustGenerate },
{ ShortcutAction::CloseWindow, USES_RESOURCE(L"CloseWindowCommandKey") },
{ ShortcutAction::CopyText, USES_RESOURCE(L"CopyTextCommandKey") },
{ ShortcutAction::DuplicateTab, USES_RESOURCE(L"DuplicateTabCommandKey") },
{ ShortcutAction::ExecuteCommandline, USES_RESOURCE(L"ExecuteCommandlineCommandKey") },
{ ShortcutAction::Find, USES_RESOURCE(L"FindCommandKey") },
{ ShortcutAction::CloseWindow, RS_(L"CloseWindowCommandKey") },
{ ShortcutAction::CopyText, RS_(L"CopyTextCommandKey") },
{ ShortcutAction::DuplicateTab, RS_(L"DuplicateTabCommandKey") },
{ ShortcutAction::ExecuteCommandline, RS_(L"ExecuteCommandlineCommandKey") },
{ ShortcutAction::Find, RS_(L"FindCommandKey") },
{ ShortcutAction::Invalid, MustGenerate },
{ ShortcutAction::MoveFocus, USES_RESOURCE(L"MoveFocusCommandKey") },
{ ShortcutAction::MovePane, USES_RESOURCE(L"MovePaneCommandKey") },
{ ShortcutAction::SwapPane, USES_RESOURCE(L"SwapPaneCommandKey") },
{ ShortcutAction::NewTab, USES_RESOURCE(L"NewTabCommandKey") },
{ ShortcutAction::NextTab, USES_RESOURCE(L"NextTabCommandKey") },
{ ShortcutAction::OpenNewTabDropdown, USES_RESOURCE(L"OpenNewTabDropdownCommandKey") },
{ ShortcutAction::OpenSettings, USES_RESOURCE(L"OpenSettingsUICommandKey") },
{ ShortcutAction::OpenTabColorPicker, USES_RESOURCE(L"OpenTabColorPickerCommandKey") },
{ ShortcutAction::PasteText, USES_RESOURCE(L"PasteTextCommandKey") },
{ ShortcutAction::PrevTab, USES_RESOURCE(L"PrevTabCommandKey") },
{ ShortcutAction::RenameTab, USES_RESOURCE(L"ResetTabNameCommandKey") },
{ ShortcutAction::OpenTabRenamer, USES_RESOURCE(L"OpenTabRenamerCommandKey") },
{ ShortcutAction::ResetFontSize, USES_RESOURCE(L"ResetFontSizeCommandKey") },
{ ShortcutAction::ResizePane, USES_RESOURCE(L"ResizePaneCommandKey") },
{ ShortcutAction::ScrollDown, USES_RESOURCE(L"ScrollDownCommandKey") },
{ ShortcutAction::ScrollDownPage, USES_RESOURCE(L"ScrollDownPageCommandKey") },
{ ShortcutAction::ScrollUp, USES_RESOURCE(L"ScrollUpCommandKey") },
{ ShortcutAction::ScrollUpPage, USES_RESOURCE(L"ScrollUpPageCommandKey") },
{ ShortcutAction::ScrollToTop, USES_RESOURCE(L"ScrollToTopCommandKey") },
{ ShortcutAction::ScrollToBottom, USES_RESOURCE(L"ScrollToBottomCommandKey") },
{ ShortcutAction::ScrollToMark, USES_RESOURCE(L"ScrollToPreviousMarkCommandKey") },
{ ShortcutAction::AddMark, USES_RESOURCE(L"AddMarkCommandKey") },
{ ShortcutAction::ClearMark, USES_RESOURCE(L"ClearMarkCommandKey") },
{ ShortcutAction::ClearAllMarks, USES_RESOURCE(L"ClearAllMarksCommandKey") },
{ ShortcutAction::MoveFocus, RS_(L"MoveFocusCommandKey") },
{ ShortcutAction::MovePane, RS_(L"MovePaneCommandKey") },
{ ShortcutAction::SwapPane, RS_(L"SwapPaneCommandKey") },
{ ShortcutAction::NewTab, RS_(L"NewTabCommandKey") },
{ ShortcutAction::NextTab, RS_(L"NextTabCommandKey") },
{ ShortcutAction::OpenNewTabDropdown, RS_(L"OpenNewTabDropdownCommandKey") },
{ ShortcutAction::OpenSettings, RS_(L"OpenSettingsUICommandKey") },
{ ShortcutAction::OpenTabColorPicker, RS_(L"OpenTabColorPickerCommandKey") },
{ ShortcutAction::PasteText, RS_(L"PasteTextCommandKey") },
{ ShortcutAction::PrevTab, RS_(L"PrevTabCommandKey") },
{ ShortcutAction::RenameTab, RS_(L"ResetTabNameCommandKey") },
{ ShortcutAction::OpenTabRenamer, RS_(L"OpenTabRenamerCommandKey") },
{ ShortcutAction::ResetFontSize, RS_(L"ResetFontSizeCommandKey") },
{ ShortcutAction::ResizePane, RS_(L"ResizePaneCommandKey") },
{ ShortcutAction::ScrollDown, RS_(L"ScrollDownCommandKey") },
{ ShortcutAction::ScrollDownPage, RS_(L"ScrollDownPageCommandKey") },
{ ShortcutAction::ScrollUp, RS_(L"ScrollUpCommandKey") },
{ ShortcutAction::ScrollUpPage, RS_(L"ScrollUpPageCommandKey") },
{ ShortcutAction::ScrollToTop, RS_(L"ScrollToTopCommandKey") },
{ ShortcutAction::ScrollToBottom, RS_(L"ScrollToBottomCommandKey") },
{ ShortcutAction::ScrollToMark, RS_(L"ScrollToPreviousMarkCommandKey") },
{ ShortcutAction::AddMark, RS_(L"AddMarkCommandKey") },
{ ShortcutAction::ClearMark, RS_(L"ClearMarkCommandKey") },
{ ShortcutAction::ClearAllMarks, RS_(L"ClearAllMarksCommandKey") },
{ ShortcutAction::SendInput, MustGenerate },
{ ShortcutAction::SetColorScheme, MustGenerate },
{ ShortcutAction::SetTabColor, USES_RESOURCE(L"ResetTabColorCommandKey") },
{ ShortcutAction::SplitPane, USES_RESOURCE(L"SplitPaneCommandKey") },
{ ShortcutAction::SwitchToTab, USES_RESOURCE(L"SwitchToTabCommandKey") },
{ ShortcutAction::TabSearch, USES_RESOURCE(L"TabSearchCommandKey") },
{ ShortcutAction::ToggleAlwaysOnTop, USES_RESOURCE(L"ToggleAlwaysOnTopCommandKey") },
{ ShortcutAction::SetTabColor, RS_(L"ResetTabColorCommandKey") },
{ ShortcutAction::SplitPane, RS_(L"SplitPaneCommandKey") },
{ ShortcutAction::SwitchToTab, RS_(L"SwitchToTabCommandKey") },
{ ShortcutAction::TabSearch, RS_(L"TabSearchCommandKey") },
{ ShortcutAction::ToggleAlwaysOnTop, RS_(L"ToggleAlwaysOnTopCommandKey") },
{ ShortcutAction::ToggleCommandPalette, MustGenerate },
{ ShortcutAction::SaveSnippet, MustGenerate },
{ ShortcutAction::Suggestions, MustGenerate },
{ ShortcutAction::ToggleFocusMode, USES_RESOURCE(L"ToggleFocusModeCommandKey") },
{ ShortcutAction::ToggleFocusMode, RS_(L"ToggleFocusModeCommandKey") },
{ ShortcutAction::SetFocusMode, MustGenerate },
{ ShortcutAction::ToggleFullscreen, USES_RESOURCE(L"ToggleFullscreenCommandKey") },
{ ShortcutAction::ToggleFullscreen, RS_(L"ToggleFullscreenCommandKey") },
{ ShortcutAction::SetFullScreen, MustGenerate },
{ ShortcutAction::SetMaximized, MustGenerate },
{ ShortcutAction::TogglePaneZoom, USES_RESOURCE(L"TogglePaneZoomCommandKey") },
{ ShortcutAction::ToggleSplitOrientation, USES_RESOURCE(L"ToggleSplitOrientationCommandKey") },
{ ShortcutAction::ToggleShaderEffects, USES_RESOURCE(L"ToggleShaderEffectsCommandKey") },
{ ShortcutAction::TogglePaneZoom, RS_(L"TogglePaneZoomCommandKey") },
{ ShortcutAction::ToggleSplitOrientation, RS_(L"ToggleSplitOrientationCommandKey") },
{ ShortcutAction::ToggleShaderEffects, RS_(L"ToggleShaderEffectsCommandKey") },
{ ShortcutAction::MoveTab, MustGenerate },
{ ShortcutAction::BreakIntoDebugger, USES_RESOURCE(L"BreakIntoDebuggerCommandKey") },
{ ShortcutAction::BreakIntoDebugger, RS_(L"BreakIntoDebuggerCommandKey") },
{ ShortcutAction::FindMatch, MustGenerate },
{ ShortcutAction::TogglePaneReadOnly, USES_RESOURCE(L"TogglePaneReadOnlyCommandKey") },
{ ShortcutAction::EnablePaneReadOnly, USES_RESOURCE(L"EnablePaneReadOnlyCommandKey") },
{ ShortcutAction::DisablePaneReadOnly, USES_RESOURCE(L"DisablePaneReadOnlyCommandKey") },
{ ShortcutAction::NewWindow, USES_RESOURCE(L"NewWindowCommandKey") },
{ ShortcutAction::IdentifyWindow, USES_RESOURCE(L"IdentifyWindowCommandKey") },
{ ShortcutAction::IdentifyWindows, USES_RESOURCE(L"IdentifyWindowsCommandKey") },
{ ShortcutAction::RenameWindow, USES_RESOURCE(L"ResetWindowNameCommandKey") },
{ ShortcutAction::OpenWindowRenamer, USES_RESOURCE(L"OpenWindowRenamerCommandKey") },
{ ShortcutAction::DisplayWorkingDirectory, USES_RESOURCE(L"DisplayWorkingDirectoryCommandKey") },
{ ShortcutAction::TogglePaneReadOnly, RS_(L"TogglePaneReadOnlyCommandKey") },
{ ShortcutAction::EnablePaneReadOnly, RS_(L"EnablePaneReadOnlyCommandKey") },
{ ShortcutAction::DisablePaneReadOnly, RS_(L"DisablePaneReadOnlyCommandKey") },
{ ShortcutAction::NewWindow, RS_(L"NewWindowCommandKey") },
{ ShortcutAction::IdentifyWindow, RS_(L"IdentifyWindowCommandKey") },
{ ShortcutAction::IdentifyWindows, RS_(L"IdentifyWindowsCommandKey") },
{ ShortcutAction::RenameWindow, RS_(L"ResetWindowNameCommandKey") },
{ ShortcutAction::OpenWindowRenamer, RS_(L"OpenWindowRenamerCommandKey") },
{ ShortcutAction::DisplayWorkingDirectory, RS_(L"DisplayWorkingDirectoryCommandKey") },
{ ShortcutAction::GlobalSummon, MustGenerate },
{ ShortcutAction::SearchForText, MustGenerate },
{ ShortcutAction::QuakeMode, USES_RESOURCE(L"QuakeModeCommandKey") },
{ ShortcutAction::QuakeMode, RS_(L"QuakeModeCommandKey") },
{ ShortcutAction::FocusPane, MustGenerate },
{ ShortcutAction::OpenSystemMenu, USES_RESOURCE(L"OpenSystemMenuCommandKey") },
{ ShortcutAction::OpenSystemMenu, RS_(L"OpenSystemMenuCommandKey") },
{ ShortcutAction::ExportBuffer, MustGenerate },
{ ShortcutAction::ClearBuffer, MustGenerate },
{ ShortcutAction::MultipleActions, MustGenerate },
{ ShortcutAction::Quit, USES_RESOURCE(L"QuitCommandKey") },
{ ShortcutAction::Quit, RS_(L"QuitCommandKey") },
{ ShortcutAction::AdjustOpacity, MustGenerate },
{ ShortcutAction::RestoreLastClosed, USES_RESOURCE(L"RestoreLastClosedCommandKey") },
{ ShortcutAction::RestoreLastClosed, RS_(L"RestoreLastClosedCommandKey") },
{ ShortcutAction::SelectCommand, MustGenerate },
{ ShortcutAction::SelectOutput, MustGenerate },
{ ShortcutAction::SelectAll, USES_RESOURCE(L"SelectAllCommandKey") },
{ ShortcutAction::MarkMode, USES_RESOURCE(L"MarkModeCommandKey") },
{ ShortcutAction::ToggleBlockSelection, USES_RESOURCE(L"ToggleBlockSelectionCommandKey") },
{ ShortcutAction::SwitchSelectionEndpoint, USES_RESOURCE(L"SwitchSelectionEndpointCommandKey") },
{ ShortcutAction::SelectAll, RS_(L"SelectAllCommandKey") },
{ ShortcutAction::MarkMode, RS_(L"MarkModeCommandKey") },
{ ShortcutAction::ToggleBlockSelection, RS_(L"ToggleBlockSelectionCommandKey") },
{ ShortcutAction::SwitchSelectionEndpoint, RS_(L"SwitchSelectionEndpointCommandKey") },
{ ShortcutAction::ColorSelection, MustGenerate },
{ ShortcutAction::ShowContextMenu, USES_RESOURCE(L"ShowContextMenuCommandKey") },
{ ShortcutAction::ExpandSelectionToWord, USES_RESOURCE(L"ExpandSelectionToWordCommandKey") },
{ ShortcutAction::RestartConnection, USES_RESOURCE(L"RestartConnectionKey") },
{ ShortcutAction::ToggleBroadcastInput, USES_RESOURCE(L"ToggleBroadcastInputCommandKey") },
{ ShortcutAction::OpenScratchpad, USES_RESOURCE(L"OpenScratchpadKey") },
{ ShortcutAction::OpenAbout, USES_RESOURCE(L"OpenAboutCommandKey") },
{ ShortcutAction::QuickFix, USES_RESOURCE(L"QuickFixCommandKey") },
{ ShortcutAction::OpenCWD, USES_RESOURCE(L"OpenCWDCommandKey") },
{ ShortcutAction::ShowContextMenu, RS_(L"ShowContextMenuCommandKey") },
{ ShortcutAction::ExpandSelectionToWord, RS_(L"ExpandSelectionToWordCommandKey") },
{ ShortcutAction::RestartConnection, RS_(L"RestartConnectionKey") },
{ ShortcutAction::ToggleBroadcastInput, RS_(L"ToggleBroadcastInputCommandKey") },
{ ShortcutAction::OpenScratchpad, RS_(L"OpenScratchpadKey") },
{ ShortcutAction::OpenAbout, RS_(L"OpenAboutCommandKey") },
{ ShortcutAction::QuickFix, RS_(L"QuickFixCommandKey") },
{ ShortcutAction::OpenCWD, RS_(L"OpenCWDCommandKey") },
};
}();
if (_Args)
{
auto nameFromArgs = _Args.GenerateName(context);
auto nameFromArgs = _Args.GenerateName();
if (!nameFromArgs.empty())
{
return nameFromArgs;
@@ -453,16 +452,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
}
const auto found = GeneratedActionNames.find(_Action);
if (found != GeneratedActionNames.end() && !found->second.empty())
{
return GetLibraryResourceLoader().ResourceMap().GetValue(found->second, context).ValueAsString();
}
return winrt::hstring{};
}
winrt::hstring ActionAndArgs::GenerateName() const
{
return GenerateName(GetLibraryResourceLoader().ResourceContext());
return found != GeneratedActionNames.end() ? found->second : winrt::hstring{};
}
// Function Description:

View File

@@ -25,7 +25,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
_Args{ args } {};
com_ptr<ActionAndArgs> Copy() const;
hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext& context) const;
hstring GenerateName() const;
hstring GenerateID() const;

View File

@@ -53,42 +53,12 @@
#include <LibraryResources.h>
#include <WtExeUtils.h>
#include <ScopedResourceLoader.h>
namespace winrt
{
namespace WARC = ::winrt::Windows::ApplicationModel::Resources::Core;
}
// Like RS_ and RS_fmt, but they use an ambient boolean named "localized" to
// determine whether to load the English version of a resource or the localized
// one.
#define RS_switchable_(x) RS_switchable_impl(context, USES_RESOURCE(x))
#define RS_switchable_fmt(x, ...) RS_switchable_fmt_impl(context, USES_RESOURCE(x), __VA_ARGS__)
static winrt::hstring RS_switchable_impl(const winrt::WARC::ResourceContext& context, std::wstring_view key)
{
return GetLibraryResourceLoader().ResourceMap().GetValue(key, context).ValueAsString();
}
template<typename... Args>
static std::wstring RS_switchable_fmt_impl(const winrt::WARC::ResourceContext& context, std::wstring_view key, Args&&... args)
{
const auto format = RS_switchable_impl(context, key);
return fmt::format(fmt::runtime(std::wstring_view{ format }), std::forward<Args>(args)...);
}
using namespace winrt::Microsoft::Terminal::Control;
namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
const ScopedResourceLoader& EnglishOnlyResourceLoader() noexcept
{
static ScopedResourceLoader loader{ GetLibraryResourceLoader().WithQualifier(L"language", L"en-US") };
return loader;
}
winrt::hstring NewTerminalArgs::GenerateName(const winrt::WARC::ResourceContext&) const
winrt::hstring NewTerminalArgs::GenerateName() const
{
std::wstring str;
@@ -224,17 +194,17 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return winrt::hstring{ str };
}
winrt::hstring CopyTextArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring CopyTextArgs::GenerateName() const
{
std::wstring str;
if (SingleLine())
{
str.append(RS_switchable_(L"CopyTextAsSingleLineCommandKey"));
str.append(RS_(L"CopyTextAsSingleLineCommandKey"));
}
else
{
str.append(RS_switchable_(L"CopyTextCommandKey"));
str.append(RS_(L"CopyTextCommandKey"));
}
if (WithControlSequences())
@@ -278,24 +248,24 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return winrt::hstring{ str };
}
winrt::hstring NewTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring NewTabArgs::GenerateName() const
{
winrt::hstring newTerminalArgsStr;
if (ContentArgs())
{
newTerminalArgsStr = ContentArgs().GenerateName(context);
newTerminalArgsStr = ContentArgs().GenerateName();
}
if (newTerminalArgsStr.empty())
{
return RS_switchable_(L"NewTabCommandKey");
return RS_(L"NewTabCommandKey");
}
return winrt::hstring{
fmt::format(FMT_COMPILE(L"{}, {}"), RS_switchable_(L"NewTabCommandKey"), newTerminalArgsStr)
fmt::format(FMT_COMPILE(L"{}, {}"), RS_(L"NewTabCommandKey"), newTerminalArgsStr)
};
}
winrt::hstring MovePaneArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring MovePaneArgs::GenerateName() const
{
if (!Window().empty())
{
@@ -304,115 +274,115 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// in the new window, till we get there.
if (Window() == L"new")
{
return RS_switchable_(L"MovePaneToNewWindowCommandKey");
return RS_(L"MovePaneToNewWindowCommandKey");
}
return winrt::hstring{
fmt::format(FMT_COMPILE(L"{}, window:{}, tab index:{}"), RS_switchable_(L"MovePaneCommandKey"), Window(), TabIndex())
fmt::format(FMT_COMPILE(L"{}, window:{}, tab index:{}"), RS_(L"MovePaneCommandKey"), Window(), TabIndex())
};
}
return winrt::hstring{
fmt::format(FMT_COMPILE(L"{}, tab index:{}"), RS_switchable_(L"MovePaneCommandKey"), TabIndex())
fmt::format(FMT_COMPILE(L"{}, tab index:{}"), RS_(L"MovePaneCommandKey"), TabIndex())
};
}
winrt::hstring SwitchToTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SwitchToTabArgs::GenerateName() const
{
if (TabIndex() == UINT32_MAX)
{
return RS_switchable_(L"SwitchToLastTabCommandKey");
return RS_(L"SwitchToLastTabCommandKey");
}
return winrt::hstring{
fmt::format(FMT_COMPILE(L"{}, index:{}"), RS_switchable_(L"SwitchToTabCommandKey"), TabIndex())
fmt::format(FMT_COMPILE(L"{}, index:{}"), RS_(L"SwitchToTabCommandKey"), TabIndex())
};
}
winrt::hstring ResizePaneArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ResizePaneArgs::GenerateName() const
{
winrt::hstring directionString;
switch (ResizeDirection())
{
case ResizeDirection::Left:
directionString = RS_switchable_(L"DirectionLeft");
directionString = RS_(L"DirectionLeft");
break;
case ResizeDirection::Right:
directionString = RS_switchable_(L"DirectionRight");
directionString = RS_(L"DirectionRight");
break;
case ResizeDirection::Up:
directionString = RS_switchable_(L"DirectionUp");
directionString = RS_(L"DirectionUp");
break;
case ResizeDirection::Down:
directionString = RS_switchable_(L"DirectionDown");
directionString = RS_(L"DirectionDown");
break;
}
return winrt::hstring{ RS_switchable_fmt(L"ResizePaneWithArgCommandKey", directionString) };
return winrt::hstring{ RS_fmt(L"ResizePaneWithArgCommandKey", directionString) };
}
winrt::hstring MoveFocusArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring MoveFocusArgs::GenerateName() const
{
winrt::hstring directionString;
switch (FocusDirection())
{
case FocusDirection::Left:
directionString = RS_switchable_(L"DirectionLeft");
directionString = RS_(L"DirectionLeft");
break;
case FocusDirection::Right:
directionString = RS_switchable_(L"DirectionRight");
directionString = RS_(L"DirectionRight");
break;
case FocusDirection::Up:
directionString = RS_switchable_(L"DirectionUp");
directionString = RS_(L"DirectionUp");
break;
case FocusDirection::Down:
directionString = RS_switchable_(L"DirectionDown");
directionString = RS_(L"DirectionDown");
break;
case FocusDirection::Previous:
return RS_switchable_(L"MoveFocusToLastUsedPane");
return RS_(L"MoveFocusToLastUsedPane");
case FocusDirection::NextInOrder:
return RS_switchable_(L"MoveFocusNextInOrder");
return RS_(L"MoveFocusNextInOrder");
case FocusDirection::PreviousInOrder:
return RS_switchable_(L"MoveFocusPreviousInOrder");
return RS_(L"MoveFocusPreviousInOrder");
case FocusDirection::First:
return RS_switchable_(L"MoveFocusFirstPane");
return RS_(L"MoveFocusFirstPane");
case FocusDirection::Parent:
return RS_switchable_(L"MoveFocusParentPane");
return RS_(L"MoveFocusParentPane");
case FocusDirection::Child:
return RS_switchable_(L"MoveFocusChildPane");
return RS_(L"MoveFocusChildPane");
}
return winrt::hstring{ RS_switchable_fmt(L"MoveFocusWithArgCommandKey", directionString) };
return winrt::hstring{ RS_fmt(L"MoveFocusWithArgCommandKey", directionString) };
}
winrt::hstring SwapPaneArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SwapPaneArgs::GenerateName() const
{
winrt::hstring directionString;
switch (Direction())
{
case FocusDirection::Left:
directionString = RS_switchable_(L"DirectionLeft");
directionString = RS_(L"DirectionLeft");
break;
case FocusDirection::Right:
directionString = RS_switchable_(L"DirectionRight");
directionString = RS_(L"DirectionRight");
break;
case FocusDirection::Up:
directionString = RS_switchable_(L"DirectionUp");
directionString = RS_(L"DirectionUp");
break;
case FocusDirection::Down:
directionString = RS_switchable_(L"DirectionDown");
directionString = RS_(L"DirectionDown");
break;
case FocusDirection::Previous:
return RS_switchable_(L"SwapPaneToLastUsedPane");
return RS_(L"SwapPaneToLastUsedPane");
case FocusDirection::NextInOrder:
return RS_switchable_(L"SwapPaneNextInOrder");
return RS_(L"SwapPaneNextInOrder");
case FocusDirection::PreviousInOrder:
return RS_switchable_(L"SwapPanePreviousInOrder");
return RS_(L"SwapPanePreviousInOrder");
case FocusDirection::First:
return RS_switchable_(L"SwapPaneFirstPane");
return RS_(L"SwapPaneFirstPane");
}
return winrt::hstring{ RS_switchable_fmt(L"SwapPaneWithArgCommandKey", directionString) };
return winrt::hstring{ RS_fmt(L"SwapPaneWithArgCommandKey", directionString) };
}
winrt::hstring AdjustFontSizeArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring AdjustFontSizeArgs::GenerateName() const
{
// If the amount is just 1 (or -1), we'll just return "Increase font
// size" (or "Decrease font size"). If the amount delta has a greater
@@ -420,25 +390,25 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// * Decrease font size, amount: {delta}"
if (Delta() < 0)
{
return Delta() == -1 ? RS_switchable_(L"DecreaseFontSizeCommandKey") : winrt::hstring{ RS_switchable_fmt(L"DecreaseFontSizeWithAmountCommandKey", -Delta()) };
return Delta() == -1 ? RS_(L"DecreaseFontSizeCommandKey") : winrt::hstring{ RS_fmt(L"DecreaseFontSizeWithAmountCommandKey", -Delta()) };
}
else
{
return Delta() == 1 ? RS_switchable_(L"IncreaseFontSizeCommandKey") : winrt::hstring{ RS_switchable_fmt(L"IncreaseFontSizeWithAmountCommandKey", Delta()) };
return Delta() == 1 ? RS_(L"IncreaseFontSizeCommandKey") : winrt::hstring{ RS_fmt(L"IncreaseFontSizeWithAmountCommandKey", Delta()) };
}
}
winrt::hstring SendInputArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SendInputArgs::GenerateName() const
{
// The string will be similar to the following:
// * "Send Input: ...input..."
const auto escapedInput = til::visualize_control_codes(Input());
const auto name = RS_switchable_fmt(L"SendInputCommandKey", escapedInput);
const auto name = RS_fmt(L"SendInputCommandKey", escapedInput);
return winrt::hstring{ name };
}
winrt::hstring SplitPaneArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SplitPaneArgs::GenerateName() const
{
// The string will be similar to the following:
// * "Duplicate pane[, split: <direction>][, size: <size>%][, new terminal arguments...]"
@@ -452,11 +422,11 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
std::wstring str;
if (SplitMode() == SplitType::Duplicate)
{
str.append(RS_switchable_(L"DuplicatePaneCommandKey"));
str.append(RS_(L"DuplicatePaneCommandKey"));
}
else
{
str.append(RS_switchable_(L"SplitPaneCommandKey"));
str.append(RS_(L"SplitPaneCommandKey"));
}
str.append(L", ");
@@ -486,7 +456,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
winrt::hstring newTerminalArgsStr;
if (ContentArgs())
{
newTerminalArgsStr = ContentArgs().GenerateName(context);
newTerminalArgsStr = ContentArgs().GenerateName();
}
if (SplitMode() != SplitType::Duplicate && !newTerminalArgsStr.empty())
@@ -500,209 +470,209 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return winrt::hstring{ str };
}
winrt::hstring OpenSettingsArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring OpenSettingsArgs::GenerateName() const
{
switch (Target())
{
case SettingsTarget::DefaultsFile:
return RS_switchable_(L"OpenDefaultSettingsCommandKey");
return RS_(L"OpenDefaultSettingsCommandKey");
case SettingsTarget::AllFiles:
return RS_switchable_(L"OpenBothSettingsFilesCommandKey");
return RS_(L"OpenBothSettingsFilesCommandKey");
case SettingsTarget::SettingsFile:
return RS_switchable_(L"OpenSettingsCommandKey");
return RS_(L"OpenSettingsCommandKey");
case SettingsTarget::Directory:
return RS_switchable_(L"SettingsFileOpenInExplorerCommandKey");
return RS_(L"SettingsFileOpenInExplorerCommandKey");
case SettingsTarget::SettingsUI:
default:
return RS_switchable_(L"OpenSettingsUICommandKey");
return RS_(L"OpenSettingsUICommandKey");
}
}
winrt::hstring SetFocusModeArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SetFocusModeArgs::GenerateName() const
{
if (IsFocusMode())
{
return RS_switchable_(L"EnableFocusModeCommandKey");
return RS_(L"EnableFocusModeCommandKey");
}
return RS_switchable_(L"DisableFocusModeCommandKey");
return RS_(L"DisableFocusModeCommandKey");
}
winrt::hstring SetFullScreenArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SetFullScreenArgs::GenerateName() const
{
if (IsFullScreen())
{
return RS_switchable_(L"EnableFullScreenCommandKey");
return RS_(L"EnableFullScreenCommandKey");
}
return RS_switchable_(L"DisableFullScreenCommandKey");
return RS_(L"DisableFullScreenCommandKey");
}
winrt::hstring SetMaximizedArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SetMaximizedArgs::GenerateName() const
{
if (IsMaximized())
{
return RS_switchable_(L"EnableMaximizedCommandKey");
return RS_(L"EnableMaximizedCommandKey");
}
return RS_switchable_(L"DisableMaximizedCommandKey");
return RS_(L"DisableMaximizedCommandKey");
}
winrt::hstring SetColorSchemeArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SetColorSchemeArgs::GenerateName() const
{
// "Set color scheme to "{_SchemeName}""
if (!SchemeName().empty())
{
return winrt::hstring{ RS_switchable_fmt(L"SetColorSchemeCommandKey", SchemeName()) };
return winrt::hstring{ RS_fmt(L"SetColorSchemeCommandKey", SchemeName()) };
}
return {};
}
winrt::hstring SetTabColorArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SetTabColorArgs::GenerateName() const
{
// "Set tab color to #RRGGBB"
// "Reset tab color"
if (TabColor())
{
til::color tabColor{ TabColor().Value() };
return winrt::hstring{ RS_switchable_fmt(L"SetTabColorCommandKey", tabColor.ToHexString(true)) };
return winrt::hstring{ RS_fmt(L"SetTabColorCommandKey", tabColor.ToHexString(true)) };
}
return RS_switchable_(L"ResetTabColorCommandKey");
return RS_(L"ResetTabColorCommandKey");
}
winrt::hstring RenameTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring RenameTabArgs::GenerateName() const
{
// "Rename tab to \"{_Title}\""
// "Reset tab title"
if (!Title().empty())
{
return winrt::hstring{ RS_switchable_fmt(L"RenameTabCommandKey", Title()) };
return winrt::hstring{ RS_fmt(L"RenameTabCommandKey", Title()) };
}
return RS_switchable_(L"ResetTabNameCommandKey");
return RS_(L"ResetTabNameCommandKey");
}
winrt::hstring ExecuteCommandlineArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ExecuteCommandlineArgs::GenerateName() const
{
// "Run commandline "{_Commandline}" in this window"
if (!Commandline().empty())
{
return winrt::hstring{ RS_switchable_fmt(L"ExecuteCommandlineCommandKey", Commandline()) };
return winrt::hstring{ RS_fmt(L"ExecuteCommandlineCommandKey", Commandline()) };
}
return {};
}
winrt::hstring CloseOtherTabsArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring CloseOtherTabsArgs::GenerateName() const
{
if (Index())
{
// "Close tabs other than index {0}"
return winrt::hstring{ RS_switchable_fmt(L"CloseOtherTabsCommandKey", Index().Value()) };
return winrt::hstring{ RS_fmt(L"CloseOtherTabsCommandKey", Index().Value()) };
}
return RS_switchable_(L"CloseOtherTabsDefaultCommandKey");
return RS_(L"CloseOtherTabsDefaultCommandKey");
}
winrt::hstring CloseTabsAfterArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring CloseTabsAfterArgs::GenerateName() const
{
if (Index())
{
// "Close tabs after index {0}"
return winrt::hstring{ RS_switchable_fmt(L"CloseTabsAfterCommandKey", Index().Value()) };
return winrt::hstring{ RS_fmt(L"CloseTabsAfterCommandKey", Index().Value()) };
}
return RS_switchable_(L"CloseTabsAfterDefaultCommandKey");
return RS_(L"CloseTabsAfterDefaultCommandKey");
}
winrt::hstring CloseTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring CloseTabArgs::GenerateName() const
{
if (Index())
{
// "Close tab at index {0}"
return winrt::hstring{ RS_switchable_fmt(L"CloseTabAtIndexCommandKey", Index().Value()) };
return winrt::hstring{ RS_fmt(L"CloseTabAtIndexCommandKey", Index().Value()) };
}
return RS_switchable_(L"CloseTabCommandKey");
return RS_(L"CloseTabCommandKey");
}
winrt::hstring ScrollUpArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ScrollUpArgs::GenerateName() const
{
if (RowsToScroll())
{
return winrt::hstring{ RS_switchable_fmt(L"ScrollUpSeveralRowsCommandKey", RowsToScroll().Value()) };
return winrt::hstring{ RS_fmt(L"ScrollUpSeveralRowsCommandKey", RowsToScroll().Value()) };
}
return RS_switchable_(L"ScrollUpCommandKey");
return RS_(L"ScrollUpCommandKey");
}
winrt::hstring ScrollDownArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ScrollDownArgs::GenerateName() const
{
if (RowsToScroll())
{
return winrt::hstring{ RS_switchable_fmt(L"ScrollDownSeveralRowsCommandKey", RowsToScroll().Value()) };
return winrt::hstring{ RS_fmt(L"ScrollDownSeveralRowsCommandKey", RowsToScroll().Value()) };
}
return RS_switchable_(L"ScrollDownCommandKey");
return RS_(L"ScrollDownCommandKey");
}
winrt::hstring ScrollToMarkArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ScrollToMarkArgs::GenerateName() const
{
switch (Direction())
{
case Microsoft::Terminal::Control::ScrollToMarkDirection::Last:
return winrt::hstring{ RS_switchable_(L"ScrollToLastMarkCommandKey") };
return winrt::hstring{ RS_(L"ScrollToLastMarkCommandKey") };
case Microsoft::Terminal::Control::ScrollToMarkDirection::First:
return winrt::hstring{ RS_switchable_(L"ScrollToFirstMarkCommandKey") };
return winrt::hstring{ RS_(L"ScrollToFirstMarkCommandKey") };
case Microsoft::Terminal::Control::ScrollToMarkDirection::Next:
return winrt::hstring{ RS_switchable_(L"ScrollToNextMarkCommandKey") };
return winrt::hstring{ RS_(L"ScrollToNextMarkCommandKey") };
case Microsoft::Terminal::Control::ScrollToMarkDirection::Previous:
default:
return winrt::hstring{ RS_switchable_(L"ScrollToPreviousMarkCommandKey") };
return winrt::hstring{ RS_(L"ScrollToPreviousMarkCommandKey") };
}
return winrt::hstring{ RS_switchable_(L"ScrollToPreviousMarkCommandKey") };
return winrt::hstring{ RS_(L"ScrollToPreviousMarkCommandKey") };
}
winrt::hstring AddMarkArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring AddMarkArgs::GenerateName() const
{
if (Color())
{
return winrt::hstring{ RS_switchable_fmt(L"AddMarkWithColorCommandKey", til::color{ Color().Value() }.ToHexString(true)) };
return winrt::hstring{ RS_fmt(L"AddMarkWithColorCommandKey", til::color{ Color().Value() }.ToHexString(true)) };
}
else
{
return RS_switchable_(L"AddMarkCommandKey");
return RS_(L"AddMarkCommandKey");
}
}
winrt::hstring MoveTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring MoveTabArgs::GenerateName() const
{
if (!Window().empty())
{
if (Window() == L"new")
{
return RS_switchable_(L"MoveTabToNewWindowCommandKey");
return RS_(L"MoveTabToNewWindowCommandKey");
}
return winrt::hstring{ RS_switchable_fmt(L"MoveTabToWindowCommandKey", Window()) };
return winrt::hstring{ RS_fmt(L"MoveTabToWindowCommandKey", Window()) };
}
winrt::hstring directionString;
switch (Direction())
{
case MoveTabDirection::Forward:
directionString = RS_switchable_(L"MoveTabDirectionForward");
directionString = RS_(L"MoveTabDirectionForward");
break;
case MoveTabDirection::Backward:
directionString = RS_switchable_(L"MoveTabDirectionBackward");
directionString = RS_(L"MoveTabDirectionBackward");
break;
}
return winrt::hstring{ RS_switchable_fmt(L"MoveTabCommandKey", directionString) };
return winrt::hstring{ RS_fmt(L"MoveTabCommandKey", directionString) };
}
winrt::hstring ToggleCommandPaletteArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ToggleCommandPaletteArgs::GenerateName() const
{
if (LaunchMode() == CommandPaletteLaunchMode::CommandLine)
{
return RS_switchable_(L"ToggleCommandPaletteCommandLineModeCommandKey");
return RS_(L"ToggleCommandPaletteCommandLineModeCommandKey");
}
return RS_switchable_(L"ToggleCommandPaletteCommandKey");
return RS_(L"ToggleCommandPaletteCommandKey");
}
winrt::hstring SuggestionsArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SuggestionsArgs::GenerateName() const
{
std::wstring str;
str.append(RS_switchable_(L"SuggestionsCommandKey"));
str.append(RS_(L"SuggestionsCommandKey"));
if (UseCommandline())
{
@@ -737,78 +707,78 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return winrt::hstring{ str };
}
winrt::hstring FindMatchArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring FindMatchArgs::GenerateName() const
{
switch (Direction())
{
case FindMatchDirection::Next:
return winrt::hstring{ RS_switchable_(L"FindNextCommandKey") };
return winrt::hstring{ RS_(L"FindNextCommandKey") };
case FindMatchDirection::Previous:
return winrt::hstring{ RS_switchable_(L"FindPrevCommandKey") };
return winrt::hstring{ RS_(L"FindPrevCommandKey") };
}
return {};
}
winrt::hstring NewWindowArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring NewWindowArgs::GenerateName() const
{
winrt::hstring newTerminalArgsStr;
if (ContentArgs())
{
newTerminalArgsStr = ContentArgs().GenerateName(context);
newTerminalArgsStr = ContentArgs().GenerateName();
}
if (newTerminalArgsStr.empty())
{
return RS_switchable_(L"NewWindowCommandKey");
return RS_(L"NewWindowCommandKey");
}
return winrt::hstring{ fmt::format(FMT_COMPILE(L"{}, {}"), RS_switchable_(L"NewWindowCommandKey"), newTerminalArgsStr) };
return winrt::hstring{ fmt::format(FMT_COMPILE(L"{}, {}"), RS_(L"NewWindowCommandKey"), newTerminalArgsStr) };
}
winrt::hstring PrevTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring PrevTabArgs::GenerateName() const
{
if (!SwitcherMode())
{
return RS_switchable_(L"PrevTabCommandKey");
return RS_(L"PrevTabCommandKey");
}
const auto mode = SwitcherMode().Value() == TabSwitcherMode::MostRecentlyUsed ? L"most recently used" : L"in order";
return winrt::hstring(fmt::format(FMT_COMPILE(L"{}, {}"), RS_switchable_(L"PrevTabCommandKey"), mode));
return winrt::hstring(fmt::format(FMT_COMPILE(L"{}, {}"), RS_(L"PrevTabCommandKey"), mode));
}
winrt::hstring NextTabArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring NextTabArgs::GenerateName() const
{
if (!SwitcherMode())
{
return RS_switchable_(L"NextTabCommandKey");
return RS_(L"NextTabCommandKey");
}
const auto mode = SwitcherMode().Value() == TabSwitcherMode::MostRecentlyUsed ? L"most recently used" : L"in order";
return winrt::hstring(fmt::format(FMT_COMPILE(L"{}, {}"), RS_switchable_(L"NextTabCommandKey"), mode));
return winrt::hstring(fmt::format(FMT_COMPILE(L"{}, {}"), RS_(L"NextTabCommandKey"), mode));
}
winrt::hstring RenameWindowArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring RenameWindowArgs::GenerateName() const
{
// "Rename window to \"{_Name}\""
// "Clear window name"
if (!Name().empty())
{
return winrt::hstring{ RS_switchable_fmt(L"RenameWindowCommandKey", Name()) };
return winrt::hstring{ RS_fmt(L"RenameWindowCommandKey", Name()) };
}
return RS_switchable_(L"ResetWindowNameCommandKey");
return RS_(L"ResetWindowNameCommandKey");
}
winrt::hstring SearchForTextArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SearchForTextArgs::GenerateName() const
{
if (QueryUrl().empty())
{
// Return the default command name, because we'll just use the
// default search engine for this.
return RS_switchable_(L"SearchWebCommandKey");
return RS_(L"SearchWebCommandKey");
}
try
{
return winrt::hstring{ RS_switchable_fmt(L"SearchForTextCommandKey", Windows::Foundation::Uri(QueryUrl()).Domain()) };
return winrt::hstring{ RS_fmt(L"SearchForTextCommandKey", Windows::Foundation::Uri(QueryUrl()).Domain()) };
}
CATCH_LOG();
@@ -817,17 +787,17 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return {};
}
winrt::hstring GlobalSummonArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring GlobalSummonArgs::GenerateName() const
{
// GH#10210 - Is this action literally the same thing as the `quakeMode`
// action? That has a special name.
static const auto quakeModeArgs{ std::get<0>(GlobalSummonArgs::QuakeModeFromJson(Json::Value::null)) };
if (quakeModeArgs.Equals(*this))
{
return RS_switchable_(L"QuakeModeCommandKey");
return RS_(L"QuakeModeCommandKey");
}
std::wstring str{ RS_switchable_(L"GlobalSummonCommandKey") };
std::wstring str{ RS_(L"GlobalSummonCommandKey") };
// "Summon the Terminal window"
// "Summon the Terminal window, name:\"{_Name}\""
@@ -839,27 +809,27 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return winrt::hstring{ str };
}
winrt::hstring FocusPaneArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring FocusPaneArgs::GenerateName() const
{
// "Focus pane {Id}"
return winrt::hstring{ RS_switchable_fmt(L"FocusPaneCommandKey", Id()) };
return winrt::hstring{ RS_fmt(L"FocusPaneCommandKey", Id()) };
}
winrt::hstring ExportBufferArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ExportBufferArgs::GenerateName() const
{
if (!Path().empty())
{
// "Export text to {path}"
return winrt::hstring{ RS_switchable_fmt(L"ExportBufferToPathCommandKey", Path()) };
return winrt::hstring{ RS_fmt(L"ExportBufferToPathCommandKey", Path()) };
}
else
{
// "Export text"
return RS_switchable_(L"ExportBufferCommandKey");
return RS_(L"ExportBufferCommandKey");
}
}
winrt::hstring ClearBufferArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ClearBufferArgs::GenerateName() const
{
// "Clear Buffer"
// "Clear Viewport"
@@ -867,49 +837,49 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
switch (Clear())
{
case Control::ClearBufferType::All:
return RS_switchable_(L"ClearAllCommandKey");
return RS_(L"ClearAllCommandKey");
case Control::ClearBufferType::Screen:
return RS_switchable_(L"ClearViewportCommandKey");
return RS_(L"ClearViewportCommandKey");
case Control::ClearBufferType::Scrollback:
return RS_switchable_(L"ClearScrollbackCommandKey");
return RS_(L"ClearScrollbackCommandKey");
}
// Return the empty string - the Clear() should be one of these values
return {};
}
winrt::hstring MultipleActionsArgs::GenerateName(const winrt::WARC::ResourceContext&) const
winrt::hstring MultipleActionsArgs::GenerateName() const
{
return {};
}
winrt::hstring AdjustOpacityArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring AdjustOpacityArgs::GenerateName() const
{
if (Relative())
{
if (Opacity() >= 0)
{
// "Increase background opacity by {Opacity}%"
return winrt::hstring{ RS_switchable_fmt(L"IncreaseOpacityCommandKey", Opacity()) };
return winrt::hstring{ RS_fmt(L"IncreaseOpacityCommandKey", Opacity()) };
}
else
{
// "Decrease background opacity by {Opacity}%"
return winrt::hstring{ RS_switchable_fmt(L"DecreaseOpacityCommandKey", Opacity()) };
return winrt::hstring{ RS_fmt(L"DecreaseOpacityCommandKey", Opacity()) };
}
}
else
{
// "Set background opacity to {Opacity}%"
return winrt::hstring{ RS_switchable_fmt(L"AdjustOpacityCommandKey", Opacity()) };
return winrt::hstring{ RS_fmt(L"AdjustOpacityCommandKey", Opacity()) };
}
}
winrt::hstring SaveSnippetArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SaveSnippetArgs::GenerateName() const
{
if (Feature_SaveSnippet::IsEnabled())
{
auto str = fmt::format(FMT_COMPILE(L"{} commandline: {}"), RS_switchable_(L"SaveSnippetNamePrefix"), Commandline());
auto str = fmt::format(FMT_COMPILE(L"{} commandline: {}"), RS_(L"SaveSnippetNamePrefix"), Commandline());
if (!Name().empty())
{
@@ -989,12 +959,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return color.with_alpha(0) == til::color{};
}
winrt::hstring ColorSelectionArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring ColorSelectionArgs::GenerateName() const
{
auto matchModeStr = winrt::hstring{};
if (MatchMode() == Core::MatchMode::All)
{
matchModeStr = fmt::format(FMT_COMPILE(L", {}"), RS_switchable_(L"ColorSelection_allMatches")); // ", all matches"
matchModeStr = fmt::format(FMT_COMPILE(L", {}"), RS_(L"ColorSelection_allMatches")); // ", all matches"
}
const auto foreground = Foreground();
@@ -1014,44 +984,44 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
if (foreground && backgroundIsBoring)
{
// "Color selection, foreground: {0}{1}"
return winrt::hstring{ RS_switchable_fmt(L"ColorSelection_fg_action", fgStr, matchModeStr) };
return winrt::hstring{ RS_fmt(L"ColorSelection_fg_action", fgStr, matchModeStr) };
}
else if (background && foregroundIsBoring)
{
// "Color selection, background: {0}{1}"
return winrt::hstring{ RS_switchable_fmt(L"ColorSelection_bg_action", bgStr, matchModeStr) };
return winrt::hstring{ RS_fmt(L"ColorSelection_bg_action", bgStr, matchModeStr) };
}
else if (foreground && background)
{
// "Color selection, foreground: {0}, background: {1}{2}"
return winrt::hstring{ RS_switchable_fmt(L"ColorSelection_fg_bg_action", fgStr, bgStr, matchModeStr) };
return winrt::hstring{ RS_fmt(L"ColorSelection_fg_bg_action", fgStr, bgStr, matchModeStr) };
}
else
{
// "Color selection, (default foreground/background){0}"
return winrt::hstring{ RS_switchable_fmt(L"ColorSelection_default_action", matchModeStr) };
return winrt::hstring{ RS_fmt(L"ColorSelection_default_action", matchModeStr) };
}
}
winrt::hstring SelectOutputArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SelectOutputArgs::GenerateName() const
{
switch (Direction())
{
case SelectOutputDirection::Next:
return RS_switchable_(L"SelectOutputNextCommandKey");
return RS_(L"SelectOutputNextCommandKey");
case SelectOutputDirection::Previous:
return RS_switchable_(L"SelectOutputPreviousCommandKey");
return RS_(L"SelectOutputPreviousCommandKey");
}
return {};
}
winrt::hstring SelectCommandArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
winrt::hstring SelectCommandArgs::GenerateName() const
{
switch (Direction())
{
case SelectOutputDirection::Next:
return RS_switchable_(L"SelectCommandNextCommandKey");
return RS_(L"SelectCommandNextCommandKey");
case SelectOutputDirection::Previous:
return RS_switchable_(L"SelectCommandPreviousCommandKey");
return RS_(L"SelectCommandPreviousCommandKey");
}
return {};
}

View File

@@ -59,9 +59,6 @@
#include "TerminalSettingsSerializationHelpers.h"
#include <LibraryResources.h>
#include <ScopedResourceLoader.h>
#include "ActionArgsMagic.h"
#define ACTION_ARG(type, name, ...) \
@@ -339,8 +336,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
copy->_Type = _Type;
return *copy;
}
winrt::hstring GenerateName() const { return GenerateName(GetLibraryResourceLoader().ResourceContext()); }
winrt::hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext&) const
winrt::hstring GenerateName() const
{
return winrt::hstring{ L"type: " } + Type();
}
@@ -397,8 +393,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
static constexpr std::string_view ContentKey{ "__content" };
public:
hstring GenerateName() const { return GenerateName(GetLibraryResourceLoader().ResourceContext()); }
hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext&) const;
hstring GenerateName() const;
hstring ToCommandline() const;
bool Equals(const Model::INewContentArgs& other)
@@ -597,8 +592,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
WINRT_PROPERTY(Model::INewContentArgs, ContentArgs, nullptr);
public:
hstring GenerateName() const { return GenerateName(GetLibraryResourceLoader().ResourceContext()); }
hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext&) const;
hstring GenerateName() const;
bool Equals(const IActionArgs& other)
{
@@ -668,8 +662,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
static constexpr std::string_view SplitSizeKey{ "size" };
public:
hstring GenerateName() const { return GenerateName(GetLibraryResourceLoader().ResourceContext()); }
hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext&) const;
hstring GenerateName() const;
bool Equals(const IActionArgs& other)
{
@@ -741,8 +734,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
WINRT_PROPERTY(Model::INewContentArgs, ContentArgs, nullptr);
public:
hstring GenerateName() const { return GenerateName(GetLibraryResourceLoader().ResourceContext()); }
hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext&) const;
hstring GenerateName() const;
bool Equals(const IActionArgs& other)
{
@@ -879,8 +871,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
static constexpr std::string_view ActionsKey{ "actions" };
public:
hstring GenerateName() const { return GenerateName(GetLibraryResourceLoader().ResourceContext()); }
hstring GenerateName(const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext&) const;
hstring GenerateName() const;
bool Equals(const IActionArgs& other)
{
@@ -973,10 +964,3 @@ namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
BASIC_FACTORY(SelectCommandArgs);
BASIC_FACTORY(SelectOutputArgs);
}
class ScopedResourceLoader;
namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
const ScopedResourceLoader& EnglishOnlyResourceLoader() noexcept;
}

View File

@@ -9,7 +9,6 @@ namespace Microsoft.Terminal.Settings.Model
{
Boolean Equals(IActionArgs other);
String GenerateName();
String GenerateName(Windows.ApplicationModel.Resources.Core.ResourceContext context);
IActionArgs Copy();
UInt64 Hash();
};
@@ -131,7 +130,6 @@ namespace Microsoft.Terminal.Settings.Model
UInt64 Hash();
INewContentArgs Copy();
String GenerateName();
String GenerateName(Windows.ApplicationModel.Resources.Core.ResourceContext context);
};
runtimeclass BaseContentArgs : [default] INewContentArgs {

View File

@@ -111,59 +111,53 @@ struct InitListPlaceholder
// * NewTerminalArgs has a ToCommandline method it needs to additionally declare.
// * GlobalSummonArgs has the QuakeModeFromJson helper
#define ACTION_ARG_BODY(className, argsMacro) \
className() = default; \
className( \
argsMacro(CTOR_PARAMS) InitListPlaceholder = {}) : \
argsMacro(CTOR_INIT) _placeholder{} {}; \
argsMacro(DECLARE_ARGS); \
\
private: \
InitListPlaceholder _placeholder; \
\
public: \
hstring GenerateName() const \
{ \
return GenerateName( \
GetLibraryResourceLoader().ResourceContext()); \
} \
hstring GenerateName( \
const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext& context) const; \
bool Equals(const IActionArgs& other) \
{ \
auto otherAsUs = other.try_as<className>(); \
if (otherAsUs) \
{ \
return true argsMacro(EQUALS_ARGS); \
} \
return false; \
}; \
static FromJsonResult FromJson(const Json::Value& json) \
{ \
auto args = winrt::make_self<className>(); \
argsMacro(FROM_JSON_ARGS); \
return { *args, {} }; \
} \
static Json::Value ToJson(const IActionArgs& val) \
{ \
if (!val) \
{ \
return {}; \
} \
Json::Value json{ Json::ValueType::objectValue }; \
const auto args{ get_self<className>(val) }; \
argsMacro(TO_JSON_ARGS); \
return json; \
} \
IActionArgs Copy() const \
{ \
auto copy{ winrt::make_self<className>() }; \
argsMacro(COPY_ARGS); \
return *copy; \
} \
size_t Hash() const \
{ \
til::hasher h; \
argsMacro(HASH_ARGS); \
return h.finalize(); \
#define ACTION_ARG_BODY(className, argsMacro) \
className() = default; \
className( \
argsMacro(CTOR_PARAMS) InitListPlaceholder = {}) : \
argsMacro(CTOR_INIT) _placeholder{} {}; \
argsMacro(DECLARE_ARGS); \
\
private: \
InitListPlaceholder _placeholder; \
\
public: \
hstring GenerateName() const; \
bool Equals(const IActionArgs& other) \
{ \
auto otherAsUs = other.try_as<className>(); \
if (otherAsUs) \
{ \
return true argsMacro(EQUALS_ARGS); \
} \
return false; \
}; \
static FromJsonResult FromJson(const Json::Value& json) \
{ \
auto args = winrt::make_self<className>(); \
argsMacro(FROM_JSON_ARGS); \
return { *args, {} }; \
} \
static Json::Value ToJson(const IActionArgs& val) \
{ \
if (!val) \
{ \
return {}; \
} \
Json::Value json{ Json::ValueType::objectValue }; \
const auto args{ get_self<className>(val) }; \
argsMacro(TO_JSON_ARGS); \
return json; \
} \
IActionArgs Copy() const \
{ \
auto copy{ winrt::make_self<className>() }; \
argsMacro(COPY_ARGS); \
return *copy; \
} \
size_t Hash() const \
{ \
til::hasher h; \
argsMacro(HASH_ARGS); \
return h.finalize(); \
}

View File

@@ -7,7 +7,6 @@
#include <LibraryResources.h>
#include <til/replace.h>
#include <ScopedResourceLoader.h>
#include "KeyChordSerialization.h"
@@ -25,61 +24,6 @@ static constexpr std::string_view ProfileNameToken{ "${profile.name}" };
static constexpr std::string_view ProfileIconToken{ "${profile.icon}" };
static constexpr std::string_view SchemeNameToken{ "${scheme.name}" };
template<>
struct Microsoft::Terminal::Settings::Model::JsonUtils::ConversionTrait<winrt::Microsoft::Terminal::Settings::Model::implementation::Command::CommandNameOrResource>
{
winrt::Microsoft::Terminal::Settings::Model::implementation::Command::CommandNameOrResource FromJson(const Json::Value& json)
{
if (json.isObject())
{
if (const auto resourceKey{ JsonUtils::GetValueForKey<std::optional<std::wstring>>(json, "key") })
{
if (HasLibraryResourceWithName(*resourceKey))
{
return { .resource = *resourceKey };
}
}
}
else if (json.isString())
{
return { .name = JsonUtils::GetValue<std::wstring>(json) };
}
return {};
}
bool CanConvert(const Json::Value& json)
{
if (json.isObject())
{
if (const auto resourceKey{ JsonUtils::GetValueForKey<std::optional<std::wstring>>(json, "key") })
{
return HasLibraryResourceWithName(*resourceKey);
}
}
return json.isString() || json.isNull();
}
Json::Value ToJson(const winrt::Microsoft::Terminal::Settings::Model::implementation::Command::CommandNameOrResource& val)
{
if (!val.resource.empty())
{
Json::Value json{ Json::objectValue };
SetValueForKey(json, "key", val.resource);
return json;
}
else if (!val.name.empty())
{
return til::u16u8(val.name);
}
return Json::Value::nullSingleton();
}
std::string TypeDescription() const
{
return "string or valid resource";
}
};
namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
Command::Command() = default;
@@ -149,14 +93,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
if (_name.has_value())
{
if (!_name->resource.empty())
{
// Resource key overrides name
return GetLibraryResourceString(_name->resource);
}
// name was explicitly set, return that value.
return hstring{ _name->name };
return hstring{ _name.value() };
}
else if (_ActionAndArgs)
{
@@ -170,28 +108,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
}
}
hstring Command::LanguageNeutralName() const noexcept
{
if (_name.has_value())
{
// User-specified names **only matter** if they are resource keys (and therefore have a language-neutral version)
if (!_name->resource.empty())
{
// Resource key overrides name
return EnglishOnlyResourceLoader().GetLocalizedString(_name->resource);
}
// ...if there was no resource, then, return nothing.
}
else if (_ActionAndArgs)
{
// generate a name from our action
return get_self<implementation::ActionAndArgs>(_ActionAndArgs)->GenerateName(EnglishOnlyResourceLoader().ResourceContext());
}
// we have no neutral name
return {};
}
hstring Command::ID() const noexcept
{
return hstring{ _ID };
@@ -217,9 +133,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
void Command::Name(const hstring& value)
{
if (!_name.has_value() || _name->name != value)
if (!_name.has_value() || _name.value() != value)
{
_name = CommandNameOrResource{ .name = std::wstring{ value } };
_name = value;
}
}
@@ -240,6 +156,45 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
}
}
// Function Description:
// - attempt to get the name of this command from the provided json object.
// * If the "name" property is a string, return that value.
// * If the "name" property is an object, attempt to lookup the string
// resource specified by the "key" property, to support localizable
// command names.
// Arguments:
// - json: The Json::Value representing the command object we should get the name for.
// Return Value:
// - the empty string if we couldn't find a name; otherwise, the command's name.
static std::optional<std::wstring> _nameFromJson(const Json::Value& json)
{
if (const auto name{ json[JsonKey(NameKey)] })
{
if (name.isObject())
{
if (const auto resourceKey{ JsonUtils::GetValueForKey<std::optional<std::wstring>>(name, "key") })
{
if (HasLibraryResourceWithName(*resourceKey))
{
return std::wstring{ GetLibraryResourceString(*resourceKey) };
}
}
}
else if (name.isString())
{
return JsonUtils::GetValue<std::wstring>(name);
}
}
else if (json.isMember(JsonKey(NameKey)))
{
// { "name": null, "command": "copy" } will land in this case, which
// should also be used for unbinding.
return std::wstring{};
}
return std::nullopt;
}
// Method Description:
// - Deserialize a Command from the `json` object. The json object should
// contain a "name" and "action", and optionally an "icon".
@@ -321,7 +276,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// currently have. It'll probably generate something like "New tab,
// profile: ${profile.name}". This string will only be temporarily
// used internally, so there's no problem.
JsonUtils::GetValueForKey(json, NameKey, result->_name);
result->_name = _nameFromJson(json);
// Stash the original json value in this object. If the command is
// iterable, we'll need to re-parse it later, once we know what all the
@@ -348,7 +303,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
JsonUtils::GetValueForKey(json, IDKey, result->_ID);
JsonUtils::GetValueForKey(json, DescriptionKey, result->_Description);
JsonUtils::GetValueForKey(json, IconKey, result->_iconPath);
JsonUtils::GetValueForKey(json, NameKey, result->_name);
result->_name = _nameFromJson(json);
const auto action{ ShortcutAction::SendInput };
IActionArgs args{ nullptr };
@@ -386,12 +341,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
if (result->ActionAndArgs().Action() == ShortcutAction::Invalid && !result->HasNestedCommands())
{
// If there wasn't a parsed command, then try to get the
// name that *was* parsed. If that name currently
// name from the json blob. If that name currently
// exists in our list of commands, we should remove it.
const auto name = result->Name();
if (!name.empty())
const auto name = _nameFromJson(value);
if (name.has_value() && !name->empty())
{
commands.Remove(name);
commands.Remove(*name);
}
}
else
@@ -657,9 +612,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
std::vector<Model::Command> result;
const auto parseElement = [&](const auto& element) {
std::wstring completionText;
std::wstring listText;
std::wstring tooltipText;
winrt::hstring completionText;
winrt::hstring listText;
winrt::hstring tooltipText;
JsonUtils::GetValueForKey(element, "CompletionText", completionText);
JsonUtils::GetValueForKey(element, "ListItemText", listText);
JsonUtils::GetValueForKey(element, "ToolTip", tooltipText);
@@ -668,12 +623,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
winrt::hstring{ fmt::format(FMT_COMPILE(L"{:\x7f^{}}{}"),
L"",
replaceLength,
completionText) });
static_cast<std::wstring_view>(completionText)) });
Model::ActionAndArgs actionAndArgs{ ShortcutAction::SendInput, *args };
auto c = winrt::make_self<Command>();
c->_name = CommandNameOrResource{ .name = listText };
c->_name = listText;
c->_Description = tooltipText;
c->_ActionAndArgs = actionAndArgs;
// Try to assign a sensible icon based on the result type. These are
@@ -778,7 +733,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
auto command = winrt::make_self<Command>();
command->_ActionAndArgs = actionAndArgs;
command->_name = CommandNameOrResource{ .name = std::wstring{ line } };
command->_name = winrt::hstring{ line };
command->_iconPath = iconPath;
result.push_back(*command);
foundCommands[line] = true;

View File

@@ -44,12 +44,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
struct Command : CommandT<Command>
{
struct CommandNameOrResource
{
std::wstring name;
std::wstring resource;
};
Command();
com_ptr<Command> Copy() const;
@@ -77,7 +71,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
bool HasName() const noexcept;
hstring Name() const noexcept;
void Name(const hstring& name);
hstring LanguageNeutralName() const noexcept;
hstring ID() const noexcept;
void GenerateID();
@@ -100,7 +93,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
private:
Json::Value _originalJson;
Windows::Foundation::Collections::IMap<winrt::hstring, Model::Command> _subcommands{ nullptr };
std::optional<CommandNameOrResource> _name;
std::optional<std::wstring> _name;
std::wstring _ID;
bool _IDWasGenerated{ false };
std::optional<std::wstring> _iconPath;

View File

@@ -37,7 +37,6 @@ namespace Microsoft.Terminal.Settings.Model
Command();
String Name { get; };
String LanguageNeutralName { get; };
String ID { get; };
String Description { get; };

View File

@@ -27,7 +27,6 @@
#include <wil/registry.h>
#include <winrt/Windows.ApplicationModel.AppExtensions.h>
#include <winrt/Windows.ApplicationModel.Resources.Core.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.h>

View File

@@ -13,9 +13,6 @@ public:
ScopedResourceLoader WithQualifier(const wil::zwstring_view qualifierName, const wil::zwstring_view qualifierValue) const;
const winrt::Windows::ApplicationModel::Resources::Core::ResourceMap& ResourceMap() const noexcept { return _resourceMap; }
const winrt::Windows::ApplicationModel::Resources::Core::ResourceContext& ResourceContext() const noexcept { return _resourceContext; }
private:
ScopedResourceLoader(winrt::Windows::ApplicationModel::Resources::Core::ResourceMap map, winrt::Windows::ApplicationModel::Resources::Core::ResourceContext context) noexcept;
winrt::Windows::ApplicationModel::Resources::Core::ResourceMap _resourceMap;

View File

@@ -1421,11 +1421,6 @@ void IslandWindow::_globalActivateWindow(const uint32_t dropdownDuration,
// will be the foreground window.
const auto oldForegroundWindow = GetForegroundWindow();
if (oldForegroundWindow == _window.get())
{
return;
}
// From: https://stackoverflow.com/a/59659421
// > The trick is to make windows think that our process and the target
// > window (hwnd) are related by attaching the threads (using
@@ -1457,40 +1452,31 @@ void IslandWindow::_globalActivateWindow(const uint32_t dropdownDuration,
}
else
{
const auto oldThreadId = GetWindowThreadProcessId(oldForegroundWindow, nullptr);
const auto currentThreadId = GetCurrentThreadId();
if (oldThreadId != currentThreadId)
// Try first to send a message to the current foreground window. If it's not responding, it may
// be waiting on us to finish launching. Passing SMTO_NOTIMEOUTIFNOTHUNG means that we get the same
// behavior as before--that is, waiting for the message loop--but we've done an early return if
// it turns out that it was hung.
// SendMessageTimeoutW returns nonzero if it succeeds.
if (0 != SendMessageTimeoutW(oldForegroundWindow, WM_NULL, 0, 0, SMTO_NOTIMEOUTIFNOTHUNG | SMTO_BLOCK | SMTO_ABORTIFHUNG, 1000, nullptr))
{
// Try first to send a message to the current foreground window. If it's not responding, it may
// be waiting on us to finish launching. Passing SMTO_NOTIMEOUTIFNOTHUNG means that we get the same
// behavior as before--that is, waiting for the message loop--but we've done an early return if
// it turns out that it was hung.
// SendMessageTimeoutW returns nonzero if it succeeds.
if (0 == SendMessageTimeoutW(oldForegroundWindow, WM_NULL, 0, 0, SMTO_NOTIMEOUTIFNOTHUNG | SMTO_BLOCK | SMTO_ABORTIFHUNG, 1000, nullptr))
{
return;
}
const auto windowThreadProcessId = GetWindowThreadProcessId(oldForegroundWindow, nullptr);
const auto currentThreadId = GetCurrentThreadId();
if (FAILED_WIN32_LOG(AttachThreadInput(oldThreadId, currentThreadId, true)))
{
return;
}
LOG_IF_WIN32_BOOL_FALSE(AttachThreadInput(windowThreadProcessId, currentThreadId, true));
// Just in case, add the thread detach as a scope_exit, to make _sure_ we do it.
auto detachThread = wil::scope_exit([windowThreadProcessId, currentThreadId]() {
LOG_IF_WIN32_BOOL_FALSE(AttachThreadInput(windowThreadProcessId, currentThreadId, false));
});
LOG_IF_WIN32_BOOL_FALSE(BringWindowToTop(_window.get()));
ShowWindow(_window.get(), SW_SHOW);
// Activate the window too. This will force us to the virtual desktop this
// window is on, if it's on another virtual desktop.
LOG_LAST_ERROR_IF_NULL(SetActiveWindow(_window.get()));
// Throw us on the active monitor.
_moveToMonitor(oldForegroundWindow, toMonitor);
}
LOG_IF_WIN32_BOOL_FALSE(BringWindowToTop(_window.get()));
ShowWindow(_window.get(), SW_SHOW);
// Activate the window too. This will force us to the virtual desktop this
// window is on, if it's on another virtual desktop.
LOG_LAST_ERROR_IF_NULL(SetActiveWindow(_window.get()));
if (oldThreadId != currentThreadId)
{
LOG_IF_WIN32_BOOL_FALSE(AttachThreadInput(oldThreadId, currentThreadId, false));
}
// Throw us on the active monitor.
_moveToMonitor(oldForegroundWindow, toMonitor);
}
}

View File

@@ -0,0 +1,130 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "../TerminalSettingsModel/Profile.h"
#include "../TerminalApp/ColorHelper.h"
// Import some templates to compare floats using approximate matching.
#include <consoletaeftemplates.hpp>
using namespace Microsoft::Console;
using namespace winrt::TerminalApp;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace WEX::Common;
namespace TerminalAppUnitTests
{
class ColorHelperTests
{
BEGIN_TEST_CLASS(ColorHelperTests)
TEST_CLASS_PROPERTY(L"ActivationContext", L"TerminalApp.Unit.Tests.manifest")
END_TEST_CLASS()
TEST_METHOD(ConvertRgbToHsl);
TEST_METHOD(ConvertHslToRgb);
TEST_METHOD(LuminanceTests);
};
void ColorHelperTests::ConvertHslToRgb()
{
auto red = winrt::Windows::UI::Colors::Red();
auto redHsl = ColorHelper::RgbToHsl(red);
VERIFY_ARE_EQUAL(0.f, redHsl.H);
VERIFY_ARE_EQUAL(1.f, redHsl.S);
VERIFY_ARE_EQUAL(0.5f, redHsl.L);
auto green = winrt::Windows::UI::Colors::Lime();
auto greenHsl = ColorHelper::RgbToHsl(green);
VERIFY_ARE_EQUAL(120.f, greenHsl.H);
VERIFY_ARE_EQUAL(1.f, greenHsl.S);
VERIFY_ARE_EQUAL(0.5f, greenHsl.L);
auto blue = winrt::Windows::UI::Colors::Blue();
auto blueHsl = ColorHelper::RgbToHsl(blue);
VERIFY_ARE_EQUAL(240.f, blueHsl.H);
VERIFY_ARE_EQUAL(1.f, blueHsl.S);
VERIFY_ARE_EQUAL(0.5f, blueHsl.L);
auto darkTurquoise = winrt::Windows::UI::Colors::DarkTurquoise();
auto darkTurquoiseHsl = ColorHelper::RgbToHsl(darkTurquoise);
VERIFY_ARE_EQUAL(181.f, darkTurquoiseHsl.H);
VERIFY_ARE_EQUAL(1.f, darkTurquoiseHsl.S);
VERIFY_ARE_EQUAL(0.41f, darkTurquoiseHsl.L);
auto darkViolet = winrt::Windows::UI::Colors::DarkViolet();
auto darkVioletHsl = ColorHelper::RgbToHsl(darkViolet);
VERIFY_ARE_EQUAL(282.f, darkVioletHsl.H);
VERIFY_ARE_EQUAL(1.f, darkVioletHsl.S);
VERIFY_ARE_EQUAL(0.414f, darkVioletHsl.L);
auto white = winrt::Windows::UI::Colors::White();
auto whiteHsl = ColorHelper::RgbToHsl(white);
VERIFY_ARE_EQUAL(0.f, whiteHsl.H);
VERIFY_ARE_EQUAL(0.f, whiteHsl.S);
VERIFY_ARE_EQUAL(1.f, whiteHsl.L);
auto black = winrt::Windows::UI::Colors::Black();
auto blackHsl = ColorHelper::RgbToHsl(black);
VERIFY_ARE_EQUAL(0.f, blackHsl.H);
VERIFY_ARE_EQUAL(0.f, blackHsl.S);
VERIFY_ARE_EQUAL(0.f, blackHsl.L);
}
void ColorHelperTests::ConvertRgbToHsl()
{
auto redHsl = HSL{ 0.f, 100.f, 50.f };
auto red = ColorHelper::HslToRgb(redHsl);
VERIFY_ARE_EQUAL(255, red.R);
VERIFY_ARE_EQUAL(0, red.G);
VERIFY_ARE_EQUAL(0, red.B);
auto greenHsl = HSL{ 120.f, 100.f, 50.f };
auto green = ColorHelper::HslToRgb(greenHsl);
VERIFY_ARE_EQUAL(0, green.R);
VERIFY_ARE_EQUAL(255, green.G);
VERIFY_ARE_EQUAL(0, green.B);
auto blueHsl = HSL{ 240.f, 100.f, 50.f };
auto blue = ColorHelper::HslToRgb(blueHsl);
VERIFY_ARE_EQUAL(0, blue.R);
VERIFY_ARE_EQUAL(0, blue.G);
VERIFY_ARE_EQUAL(255, blue.B);
auto darkTurquoiseHsl = HSL{ 181.f, 100.f, 41.f };
auto darkTurquoise = ColorHelper::HslToRgb(darkTurquoiseHsl);
VERIFY_ARE_EQUAL(0, darkTurquoise.R);
VERIFY_ARE_EQUAL(206, darkTurquoise.G);
VERIFY_ARE_EQUAL(209, darkTurquoise.B);
auto darkVioletHsl = HSL{ 282.f, 100.f, 41.4f };
auto darkViolet = ColorHelper::HslToRgb(darkVioletHsl);
VERIFY_ARE_EQUAL(148, darkViolet.R);
VERIFY_ARE_EQUAL(0, darkViolet.G);
VERIFY_ARE_EQUAL(211, darkViolet.B);
auto whiteHsl = HSL{ 360.f, 100.f, 100.f };
auto white = ColorHelper::HslToRgb(whiteHsl);
VERIFY_ARE_EQUAL(255, white.R);
VERIFY_ARE_EQUAL(255, white.G);
VERIFY_ARE_EQUAL(255, white.B);
auto blackHsl = HSL{ 0.f, 0.f, 0.f };
auto black = ColorHelper::HslToRgb(blackHsl);
VERIFY_ARE_EQUAL(0, black.R);
VERIFY_ARE_EQUAL(0, black.G);
VERIFY_ARE_EQUAL(0, black.B);
}
void ColorHelperTests::LuminanceTests()
{
auto darkTurquoiseLuminance = ColorHelper::GetLuminance(winrt::Windows::UI::Colors::DarkTurquoise());
VERIFY_ARE_EQUAL(48.75f, darkTurquoiseLuminance * 100);
auto darkVioletLuminance = ColorHelper::GetLuminance(winrt::Windows::UI::Colors::DarkViolet());
VERIFY_ARE_EQUAL(11.f, darkVioletLuminance * 100);
auto magentaLuminance = ColorHelper::GetLuminance(winrt::Windows::UI::Colors::Magenta());
VERIFY_ARE_EQUAL(28.48f, magentaLuminance * 100);
}
}

View File

@@ -21,11 +21,17 @@
<!-- ========================= Cpp Files ======================== -->
<ItemGroup>
<ClCompile Include="ColorHelperTests.cpp" />
<ClCompile Include="JsonUtilsTests.cpp" />
<ClCompile Include="FzfTests.cpp" />
<ClCompile Include="precomp.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\TerminalApp\ColorHelper.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<!-- ========================= Project References ======================== -->

View File

@@ -446,11 +446,6 @@ void ConhostInternalGetSet::NotifyBufferRotation(const int delta)
}
}
void ConhostInternalGetSet::NotifyShellIntegrationMark()
{
// Not implemented for conhost - shell integration marks are a Terminal app feature.
}
void ConhostInternalGetSet::InvokeCompletions(std::wstring_view /*menuJson*/, unsigned int /*replaceLength*/)
{
// Not implemented for conhost.

View File

@@ -67,7 +67,6 @@ public:
void NotifyAccessibilityChange(const til::rect& changedRect) override;
void NotifyBufferRotation(const int delta) override;
void NotifyShellIntegrationMark() override;
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;

View File

@@ -176,11 +176,6 @@ COOKED_READ_DATA::COOKED_READ_DATA(_In_ InputBuffer* const pInputBuffer,
}
}
const SCREEN_INFORMATION* COOKED_READ_DATA::GetScreenBuffer() const noexcept
{
return &_screenInfo;
}
// Routine Description:
// - This routine is called to complete a cooked read that blocked in ReadInputBuffer.
// - The context of the read was saved in the CookedReadData structure.

View File

@@ -19,7 +19,6 @@ public:
_In_ std::wstring_view initialData,
_In_ ConsoleProcessHandle* pClientProcess);
const SCREEN_INFORMATION* GetScreenBuffer() const noexcept override;
void MigrateUserBuffersOnTransitionToBackgroundWait(const void* oldBuffer, void* newBuffer) noexcept override;
bool Notify(WaitTerminationReason TerminationReason,

View File

@@ -192,9 +192,6 @@ void SCREEN_INFORMATION::s_InsertScreenBuffer(_In_ SCREEN_INFORMATION* const pSc
void SCREEN_INFORMATION::s_RemoveScreenBuffer(_In_ SCREEN_INFORMATION* const pScreenInfo)
{
auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
gci.GetActiveInputBuffer()->WaitQueue.CancelWaitersForScreenBuffer(pScreenInfo);
if (pScreenInfo == gci.ScreenBuffers)
{
gci.ScreenBuffers = pScreenInfo->Next;

View File

@@ -55,22 +55,20 @@
namespace til // Terminal Implementation Library. Also: "Today I Learned"
{
template<typename T>
as_view_t<T> safe_slice_abs(const T& view, size_t beg, size_t end) noexcept
as_view_t<T> safe_slice_abs(const T& view, size_t beg, size_t end)
{
const size_t len = view.size();
end = std::min(end, len);
beg = std::min(beg, end);
#pragma warning(suppress : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
return { view.data() + beg, end - beg };
}
template<typename T>
as_view_t<T> safe_slice_len(const T& view, size_t start, size_t count) noexcept
as_view_t<T> safe_slice_len(const T& view, size_t start, size_t count)
{
const size_t len = view.size();
start = std::min(start, len);
count = std::min(count, len - start);
#pragma warning(suppress : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
return { view.data() + start, count };
}

View File

@@ -322,7 +322,7 @@ CATCH_RETURN()
auto misc = _api.s.write()->misc.write();
misc->selectionColor = newSelectionColor;
// Select a black or white foreground based on the perceptual lightness of the background.
misc->selectionForeground = ColorFix::GetLightness(newSelectionColor) < 0.5f ? 0xffffffff : 0xff000000;
misc->selectionForeground = ColorFix::GetLuminosity(newSelectionColor) < 0.5f ? 0xffffffff : 0xff000000;
// We copied the selection colors into _p during StartPaint, which happened just before PrepareRenderInfo
// This keeps their generations in sync.

View File

@@ -42,10 +42,6 @@ public:
IWaitRoutine& operator=(const IWaitRoutine&) & = delete;
IWaitRoutine& operator=(IWaitRoutine&&) & = delete;
virtual const SCREEN_INFORMATION* GetScreenBuffer() const noexcept
{
return nullptr;
}
virtual void MigrateUserBuffersOnTransitionToBackgroundWait(const void* oldBuffer, void* newBuffer) = 0;
virtual bool Notify(const WaitTerminationReason TerminationReason,

View File

@@ -75,11 +75,6 @@ ConsoleWaitBlock::~ConsoleWaitBlock()
delete _pWaiter;
}
const SCREEN_INFORMATION* ConsoleWaitBlock::GetScreenBuffer() const noexcept
{
return _pWaiter->GetScreenBuffer();
}
// Routine Description:
// - Creates and enqueues a new wait for later callback when a routine cannot be serviced at this time.
// - Will extract the process ID and the target object, enqueuing in both to know when to callback

View File

@@ -30,7 +30,6 @@ class ConsoleWaitBlock
public:
~ConsoleWaitBlock();
const SCREEN_INFORMATION* GetScreenBuffer() const noexcept;
bool Notify(const WaitTerminationReason TerminationReason);
[[nodiscard]] static HRESULT s_CreateWait(_Inout_ CONSOLE_API_MSG* const pWaitReplymessage,

View File

@@ -103,22 +103,6 @@ bool ConsoleWaitQueue::NotifyWaiters(const bool fNotifyAll,
return fResult;
}
void ConsoleWaitQueue::CancelWaitersForScreenBuffer(const SCREEN_INFORMATION* pScreenInfo)
{
for (auto it = _blocks.begin(); it != _blocks.end();)
{
const auto nextIt = std::next(it); // we have to capture next before it is potentially erased
auto* pWaitBlock = *it;
if (pWaitBlock->GetScreenBuffer() == pScreenInfo)
{
_NotifyBlock(pWaitBlock, WaitTerminationReason::HandleClosing);
}
it = nextIt;
}
}
// Routine Description:
// - A helper to delete successfully notified callbacks
// Arguments:

View File

@@ -37,8 +37,6 @@ public:
bool NotifyWaiters(const bool fNotifyAll,
const WaitTerminationReason TerminationReason);
void CancelWaitersForScreenBuffer(const SCREEN_INFORMATION* pScreenInfo);
[[nodiscard]] static HRESULT s_CreateWait(_Inout_ CONSOLE_API_MSG* const pWaitReplyMessage,
_In_ IWaitRoutine* const pWaiter);

View File

@@ -86,7 +86,6 @@ namespace Microsoft::Console::VirtualTerminal
virtual void NotifyAccessibilityChange(const til::rect& changedRect) = 0;
virtual void NotifyBufferRotation(const int delta) = 0;
virtual void NotifyShellIntegrationMark() = 0;
virtual void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) = 0;

View File

@@ -3600,7 +3600,6 @@ void AdaptDispatch::DoConEmuAction(const std::wstring_view string)
else if (subParam == 12)
{
_pages.ActivePage().Buffer().StartCommand();
_api.NotifyShellIntegrationMark();
}
}
@@ -3631,7 +3630,6 @@ void AdaptDispatch::DoITerm2Action(const std::wstring_view string)
if (action == L"SetMark")
{
_pages.ActivePage().Buffer().StartPrompt();
_api.NotifyShellIntegrationMark();
}
}
@@ -3665,19 +3663,16 @@ void AdaptDispatch::DoFinalTermAction(const std::wstring_view string)
case L'A': // FTCS_PROMPT
{
_pages.ActivePage().Buffer().StartPrompt();
_api.NotifyShellIntegrationMark();
break;
}
case L'B': // FTCS_COMMAND_START
{
_pages.ActivePage().Buffer().StartCommand();
_api.NotifyShellIntegrationMark();
break;
}
case L'C': // FTCS_COMMAND_EXECUTED
{
_pages.ActivePage().Buffer().StartOutput();
_api.NotifyShellIntegrationMark();
break;
}
case L'D': // FTCS_COMMAND_FINISHED
@@ -3698,7 +3693,6 @@ void AdaptDispatch::DoFinalTermAction(const std::wstring_view string)
}
_pages.ActivePage().Buffer().EndCurrentCommand(error);
_api.NotifyShellIntegrationMark();
break;
}

View File

@@ -212,11 +212,6 @@ public:
Log::Comment(L"NotifyBufferRotation MOCK called...");
}
void NotifyShellIntegrationMark() override
{
Log::Comment(L"NotifyShellIntegrationMark MOCK called...");
}
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override
{
Log::Comment(L"InvokeCompletions MOCK called...");

View File

@@ -209,14 +209,7 @@ COLORREF ColorFix::GetPerceivableColor(COLORREF color, COLORREF reference, float
return linearToColorref(oklab::oklab_to_linear_srgb(colorOklab)) | (color & 0xff000000);
}
COLORREF ColorFix::AdjustLightness(COLORREF color, float delta) noexcept
{
auto lab = oklab::linear_srgb_to_oklab(colorrefToLinear(color));
lab.l = saturate(lab.l + delta);
return linearToColorref(oklab::oklab_to_linear_srgb(lab)) | (color & 0xff000000);
}
float ColorFix::GetLightness(COLORREF color) noexcept
float ColorFix::GetLuminosity(COLORREF color) noexcept
{
return oklab::linear_srgb_to_oklab(colorrefToLinear(color)).l;
}

View File

@@ -10,6 +10,5 @@
namespace ColorFix
{
COLORREF GetPerceivableColor(COLORREF color, COLORREF reference, float minSquaredDistance) noexcept;
COLORREF AdjustLightness(COLORREF color, float delta) noexcept;
float GetLightness(COLORREF color) noexcept;
float GetLuminosity(COLORREF color) noexcept;
}