mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-20 22:06:56 +00:00
a few more
This commit is contained in:
@@ -26,15 +26,19 @@ using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
#define INITIALIZE_ENUM_LIST_AND_VALUE(enumMappingsName, enumType, resourceSectionAndType, resourceProperty) \
|
||||
std::vector<winrt::Microsoft::Terminal::Settings::Editor::EnumEntry> enumList; \
|
||||
const auto mappings = winrt::Microsoft::Terminal::Settings::Model::EnumMappings::enumMappingsName(); \
|
||||
const auto unboxedValue = unbox_value<enumType>(value); \
|
||||
enumType unboxedValue; \
|
||||
if (value) \
|
||||
{ \
|
||||
unboxedValue = unbox_value<enumType>(value); \
|
||||
} \
|
||||
for (const auto [enumKey, enumValue] : mappings) \
|
||||
{ \
|
||||
const auto enumName = LocalizedNameForEnumName(resourceSectionAndType, enumKey, resourceProperty); \
|
||||
auto entry = winrt::make<winrt::Microsoft::Terminal::Settings::Editor::implementation::EnumEntry>(enumName, winrt::box_value<enumType>(enumValue)); \
|
||||
enumList.emplace_back(entry); \
|
||||
if (unboxedValue == enumValue) \
|
||||
if (value && unboxedValue == enumValue) \
|
||||
{ \
|
||||
EnumValue(entry); \
|
||||
EnumValue(entry); \
|
||||
} \
|
||||
} \
|
||||
std::sort(enumList.begin(), enumList.end(), EnumEntryReverseComparator<enumType>()); \
|
||||
@@ -261,6 +265,22 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
INITIALIZE_ENUM_LIST_AND_VALUE(ResizeDirection, Model::ResizeDirection, L"Actions_ResizeDirection", L"Content");
|
||||
}
|
||||
else if (_type == L"Model::FocusDirection")
|
||||
{
|
||||
INITIALIZE_ENUM_LIST_AND_VALUE(FocusDirection, Model::FocusDirection, L"Actions_FocusDirection", L"Content");
|
||||
}
|
||||
else if (_type == L"SettingsTarget")
|
||||
{
|
||||
INITIALIZE_ENUM_LIST_AND_VALUE(SettingsTarget, Model::SettingsTarget, L"Actions_SettingsTarget", L"Content");
|
||||
}
|
||||
else if (_type == L"MoveTabDirection")
|
||||
{
|
||||
INITIALIZE_ENUM_LIST_AND_VALUE(MoveTabDirection, Model::MoveTabDirection, L"Actions_MoveTabDirection", L"Content");
|
||||
}
|
||||
// todo:
|
||||
// copyformat (flags)
|
||||
// color (weird type), optional color
|
||||
// optional uint32 (kinda defaults it to 0 right now which is incorrect...)
|
||||
}
|
||||
|
||||
void ArgWrapper::EnumValue(const Windows::Foundation::IInspectable& enumValue)
|
||||
|
||||
@@ -180,6 +180,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
void DoubleBindBack(const double newValue) { Value(box_value(static_cast<uint32_t>(newValue))); };
|
||||
|
||||
void DoubleOptionalBindBack(const double newValue) { Value(box_value(static_cast<uint32_t>(newValue))); };
|
||||
|
||||
void FloatBindBack(const double newValue) { Value(box_value(static_cast<float>(newValue))); };
|
||||
|
||||
void BoolBindBack(const Windows::Foundation::IReference<bool> newValue)
|
||||
{
|
||||
if (newValue)
|
||||
|
||||
@@ -85,6 +85,8 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> EnumList { get; };
|
||||
void StringBindBack(String newValue);
|
||||
void DoubleBindBack(Double newValue);
|
||||
void DoubleOptionalBindBack(Double newValue);
|
||||
void FloatBindBack(Double newValue);
|
||||
void BoolBindBack(Windows.Foundation.IReference<Boolean> newValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
return UInt32Template();
|
||||
}
|
||||
else if (argType == L"float")
|
||||
{
|
||||
return FloatTemplate();
|
||||
}
|
||||
else if (argType == L"bool")
|
||||
{
|
||||
if (argWrapper.Required())
|
||||
@@ -49,7 +53,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
return UInt32Template();
|
||||
}
|
||||
else if (argType == L"Model::ResizeDirection")
|
||||
else if (argType == L"Model::ResizeDirection" || argType == L"Model::FocusDirection" || argType == L"SettingsTarget" || argType == L"MoveTabDirection")
|
||||
{
|
||||
return EnumTemplate();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
Windows::UI::Xaml::DataTemplate SelectTemplateCore(const winrt::Windows::Foundation::IInspectable&);
|
||||
|
||||
WINRT_PROPERTY(winrt::Windows::UI::Xaml::DataTemplate, UInt32Template);
|
||||
WINRT_PROPERTY(winrt::Windows::UI::Xaml::DataTemplate, UInt32OptionalTemplate);
|
||||
WINRT_PROPERTY(winrt::Windows::UI::Xaml::DataTemplate, FloatTemplate);
|
||||
WINRT_PROPERTY(winrt::Windows::UI::Xaml::DataTemplate, StringTemplate);
|
||||
WINRT_PROPERTY(winrt::Windows::UI::Xaml::DataTemplate, BoolTemplate);
|
||||
WINRT_PROPERTY(winrt::Windows::UI::Xaml::DataTemplate, BoolOptionalTemplate);
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
ArgsTemplateSelectors();
|
||||
|
||||
Windows.UI.Xaml.DataTemplate UInt32Template;
|
||||
Windows.UI.Xaml.DataTemplate UInt32OptionalTemplate;
|
||||
Windows.UI.Xaml.DataTemplate FloatTemplate;
|
||||
Windows.UI.Xaml.DataTemplate StringTemplate;
|
||||
Windows.UI.Xaml.DataTemplate BoolTemplate;
|
||||
Windows.UI.Xaml.DataTemplate BoolOptionalTemplate;
|
||||
|
||||
@@ -239,6 +239,34 @@
|
||||
</ListViewItem>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="UInt32OptionalTemplate"
|
||||
x:DataType="local:ArgWrapper">
|
||||
<ListViewItem>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<muxc:NumberBox Value="{x:Bind mtu:Converters.UnboxUInt32Optional(Value), Mode=TwoWay, BindBack=DoubleOptionalBindBack}"
|
||||
Style="{StaticResource NumberBoxSettingStyle}"
|
||||
Minimum="0"
|
||||
Maximum="999"
|
||||
LargeChange="1"
|
||||
SmallChange="1"/>
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="FloatTemplate"
|
||||
x:DataType="local:ArgWrapper">
|
||||
<ListViewItem>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<muxc:NumberBox Value="{x:Bind mtu:Converters.UnboxFloat(Value), Mode=TwoWay, BindBack=FloatBindBack}"
|
||||
Style="{StaticResource NumberBoxSettingStyle}"
|
||||
Minimum="0"
|
||||
Maximum="999"
|
||||
LargeChange="1"
|
||||
SmallChange="1"/>
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="StringTemplate"
|
||||
x:DataType="local:ArgWrapper">
|
||||
<ListViewItem>
|
||||
@@ -286,6 +314,8 @@
|
||||
|
||||
<local:ArgsTemplateSelectors x:Key="ArgsTemplateSelector"
|
||||
UInt32Template="{StaticResource UInt32Template}"
|
||||
UInt32OptionalTemplate="{StaticResource UInt32OptionalTemplate}"
|
||||
FloatTemplate="{StaticResource FloatTemplate}"
|
||||
StringTemplate="{StaticResource StringTemplate}"
|
||||
BoolTemplate="{StaticResource BoolTemplate}"
|
||||
BoolOptionalTemplate="{StaticResource BoolOptionalTemplate}"
|
||||
|
||||
@@ -1864,13 +1864,81 @@
|
||||
<value>Down</value>
|
||||
<comment>An option to choose from for the "resize direction". Down option.</comment>
|
||||
</data>
|
||||
<data name="ShortcutAction_SendInput" xml:space="preserve">
|
||||
<value>Send input</value>
|
||||
<comment>One of the possible shortcut action types. This represents the "Send input" action.</comment>
|
||||
<data name="Actions_FocusDirectionNone.Content" xml:space="preserve">
|
||||
<value>None</value>
|
||||
<comment>An option to choose from for the "focus direction". None option.</comment>
|
||||
</data>
|
||||
<data name="ShortcutAction_CloseTab" xml:space="preserve">
|
||||
<value>Close tab</value>
|
||||
<comment>One of the possible shortcut action types. This represents the "Close tab" action.</comment>
|
||||
<data name="Actions_FocusDirectionLeft.Content" xml:space="preserve">
|
||||
<value>Left</value>
|
||||
<comment>An option to choose from for the "focus direction". Left option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionRight.Content" xml:space="preserve">
|
||||
<value>Right</value>
|
||||
<comment>An option to choose from for the "focus direction". Right option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionUp.Content" xml:space="preserve">
|
||||
<value>Up</value>
|
||||
<comment>An option to choose from for the "focus direction". Up option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionDown.Content" xml:space="preserve">
|
||||
<value>Down</value>
|
||||
<comment>An option to choose from for the "focus direction". Down option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionPrevious.Content" xml:space="preserve">
|
||||
<value>Previous</value>
|
||||
<comment>An option to choose from for the "focus direction". Previous option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionPreviousInOrder.Content" xml:space="preserve">
|
||||
<value>Previous In Order</value>
|
||||
<comment>An option to choose from for the "focus direction". Previous in order option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionNextInOrder.Content" xml:space="preserve">
|
||||
<value>Next In Order</value>
|
||||
<comment>An option to choose from for the "focus direction". Next in order option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionFirst.Content" xml:space="preserve">
|
||||
<value>First</value>
|
||||
<comment>An option to choose from for the "focus direction". First option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionParent.Content" xml:space="preserve">
|
||||
<value>Parent</value>
|
||||
<comment>An option to choose from for the "focus direction". Parent option.</comment>
|
||||
</data>
|
||||
<data name="Actions_FocusDirectionChild.Content" xml:space="preserve">
|
||||
<value>Child</value>
|
||||
<comment>An option to choose from for the "focus direction". Child option.</comment>
|
||||
</data>
|
||||
<data name="Actions_SettingsTargetSettingsFile.Content" xml:space="preserve">
|
||||
<value>Settings File</value>
|
||||
<comment>An option to choose from for the "settings target". Targets the settings file.</comment>
|
||||
</data>
|
||||
<data name="Actions_SettingsTargetDefaultsFile.Content" xml:space="preserve">
|
||||
<value>Defaults File</value>
|
||||
<comment>An option to choose from for the "settings target". Targets the defaults file.</comment>
|
||||
</data>
|
||||
<data name="Actions_SettingsTargetAllFiles.Content" xml:space="preserve">
|
||||
<value>All Files</value>
|
||||
<comment>An option to choose from for the "settings target". Targets all files.</comment>
|
||||
</data>
|
||||
<data name="Actions_SettingsTargetSettingsUI.Content" xml:space="preserve">
|
||||
<value>Settings UI</value>
|
||||
<comment>An option to choose from for the "settings target". Targets the settings UI.</comment>
|
||||
</data>
|
||||
<data name="Actions_SettingsTargetDirectory.Content" xml:space="preserve">
|
||||
<value>Directory</value>
|
||||
<comment>An option to choose from for the "settings target". Targets the directory.</comment>
|
||||
</data>
|
||||
<data name="Actions_MoveTabDirectionNone.Content" xml:space="preserve">
|
||||
<value>None</value>
|
||||
<comment>An option to choose from for the "move tab direction". No movement.</comment>
|
||||
</data>
|
||||
<data name="Actions_MoveTabDirectionForward.Content" xml:space="preserve">
|
||||
<value>Forward</value>
|
||||
<comment>An option to choose from for the "move tab direction". Moves the tab forward.</comment>
|
||||
</data>
|
||||
<data name="Actions_MoveTabDirectionBackward.Content" xml:space="preserve">
|
||||
<value>Backward</value>
|
||||
<comment>An option to choose from for the "move tab direction". Moves the tab backward.</comment>
|
||||
</data>
|
||||
<data name="KeyChordListener.[using:Windows.UI.Xaml.Automation]AutomationProperties.HelpText" xml:space="preserve">
|
||||
<value>Input your desired keyboard shortcut.</value>
|
||||
|
||||
@@ -998,18 +998,44 @@ Model::IActionArgs CascadiaSettings::GetEmptyArgsForAction(Model::ShortcutAction
|
||||
{
|
||||
switch (shortcutAction)
|
||||
{
|
||||
case Model::ShortcutAction::CopyText:
|
||||
return winrt::make<CopyTextArgs>();
|
||||
case Model::ShortcutAction::MovePane:
|
||||
return winrt::make<MovePaneArgs>();
|
||||
case Model::ShortcutAction::SwitchToTab:
|
||||
return winrt::make<SwitchToTabArgs>();
|
||||
case Model::ShortcutAction::ResizePane:
|
||||
return winrt::make<ResizePaneArgs>();
|
||||
case Model::ShortcutAction::MoveFocus:
|
||||
return winrt::make<MoveFocusArgs>();
|
||||
case Model::ShortcutAction::SwapPane:
|
||||
return winrt::make<SwapPaneArgs>();
|
||||
case Model::ShortcutAction::AdjustFontSize:
|
||||
return winrt::make<AdjustFontSizeArgs>();
|
||||
case Model::ShortcutAction::SendInput:
|
||||
return winrt::make<SendInputArgs>();
|
||||
case Model::ShortcutAction::MovePane:
|
||||
return winrt::make<MovePaneArgs>();
|
||||
case Model::ShortcutAction::CopyText:
|
||||
return winrt::make<CopyTextArgs>();
|
||||
case Model::ShortcutAction::OpenSettings:
|
||||
return winrt::make<OpenSettingsArgs>();
|
||||
case Model::ShortcutAction::SetFocusMode:
|
||||
return winrt::make<SetFocusModeArgs>();
|
||||
case Model::ShortcutAction::SetFullScreen:
|
||||
return winrt::make<SetFullScreenArgs>();
|
||||
case Model::ShortcutAction::SetMaximized:
|
||||
return winrt::make<SetMaximizedArgs>();
|
||||
case Model::ShortcutAction::SetColorScheme:
|
||||
return winrt::make<SetColorSchemeArgs>();
|
||||
case Model::ShortcutAction::RenameTab:
|
||||
return winrt::make<RenameTabArgs>();
|
||||
case Model::ShortcutAction::ExecuteCommandline:
|
||||
return winrt::make<ExecuteCommandlineArgs>();
|
||||
case Model::ShortcutAction::CloseOtherTabs:
|
||||
return winrt::make<CloseOtherTabsArgs>();
|
||||
case Model::ShortcutAction::CloseTabsAfter:
|
||||
return winrt::make<CloseTabsAfterArgs>();
|
||||
case Model::ShortcutAction::CloseTab:
|
||||
return winrt::make<CloseTabArgs>();
|
||||
case Model::ShortcutAction::MoveTab:
|
||||
return winrt::make<MoveTabArgs>();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
// Actions
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Settings::Model::ResizeDirection, ResizeDirection);
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Settings::Model::FocusDirection, FocusDirection);
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Settings::Model::SettingsTarget, SettingsTarget);
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Settings::Model::MoveTabDirection, MoveTabDirection);
|
||||
|
||||
// FontWeight is special because the JsonUtils::ConversionTrait for it
|
||||
// creates a FontWeight object, but we need to use the uint16_t value.
|
||||
|
||||
@@ -52,6 +52,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
// Actions
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Settings::Model::ResizeDirection> ResizeDirection();
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Settings::Model::FocusDirection> FocusDirection();
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Settings::Model::SettingsTarget> SettingsTarget();
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Settings::Model::MoveTabDirection> MoveTabDirection();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -34,5 +34,8 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
|
||||
// Actions
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Settings.Model.ResizeDirection> ResizeDirection { get; };
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Settings.Model.FocusDirection> FocusDirection { get; };
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Settings.Model.SettingsTarget> SettingsTarget { get; };
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Settings.Model.MoveTabDirection> MoveTabDirection { get; };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,24 @@ namespace winrt::Microsoft::Terminal::UI::implementation
|
||||
return winrt::unbox_value<uint32_t>(value);
|
||||
}
|
||||
|
||||
uint32_t Converters::UnboxUInt32Optional(const Windows::Foundation::IInspectable& value)
|
||||
{
|
||||
const auto unboxed = winrt::unbox_value<winrt::Windows::Foundation::IReference<uint32_t>>(value);
|
||||
if (unboxed)
|
||||
{
|
||||
return unboxed.Value();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
float Converters::UnboxFloat(const Windows::Foundation::IInspectable& value)
|
||||
{
|
||||
return winrt::unbox_value<float>(value);
|
||||
}
|
||||
|
||||
bool Converters::UnboxBool(const Windows::Foundation::IInspectable& value)
|
||||
{
|
||||
return winrt::unbox_value<bool>(value);
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace winrt::Microsoft::Terminal::UI::implementation
|
||||
// Unboxing
|
||||
static winrt::hstring UnboxString(const Windows::Foundation::IInspectable& value);
|
||||
static uint32_t UnboxUInt32(const Windows::Foundation::IInspectable& value);
|
||||
static uint32_t UnboxUInt32Optional(const Windows::Foundation::IInspectable& value);
|
||||
static float UnboxFloat(const Windows::Foundation::IInspectable& value);
|
||||
static bool UnboxBool(const Windows::Foundation::IInspectable& value);
|
||||
static winrt::Windows::Foundation::IReference<bool> UnboxBoolOptional(const Windows::Foundation::IInspectable& value);
|
||||
};
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace Microsoft.Terminal.UI
|
||||
// Unboxing
|
||||
static String UnboxString(Object value);
|
||||
static UInt32 UnboxUInt32(Object value);
|
||||
static UInt32 UnboxUInt32Optional(Object value);
|
||||
static Single UnboxFloat(Object value);
|
||||
static Boolean UnboxBool(Object value);
|
||||
static Windows.Foundation.IReference<Boolean> UnboxBoolOptional(Object value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user