From 1d224bbbd42f4f4d1026573c609378ef61461094 Mon Sep 17 00:00:00 2001 From: Dustin Howett Date: Mon, 30 Mar 2020 13:59:34 -0700 Subject: [PATCH] Settings: delete all legacy keybinding deserializers Fixes #1069. --- .../KeyBindingsTests.cpp | 76 +----- .../AppKeyBindingsSerialization.cpp | 238 +----------------- .../TerminalApp/ShortcutActionDispatch.cpp | 38 +-- .../TerminalApp/ShortcutActionDispatch.idl | 30 +-- src/cascadia/TerminalApp/TerminalPage.cpp | 29 +-- src/cascadia/TerminalApp/defaults.json | 4 +- 6 files changed, 26 insertions(+), 389 deletions(-) diff --git a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp index ba0c9e686f92..7db97c043958 100644 --- a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp @@ -170,21 +170,18 @@ namespace TerminalAppLocalTests { const std::string bindings0String{ R"([ { "command": "copy", "keys": ["ctrl+c"] }, - { "command": "copyTextWithoutNewlines", "keys": ["alt+c"] }, { "command": { "action": "copy", "trimWhitespace": false }, "keys": ["ctrl+shift+c"] }, { "command": { "action": "copy", "trimWhitespace": true }, "keys": ["alt+shift+c"] }, { "command": "newTab", "keys": ["ctrl+t"] }, { "command": { "action": "newTab", "index": 0 }, "keys": ["ctrl+shift+t"] }, - { "command": "newTabProfile0", "keys": ["alt+shift+t"] }, { "command": { "action": "newTab", "index": 11 }, "keys": ["ctrl+shift+y"] }, - { "command": "newTabProfile8", "keys": ["alt+shift+y"] }, { "command": { "action": "copy", "madeUpBool": true }, "keys": ["ctrl+b"] }, { "command": { "action": "copy" }, "keys": ["ctrl+shift+b"] }, - { "command": "increaseFontSize", "keys": ["ctrl+f"] }, - { "command": "decreaseFontSize", "keys": ["ctrl+g"] } + { "command": { "action": "adjustFontSize", "delta": 1 }, "keys": ["ctrl+f"] }, + { "command": { "action": "adjustFontSize", "delta": -1 }, "keys": ["ctrl+g"] } ])" }; @@ -194,7 +191,7 @@ namespace TerminalAppLocalTests VERIFY_IS_NOT_NULL(appKeyBindings); VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size()); appKeyBindings->LayerJson(bindings0Json); - VERIFY_ARE_EQUAL(13u, appKeyBindings->_keyShortcuts.size()); + VERIFY_ARE_EQUAL(10u, appKeyBindings->_keyShortcuts.size()); { Log::Comment(NoThrowString().Format( @@ -207,17 +204,6 @@ namespace TerminalAppLocalTests VERIFY_IS_TRUE(realArgs.TrimWhitespace()); } - { - Log::Comment(NoThrowString().Format( - L"Verify that `copyTextWithoutNewlines` parses as Copy(TrimWhitespace=false)")); - KeyChord kc{ false, true, false, static_cast('C') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - const auto& realArgs = actionAndArgs.Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_IS_FALSE(realArgs.TrimWhitespace()); - } - { Log::Comment(NoThrowString().Format( L"Verify that `copy` with args parses them correctly")); @@ -265,19 +251,6 @@ namespace TerminalAppLocalTests VERIFY_IS_NOT_NULL(realArgs.TerminalArgs().ProfileIndex()); VERIFY_ARE_EQUAL(0, realArgs.TerminalArgs().ProfileIndex().Value()); } - { - Log::Comment(NoThrowString().Format( - L"Verify that `newTabProfile0` parses as NewTab(Index=0)")); - KeyChord kc{ false, true, true, static_cast('T') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::NewTabProfile0, actionAndArgs.Action()); - const auto& realArgs = actionAndArgs.Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_IS_NOT_NULL(realArgs.TerminalArgs()); - VERIFY_IS_NOT_NULL(realArgs.TerminalArgs().ProfileIndex()); - VERIFY_ARE_EQUAL(0, realArgs.TerminalArgs().ProfileIndex().Value()); - } { Log::Comment(NoThrowString().Format( L"Verify that `newTab` with an index greater than the legacy " @@ -292,19 +265,6 @@ namespace TerminalAppLocalTests VERIFY_IS_NOT_NULL(realArgs.TerminalArgs().ProfileIndex()); VERIFY_ARE_EQUAL(11, realArgs.TerminalArgs().ProfileIndex().Value()); } - { - Log::Comment(NoThrowString().Format( - L"Verify that `newTabProfile8` parses as NewTab(Index=8)")); - KeyChord kc{ false, true, true, static_cast('Y') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::NewTabProfile8, actionAndArgs.Action()); - const auto& realArgs = actionAndArgs.Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_IS_NOT_NULL(realArgs.TerminalArgs()); - VERIFY_IS_NOT_NULL(realArgs.TerminalArgs().ProfileIndex()); - VERIFY_ARE_EQUAL(8, realArgs.TerminalArgs().ProfileIndex().Value()); - } { Log::Comment(NoThrowString().Format( @@ -332,10 +292,10 @@ namespace TerminalAppLocalTests { Log::Comment(NoThrowString().Format( - L"Verify that `increaseFontSize` without args parses as AdjustFontSize(Delta=1)")); + L"Verify that `adjustFontSize` with a positive delta parses args correctly")); KeyChord kc{ true, false, false, static_cast('F') }; auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::IncreaseFontSize, actionAndArgs.Action()); + VERIFY_ARE_EQUAL(ShortcutAction::AdjustFontSize, actionAndArgs.Action()); const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value @@ -344,10 +304,10 @@ namespace TerminalAppLocalTests { Log::Comment(NoThrowString().Format( - L"Verify that `decreaseFontSize` without args parses as AdjustFontSize(Delta=-1)")); + L"Verify that `adjustFontSize` with a negative delta parses args correctly")); KeyChord kc{ true, false, false, static_cast('G') }; auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::DecreaseFontSize, actionAndArgs.Action()); + VERIFY_ARE_EQUAL(ShortcutAction::AdjustFontSize, actionAndArgs.Action()); const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value @@ -358,8 +318,6 @@ namespace TerminalAppLocalTests void KeyBindingsTests::TestSplitPaneArgs() { const std::string bindings0String{ R"([ - { "keys": ["ctrl+a"], "command": "splitVertical" }, - { "keys": ["ctrl+b"], "command": "splitHorizontal" }, { "keys": ["ctrl+c"], "command": { "action": "splitPane", "split": null } }, { "keys": ["ctrl+d"], "command": { "action": "splitPane", "split": "vertical" } }, { "keys": ["ctrl+e"], "command": { "action": "splitPane", "split": "horizontal" } }, @@ -375,26 +333,8 @@ namespace TerminalAppLocalTests VERIFY_IS_NOT_NULL(appKeyBindings); VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size()); appKeyBindings->LayerJson(bindings0Json); - VERIFY_ARE_EQUAL(9u, appKeyBindings->_keyShortcuts.size()); + VERIFY_ARE_EQUAL(7u, appKeyBindings->_keyShortcuts.size()); - { - KeyChord kc{ true, false, false, static_cast('A') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::SplitVertical, 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, false, static_cast('B') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::SplitHorizontal, 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, false, static_cast('C') }; auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); diff --git a/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp b/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp index 46f6e5871538..00220cba64c9 100644 --- a/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp +++ b/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp @@ -25,20 +25,10 @@ static constexpr std::string_view ActionKey{ "action" }; static constexpr std::string_view UnboundKey{ "unbound" }; static constexpr std::string_view CopyTextKey{ "copy" }; -static constexpr std::string_view CopyTextWithoutNewlinesKey{ "copyTextWithoutNewlines" }; // Legacy static constexpr std::string_view PasteTextKey{ "paste" }; static constexpr std::string_view OpenNewTabDropdownKey{ "openNewTabDropdown" }; static constexpr std::string_view DuplicateTabKey{ "duplicateTab" }; static constexpr std::string_view NewTabKey{ "newTab" }; -static constexpr std::string_view NewTabWithProfile0Key{ "newTabProfile0" }; // Legacy -static constexpr std::string_view NewTabWithProfile1Key{ "newTabProfile1" }; // Legacy -static constexpr std::string_view NewTabWithProfile2Key{ "newTabProfile2" }; // Legacy -static constexpr std::string_view NewTabWithProfile3Key{ "newTabProfile3" }; // Legacy -static constexpr std::string_view NewTabWithProfile4Key{ "newTabProfile4" }; // Legacy -static constexpr std::string_view NewTabWithProfile5Key{ "newTabProfile5" }; // Legacy -static constexpr std::string_view NewTabWithProfile6Key{ "newTabProfile6" }; // Legacy -static constexpr std::string_view NewTabWithProfile7Key{ "newTabProfile7" }; // Legacy -static constexpr std::string_view NewTabWithProfile8Key{ "newTabProfile8" }; // Legacy static constexpr std::string_view NewWindowKey{ "newWindow" }; static constexpr std::string_view CloseWindowKey{ "closeWindow" }; static constexpr std::string_view CloseTabKey{ "closeTab" }; @@ -46,37 +36,17 @@ static constexpr std::string_view ClosePaneKey{ "closePane" }; static constexpr std::string_view SwitchtoTabKey{ "switchToTab" }; static constexpr std::string_view NextTabKey{ "nextTab" }; static constexpr std::string_view PrevTabKey{ "prevTab" }; -static constexpr std::string_view IncreaseFontSizeKey{ "increaseFontSize" }; -static constexpr std::string_view DecreaseFontSizeKey{ "decreaseFontSize" }; +static constexpr std::string_view AdjustFontSizeKey{ "adjustFontSize" }; static constexpr std::string_view ResetFontSizeKey{ "resetFontSize" }; static constexpr std::string_view ScrollupKey{ "scrollUp" }; static constexpr std::string_view ScrolldownKey{ "scrollDown" }; static constexpr std::string_view ScrolluppageKey{ "scrollUpPage" }; static constexpr std::string_view ScrolldownpageKey{ "scrollDownPage" }; static constexpr std::string_view SwitchToTabKey{ "switchToTab" }; -static constexpr std::string_view SwitchToTab0Key{ "switchToTab0" }; // Legacy -static constexpr std::string_view SwitchToTab1Key{ "switchToTab1" }; // Legacy -static constexpr std::string_view SwitchToTab2Key{ "switchToTab2" }; // Legacy -static constexpr std::string_view SwitchToTab3Key{ "switchToTab3" }; // Legacy -static constexpr std::string_view SwitchToTab4Key{ "switchToTab4" }; // Legacy -static constexpr std::string_view SwitchToTab5Key{ "switchToTab5" }; // Legacy -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 OpenSettingsKey{ "openSettings" }; // TODO GH#XXXX: give this one arguments 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 -static constexpr std::string_view ResizePaneUpKey{ "resizePaneUp" }; // Legacy -static constexpr std::string_view ResizePaneDownKey{ "resizePaneDown" }; // Legacy static constexpr std::string_view MoveFocusKey{ "moveFocus" }; -static constexpr std::string_view MoveFocusLeftKey{ "moveFocusLeft" }; // Legacy -static constexpr std::string_view MoveFocusRightKey{ "moveFocusRight" }; // Legacy -static constexpr std::string_view MoveFocusUpKey{ "moveFocusUp" }; // Legacy -static constexpr std::string_view MoveFocusDownKey{ "moveFocusDown" }; // Legacy static constexpr std::string_view FindKey{ "find" }; static constexpr std::string_view ToggleFullscreenKey{ "toggleFullscreen" }; @@ -90,55 +60,25 @@ static constexpr std::string_view ToggleFullscreenKey{ "toggleFullscreen" }; // about here. static const std::map> commandNames{ { CopyTextKey, ShortcutAction::CopyText }, - { CopyTextWithoutNewlinesKey, ShortcutAction::CopyTextWithoutNewlines }, { PasteTextKey, ShortcutAction::PasteText }, { OpenNewTabDropdownKey, ShortcutAction::OpenNewTabDropdown }, { DuplicateTabKey, ShortcutAction::DuplicateTab }, { NewTabKey, ShortcutAction::NewTab }, - { NewTabWithProfile0Key, ShortcutAction::NewTabProfile0 }, - { NewTabWithProfile1Key, ShortcutAction::NewTabProfile1 }, - { NewTabWithProfile2Key, ShortcutAction::NewTabProfile2 }, - { NewTabWithProfile3Key, ShortcutAction::NewTabProfile3 }, - { NewTabWithProfile4Key, ShortcutAction::NewTabProfile4 }, - { NewTabWithProfile5Key, ShortcutAction::NewTabProfile5 }, - { NewTabWithProfile6Key, ShortcutAction::NewTabProfile6 }, - { NewTabWithProfile7Key, ShortcutAction::NewTabProfile7 }, - { NewTabWithProfile8Key, ShortcutAction::NewTabProfile8 }, { NewWindowKey, ShortcutAction::NewWindow }, { CloseWindowKey, ShortcutAction::CloseWindow }, { CloseTabKey, ShortcutAction::CloseTab }, { ClosePaneKey, ShortcutAction::ClosePane }, { NextTabKey, ShortcutAction::NextTab }, { PrevTabKey, ShortcutAction::PrevTab }, - { IncreaseFontSizeKey, ShortcutAction::IncreaseFontSize }, - { DecreaseFontSizeKey, ShortcutAction::DecreaseFontSize }, + { AdjustFontSizeKey, ShortcutAction::AdjustFontSize }, { ResetFontSizeKey, ShortcutAction::ResetFontSize }, { ScrollupKey, ShortcutAction::ScrollUp }, { ScrolldownKey, ShortcutAction::ScrollDown }, { ScrolluppageKey, ShortcutAction::ScrollUpPage }, { ScrolldownpageKey, ShortcutAction::ScrollDownPage }, { SwitchToTabKey, ShortcutAction::SwitchToTab }, - { SwitchToTab0Key, ShortcutAction::SwitchToTab0 }, - { SwitchToTab1Key, ShortcutAction::SwitchToTab1 }, - { SwitchToTab2Key, ShortcutAction::SwitchToTab2 }, - { SwitchToTab3Key, ShortcutAction::SwitchToTab3 }, - { SwitchToTab4Key, ShortcutAction::SwitchToTab4 }, - { SwitchToTab5Key, ShortcutAction::SwitchToTab5 }, - { SwitchToTab6Key, ShortcutAction::SwitchToTab6 }, - { SwitchToTab7Key, ShortcutAction::SwitchToTab7 }, - { SwitchToTab8Key, ShortcutAction::SwitchToTab8 }, - { SplitHorizontalKey, ShortcutAction::SplitHorizontal }, - { SplitVerticalKey, ShortcutAction::SplitVertical }, { ResizePaneKey, ShortcutAction::ResizePane }, - { ResizePaneLeftKey, ShortcutAction::ResizePaneLeft }, - { ResizePaneRightKey, ShortcutAction::ResizePaneRight }, - { ResizePaneUpKey, ShortcutAction::ResizePaneUp }, - { ResizePaneDownKey, ShortcutAction::ResizePaneDown }, { MoveFocusKey, ShortcutAction::MoveFocus }, - { MoveFocusLeftKey, ShortcutAction::MoveFocusLeft }, - { MoveFocusRightKey, ShortcutAction::MoveFocusRight }, - { MoveFocusUpKey, ShortcutAction::MoveFocusUp }, - { MoveFocusDownKey, ShortcutAction::MoveFocusDown }, { OpenSettingsKey, ShortcutAction::OpenSettings }, { ToggleFullscreenKey, ShortcutAction::ToggleFullscreen }, { SplitPaneKey, ShortcutAction::SplitPane }, @@ -149,146 +89,6 @@ static const std::map> commandName using ParseResult = std::tuple>; using ParseActionFunction = std::function; -// 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. -ParseActionFunction LegacyParseSplitPaneArgs(SplitState style) -{ - auto pfn = [style](const Json::Value & /*value*/) -> ParseResult { - 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 -// json, instead, they just return a MoveFocusArgs with the Direction already -// per-defined, based on the input param. -// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. -// Arguments: -// - direction: the direction to create the parse function for. -// Return Value: -// - A function that can be used to "parse" json into one of the legacy -// MoveFocus[Direction] args. -ParseActionFunction LegacyParseMoveFocusArgs(Direction direction) -{ - auto pfn = [direction](const Json::Value & /*value*/) -> ParseResult { - auto args = winrt::make_self(); - args->Direction(direction); - return { *args, {} }; - }; - return pfn; -} - -// Function Description: -// - Creates a function that can be used to generate a ResizePaneArgs for the -// legacy ResizePane[Direction] actions. These actions don't accept args from -// json, instead, they just return a ResizePaneArgs with the Direction already -// per-defined, based on the input param. -// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. -// Arguments: -// - direction: the direction to create the parse function for. -// Return Value: -// - A function that can be used to "parse" json into one of the legacy -// ResizePane[Direction] args. -ParseActionFunction LegacyParseResizePaneArgs(Direction direction) -{ - auto pfn = [direction](const Json::Value & /*value*/) -> ParseResult { - auto args = winrt::make_self(); - args->Direction(direction); - return { *args, {} }; - }; - return pfn; -} - -// Function Description: -// - Creates a function that can be used to generate a NewTabWithProfileArgs for -// the legacy NewTabWithProfile[Index] actions. These actions don't accept -// args from json, instead, they just return a NewTabWithProfileArgs with the -// index already per-defined, based on the input param. -// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. -// Arguments: -// - index: the profile index to create the parse function for. -// Return Value: -// - A function that can be used to "parse" json into one of the legacy -// NewTabWithProfile[Index] args. -ParseActionFunction LegacyParseNewTabWithProfileArgs(int index) -{ - auto pfn = [index](const Json::Value & /*value*/) -> ParseResult { - auto args = winrt::make_self(); - auto newTerminalArgs = winrt::make_self(); - newTerminalArgs->ProfileIndex(index); - args->TerminalArgs(*newTerminalArgs); - return { *args, {} }; - }; - return pfn; -} - -// Function Description: -// - Creates a function that can be used to generate a SwitchToTabArgs for the -// legacy SwitchToTab[Index] actions. These actions don't accept args from -// json, instead, they just return a SwitchToTabArgs with the index already -// per-defined, based on the input param. -// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. -// Arguments: -// - index: the tab index to create the parse function for. -// Return Value: -// - A function that can be used to "parse" json into one of the legacy -// SwitchToTab[Index] args. -ParseActionFunction LegacyParseSwitchToTabArgs(int index) -{ - auto pfn = [index](const Json::Value & /*value*/) -> ParseResult { - auto args = winrt::make_self(); - args->TabIndex(index); - return { *args, {} }; - }; - return pfn; -} - -// Function Description: -// - Used to generate a CopyTextArgs for the legacy CopyTextWithoutNewlines -// action. -// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. -// Arguments: -// - direction: the direction to create the parse function for. -// Return Value: -// - A CopyTextArgs with TrimWhitespace set to true, to emulate "CopyTextWithoutNewlines". -ParseResult LegacyParseCopyTextWithoutNewlinesArgs(const Json::Value& /*json*/) -{ - auto args = winrt::make_self(); - args->TrimWhitespace(false); - return { *args, {} }; -}; - -// Function Description: -// - Used to generate a AdjustFontSizeArgs for IncreaseFontSize/DecreaseFontSize -// actions with a delta of 1/-1. -// - TODO: GH#1069 Remove this before 1.0, and force an upgrade to the new args. -// Arguments: -// - delta: the font size delta to create the parse function for. -// Return Value: -// - A function that can be used to "parse" json into an AdjustFontSizeArgs. -ParseActionFunction LegacyParseAdjustFontSizeArgs(int delta) -{ - auto pfn = [delta](const Json::Value & /*value*/) -> ParseResult { - auto args = winrt::make_self(); - args->Delta(delta); - return { *args, {} }; - }; - return pfn; -} - // This is a map of ShortcutAction->function. It holds // a set of deserializer functions that can be used to deserialize a IActionArgs // from json. Each type of IActionArgs that can accept arbitrary args should be @@ -296,48 +96,18 @@ ParseActionFunction LegacyParseAdjustFontSizeArgs(int delta) // value. static const std::map> argParsers{ { ShortcutAction::CopyText, winrt::TerminalApp::implementation::CopyTextArgs::FromJson }, - { ShortcutAction::CopyTextWithoutNewlines, LegacyParseCopyTextWithoutNewlinesArgs }, { ShortcutAction::NewTab, winrt::TerminalApp::implementation::NewTabArgs::FromJson }, - { ShortcutAction::NewTabProfile0, LegacyParseNewTabWithProfileArgs(0) }, - { ShortcutAction::NewTabProfile1, LegacyParseNewTabWithProfileArgs(1) }, - { ShortcutAction::NewTabProfile2, LegacyParseNewTabWithProfileArgs(2) }, - { ShortcutAction::NewTabProfile3, LegacyParseNewTabWithProfileArgs(3) }, - { ShortcutAction::NewTabProfile4, LegacyParseNewTabWithProfileArgs(4) }, - { ShortcutAction::NewTabProfile5, LegacyParseNewTabWithProfileArgs(5) }, - { ShortcutAction::NewTabProfile6, LegacyParseNewTabWithProfileArgs(6) }, - { ShortcutAction::NewTabProfile7, LegacyParseNewTabWithProfileArgs(7) }, - { ShortcutAction::NewTabProfile8, LegacyParseNewTabWithProfileArgs(8) }, { ShortcutAction::SwitchToTab, winrt::TerminalApp::implementation::SwitchToTabArgs::FromJson }, - { ShortcutAction::SwitchToTab0, LegacyParseSwitchToTabArgs(0) }, - { ShortcutAction::SwitchToTab1, LegacyParseSwitchToTabArgs(1) }, - { ShortcutAction::SwitchToTab2, LegacyParseSwitchToTabArgs(2) }, - { ShortcutAction::SwitchToTab3, LegacyParseSwitchToTabArgs(3) }, - { ShortcutAction::SwitchToTab4, LegacyParseSwitchToTabArgs(4) }, - { ShortcutAction::SwitchToTab5, LegacyParseSwitchToTabArgs(5) }, - { ShortcutAction::SwitchToTab6, LegacyParseSwitchToTabArgs(6) }, - { ShortcutAction::SwitchToTab7, LegacyParseSwitchToTabArgs(7) }, - { ShortcutAction::SwitchToTab8, LegacyParseSwitchToTabArgs(8) }, { ShortcutAction::ResizePane, winrt::TerminalApp::implementation::ResizePaneArgs::FromJson }, - { ShortcutAction::ResizePaneLeft, LegacyParseResizePaneArgs(Direction::Left) }, - { ShortcutAction::ResizePaneRight, LegacyParseResizePaneArgs(Direction::Right) }, - { ShortcutAction::ResizePaneUp, LegacyParseResizePaneArgs(Direction::Up) }, - { ShortcutAction::ResizePaneDown, LegacyParseResizePaneArgs(Direction::Down) }, { ShortcutAction::MoveFocus, winrt::TerminalApp::implementation::MoveFocusArgs::FromJson }, - { ShortcutAction::MoveFocusLeft, LegacyParseMoveFocusArgs(Direction::Left) }, - { ShortcutAction::MoveFocusRight, LegacyParseMoveFocusArgs(Direction::Right) }, - { ShortcutAction::MoveFocusUp, LegacyParseMoveFocusArgs(Direction::Up) }, - { ShortcutAction::MoveFocusDown, LegacyParseMoveFocusArgs(Direction::Down) }, - { ShortcutAction::DecreaseFontSize, LegacyParseAdjustFontSizeArgs(-1) }, - { ShortcutAction::IncreaseFontSize, LegacyParseAdjustFontSizeArgs(1) }, + { ShortcutAction::AdjustFontSize, winrt::TerminalApp::implementation::AdjustFontSizeArgs::FromJson }, { ShortcutAction::SplitPane, winrt::TerminalApp::implementation::SplitPaneArgs::FromJson }, - { ShortcutAction::SplitVertical, LegacyParseSplitPaneArgs(SplitState::Vertical) }, - { ShortcutAction::SplitHorizontal, LegacyParseSplitPaneArgs(SplitState::Horizontal) }, { ShortcutAction::Invalid, nullptr }, }; diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp index bac268726c4a..673876af9206 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp @@ -33,11 +33,6 @@ namespace winrt::TerminalApp::implementation _CopyTextHandlers(*this, *eventArgs); break; } - case ShortcutAction::CopyTextWithoutNewlines: - { - _CopyTextHandlers(*this, *eventArgs); - break; - } case ShortcutAction::PasteText: { _PasteTextHandlers(*this, *eventArgs); @@ -60,15 +55,6 @@ namespace winrt::TerminalApp::implementation } case ShortcutAction::NewTab: - case ShortcutAction::NewTabProfile0: - case ShortcutAction::NewTabProfile1: - case ShortcutAction::NewTabProfile2: - case ShortcutAction::NewTabProfile3: - case ShortcutAction::NewTabProfile4: - case ShortcutAction::NewTabProfile5: - case ShortcutAction::NewTabProfile6: - case ShortcutAction::NewTabProfile7: - case ShortcutAction::NewTabProfile8: { _NewTabHandlers(*this, *eventArgs); break; @@ -136,46 +122,24 @@ namespace winrt::TerminalApp::implementation } case ShortcutAction::SwitchToTab: - case ShortcutAction::SwitchToTab0: - case ShortcutAction::SwitchToTab1: - case ShortcutAction::SwitchToTab2: - case ShortcutAction::SwitchToTab3: - case ShortcutAction::SwitchToTab4: - case ShortcutAction::SwitchToTab5: - case ShortcutAction::SwitchToTab6: - case ShortcutAction::SwitchToTab7: - case ShortcutAction::SwitchToTab8: { _SwitchToTabHandlers(*this, *eventArgs); break; } case ShortcutAction::ResizePane: - case ShortcutAction::ResizePaneLeft: - case ShortcutAction::ResizePaneRight: - case ShortcutAction::ResizePaneUp: - case ShortcutAction::ResizePaneDown: { _ResizePaneHandlers(*this, *eventArgs); break; } case ShortcutAction::MoveFocus: - case ShortcutAction::MoveFocusLeft: - case ShortcutAction::MoveFocusRight: - case ShortcutAction::MoveFocusUp: - case ShortcutAction::MoveFocusDown: { _MoveFocusHandlers(*this, *eventArgs); break; } - case ShortcutAction::IncreaseFontSize: - { - _AdjustFontSizeHandlers(*this, *eventArgs); - break; - } - case ShortcutAction::DecreaseFontSize: + case ShortcutAction::AdjustFontSize: { _AdjustFontSizeHandlers(*this, *eventArgs); break; diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.idl b/src/cascadia/TerminalApp/ShortcutActionDispatch.idl index 6df2d58bbcb4..0a51d6b0a3a4 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.idl +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.idl @@ -11,20 +11,10 @@ namespace TerminalApp { Invalid = 0, CopyText, - CopyTextWithoutNewlines, PasteText, OpenNewTabDropdown, DuplicateTab, NewTab, - NewTabProfile0, // Legacy - NewTabProfile1, // Legacy - NewTabProfile2, // Legacy - NewTabProfile3, // Legacy - NewTabProfile4, // Legacy - NewTabProfile5, // Legacy - NewTabProfile6, // Legacy - NewTabProfile7, // Legacy - NewTabProfile8, // Legacy NewWindow, CloseWindow, CloseTab, @@ -35,32 +25,14 @@ namespace TerminalApp SplitHorizontal, SplitPane, SwitchToTab, - SwitchToTab0, // Legacy - SwitchToTab1, // Legacy - SwitchToTab2, // Legacy - SwitchToTab3, // Legacy - SwitchToTab4, // Legacy - SwitchToTab5, // Legacy - SwitchToTab6, // Legacy - SwitchToTab7, // Legacy - SwitchToTab8, // Legacy - IncreaseFontSize, - DecreaseFontSize, + AdjustFontSize, ResetFontSize, ScrollUp, ScrollDown, ScrollUpPage, ScrollDownPage, ResizePane, - ResizePaneLeft, // Legacy - ResizePaneRight, // Legacy - ResizePaneUp, // Legacy - ResizePaneDown, // Legacy MoveFocus, - MoveFocusLeft, // Legacy - MoveFocusRight, // Legacy - MoveFocusUp, // Legacy - MoveFocusDown, // Legacy Find, ToggleFullscreen, OpenSettings diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 064251b79e0e..9e96cee6e389 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -292,25 +292,16 @@ namespace winrt::TerminalApp::implementation // add the keyboard shortcuts for the first 9 profiles if (profileIndex < 9) { - // enum value for ShortcutAction::NewTabProfileX; 0==NewTabProfile0 - const auto action = static_cast(profileIndex + static_cast(ShortcutAction::NewTabProfile0)); - // First, attempt to search for the keybinding for the simple - // NewTabProfile0-9 ShortcutActions. - auto profileKeyChord = keyBindings.GetKeyBindingForAction(action); - if (!profileKeyChord) - { - // If NewTabProfileN didn't have a binding, look for a - // keychord that is bound to the equivalent - // NewTab(ProfileIndex=N) action - auto actionAndArgs = winrt::make_self(); - actionAndArgs->Action(ShortcutAction::NewTab); - auto newTabArgs = winrt::make_self(); - auto newTerminalArgs = winrt::make_self(); - newTerminalArgs->ProfileIndex(profileIndex); - newTabArgs->TerminalArgs(*newTerminalArgs); - actionAndArgs->Args(*newTabArgs); - profileKeyChord = keyBindings.GetKeyBindingForActionWithArgs(*actionAndArgs); - } + // Look for a keychord that is bound to the equivalent + // NewTab(ProfileIndex=N) action + auto actionAndArgs = winrt::make_self(); + actionAndArgs->Action(ShortcutAction::NewTab); + auto newTabArgs = winrt::make_self(); + auto newTerminalArgs = winrt::make_self(); + newTerminalArgs->ProfileIndex(profileIndex); + newTabArgs->TerminalArgs(*newTerminalArgs); + actionAndArgs->Args(*newTabArgs); + auto profileKeyChord{ keyBindings.GetKeyBindingForActionWithArgs(*actionAndArgs) }; // make sure we find one to display if (profileKeyChord) diff --git a/src/cascadia/TerminalApp/defaults.json b/src/cascadia/TerminalApp/defaults.json index 8edc7c1b3e47..bd8bc795593f 100644 --- a/src/cascadia/TerminalApp/defaults.json +++ b/src/cascadia/TerminalApp/defaults.json @@ -210,13 +210,13 @@ ], "keybindings": [ + { "command": { "action": "adjustFontSize", "delta": 1 }, "keys": "ctrl+=" }, + { "command": { "action": "adjustFontSize", "delta": -1 }, "keys": "ctrl+-" }, { "command": "closePane", "keys": "ctrl+shift+w" }, { "command": "closeWindow", "keys": "alt+f4" }, { "command": "copy", "keys": "ctrl+shift+c" }, { "command": "copy", "keys": "ctrl+insert" }, - { "command": "decreaseFontSize", "keys": "ctrl+-" }, { "command": "duplicateTab", "keys": "ctrl+shift+d" }, - { "command": "increaseFontSize", "keys": "ctrl+=" }, { "command": { "action": "moveFocus", "direction": "down" }, "keys": "alt+down" }, { "command": { "action": "moveFocus", "direction": "left" }, "keys": "alt+left" }, { "command": { "action": "moveFocus", "direction": "right" }, "keys": "alt+right" },