Adding keymapping for access to Settings (#684)

This commit adds the keychord Ctrl+Comma, which launches settings.
This commit is contained in:
Tim Heuer 2019-05-13 18:02:06 -07:00 committed by Dustin L. Howett (MSFT)
parent c2ee6277f8
commit 04c7b944bd
6 changed files with 20 additions and 1 deletions

View file

@ -330,6 +330,7 @@ namespace winrt::TerminalApp::implementation
bindings.NextTab([this]() { _SelectNextTab(true); });
bindings.PrevTab([this]() { _SelectNextTab(false); });
bindings.SwitchToTab([this](const auto index) { _SelectTab({ index }); });
bindings.OpenSettings([this]() { _OpenSettings(); });
}
// Method Description:
@ -658,6 +659,11 @@ namespace winrt::TerminalApp::implementation
return _tabView.SelectedIndex();
}
void App::_OpenSettings()
{
LaunchSettings();
}
// Method Description:
// - Close the currently focused tab. Focus will move to the left, if possible.
void App::_CloseFocusedTab()

View file

@ -72,6 +72,8 @@ namespace winrt::TerminalApp::implementation
void _CreateNewTabFlyout();
void _LoadSettings();
void _OpenSettings();
void _HookupKeyBindings(TerminalApp::AppKeyBindings bindings) noexcept;
void _RegisterSettingsChange();

View file

@ -38,6 +38,9 @@ namespace winrt::TerminalApp::implementation
case ShortcutAction::NewTab:
_NewTabHandlers();
return true;
case ShortcutAction::OpenSettings:
_OpenSettingsHandlers();
return true;
case ShortcutAction::NewTabProfile0:
_NewTabWithProfileHandlers(0);
@ -143,6 +146,7 @@ namespace winrt::TerminalApp::implementation
DEFINE_EVENT(AppKeyBindings, DecreaseFontSize, _DecreaseFontSizeHandlers, TerminalApp::DecreaseFontSizeEventArgs);
DEFINE_EVENT(AppKeyBindings, ScrollUp, _ScrollUpHandlers, TerminalApp::ScrollUpEventArgs);
DEFINE_EVENT(AppKeyBindings, ScrollDown, _ScrollDownHandlers, TerminalApp::ScrollDownEventArgs);
DEFINE_EVENT(AppKeyBindings, OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs);
}

View file

@ -49,6 +49,7 @@ namespace winrt::TerminalApp::implementation
DECLARE_EVENT(DecreaseFontSize, _DecreaseFontSizeHandlers, TerminalApp::DecreaseFontSizeEventArgs);
DECLARE_EVENT(ScrollUp, _ScrollUpHandlers, TerminalApp::ScrollUpEventArgs);
DECLARE_EVENT(ScrollDown, _ScrollDownHandlers, TerminalApp::ScrollDownEventArgs);
DECLARE_EVENT(OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs);
private:
std::unordered_map<winrt::Microsoft::Terminal::Settings::KeyChord, TerminalApp::ShortcutAction, KeyChordHash, KeyChordEquality> _keyShortcuts;

View file

@ -36,7 +36,8 @@ namespace TerminalApp
IncreaseFontSize,
DecreaseFontSize,
ScrollUp,
ScrollDown
ScrollDown,
OpenSettings
};
delegate void CopyTextEventArgs();
@ -53,6 +54,7 @@ namespace TerminalApp
delegate void DecreaseFontSizeEventArgs();
delegate void ScrollUpEventArgs();
delegate void ScrollDownEventArgs();
delegate void OpenSettingsEventArgs();
[default_interface]
runtimeclass AppKeyBindings : Microsoft.Terminal.Settings.IKeyBindings
@ -75,5 +77,6 @@ namespace TerminalApp
event DecreaseFontSizeEventArgs DecreaseFontSize;
event ScrollUpEventArgs ScrollUp;
event ScrollDownEventArgs ScrollDown;
event OpenSettingsEventArgs OpenSettings;
}
}

View file

@ -175,6 +175,9 @@ void CascadiaSettings::_CreateDefaultKeybindings()
keyBindings.SetKeyBinding(ShortcutAction::CloseTab,
KeyChord{ KeyModifiers::Ctrl,
static_cast<int>('W') });
keyBindings.SetKeyBinding(ShortcutAction::OpenSettings,
KeyChord{ KeyModifiers::Ctrl,
VK_OEM_COMMA });
keyBindings.SetKeyBinding(ShortcutAction::NextTab,
KeyChord{ KeyModifiers::Ctrl,