Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Aug 24, 2023
1 parent 0c4fbba commit e69f19b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,11 @@ namespace winrt::TerminalApp::implementation
// use as a title though!
//
// First, check the reserved keywords:
if (parsedTarget == "new")
if (parsedTarget == NewWindow)
{
return winrt::make<FindTargetWindowResult>(WindowingBehaviorUseNew);
}
else if (parsedTarget == "last")
else if (parsedTarget == MostRecentlyUsedWindow)
{
return winrt::make<FindTargetWindowResult>(WindowingBehaviorUseExisting);
}
Expand Down
8 changes: 6 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,11 @@ namespace winrt::TerminalApp::implementation

bool TerminalPage::_MoveTab(winrt::com_ptr<TerminalTab> tab, MoveTabArgs args)
{
if (!tab)
{
return false;
}

// If there was a windowId in the action, try to move it to the
// specified window instead of moving it in our tab row.
const auto windowId{ args.Window() };
Expand Down Expand Up @@ -2142,8 +2147,7 @@ namespace winrt::TerminalApp::implementation
// Use the requested tab, if provided. Otherwise, use the currently
// focused tab.
const auto tabIndex = til::coalesce(_GetTabIndex(*tab),
_GetFocusedTabIndex(),
std::optional<uint32_t>{ std::nullopt });
_GetFocusedTabIndex());
if (tabIndex)
{
const auto currentTabIndex = tabIndex.value();
Expand Down
7 changes: 3 additions & 4 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Utils.h"
#include "ColorHelper.h"
#include "AppLogic.h"
#include "../inc/WindowingBehavior.h"

using namespace winrt;
using namespace winrt::Windows::UI::Xaml;
Expand Down Expand Up @@ -1844,10 +1845,8 @@ namespace winrt::TerminalApp::implementation
void TerminalTab::_moveTabToNewWindowClicked(const winrt::Windows::Foundation::IInspectable& /* sender */,
const winrt::Windows::UI::Xaml::RoutedEventArgs& /* args */)
{
ActionAndArgs actionAndArgs{};
MoveTabArgs args{ hstring{ L"new" }, MoveTabDirection::Forward };
actionAndArgs.Action(ShortcutAction::MoveTab);
actionAndArgs.Args(args);
MoveTabArgs args{ winrt::to_hstring(NewWindow), MoveTabDirection::Forward };
ActionAndArgs actionAndArgs{ ShortcutAction::MoveTab, args };
_dispatch.DoAction(*this, actionAndArgs);
}
void TerminalTab::_findClicked(const winrt::Windows::Foundation::IInspectable& /* sender */,
Expand Down
7 changes: 7 additions & 0 deletions src/cascadia/inc/WindowingBehavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ inline constexpr int32_t WindowingBehaviorUseName{ -4 };
inline constexpr int32_t WindowingBehaviorUseNone{ -5 };

inline constexpr std::wstring_view QuakeWindowName{ L"_quake" };

// Magic names for magic windowing behaviors. These are reserved names, in place
// of window names. "new" can also be used in MoveTab / MovePane actions.
// * new: to use a new window, always
// * last: use the most recent window
inline constexpr std::string_view NewWindow{ "new" };
inline constexpr std::string_view MostRecentlyUsedWindow{ "last" };

0 comments on commit e69f19b

Please sign in to comment.