diff --git a/src/cascadia/TerminalApp/App.cpp b/src/cascadia/TerminalApp/App.cpp index 9086a2bf1..9cb852ea5 100644 --- a/src/cascadia/TerminalApp/App.cpp +++ b/src/cascadia/TerminalApp/App.cpp @@ -329,6 +329,7 @@ namespace winrt::TerminalApp::implementation bindings.ScrollDown([this]() { _DoScroll(1); }); bindings.NextTab([this]() { _SelectNextTab(true); }); bindings.PrevTab([this]() { _SelectNextTab(false); }); + bindings.SwitchToTab([this](const auto index) { _SelectTab({ index }); }); } // Method Description: @@ -715,6 +716,16 @@ namespace winrt::TerminalApp::implementation ); } + // Method Description: + // - Sets focus to the desired tab. + void App::_SelectTab(const int tabIndex) + { + if (tabIndex >= 0 && tabIndex < _tabs.size()) + { + _SetFocusedTabIndex(tabIndex); + } + } + // Method Description: // - Responds to the TabView control's Selection Changed event (to move a // new terminal control into focus.) diff --git a/src/cascadia/TerminalApp/App.h b/src/cascadia/TerminalApp/App.h index 87b391574..b31f26557 100644 --- a/src/cascadia/TerminalApp/App.h +++ b/src/cascadia/TerminalApp/App.h @@ -87,6 +87,7 @@ namespace winrt::TerminalApp::implementation void _OpenNewTab(std::optional profileIndex); void _CloseFocusedTab(); void _SelectNextTab(const bool bMoveRight); + void _SelectTab(const int tabIndex); void _SetFocusedTabIndex(int tabIndex); int _GetFocusedTabIndex() const; diff --git a/src/cascadia/TerminalApp/AppKeyBindings.cpp b/src/cascadia/TerminalApp/AppKeyBindings.cpp index 85fee19a3..6bb25bace 100644 --- a/src/cascadia/TerminalApp/AppKeyBindings.cpp +++ b/src/cascadia/TerminalApp/AppKeyBindings.cpp @@ -93,6 +93,37 @@ namespace winrt::TerminalApp::implementation case ShortcutAction::PrevTab: _PrevTabHandlers(); return true; + + case ShortcutAction::SwitchToTab0: + _SwitchToTabHandlers(0); + return true; + case ShortcutAction::SwitchToTab1: + _SwitchToTabHandlers(1); + return true; + case ShortcutAction::SwitchToTab2: + _SwitchToTabHandlers(2); + return true; + case ShortcutAction::SwitchToTab3: + _SwitchToTabHandlers(3); + return true; + case ShortcutAction::SwitchToTab4: + _SwitchToTabHandlers(4); + return true; + case ShortcutAction::SwitchToTab5: + _SwitchToTabHandlers(5); + return true; + case ShortcutAction::SwitchToTab6: + _SwitchToTabHandlers(6); + return true; + case ShortcutAction::SwitchToTab7: + _SwitchToTabHandlers(7); + return true; + case ShortcutAction::SwitchToTab8: + _SwitchToTabHandlers(8); + return true; + case ShortcutAction::SwitchToTab9: + _SwitchToTabHandlers(9); + return true; } return false; } diff --git a/src/cascadia/TerminalApp/AppKeyBindings.idl b/src/cascadia/TerminalApp/AppKeyBindings.idl index 00212eda6..196242840 100644 --- a/src/cascadia/TerminalApp/AppKeyBindings.idl +++ b/src/cascadia/TerminalApp/AppKeyBindings.idl @@ -21,9 +21,18 @@ namespace TerminalApp NewWindow, CloseWindow, CloseTab, - SwitchToTab, NextTab, PrevTab, + SwitchToTab0, + SwitchToTab1, + SwitchToTab2, + SwitchToTab3, + SwitchToTab4, + SwitchToTab5, + SwitchToTab6, + SwitchToTab7, + SwitchToTab8, + SwitchToTab9, IncreaseFontSize, DecreaseFontSize, ScrollUp, @@ -37,9 +46,9 @@ namespace TerminalApp delegate void NewWindowEventArgs(); delegate void CloseWindowEventArgs(); delegate void CloseTabEventArgs(); - delegate void SwitchToTabEventArgs(); delegate void NextTabEventArgs(); delegate void PrevTabEventArgs(); + delegate void SwitchToTabEventArgs(Int32 profileIndex); delegate void IncreaseFontSizeEventArgs(); delegate void DecreaseFontSizeEventArgs(); delegate void ScrollUpEventArgs(); diff --git a/src/cascadia/TerminalApp/CascadiaSettings.cpp b/src/cascadia/TerminalApp/CascadiaSettings.cpp index 0f36c880c..2b41498f0 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettings.cpp @@ -221,6 +221,37 @@ void CascadiaSettings::_CreateDefaultKeybindings() keyBindings.SetKeyBinding(ShortcutAction::ScrollDown, KeyChord{ KeyModifiers::Ctrl | KeyModifiers::Shift, VK_NEXT }); + + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab0, + KeyChord{ KeyModifiers::Alt, + static_cast('1') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab1, + KeyChord{ KeyModifiers::Alt, + static_cast('2') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab2, + KeyChord{ KeyModifiers::Alt, + static_cast('3') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab3, + KeyChord{ KeyModifiers::Alt, + static_cast('4') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab4, + KeyChord{ KeyModifiers::Alt, + static_cast('5') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab5, + KeyChord{ KeyModifiers::Alt, + static_cast('6') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab6, + KeyChord{ KeyModifiers::Alt, + static_cast('7') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab7, + KeyChord{ KeyModifiers::Alt, + static_cast('8') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab8, + KeyChord{ KeyModifiers::Alt, + static_cast('9') }); + keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab9, + KeyChord{ KeyModifiers::Alt, + static_cast('0') }); } // Method Description: