Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 4, 2024
1 parent 0a11643 commit 4d47cd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 60 deletions.
48 changes: 4 additions & 44 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3306,59 +3306,19 @@ namespace winrt::TerminalApp::implementation

// Refresh UI elements

// Recreate the TerminalSettings cache here. We'll use that as we're
// updating terminal panes, so that we don't have to build a _new_
// TerminalSettings for every profile we update - we can just look them
// up the previous ones we built.
_terminalSettingsCache = TerminalApp::TerminalSettingsCache{ _settings, *_bindings };

// // Mapping by GUID isn't _excellent_ because the defaults profile doesn't have a stable GUID; however,
// // when we stabilize its guid this will become fully safe.
// std::unordered_map<winrt::guid, std::pair<Profile, TerminalSettingsCreateResult>> profileGuidSettingsMap;
// const auto profileDefaults{ _settings.ProfileDefaults() };
// const auto allProfiles{ _settings.AllProfiles() };

// profileGuidSettingsMap.reserve(allProfiles.Size() + 1);

// // Include the Defaults profile for consideration
// profileGuidSettingsMap.insert_or_assign(profileDefaults.Guid(), std::pair{ profileDefaults, nullptr });
// for (const auto& newProfile : allProfiles)
// {
// // Avoid creating a TerminalSettings right now. They're not totally cheap, and we suspect that users with many
// // panes may not be using all of their profiles at the same time. Lazy evaluation is king!
// profileGuidSettingsMap.insert_or_assign(newProfile.Guid(), std::pair{ newProfile, nullptr });
// }

for (const auto& tab : _tabs)
{
if (auto terminalTab{ _GetTerminalTabImpl(tab) })
{
// Let the tab know that there are new settings. It's up to each content to decide what to do with them.
terminalTab->UpdateSettings(_settings, _terminalSettingsCache);

// // FURTHERMORE We need to do a bit more work here for terminal
// // panes. They need to know about the profile that was used for
// // them, and about the focused/unfocused settings.

// // Manually enumerate the panes in each tab; this will let us recycle TerminalSettings
// // objects but only have to iterate one time.
// terminalTab->GetRootPane()->WalkTree([&](auto&& pane) {
// // If the pane isn't a terminal pane, it won't have a profile.
// if (const auto profile{ pane->GetProfile() })
// {
// const auto found{ profileGuidSettingsMap.find(profile.Guid()) };
// // GH#2455: If there are any panes with controls that had been
// // initialized with a Profile that no longer exists in our list of
// // profiles, we'll leave it unmodified. The profile doesn't exist
// // anymore, so we can't possibly update its settings.
// if (found != profileGuidSettingsMap.cend())
// {
// auto& pair{ found->second };
// if (!pair.second)
// {
// pair.second = TerminalSettings::CreateWithProfile(_settings, pair.first, *_bindings);
// }
// pane->UpdateTerminalSettings(pair.second, pair.first);
// }
// }
// });

// Update the icon of the tab for the currently focused profile in that tab.
// Only do this for TerminalTabs. Other types of tabs won't have multiple panes
// and profiles so the Title and Icon will be set once and only once on init.
Expand Down
21 changes: 5 additions & 16 deletions src/cascadia/TerminalApp/TerminalSettingsCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@ Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Class Name:
- ContentManager.h
- TerminalSettingsCache.h
Abstract:
- This is a helper class for tracking all of the terminal "content" instances of
the Terminal. These are all the ControlInteractivity & ControlCore's of each
of our TermControls. These are each assigned a GUID on creation, and stored in
a map for later lookup.
- This is used to enable moving panes between windows. TermControl's are not
thread-agile, so they cannot be reused on other threads. However, the content
is. This helper, which exists as a singleton across all the threads in the
Terminal app, allows each thread to create content, assign it to a
TermControl, detach it from that control, and reattach to new controls on
other threads.
- When you want to create a new TermControl, call CreateCore to instantiate a
new content with a GUID for later reparenting.
- Detach can be used to temporarily remove a content from its hosted
TermControl. After detaching, you can still use LookupCore &
TermControl::AttachContent to re-attach to the content.
- This is a helper class used as we update the settings for panes. This class
contains a single map of guid -> TerminalSettings, so that as we update all
the panes during a settings reload, we only need to create a TerminalSettings
once per profile.
--*/
#pragma once

Expand Down

0 comments on commit 4d47cd5

Please sign in to comment.