Skip to content

Commit 29d0d57

Browse files
committed
this works better than it has any right to
1 parent cbd61b0 commit 29d0d57

7 files changed

+64
-45
lines changed

src/cascadia/TerminalApp/AppActionHandlers.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "TerminalPage.h"
88
#include "ScratchpadContent.h"
9-
#include "SettingsPaneContent.h"
109
#include "../WinRTUtils/inc/WtExeUtils.h"
1110
#include "../../types/inc/utils.hpp"
1211
#include "Utils.h"
@@ -1323,8 +1322,8 @@ namespace winrt::TerminalApp::implementation
13231322
{
13241323
if (Feature_ScratchpadPane::IsEnabled())
13251324
{
1326-
// auto scratchPane{ winrt::make_self<ScratchpadContent>() };
1327-
auto scratchPane{ winrt::make_self<SettingsPaneContent>(_settings) };
1325+
auto scratchPane{ winrt::make_self<ScratchpadContent>() };
1326+
// auto scratchPane{ winrt::make_self<SettingsPaneContent>(_settings) };
13281327

13291328
// This is maybe a little wacky - add our key event handler to the pane
13301329
// we made. So that we can get actions for keys that the content didn't

src/cascadia/TerminalApp/SettingsPaneContent.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace winrt::TerminalApp::implementation
5353

5454
NewTerminalArgs SettingsPaneContent::GetNewTerminalArgs(const bool /* asContent */) const
5555
{
56+
// TODO! hey, can we somehow replicate std::vector<ActionAndArgs> SettingsTab::BuildStartupActions?
5657
return nullptr;
5758
}
5859
}

src/cascadia/TerminalApp/SettingsPaneContent.h

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

1313
winrt::Windows::UI::Xaml::FrameworkElement GetRoot();
14+
winrt::Microsoft::Terminal::Settings::Editor::MainPage SettingsUI() { return _sui; }
1415

1516
winrt::Windows::Foundation::Size MinSize();
1617
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
1718
void Close();
1819
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const bool asContent) const;
1920

20-
winrt::hstring Title() { return L"Scratchpad"; }
21+
winrt::hstring Title() { return RS_(L"SettingsTab"); }
2122
uint64_t TaskbarState() { return 0; }
2223
uint64_t TaskbarProgress() { return 0; }
2324
bool ReadOnly() { return false; }
@@ -31,8 +32,6 @@ namespace winrt::TerminalApp::implementation
3132
til::typed_event<> FocusRequested;
3233

3334
private:
34-
winrt::Windows::UI::Xaml::Controls::Grid _root{ nullptr };
35-
winrt::Windows::UI::Xaml::Controls::TextBox _box{ nullptr };
3635
winrt::Microsoft::Terminal::Settings::Editor::MainPage _sui{ nullptr };
3736
};
3837
}

src/cascadia/TerminalApp/SettingsTab.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace winrt::TerminalApp::implementation
3838

3939
void SettingsTab::UpdateSettings(CascadiaSettings settings)
4040
{
41+
// TODO! oh noes, we need to do this too in the content
4142
ASSERT_UI_THREAD();
4243

4344
auto settingsUI{ Content().as<MainPage>() };
@@ -109,6 +110,8 @@ namespace winrt::TerminalApp::implementation
109110
// - <none>
110111
void SettingsTab::_CreateIcon()
111112
{
113+
// TODO! make sure this works
114+
112115
// This is the Setting icon (looks like a gear)
113116
static constexpr std::wstring_view glyph{ L"\xE713" };
114117

@@ -119,6 +122,9 @@ namespace winrt::TerminalApp::implementation
119122

120123
winrt::Windows::UI::Xaml::Media::Brush SettingsTab::_BackgroundBrush()
121124
{
125+
// TODO! make sure this still works. It would be ironic if this _just
126+
// worked_ because the SUI was the same color as a tab with no styling.
127+
122128
// Look up the color we should use for the settings tab item from our
123129
// resources. This should only be used for when "terminalBackground" is
124130
// requested.

src/cascadia/TerminalApp/TabManagement.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,15 @@ namespace winrt::TerminalApp::implementation
275275
// Arguments:
276276
// - pane: The pane to use as the root.
277277
// - insertPosition: Optional parameter to indicate the position of tab.
278-
void TerminalPage::_CreateNewTabFromPane(std::shared_ptr<Pane> pane, uint32_t insertPosition)
278+
TerminalApp::TerminalTab TerminalPage::_CreateNewTabFromPane(std::shared_ptr<Pane> pane, uint32_t insertPosition)
279279
{
280280
if (pane)
281281
{
282282
auto newTabImpl = winrt::make_self<TerminalTab>(pane);
283283
_InitializeTab(newTabImpl, insertPosition);
284+
return *newTabImpl;
284285
}
286+
return nullptr;
285287
}
286288

287289
// Method Description:

src/cascadia/TerminalApp/TerminalPage.cpp

+48-36
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ColorHelper.h"
2323
#include "DebugTapConnection.h"
2424
#include "SettingsTab.h"
25+
#include "SettingsPaneContent.h"
2526
#include "TabRowControl.h"
2627
#include "Utils.h"
2728

@@ -2264,6 +2265,8 @@ namespace winrt::TerminalApp::implementation
22642265
const float splitSize,
22652266
std::shared_ptr<Pane> newPane)
22662267
{
2268+
// TODO! Prevent splitting the _settingsTab!
2269+
22672270
// If the caller is calling us with the return value of _MakePane
22682271
// directly, it's possible that nullptr was returned, if the connections
22692272
// was supposed to be launched in an elevated window. In that case, do
@@ -3768,7 +3771,10 @@ namespace winrt::TerminalApp::implementation
37683771
}
37693772
}
37703773

3771-
winrt::Microsoft::Terminal::Settings::Editor::MainPage sui{ _settings };
3774+
// Create the SUI pane content
3775+
auto settingsContent{ winrt::make_self<SettingsPaneContent>(_settings) };
3776+
auto sui = settingsContent->SettingsUI();
3777+
37723778
if (_hostingHwnd)
37733779
{
37743780
sui.SetHostingWindow(reinterpret_cast<uint64_t>(*_hostingHwnd));
@@ -3784,52 +3790,58 @@ namespace winrt::TerminalApp::implementation
37843790
}
37853791
});
37863792

3787-
auto newTabImpl = winrt::make_self<SettingsTab>(sui, _settings.GlobalSettings().CurrentTheme().RequestedTheme());
3793+
// Create the tab
3794+
auto resultPane = std::make_shared<Pane>(*settingsContent);
3795+
_settingsTab = _CreateNewTabFromPane(resultPane);
37883796

3789-
// Add the new tab to the list of our tabs.
3790-
_tabs.Append(*newTabImpl);
3791-
_mruTabs.Append(*newTabImpl);
3797+
// auto newTabImpl = winrt::make_self<SettingsTab>(sui, _settings.GlobalSettings().CurrentTheme().RequestedTheme());
37923798

3793-
newTabImpl->SetDispatch(*_actionDispatch);
3794-
newTabImpl->SetActionMap(_settings.ActionMap());
3799+
// // Add the new tab to the list of our tabs.
3800+
// _tabs.Append(*newTabImpl);
3801+
// _mruTabs.Append(*newTabImpl);
37953802

3796-
// Give the tab its index in the _tabs vector so it can manage its own SwitchToTab command.
3797-
_UpdateTabIndices();
3803+
// newTabImpl->SetDispatch(*_actionDispatch);
3804+
// newTabImpl->SetActionMap(_settings.ActionMap());
37983805

3799-
// Don't capture a strong ref to the tab. If the tab is removed as this
3800-
// is called, we don't really care anymore about handling the event.
3801-
auto weakTab = make_weak(newTabImpl);
3806+
// // Give the tab its index in the _tabs vector so it can manage its own SwitchToTab command.
3807+
// _UpdateTabIndices();
38023808

3803-
auto tabViewItem = newTabImpl->TabViewItem();
3804-
_tabView.TabItems().Append(tabViewItem);
3809+
// // Don't capture a strong ref to the tab. If the tab is removed as this
3810+
// // is called, we don't really care anymore about handling the event.
3811+
// auto weakTab = make_weak(newTabImpl);
38053812

3806-
tabViewItem.PointerPressed({ this, &TerminalPage::_OnTabClick });
3813+
// auto tabViewItem = newTabImpl->TabViewItem();
3814+
// _tabView.TabItems().Append(tabViewItem);
38073815

3808-
// When the tab requests close, try to close it (prompt for approval, if required)
3809-
newTabImpl->CloseRequested([weakTab, weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
3810-
auto page{ weakThis.get() };
3811-
auto tab{ weakTab.get() };
3816+
// tabViewItem.PointerPressed({ this, &TerminalPage::_OnTabClick });
38123817

3813-
if (page && tab)
3814-
{
3815-
page->_HandleCloseTabRequested(*tab);
3816-
}
3817-
});
3818+
// // When the tab requests close, try to close it (prompt for approval, if required)
3819+
// newTabImpl->CloseRequested([weakTab, weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
3820+
// auto page{ weakThis.get() };
3821+
// auto tab{ weakTab.get() };
38183822

3819-
// When the tab is closed, remove it from our list of tabs.
3820-
newTabImpl->Closed([tabViewItem, weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
3821-
if (auto page{ weakThis.get() })
3822-
{
3823-
page->_settingsTab = nullptr;
3824-
page->_RemoveOnCloseRoutine(tabViewItem, page);
3825-
}
3826-
});
3823+
// if (page && tab)
3824+
// {
3825+
// page->_HandleCloseTabRequested(*tab);
3826+
// }
3827+
// });
3828+
3829+
// TODO! Make sure we remove the _settingsTab if it is closed!
3830+
3831+
// // When the tab is closed, remove it from our list of tabs.
3832+
// newTabImpl->Closed([tabViewItem, weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
3833+
// if (auto page{ weakThis.get() })
3834+
// {
3835+
// page->_settingsTab = nullptr;
3836+
// page->_RemoveOnCloseRoutine(tabViewItem, page);
3837+
// }
3838+
// });
38273839

3828-
_settingsTab = *newTabImpl;
3840+
// _settingsTab = *newTabImpl;
38293841

3830-
// This kicks off TabView::SelectionChanged, in response to which
3831-
// we'll attach the terminal's Xaml control to the Xaml root.
3832-
_tabView.SelectedItem(tabViewItem);
3842+
//// This kicks off TabView::SelectionChanged, in response to which
3843+
//// we'll attach the terminal's Xaml control to the Xaml root.
3844+
//_tabView.SelectedItem(tabViewItem);
38333845
}
38343846
else
38353847
{

src/cascadia/TerminalApp/TerminalPage.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace winrt::TerminalApp::implementation
220220

221221
void _UpdateTabIndices();
222222

223-
TerminalApp::SettingsTab _settingsTab{ nullptr };
223+
TerminalApp::TerminalTab _settingsTab{ nullptr };
224224

225225
bool _isInFocusMode{ false };
226226
bool _isFullscreen{ false };
@@ -297,7 +297,7 @@ namespace winrt::TerminalApp::implementation
297297

298298
void _OpenNewTabDropdown();
299299
HRESULT _OpenNewTab(const Microsoft::Terminal::Settings::Model::NewTerminalArgs& newTerminalArgs);
300-
void _CreateNewTabFromPane(std::shared_ptr<Pane> pane, uint32_t insertPosition = -1);
300+
TerminalApp::TerminalTab _CreateNewTabFromPane(std::shared_ptr<Pane> pane, uint32_t insertPosition = -1);
301301

302302
std::wstring _evaluatePathForCwd(std::wstring_view path);
303303

0 commit comments

Comments
 (0)