Changes to be able to quit the application via exit inside a CLI prompt. (#746)
* Changes to be able to quit the application via exit inside a CLI prompt.
This commit is contained in:
parent
de24334898
commit
bc69d1a99a
|
@ -827,12 +827,11 @@ namespace winrt::TerminalApp::implementation
|
|||
// - tabViewItem: the TabViewItem in the TabView that is being removed.
|
||||
void App::_RemoveTabViewItem(const IInspectable& tabViewItem)
|
||||
{
|
||||
// TODO: GitHub:627: Need a better story for what should happen when the last tab is closed.
|
||||
if (_tabs.size() <= 1)
|
||||
// To close the window here, we need to close the hosting window.
|
||||
if (_tabs.size() == 1)
|
||||
{
|
||||
return;
|
||||
_lastTabClosedHandlers();
|
||||
}
|
||||
|
||||
uint32_t tabIndexFromControl = 0;
|
||||
_tabView.Items().IndexOf(tabViewItem, tabIndexFromControl);
|
||||
|
||||
|
@ -885,4 +884,5 @@ namespace winrt::TerminalApp::implementation
|
|||
// Winrt events need a method for adding a callback to the event and removing the callback.
|
||||
// These macros will define them both for you.
|
||||
DEFINE_EVENT(App, TitleChanged, _titleChangeHandlers, TerminalControl::TitleChangedEventArgs);
|
||||
DEFINE_EVENT(App, LastTabClosed, _lastTabClosedHandlers, winrt::TerminalApp::LastTabClosedEventArgs);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
// -------------------------------- WinRT Events ---------------------------------
|
||||
DECLARE_EVENT(TitleChanged, _titleChangeHandlers, winrt::Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
DECLARE_EVENT(LastTabClosed, _lastTabClosedHandlers, winrt::TerminalApp::LastTabClosedEventArgs);
|
||||
|
||||
private:
|
||||
App(Windows::UI::Xaml::Markup::IXamlMetadataProvider const& parentProvider);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace TerminalApp
|
||||
{
|
||||
delegate void LastTabClosedEventArgs();
|
||||
[default_interface]
|
||||
runtimeclass App : Microsoft.UI.Xaml.Markup.XamlApplication
|
||||
{
|
||||
|
@ -24,6 +25,7 @@ namespace TerminalApp
|
|||
Boolean GetShowTabsInTitlebar();
|
||||
|
||||
event Microsoft.Terminal.TerminalControl.TitleChangedEventArgs TitleChanged;
|
||||
event LastTabClosedEventArgs LastTabClosed;
|
||||
|
||||
String GetTitle();
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ void AppHost::Initialize()
|
|||
_app.Create();
|
||||
|
||||
_app.TitleChanged({ this, &AppHost::AppTitleChanged });
|
||||
_app.LastTabClosed({ this, &AppHost::LastTabClosed });
|
||||
|
||||
AppTitleChanged(_app.GetTitle());
|
||||
|
||||
|
@ -93,6 +94,16 @@ void AppHost::AppTitleChanged(winrt::hstring newTitle)
|
|||
_window->UpdateTitle(newTitle.c_str());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Called when no tab is remaining to close the window.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void AppHost::LastTabClosed() {
|
||||
_window->Close();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Resize the window we're about to create to the appropriate dimensions, as
|
||||
// specified in the settings. This will be called during the handling of
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
virtual ~AppHost();
|
||||
|
||||
void AppTitleChanged(winrt::hstring newTitle);
|
||||
|
||||
void LastTabClosed();
|
||||
void Initialize();
|
||||
|
||||
private:
|
||||
|
|
|
@ -61,6 +61,17 @@ void IslandWindow::MakeWindow() noexcept
|
|||
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Called when no tab is remaining to close the window.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void IslandWindow::Close()
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Set a callback to be called when we process a WM_CREATE message. This gives
|
||||
// the AppHost a chance to resize the window to the propoer size.
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
virtual ~IslandWindow() override;
|
||||
|
||||
void MakeWindow() noexcept;
|
||||
|
||||
void Close();
|
||||
virtual void OnSize();
|
||||
|
||||
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
|
||||
|
|
Loading…
Reference in a new issue