Skip to content
Open
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
d973836
settings model reflection
PankajBhojwani May 14, 2025
2f6108d
settings actions editor
PankajBhojwani May 14, 2025
ce8b31b
use x-macro here instead
PankajBhojwani May 14, 2025
acad388
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani May 14, 2025
63ec868
remove old actions page
PankajBhojwani May 15, 2025
8d0f947
remove old stuff
PankajBhojwani May 15, 2025
72e9b64
format
PankajBhojwani May 15, 2025
23a0432
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani May 15, 2025
eecb32d
format
PankajBhojwani May 15, 2025
9618831
first nits
PankajBhojwani May 16, 2025
5b617e0
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani May 16, 2025
6557d17
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani May 29, 2025
d62ede4
init as nullptr
PankajBhojwani May 29, 2025
ed25720
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani May 29, 2025
18830be
change this back
PankajBhojwani May 29, 2025
035b341
static actionargfactory class
PankajBhojwani May 30, 2025
80924f2
rename and separate interface
PankajBhojwani May 30, 2025
46b036b
folder path, only capitalize first letter
PankajBhojwani May 30, 2025
b0ba0df
deduplicate resource strings
PankajBhojwani Jun 2, 2025
e2b2d46
new tab menu updates with id changes
PankajBhojwani Jun 2, 2025
cdb9599
name fix
PankajBhojwani Jun 2, 2025
0227969
undef the correct thing
PankajBhojwani Jun 3, 2025
0cb802e
format
PankajBhojwani Jun 3, 2025
4a972cc
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Jun 3, 2025
c55ba1b
post merge updates
PankajBhojwani Jun 3, 2025
4e87177
spelling
PankajBhojwani Jun 3, 2025
21e1e15
how about now
PankajBhojwani Jun 3, 2025
5dde183
add examples, remove some stuff
PankajBhojwani Jun 10, 2025
3e426d7
remvoe more
PankajBhojwani Jun 10, 2025
54b850e
no more no arg
PankajBhojwani Jun 10, 2025
7fac89c
some wrapping
PankajBhojwani Jun 11, 2025
2e5c54c
folder picker
PankajBhojwani Jun 11, 2025
f853aa4
abstract
PankajBhojwani Jun 11, 2025
9fa1c94
we're not listening to this
PankajBhojwani Jun 11, 2025
a611189
move to action map
PankajBhojwani Jun 13, 2025
67a1b4e
alphabetical
PankajBhojwani Jun 13, 2025
78395fb
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Jun 13, 2025
f601fc7
keyboard nav, event handler cleanup
PankajBhojwani Jun 16, 2025
7db0cd6
spell
PankajBhojwani Jun 16, 2025
d862d67
uia names
PankajBhojwani Jun 16, 2025
c24035f
...xaml side too
PankajBhojwani Jun 16, 2025
bafe0b1
automation props, tab stop fixes
PankajBhojwani Jun 17, 2025
caedc8f
items control here
PankajBhojwani Jun 17, 2025
c47a353
switch to items control
PankajBhojwani Jun 18, 2025
c4529aa
uia text
PankajBhojwani Jun 18, 2025
b23ce87
remove these notifies
PankajBhojwani Jun 18, 2025
43ad62c
proposed shortcut action name
PankajBhojwani Jun 18, 2025
c24293c
getter only
PankajBhojwani Jun 18, 2025
ad0f79d
name fixes
PankajBhojwani Jun 18, 2025
849eb1d
access maps through page vm
PankajBhojwani Jun 19, 2025
cd424f4
assert
PankajBhojwani Jun 19, 2025
ccc7292
init to first item in the enum list
PankajBhojwani Jun 19, 2025
54681b4
localized arg names
PankajBhojwani Jun 20, 2025
757191b
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Jun 20, 2025
4311a2b
add todos, remove guid
PankajBhojwani Jun 20, 2025
ac0eb51
new info badge
PankajBhojwani Jun 20, 2025
10b8475
rename
PankajBhojwani Jun 20, 2025
bbdc671
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Jun 20, 2025
2f4a0c9
Arg_desc
PankajBhojwani Jun 23, 2025
816df33
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Jun 23, 2025
2b086cb
deduplicate enums that have different names but mean the same thing
PankajBhojwani Jun 23, 2025
d682ded
update display name on argument change
PankajBhojwani Jun 24, 2025
52abb0d
Some keyboard nav stuff
PankajBhojwani Jun 26, 2025
b1550c8
show the first keybinding on the top level page
PankajBhojwani Jun 27, 2025
9c50b62
prop names
PankajBhojwani Aug 7, 2025
24edaa9
comma
PankajBhojwani Aug 7, 2025
da0a7a0
conflict
PankajBhojwani Aug 12, 2025
9eb6c77
conflict
PankajBhojwani Aug 12, 2025
c5dd430
const vectors, rename to typeHint
PankajBhojwani Aug 13, 2025
fa36c50
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Aug 13, 2025
6cb9909
typehint
PankajBhojwani Aug 14, 2025
2b1ffd4
__COUNTER__, lazy init static arg descriptors
PankajBhojwani Aug 14, 2025
ccfb4bd
format
PankajBhojwani Aug 14, 2025
b3f9c89
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Aug 14, 2025
9366666
get arg descriptors
PankajBhojwani Aug 15, 2025
06c051b
+1
PankajBhojwani Aug 15, 2025
19fb26d
split pane args fix
PankajBhojwani Aug 15, 2025
8a81db7
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Aug 15, 2025
6c08bcb
cache the displayname
PankajBhojwani Aug 15, 2025
981a01e
don't need this anymore
PankajBhojwani Aug 15, 2025
ef197d2
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Aug 15, 2025
892ced6
two cached vectors
PankajBhojwani Aug 18, 2025
75d0a1b
lightweight arg count
PankajBhojwani Aug 18, 2025
e2a758e
first round
PankajBhojwani Aug 20, 2025
e9291ba
init newterminalargs in getemptyargs
PankajBhojwani Aug 21, 2025
ea36019
unnecessary includes
PankajBhojwani Aug 21, 2025
890671a
callback instead
PankajBhojwani Aug 21, 2025
84aaf05
lowercase i
PankajBhojwani Aug 21, 2025
ebee14b
map handles id changes
PankajBhojwani Aug 22, 2025
64dfb94
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Aug 22, 2025
bbdfb37
use action map's update id
PankajBhojwani Aug 22, 2025
cde4c03
vector instead
PankajBhojwani Aug 25, 2025
d9a409a
updateid moved to cascadia settings
PankajBhojwani Aug 25, 2025
41ae713
Merge branch 'dev/pabhoj/settings_model_reflection' into dev/pabhoj/s…
PankajBhojwani Aug 25, 2025
b2a624e
updateid update
PankajBhojwani Aug 25, 2025
e995a5f
conflict
PankajBhojwani Sep 3, 2025
8e0a447
whitespace
PankajBhojwani Sep 3, 2025
2366b3f
format
PankajBhojwani Sep 3, 2025
6cffe9f
first pass
PankajBhojwani Sep 25, 2025
1693773
formatt
PankajBhojwani Sep 25, 2025
e0352e4
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Sep 25, 2025
8b3c12e
edit action resource
PankajBhojwani Sep 25, 2025
757bd15
function template instead
PankajBhojwani Sep 26, 2025
8d1f280
expose int value on enum and flag entry
PankajBhojwani Sep 30, 2025
294e2e3
safer handling
PankajBhojwani Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 9 additions & 44 deletions src/cascadia/TerminalSettingsEditor/Actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Automation::AutomationProperties::SetName(AddNewButton(), RS_(L"Actions_AddNewTextBlock/Text"));
}

Automation::Peers::AutomationPeer Actions::OnCreateAutomationPeer()
{
_ViewModel.OnAutomationPeerAttached();
return nullptr;
}

void Actions::OnNavigatedTo(const NavigationEventArgs& e)
{
_ViewModel = e.Parameter().as<Editor::ActionsViewModel>();

// Subscribe to the view model's FocusContainer event.
// Use the KeyBindingViewModel or index provided in the event to focus the corresponding container
_ViewModel.FocusContainer([this](const auto& /*sender*/, const auto& args) {
if (auto kbdVM{ args.try_as<KeyBindingViewModel>() })
{
if (const auto& container = KeyBindingsListView().ContainerFromItem(*kbdVM))
{
container.as<Controls::ListViewItem>().Focus(FocusState::Programmatic);
}
}
else if (const auto& index = args.try_as<uint32_t>())
{
if (const auto& container = KeyBindingsListView().ContainerFromIndex(*index))
{
container.as<Controls::ListViewItem>().Focus(FocusState::Programmatic);
}
}
});

// Subscribe to the view model's UpdateBackground event.
// The view model does not have access to the page resources, so it asks us
// to update the key binding's container background
_ViewModel.UpdateBackground([this](const auto& /*sender*/, const auto& args) {
if (auto kbdVM{ args.try_as<KeyBindingViewModel>() })
{
if (kbdVM->IsInEditMode())
{
const auto& containerBackground{ Resources().Lookup(box_value(L"ActionContainerBackgroundEditing")).as<Windows::UI::Xaml::Media::Brush>() };
kbdVM->ContainerBackground(containerBackground);
}
else
{
const auto& containerBackground{ Resources().Lookup(box_value(L"ActionContainerBackground")).as<Windows::UI::Xaml::Media::Brush>() };
kbdVM->ContainerBackground(containerBackground);
}
}
_ViewModel.CurrentPage(ActionsSubPage::Base);
auto vmImpl = get_self<ActionsViewModel>(_ViewModel);
vmImpl->MarkAsVisited();
_layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
// Only let this succeed once.
_layoutUpdatedRevoker.revoke();

AddNewButton().Focus(FocusState::Programmatic);
});

TraceLoggingWrite(
Expand All @@ -78,6 +43,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void Actions::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*eventArgs*/)
{
_ViewModel.AddNewKeybinding();
_ViewModel.AddNewCommand();
}
}
4 changes: 3 additions & 1 deletion src/cascadia/TerminalSettingsEditor/Actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
Actions();

void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
Windows::UI::Xaml::Automation::Peers::AutomationPeer OnCreateAutomationPeer();

void AddNew_Click(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);

til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(Editor::ActionsViewModel, ViewModel, PropertyChanged.raise, nullptr);

private:
winrt::Windows::UI::Xaml::FrameworkElement::LayoutUpdated_revoker _layoutUpdatedRevoker;
};
}

Expand Down
177 changes: 19 additions & 158 deletions src/cascadia/TerminalSettingsEditor/Actions.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<Style x:Key="KeyBindingContainerStyle"
BasedOn="{StaticResource DefaultListViewItemStyle}"
TargetType="ListViewItem">
<Setter Property="Padding" Value="4" />
<Setter Property="Padding" Value="12,4,4,4" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="XYFocusKeyboardNavigation" Value="Enabled" />
</Style>
Expand All @@ -138,24 +138,6 @@
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<x:Int32 x:Key="EditButtonSize">32</x:Int32>
<x:Double x:Key="EditButtonIconSize">14</x:Double>
<Style x:Key="EditButtonStyle"
BasedOn="{StaticResource DefaultButtonStyle}"
TargetType="Button">
<Setter Property="Padding" Value="0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Height" Value="{StaticResource EditButtonSize}" />
<Setter Property="Width" Value="{StaticResource EditButtonSize}" />
</Style>
<Style x:Key="AccentEditButtonStyle"
BasedOn="{StaticResource AccentButtonStyle}"
TargetType="Button">
<Setter Property="Padding" Value="4" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Height" Value="{StaticResource EditButtonSize}" />
<Setter Property="Width" Value="{StaticResource EditButtonSize}" />
</Style>

<!-- Converters & Misc. -->
<SolidColorBrush x:Key="ActionContainerBackgroundEditing"
Expand All @@ -164,162 +146,35 @@
Color="Transparent" />

<!-- Templates -->
<DataTemplate x:Key="KeyBindingTemplate"
x:DataType="local:KeyBindingViewModel">
<ListViewItem AutomationProperties.AcceleratorKey="{x:Bind KeyChordText, Mode=OneWay}"
AutomationProperties.Name="{x:Bind Name, Mode=OneWay}"
Background="{x:Bind ContainerBackground, Mode=OneWay}"
GotFocus="{x:Bind ActionGotFocus}"
LostFocus="{x:Bind ActionLostFocus}"
PointerEntered="{x:Bind EnterHoverMode}"
PointerExited="{x:Bind ExitHoverMode}"
<DataTemplate x:Key="CommandTemplate"
x:DataType="local:CommandViewModel">
<ListViewItem AutomationProperties.Name="{x:Bind DisplayNameAndKeyChordAutomationPropName, Mode=OneWay}"
Style="{StaticResource KeyBindingContainerStyle}">
<Grid ColumnSpacing="8">
<Grid.ColumnDefinitions>
<!-- command name -->
<ColumnDefinition Width="*" />
<!-- key chord -->
<ColumnDefinition Width="auto" />
<!-- edit buttons -->
<!--
This needs to be 112 because that is the width of the row of buttons in edit mode + padding.
3 buttons: 32+32+32
Padding: 8+ 8
This allows the "edit" button to align with the "cancel" button seamlessly
-->
<ColumnDefinition Width="112" />
</Grid.ColumnDefinitions>

<!-- Command Name -->
<TextBlock Grid.Column="0"
FontWeight="Normal"
Style="{StaticResource KeyBindingNameTextBlockStyle}"
Text="{x:Bind Name, Mode=OneWay}"
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(IsInEditMode), Mode=OneWay}" />

<!-- Edit Mode: Action Combo-box -->
<ComboBox x:Uid="Actions_ActionComboBox"
Grid.Column="0"
VerticalAlignment="Center"
ItemsSource="{x:Bind AvailableActions, Mode=OneWay}"
SelectedItem="{x:Bind ProposedAction, Mode=TwoWay}"
Visibility="{x:Bind IsInEditMode, Mode=OneWay}" />

Text="{x:Bind DisplayName, Mode=OneWay}" />
<!-- Key Chord Text -->
<Border Grid.Column="1"
Padding="2,0,2,0"
Padding="8,4,8,4"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Style="{ThemeResource KeyChordBorderStyle}"
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(IsInEditMode), Mode=OneWay}">

Visibility="{x:Bind mtu:Converters.StringNotEmptyToVisibility(FirstKeyChordText)}">
<TextBlock FontSize="14"
Style="{ThemeResource KeyChordTextBlockStyle}"
Text="{x:Bind KeyChordText, Mode=OneWay}"
Text="{x:Bind FirstKeyChordText, Mode=OneWay}"
TextWrapping="WrapWholeWords" />
</Border>

<!-- Edit Mode: Key Chord Listener -->
<local:KeyChordListener Grid.Column="1"
Keys="{x:Bind ProposedKeys, Mode=TwoWay}"
Style="{StaticResource KeyChordEditorStyle}"
Visibility="{x:Bind IsInEditMode, Mode=OneWay}" />

<!-- Edit Button -->
<Button x:Uid="Actions_EditButton"
Grid.Column="2"
AutomationProperties.Name="{x:Bind EditButtonName}"
Background="Transparent"
Click="{x:Bind ToggleEditMode}"
GettingFocus="{x:Bind EditButtonGettingFocus}"
LosingFocus="{x:Bind EditButtonLosingFocus}"
Style="{StaticResource EditButtonStyle}"
Visibility="{x:Bind ShowEditButton, Mode=OneWay}">
<Button.Content>
<FontIcon FontSize="{StaticResource EditButtonIconSize}"
Glyph="&#xE70F;" />
</Button.Content>
<Button.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Color="{StaticResource SystemAccentColor}" />
<SolidColorBrush x:Key="ButtonForegroundPressed"
Color="{StaticResource SystemAccentColor}" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Color="{StaticResource SystemAccentColor}" />
<SolidColorBrush x:Key="ButtonForegroundPressed"
Color="{StaticResource SystemAccentColor}" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="ButtonBackground"
Color="{ThemeResource SystemColorButtonFaceColor}" />
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="ButtonBackgroundPressed"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="ButtonForeground"
Color="{ThemeResource SystemColorButtonTextColor}" />
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="ButtonForegroundPressed"
Color="{ThemeResource SystemColorHighlightTextColor}" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Button.Resources>
</Button>

<!-- Edit Mode: Buttons -->
<StackPanel Grid.Column="2"
Orientation="Horizontal"
Visibility="{x:Bind IsInEditMode, Mode=OneWay}">

<!-- Cancel editing the action -->
<Button x:Uid="Actions_CancelButton"
AutomationProperties.Name="{x:Bind CancelButtonName}"
Click="{x:Bind CancelChanges}"
Style="{StaticResource EditButtonStyle}">
<FontIcon FontSize="{StaticResource EditButtonIconSize}"
Glyph="&#xE711;" />
</Button>

<!-- Accept changes -->
<Button x:Uid="Actions_AcceptButton"
Margin="8,0,0,0"
AutomationProperties.Name="{x:Bind AcceptButtonName}"
Click="{x:Bind AttemptAcceptChanges}"
Flyout="{x:Bind AcceptChangesFlyout, Mode=OneWay}"
Style="{StaticResource AccentEditButtonStyle}">
<FontIcon FontSize="{StaticResource EditButtonIconSize}"
Glyph="&#xE8FB;" />
</Button>

<!-- Delete the current key binding -->
<Button x:Uid="Actions_DeleteButton"
Margin="8,0,0,0"
AutomationProperties.Name="{x:Bind DeleteButtonName}"
Style="{StaticResource DeleteSmallButtonStyle}"
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(IsNewlyAdded), Mode=OneWay}">
<Button.Content>
<FontIcon FontSize="{StaticResource EditButtonIconSize}"
Glyph="&#xE74D;" />
</Button.Content>
<Button.Flyout>
<Flyout FlyoutPresenterStyle="{StaticResource CustomFlyoutPresenterStyle}">
<StackPanel>
<TextBlock x:Uid="Actions_DeleteConfirmationMessage"
Style="{StaticResource CustomFlyoutTextStyle}" />
<Button x:Uid="Actions_DeleteConfirmationButton"
Click="{x:Bind DeleteKeyBinding}" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
</Grid>
</ListViewItem>
</DataTemplate>
Expand All @@ -331,6 +186,10 @@
HorizontalAlignment="Left"
Spacing="8"
Style="{StaticResource SettingsStackStyle}">
<HyperlinkButton x:Uid="Actions_Disclaimer"
Margin="0"
Padding="0"
NavigateUri="https://learn.microsoft.com/en-us/windows/terminal/customize-settings/actions" />
<!-- Add New Button -->
<Button x:Name="AddNewButton"
Margin="0,12,0,0"
Expand All @@ -345,11 +204,13 @@
</Button.Content>
</Button>

<!-- Keybindings -->
<ListView x:Name="KeyBindingsListView"
ItemTemplate="{StaticResource KeyBindingTemplate}"
ItemsSource="{x:Bind ViewModel.KeyBindingList, Mode=OneWay}"
SelectionMode="None" />
<!-- Commands -->
<ListView x:Name="CommandsListView"
Margin="-8,0,0,0"
IsItemClickEnabled="True"
ItemClick="{x:Bind ViewModel.CmdListItemClicked}"
ItemTemplate="{StaticResource CommandTemplate}"
ItemsSource="{x:Bind ViewModel.CommandList, Mode=OneWay}" />
</StackPanel>
</Border>
</Page>
Loading
Loading