Skip to content

Commit 521e301

Browse files
committed
update settings should work now
1 parent 842326d commit 521e301

14 files changed

+70
-19
lines changed

src/cascadia/TerminalApp/IPaneContent.idl

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace TerminalApp
1212
interface IPaneContent
1313
{
1414
Windows.UI.Xaml.FrameworkElement GetRoot();
15+
void UpdateSettings(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
1516

1617
Windows.Foundation.Size MinSize { get; };
1718

src/cascadia/TerminalApp/Pane.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -1276,20 +1276,28 @@ void Pane::_FocusFirstChild()
12761276
}
12771277
}
12781278

1279+
void Pane::UpdateSettings(const CascadiaSettings& settings)
1280+
{
1281+
if (_content)
1282+
{
1283+
_content.UpdateSettings(settings);
1284+
}
1285+
}
1286+
12791287
// Method Description:
12801288
// - Updates the settings of this pane, presuming that it is a leaf.
12811289
// Arguments:
12821290
// - settings: The new TerminalSettings to apply to any matching controls
12831291
// - profile: The profile from which these settings originated.
12841292
// Return Value:
12851293
// - <none>
1286-
void Pane::UpdateSettings(const TerminalSettingsCreateResult& settings, const Profile& profile)
1294+
void Pane::UpdateTerminalSettings(const TerminalSettingsCreateResult& settings, const Profile& profile)
12871295
{
12881296
assert(_IsLeaf());
12891297

12901298
if (const auto& terminalPane{ _getTerminalContent() })
12911299
{
1292-
return terminalPane.UpdateSettings(settings, profile);
1300+
return terminalPane.UpdateTerminalSettings(settings, profile);
12931301
}
12941302
}
12951303

src/cascadia/TerminalApp/Pane.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ class Pane : public std::enable_shared_from_this<Pane>
106106
BuildStartupState BuildStartupActions(uint32_t currentId, uint32_t nextId, const bool asContent = false, const bool asMovePane = false);
107107
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetTerminalArgsForPane(const bool asContent = false) const;
108108

109-
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult& settings,
110-
const winrt::Microsoft::Terminal::Settings::Model::Profile& profile);
109+
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
110+
void UpdateTerminalSettings(const winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult& settings,
111+
const winrt::Microsoft::Terminal::Settings::Model::Profile& profile);
111112
bool ResizePane(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
112113
std::shared_ptr<Pane> NavigateDirection(const std::shared_ptr<Pane> sourcePane,
113114
const winrt::Microsoft::Terminal::Settings::Model::FocusDirection& direction,

src/cascadia/TerminalApp/ScratchpadContent.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ namespace winrt::TerminalApp::implementation
2929
_root.Children().Append(_box);
3030
}
3131

32+
void ScratchpadContent::UpdateSettings(const CascadiaSettings& /*settings*/)
33+
{
34+
// Nothing to do.
35+
}
36+
3237
winrt::Windows::UI::Xaml::FrameworkElement ScratchpadContent::GetRoot()
3338
{
3439
return _root;

src/cascadia/TerminalApp/ScratchpadContent.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace winrt::TerminalApp::implementation
1212

1313
winrt::Windows::UI::Xaml::FrameworkElement GetRoot();
1414

15+
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
16+
1517
winrt::Windows::Foundation::Size MinSize();
1618
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
1719
void Close();

src/cascadia/TerminalApp/SettingsPaneContent.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,25 @@ using namespace winrt::Windows::Foundation;
1010
using namespace winrt::Windows::UI::Xaml;
1111
using namespace winrt::Microsoft::Terminal::Settings::Model;
1212

13+
#define ASSERT_UI_THREAD() assert(_sui.Dispatcher().HasThreadAccess())
14+
1315
namespace winrt::TerminalApp::implementation
1416
{
1517
SettingsPaneContent::SettingsPaneContent(CascadiaSettings settings)
1618
{
1719
_sui = winrt::Microsoft::Terminal::Settings::Editor::MainPage{ settings };
1820
}
1921

22+
void SettingsPaneContent::UpdateSettings(const CascadiaSettings& settings)
23+
{
24+
ASSERT_UI_THREAD();
25+
_sui.UpdateSettings(settings);
26+
27+
// Stash away the current requested theme of the app. We'll need that in
28+
// _BackgroundBrush() to do a theme-aware resource lookup
29+
// _requestedTheme = settings.GlobalSettings().CurrentTheme().RequestedTheme();
30+
}
31+
2032
winrt::Windows::UI::Xaml::FrameworkElement SettingsPaneContent::GetRoot()
2133
{
2234
return _sui;

src/cascadia/TerminalApp/SettingsPaneContent.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace winrt::TerminalApp::implementation
1111
{
1212
SettingsPaneContent(winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings settings);
1313

14+
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
15+
1416
winrt::Windows::UI::Xaml::FrameworkElement GetRoot();
1517
winrt::Microsoft::Terminal::Settings::Editor::MainPage SettingsUI() { return _sui; }
1618

src/cascadia/TerminalApp/TabManagement.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ namespace winrt::TerminalApp::implementation
289289
{
290290
if (const auto content{ tab.GetActiveContent() })
291291
{
292-
tab.UpdateIcon(content.Icon());
292+
const auto& icon{ content.Icon() };
293+
tab.UpdateIcon(icon);
293294
}
294295
}
295296

src/cascadia/TerminalApp/TerminalPage.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -3154,11 +3154,17 @@ namespace winrt::TerminalApp::implementation
31543154
{
31553155
if (auto terminalTab{ _GetTerminalTabImpl(tab) })
31563156
{
3157-
terminalTab->UpdateSettings();
3157+
// Let the tab know that there are new settings. It's up to each content to decide what to do with them.
3158+
terminalTab->UpdateSettings(_settings);
3159+
3160+
// FURTHERMORE We need to do a bit more work here for terminal
3161+
// panes. They need to know about the profile that was used for
3162+
// them, and about the focused/unfocused settings.
31583163

31593164
// Manually enumerate the panes in each tab; this will let us recycle TerminalSettings
31603165
// objects but only have to iterate one time.
31613166
terminalTab->GetRootPane()->WalkTree([&](auto&& pane) {
3167+
// If the pane isn't a terminal pane, it won't have a profile.
31623168
if (const auto profile{ pane->GetProfile() })
31633169
{
31643170
const auto found{ profileGuidSettingsMap.find(profile.Guid()) };
@@ -3173,7 +3179,7 @@ namespace winrt::TerminalApp::implementation
31733179
{
31743180
pair.second = TerminalSettings::CreateWithProfile(_settings, pair.first, *_bindings);
31753181
}
3176-
pane->UpdateSettings(pair.second, pair.first);
3182+
pane->UpdateTerminalSettings(pair.second, pair.first);
31773183
}
31783184
}
31793185
});

src/cascadia/TerminalApp/TerminalPaneContent.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,15 @@ namespace winrt::TerminalApp::implementation
288288
RestartTerminalRequested.raise(*this, nullptr);
289289
}
290290

291-
void TerminalPaneContent::UpdateSettings(const TerminalSettingsCreateResult& settings,
292-
const Profile& profile)
291+
void TerminalPaneContent::UpdateSettings(const CascadiaSettings& /*settings*/)
292+
{
293+
// Do nothing. We'll later be updated manually by
294+
// UpdateTerminalSettings, which we need for profile and
295+
// focused/unfocused settings.
296+
}
297+
298+
void TerminalPaneContent::UpdateTerminalSettings(const TerminalSettingsCreateResult& settings,
299+
const Profile& profile)
293300
{
294301
_profile = profile;
295302
_control.UpdateControlSettings(settings.DefaultSettings(), settings.UnfocusedSettings());

src/cascadia/TerminalApp/TerminalPaneContent.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ namespace winrt::TerminalApp::implementation
2121

2222
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const bool asContent) const;
2323

24-
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult& settings,
25-
const winrt::Microsoft::Terminal::Settings::Model::Profile& profile);
24+
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
25+
void UpdateTerminalSettings(const winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult& settings,
26+
const winrt::Microsoft::Terminal::Settings::Model::Profile& profile);
2627

2728
void MarkAsDefterm();
2829

src/cascadia/TerminalApp/TerminalPaneContent.idl

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace TerminalApp
99
{
1010
Microsoft.Terminal.Control.TermControl GetTerminal();
1111

12-
void UpdateSettings(const Microsoft.Terminal.Settings.Model.TerminalSettingsCreateResult settings,
13-
const Microsoft.Terminal.Settings.Model.Profile profile);
12+
void UpdateTerminalSettings(Microsoft.Terminal.Settings.Model.TerminalSettingsCreateResult settings,
13+
Microsoft.Terminal.Settings.Model.Profile profile);
1414

1515
void MarkAsDefterm();
1616

src/cascadia/TerminalApp/TerminalTab.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,18 @@ namespace winrt::TerminalApp::implementation
268268
// of the settings that apply to all tabs.
269269
// Return Value:
270270
// - <none>
271-
void TerminalTab::UpdateSettings()
271+
void TerminalTab::UpdateSettings(const CascadiaSettings& settings)
272272
{
273273
ASSERT_UI_THREAD();
274274

275275
// The tabWidthMode may have changed, update the header control accordingly
276276
_UpdateHeaderControlMaxWidth();
277+
278+
// Update the settings on all our panes.
279+
_rootPane->WalkTree([&](auto pane) {
280+
pane->UpdateSettings(settings);
281+
return false;
282+
});
277283
}
278284

279285
// Method Description:
@@ -282,7 +288,7 @@ namespace winrt::TerminalApp::implementation
282288
// - iconPath: The new path string to use as the IconPath for our TabViewItem
283289
// Return Value:
284290
// - <none>
285-
void TerminalTab::UpdateIcon(const winrt::hstring iconPath)
291+
void TerminalTab::UpdateIcon(const winrt::hstring& iconPath)
286292
{
287293
ASSERT_UI_THREAD();
288294

@@ -377,7 +383,7 @@ namespace winrt::TerminalApp::implementation
377383
return RS_(L"MultiplePanes");
378384
}
379385
const auto activeContent = GetActiveContent();
380-
return activeContent ? activeContent.Title() : L"";
386+
return activeContent ? activeContent.Title() : winrt::hstring{ L"" };
381387
}
382388

383389
// Method Description:
@@ -987,7 +993,6 @@ namespace winrt::TerminalApp::implementation
987993
if (const auto& termContent{ content.try_as<TerminalApp::TerminalPaneContent>() })
988994
{
989995
_addBroadcastHandlers(termContent.GetTerminal(), events);
990-
991996
}
992997
}
993998

src/cascadia/TerminalApp/TerminalTab.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace winrt::TerminalApp::implementation
4242
std::shared_ptr<Pane> newPane);
4343

4444
void ToggleSplitOrientation();
45-
void UpdateIcon(const winrt::hstring iconPath);
45+
void UpdateIcon(const winrt::hstring& iconPath);
4646
void HideIcon(const bool hide);
4747

4848
void ShowBellIndicator(const bool show);
@@ -58,7 +58,7 @@ namespace winrt::TerminalApp::implementation
5858
bool SwapPane(const winrt::Microsoft::Terminal::Settings::Model::FocusDirection& direction);
5959
bool FocusPane(const uint32_t id);
6060

61-
void UpdateSettings();
61+
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
6262
void UpdateTitle();
6363

6464
void Shutdown() override;

0 commit comments

Comments
 (0)