From eed351eb47ae3042bc4e09e0c5d1dfe2a54151e7 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 28 Nov 2019 07:42:15 -0600 Subject: [PATCH] Add a 'splitPane' ShortcutAction (#3722) ## Summary of the Pull Request We already have "splitHorizontal" and "splitVertical", but those will both be deprecated in favor of "splitPane" with arguments. Currently, there's one argument: "style", which is one of "vertical" or "horizontal." ## References This is being done in pursuit of supporting #607 and #998. I don't really want to lob #998 in with this one, since both that and this are hefty enough PRs even as they are. (I have a branch for #998, but it needs this first) This will probably conflict with #3658 ## PR Checklist * [ ] Doesn't actually close anything, only enables #998 * [x] I work here * [ ] Tests added/passed - yea okay no excuses here * [x] Requires documentation to be updated ## Validation Steps Performed Added new keybindings with the args - works Tried the old keybindings without the args - still works --------------------------------------- * Add a 'splitPane' keybinding that can be used for splitting a pane either vertically or horizontally * Update documentation too * Good lord this is important * Add a test too, though I have no idea if it works * "style" -> "split" * pr comments from carlos --- doc/cascadia/SettingsSchema.md | 3 +- doc/cascadia/profiles.schema.json | 26 ++++++ .../KeyBindingsTests.cpp | 91 +++++++++++++++++++ src/cascadia/TerminalApp/ActionArgs.cpp | 1 + src/cascadia/TerminalApp/ActionArgs.h | 48 ++++++++++ src/cascadia/TerminalApp/ActionArgs.idl | 11 +++ .../TerminalApp/AppActionHandlers.cpp | 22 ++--- .../AppKeyBindingsSerialization.cpp | 31 ++++++- src/cascadia/TerminalApp/Pane.h | 29 +++--- .../TerminalApp/ShortcutActionDispatch.cpp | 7 +- .../TerminalApp/ShortcutActionDispatch.h | 3 +- .../TerminalApp/ShortcutActionDispatch.idl | 4 +- src/cascadia/TerminalApp/Tab.cpp | 4 +- src/cascadia/TerminalApp/Tab.h | 4 +- src/cascadia/TerminalApp/TerminalPage.cpp | 31 +------ src/cascadia/TerminalApp/TerminalPage.h | 7 +- src/cascadia/TerminalApp/defaults.json | 4 +- 17 files changed, 246 insertions(+), 80 deletions(-) diff --git a/doc/cascadia/SettingsSchema.md b/doc/cascadia/SettingsSchema.md index 71170be5c37..0e78183a28e 100644 --- a/doc/cascadia/SettingsSchema.md +++ b/doc/cascadia/SettingsSchema.md @@ -127,8 +127,7 @@ Bindings listed below are per the implementation in `src/cascadia/TerminalApp/Ap - switchToTab7 - switchToTab8 - openSettings -- splitHorizontal -- splitVertical +- splitPane - resizePaneLeft - resizePaneRight - resizePaneUp diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 2bc1df89fae..445ed111320 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -56,6 +56,7 @@ "scrollUpPage", "splitHorizontal", "splitVertical", + "splitPane", "switchToTab", "switchToTab0", "switchToTab1", @@ -79,6 +80,13 @@ ], "type": "string" }, + "SplitState": { + "enum": [ + "vertical", + "horizontal" + ], + "type": "string" + }, "ShortcutAction": { "properties": { "action": { @@ -173,6 +181,23 @@ ], "required": [ "direction" ] }, + "SplitPaneAction": { + "description": "Arguments corresponding to a Split Pane Action", + "allOf": [ + { "$ref": "#/definitions/ShortcutAction" }, + { + "properties": { + "action": { "type": "string", "pattern": "splitPane" }, + "split": { + "$ref": "#/definitions/SplitState", + "default": "vertical", + "description": "The orientation to split the pane in, either vertical (think [|]) or horizontal (think [-])" + } + } + } + ], + "required": [ "split" ] + }, "Keybinding": { "additionalProperties": false, "properties": { @@ -185,6 +210,7 @@ { "$ref": "#/definitions/SwitchToTabAction" }, { "$ref": "#/definitions/MoveFocusAction" }, { "$ref": "#/definitions/ResizePaneAction" } + { "$ref": "#/definitions/SplitPaneAction" } ] }, "keys": { diff --git a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp index 5c0dfd6061f..505270adc77 100644 --- a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp @@ -38,6 +38,7 @@ namespace TerminalAppLocalTests TEST_METHOD(UnbindKeybindings); TEST_METHOD(TestArbitraryArgs); + TEST_METHOD(TestSplitPaneArgs); TEST_CLASS_SETUP(ClassSetup) { @@ -365,4 +366,94 @@ namespace TerminalAppLocalTests } } + void KeyBindingsTests::TestSplitPaneArgs() + { + // TODO:GH#3536 - These tests _should_ work, but since the LocalTests + // fail to run at all right now, I can't be sure that they do. When + // #3536 is fixed, make sure that these tests were authored correctly. + + const std::string bindings0String{ R"([ + { "command": "splitVertical", "keys": ["ctrl+a"] }, + { "command": "splitHorizontal", "keys": ["ctrl+b"] }, + { "command": { "action": "splitPane", "split": null }, "keys": ["ctrl+c"] }, + { "command": { "action": "splitPane", "split": "vertical" }, "keys": ["ctrl+d"] }, + { "command": { "action": "splitPane", "split": "horizontal" }, "keys": ["ctrl+e"] }, + { "command": { "action": "splitPane", "split": "none" }, "keys": ["ctrl+f"] }, + { "command": { "action": "splitPane" }, "keys": ["ctrl+g"] } + + ])" }; + + const auto bindings0Json = VerifyParseSucceeded(bindings0String); + + auto appKeyBindings = winrt::make_self(); + VERIFY_IS_NOT_NULL(appKeyBindings); + VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size()); + appKeyBindings->LayerJson(bindings0Json); + VERIFY_ARE_EQUAL(7u, appKeyBindings->_keyShortcuts.size()); + + { + KeyChord kc{ true, false, true, static_cast('A') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Vertical, realArgs.SplitStyle()); + } + { + KeyChord kc{ true, false, true, static_cast('B') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Horizontal, realArgs.SplitStyle()); + } + { + KeyChord kc{ true, false, true, static_cast('C') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::None, realArgs.SplitStyle()); + } + { + KeyChord kc{ true, false, true, static_cast('D') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Vertical, realArgs.SplitStyle()); + } + { + KeyChord kc{ true, false, true, static_cast('E') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Horizontal, realArgs.SplitStyle()); + } + { + KeyChord kc{ true, false, true, static_cast('F') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::None, realArgs.SplitStyle()); + } + { + KeyChord kc{ true, false, true, static_cast('G') }; + auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); + VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); + const auto& realArgs = actionAndArgs.Args().try_as(); + VERIFY_IS_NOT_NULL(realArgs); + // Verify the args have the expected value + VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::None, realArgs.SplitStyle()); + } + } + } diff --git a/src/cascadia/TerminalApp/ActionArgs.cpp b/src/cascadia/TerminalApp/ActionArgs.cpp index 1d000633103..f343e519fdc 100644 --- a/src/cascadia/TerminalApp/ActionArgs.cpp +++ b/src/cascadia/TerminalApp/ActionArgs.cpp @@ -12,3 +12,4 @@ #include "ResizePaneArgs.g.cpp" #include "MoveFocusArgs.g.cpp" #include "AdjustFontSizeArgs.g.cpp" +#include "SplitPaneArgs.g.cpp" diff --git a/src/cascadia/TerminalApp/ActionArgs.h b/src/cascadia/TerminalApp/ActionArgs.h index bd9d7b86122..4e95f85527f 100644 --- a/src/cascadia/TerminalApp/ActionArgs.h +++ b/src/cascadia/TerminalApp/ActionArgs.h @@ -12,6 +12,7 @@ #include "ResizePaneArgs.g.h" #include "MoveFocusArgs.g.h" #include "AdjustFontSizeArgs.g.h" +#include "SplitPaneArgs.g.h" #include "../../cascadia/inc/cppwinrt_utils.h" #include "Utils.h" @@ -241,6 +242,53 @@ namespace winrt::TerminalApp::implementation return *args; } }; + + // Possible SplitState values + // TODO:GH#2550/#3475 - move these to a centralized deserializing place + static constexpr std::string_view VerticalKey{ "vertical" }; + static constexpr std::string_view HorizontalKey{ "horizontal" }; + static TerminalApp::SplitState ParseSplitState(const std::string& stateString) + { + if (stateString == VerticalKey) + { + return TerminalApp::SplitState::Vertical; + } + else if (stateString == HorizontalKey) + { + return TerminalApp::SplitState::Horizontal; + } + // default behavior for invalid data + return TerminalApp::SplitState::None; + }; + + struct SplitPaneArgs : public SplitPaneArgsT + { + SplitPaneArgs() = default; + GETSET_PROPERTY(winrt::TerminalApp::SplitState, SplitStyle, winrt::TerminalApp::SplitState::None); + + static constexpr std::string_view SplitKey{ "split" }; + + public: + bool Equals(const IActionArgs& other) + { + auto otherAsUs = other.try_as(); + if (otherAsUs) + { + return otherAsUs->_SplitStyle == _SplitStyle; + } + return false; + }; + static winrt::TerminalApp::IActionArgs FromJson(const Json::Value& json) + { + // LOAD BEARING: Not using make_self here _will_ break you in the future! + auto args = winrt::make_self(); + if (auto jsonStyle{ json[JsonKey(SplitKey)] }) + { + args->_SplitStyle = ParseSplitState(jsonStyle.asString()); + } + return *args; + } + }; } namespace winrt::TerminalApp::factory_implementation diff --git a/src/cascadia/TerminalApp/ActionArgs.idl b/src/cascadia/TerminalApp/ActionArgs.idl index cd625931b30..9f8671d3f34 100644 --- a/src/cascadia/TerminalApp/ActionArgs.idl +++ b/src/cascadia/TerminalApp/ActionArgs.idl @@ -23,6 +23,13 @@ namespace TerminalApp Down }; + enum SplitState + { + None = 0, + Vertical = 1, + Horizontal = 2 + }; + [default_interface] runtimeclass ActionEventArgs : IActionEventArgs { ActionEventArgs(IActionArgs args); @@ -60,4 +67,8 @@ namespace TerminalApp Int32 Delta { get; }; }; + [default_interface] runtimeclass SplitPaneArgs : IActionArgs + { + SplitState SplitStyle { get; }; + }; } diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 2094fd887e4..8c18463a042 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -89,18 +89,18 @@ namespace winrt::TerminalApp::implementation args.Handled(true); } - void TerminalPage::_HandleSplitVertical(const IInspectable& /*sender*/, - const TerminalApp::ActionEventArgs& args) - { - _SplitVertical(std::nullopt); - args.Handled(true); - } - - void TerminalPage::_HandleSplitHorizontal(const IInspectable& /*sender*/, - const TerminalApp::ActionEventArgs& args) + void TerminalPage::_HandleSplitPane(const IInspectable& /*sender*/, + const TerminalApp::ActionEventArgs& args) { - _SplitHorizontal(std::nullopt); - args.Handled(true); + if (args == nullptr) + { + args.Handled(false); + } + else if (const auto& realArgs = args.ActionArgs().try_as()) + { + _SplitPane(realArgs.SplitStyle(), std::nullopt); + args.Handled(true); + } } void TerminalPage::_HandleScrollUpPage(const IInspectable& /*sender*/, diff --git a/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp b/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp index 5fbe4c1be07..423a4a222e2 100644 --- a/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp +++ b/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp @@ -64,8 +64,9 @@ static constexpr std::string_view SwitchToTab6Key{ "switchToTab6" }; // Legacy static constexpr std::string_view SwitchToTab7Key{ "switchToTab7" }; // Legacy static constexpr std::string_view SwitchToTab8Key{ "switchToTab8" }; // Legacy static constexpr std::string_view OpenSettingsKey{ "openSettings" }; // Legacy -static constexpr std::string_view SplitHorizontalKey{ "splitHorizontal" }; -static constexpr std::string_view SplitVerticalKey{ "splitVertical" }; +static constexpr std::string_view SplitPaneKey{ "splitPane" }; +static constexpr std::string_view SplitHorizontalKey{ "splitHorizontal" }; // Legacy +static constexpr std::string_view SplitVerticalKey{ "splitVertical" }; // Legacy static constexpr std::string_view ResizePaneKey{ "resizePane" }; static constexpr std::string_view ResizePaneLeftKey{ "resizePaneLeft" }; // Legacy static constexpr std::string_view ResizePaneRightKey{ "resizePaneRight" }; // Legacy @@ -139,9 +140,31 @@ static const std::map> commandName { MoveFocusDownKey, ShortcutAction::MoveFocusDown }, { OpenSettingsKey, ShortcutAction::OpenSettings }, { ToggleFullscreenKey, ShortcutAction::ToggleFullscreen }, + { SplitPaneKey, ShortcutAction::SplitPane }, { UnboundKey, ShortcutAction::Invalid }, }; +// Function Description: +// - Creates a function that can be used to generate a SplitPaneArgs for the +// legacy Split[SplitState] actions. These actions don't accept args from +// json, instead, they just return a SplitPaneArgs with the style already +// pre-defined, based on the input param. +// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. +// Arguments: +// - style: the split style to create the parse function for. +// Return Value: +// - A function that can be used to "parse" json into one of the legacy +// Split[SplitState] args. +std::function LegacyParseSplitPaneArgs(SplitState style) +{ + auto pfn = [style](const Json::Value & /*value*/) -> IActionArgs { + auto args = winrt::make_self(); + args->SplitStyle(style); + return *args; + }; + return pfn; +} + // Function Description: // - Creates a function that can be used to generate a MoveFocusArgs for the // legacy MoveFocus[Direction] actions. These actions don't accept args from @@ -305,6 +328,10 @@ static const std::map { public: - enum class SplitState : int - { - None = 0, - Vertical = 1, - Horizontal = 2 - }; - Pane(const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control, const bool lastFocused = false); @@ -64,8 +57,8 @@ class Pane : public std::enable_shared_from_this bool ResizePane(const winrt::TerminalApp::Direction& direction); bool NavigateFocus(const winrt::TerminalApp::Direction& direction); - bool CanSplit(SplitState splitType); - std::pair, std::shared_ptr> Split(SplitState splitType, + bool CanSplit(winrt::TerminalApp::SplitState splitType); + std::pair, std::shared_ptr> Split(winrt::TerminalApp::SplitState splitType, const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control); @@ -83,7 +76,7 @@ class Pane : public std::enable_shared_from_this std::shared_ptr _firstChild{ nullptr }; std::shared_ptr _secondChild{ nullptr }; - SplitState _splitState{ SplitState::None }; + winrt::TerminalApp::SplitState _splitState{ winrt::TerminalApp::SplitState::None }; std::optional _firstPercent{ std::nullopt }; std::optional _secondPercent{ std::nullopt }; @@ -103,8 +96,8 @@ class Pane : public std::enable_shared_from_this bool _HasFocusedChild() const noexcept; void _SetupChildCloseHandlers(); - bool _CanSplit(SplitState splitType); - std::pair, std::shared_ptr> _Split(SplitState splitType, + bool _CanSplit(winrt::TerminalApp::SplitState splitType); + std::pair, std::shared_ptr> _Split(winrt::TerminalApp::SplitState splitType, const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control); @@ -137,23 +130,23 @@ class Pane : public std::enable_shared_from_this // again happens _across_ a separator. // Arguments: // - direction: The Direction to compare - // - splitType: The SplitState to compare + // - splitType: The winrt::TerminalApp::SplitState to compare // Return Value: // - true iff the direction is perpendicular to the splitType. False for - // SplitState::None. + // winrt::TerminalApp::SplitState::None. static constexpr bool DirectionMatchesSplit(const winrt::TerminalApp::Direction& direction, - const SplitState& splitType) + const winrt::TerminalApp::SplitState& splitType) { - if (splitType == SplitState::None) + if (splitType == winrt::TerminalApp::SplitState::None) { return false; } - else if (splitType == SplitState::Horizontal) + else if (splitType == winrt::TerminalApp::SplitState::Horizontal) { return direction == winrt::TerminalApp::Direction::Up || direction == winrt::TerminalApp::Direction::Down; } - else if (splitType == SplitState::Vertical) + else if (splitType == winrt::TerminalApp::SplitState::Vertical) { return direction == winrt::TerminalApp::Direction::Left || direction == winrt::TerminalApp::Direction::Right; diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp index 6101bbe1766..cf845c2c08f 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp @@ -128,13 +128,10 @@ namespace winrt::TerminalApp::implementation } case ShortcutAction::SplitVertical: - { - _SplitVerticalHandlers(*this, *eventArgs); - break; - } case ShortcutAction::SplitHorizontal: + case ShortcutAction::SplitPane: { - _SplitHorizontalHandlers(*this, *eventArgs); + _SplitPaneHandlers(*this, *eventArgs); break; } diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.h b/src/cascadia/TerminalApp/ShortcutActionDispatch.h index 5c0262146e3..bb2b72e5bd7 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.h +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.h @@ -35,8 +35,7 @@ namespace winrt::TerminalApp::implementation TYPED_EVENT(SwitchToTab, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(NextTab, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(PrevTab, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); - TYPED_EVENT(SplitVertical, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); - TYPED_EVENT(SplitHorizontal, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); + TYPED_EVENT(SplitPane, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(AdjustFontSize, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(ResetFontSize, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(ScrollUp, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.idl b/src/cascadia/TerminalApp/ShortcutActionDispatch.idl index 5a1496b6283..01a065e6b73 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.idl +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.idl @@ -33,6 +33,7 @@ namespace TerminalApp PrevTab, SplitVertical, SplitHorizontal, + SplitPane, SwitchToTab, SwitchToTab0, // Legacy SwitchToTab1, // Legacy @@ -87,8 +88,7 @@ namespace TerminalApp event Windows.Foundation.TypedEventHandler SwitchToTab; event Windows.Foundation.TypedEventHandler NextTab; event Windows.Foundation.TypedEventHandler PrevTab; - event Windows.Foundation.TypedEventHandler SplitVertical; - event Windows.Foundation.TypedEventHandler SplitHorizontal; + event Windows.Foundation.TypedEventHandler SplitPane; event Windows.Foundation.TypedEventHandler AdjustFontSize; event Windows.Foundation.TypedEventHandler ResetFontSize; event Windows.Foundation.TypedEventHandler ScrollUp; diff --git a/src/cascadia/TerminalApp/Tab.cpp b/src/cascadia/TerminalApp/Tab.cpp index 6969c1c4fed..dd396f251fe 100644 --- a/src/cascadia/TerminalApp/Tab.cpp +++ b/src/cascadia/TerminalApp/Tab.cpp @@ -203,7 +203,7 @@ void Tab::Scroll(const int delta) // - splitType: The type of split we want to create. // Return Value: // - True if the focused pane can be split. False otherwise. -bool Tab::CanSplitPane(Pane::SplitState splitType) +bool Tab::CanSplitPane(winrt::TerminalApp::SplitState splitType) { return _activePane->CanSplit(splitType); } @@ -217,7 +217,7 @@ bool Tab::CanSplitPane(Pane::SplitState splitType) // - control: A TermControl to use in the new pane. // Return Value: // - -void Tab::SplitPane(Pane::SplitState splitType, const GUID& profile, TermControl& control) +void Tab::SplitPane(winrt::TerminalApp::SplitState splitType, const GUID& profile, TermControl& control) { auto [first, second] = _activePane->Split(splitType, profile, control); diff --git a/src/cascadia/TerminalApp/Tab.h b/src/cascadia/TerminalApp/Tab.h index 336372a1d5f..429031dc193 100644 --- a/src/cascadia/TerminalApp/Tab.h +++ b/src/cascadia/TerminalApp/Tab.h @@ -20,8 +20,8 @@ class Tab void Scroll(const int delta); - bool CanSplitPane(Pane::SplitState splitType); - void SplitPane(Pane::SplitState splitType, const GUID& profile, winrt::Microsoft::Terminal::TerminalControl::TermControl& control); + bool CanSplitPane(winrt::TerminalApp::SplitState splitType); + void SplitPane(winrt::TerminalApp::SplitState splitType, const GUID& profile, winrt::Microsoft::Terminal::TerminalControl::TermControl& control); void UpdateIcon(const winrt::hstring iconPath); diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 598d361c8b7..6edb8c0ba4c 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -610,8 +610,7 @@ namespace winrt::TerminalApp::implementation _actionDispatch.ScrollDown({ this, &TerminalPage::_HandleScrollDown }); _actionDispatch.NextTab({ this, &TerminalPage::_HandleNextTab }); _actionDispatch.PrevTab({ this, &TerminalPage::_HandlePrevTab }); - _actionDispatch.SplitVertical({ this, &TerminalPage::_HandleSplitVertical }); - _actionDispatch.SplitHorizontal({ this, &TerminalPage::_HandleSplitHorizontal }); + _actionDispatch.SplitPane({ this, &TerminalPage::_HandleSplitPane }); _actionDispatch.ScrollUpPage({ this, &TerminalPage::_HandleScrollUpPage }); _actionDispatch.ScrollDownPage({ this, &TerminalPage::_HandleScrollDownPage }); _actionDispatch.OpenSettings({ this, &TerminalPage::_HandleOpenSettings }); @@ -913,41 +912,19 @@ namespace winrt::TerminalApp::implementation _tabs[focusedTabIndex]->Scroll(delta); } - // Method Description: - // - Vertically split the focused pane, and place the given TermControl into - // the newly created pane. - // Arguments: - // - profile: The profile GUID to associate with the newly created pane. If - // this is nullopt, use the default profile. - void TerminalPage::_SplitVertical(const std::optional& profileGuid) - { - _SplitPane(Pane::SplitState::Vertical, profileGuid); - } - - // Method Description: - // - Horizontally split the focused pane and place the given TermControl - // into the newly created pane. - // Arguments: - // - profile: The profile GUID to associate with the newly created pane. If - // this is nullopt, use the default profile. - void TerminalPage::_SplitHorizontal(const std::optional& profileGuid) - { - _SplitPane(Pane::SplitState::Horizontal, profileGuid); - } - // Method Description: // - Split the focused pane either horizontally or vertically, and place the // given TermControl into the newly created pane. // - If splitType == SplitState::None, this method does nothing. // Arguments: - // - splitType: one value from the Pane::SplitState enum, indicating how the + // - splitType: one value from the TerminalApp::SplitState enum, indicating how the // new pane should be split from its parent. // - profile: The profile GUID to associate with the newly created pane. If // this is nullopt, use the default profile. - void TerminalPage::_SplitPane(const Pane::SplitState splitType, const std::optional& profileGuid) + void TerminalPage::_SplitPane(const TerminalApp::SplitState splitType, const std::optional& profileGuid) { // Do nothing if we're requesting no split. - if (splitType == Pane::SplitState::None) + if (splitType == TerminalApp::SplitState::None) { return; } diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 4a8aee5767f..1cd202b38eb 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -107,9 +107,7 @@ namespace winrt::TerminalApp::implementation // Todo: add more event implementations here // MSFT:20641986: Add keybindings for New Window void _Scroll(int delta); - void _SplitVertical(const std::optional& profileGuid); - void _SplitHorizontal(const std::optional& profileGuid); - void _SplitPane(const Pane::SplitState splitType, const std::optional& profileGuid); + void _SplitPane(const winrt::TerminalApp::SplitState splitType, const std::optional& profileGuid); void _ResizePane(const Direction& direction); void _ScrollPage(int delta); void _SetAcceleratorForMenuItem(Windows::UI::Xaml::Controls::MenuFlyoutItem& menuItem, const winrt::Microsoft::Terminal::Settings::KeyChord& keyChord); @@ -143,8 +141,7 @@ namespace winrt::TerminalApp::implementation void _HandleScrollDown(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleNextTab(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandlePrevTab(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); - void _HandleSplitVertical(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); - void _HandleSplitHorizontal(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); + void _HandleSplitPane(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleScrollUpPage(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleScrollDownPage(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleOpenSettings(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); diff --git a/src/cascadia/TerminalApp/defaults.json b/src/cascadia/TerminalApp/defaults.json index 6319021a73e..c3a311c0f72 100644 --- a/src/cascadia/TerminalApp/defaults.json +++ b/src/cascadia/TerminalApp/defaults.json @@ -234,8 +234,8 @@ { "command": "scrollDownPage", "keys": [ "ctrl+shift+pgdn" ] }, { "command": "scrollUp", "keys": [ "ctrl+shift+up" ] }, { "command": "scrollUpPage", "keys": [ "ctrl+shift+pgup" ] }, - { "command": "splitHorizontal", "keys": [ "alt+shift+-" ] }, - { "command": "splitVertical", "keys": [ "alt+shift+plus" ] }, + { "command": { "action": "splitPane", "split": "horizontal"}, "keys": [ "alt+shift+-" ] }, + { "command": { "action": "splitPane", "split": "vertical"}, "keys": [ "alt+shift+plus" ] }, { "command": { "action": "switchToTab", "index": 0 }, "keys": ["ctrl+alt+1"] }, { "command": { "action": "switchToTab", "index": 1 }, "keys": ["ctrl+alt+2"] }, { "command": { "action": "switchToTab", "index": 2 }, "keys": ["ctrl+alt+3"] },