Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding keymapping for access to Settings #684

Merged
merged 6 commits into from May 14, 2019

Adding a keybinding for launching the settings. Suggested fix for #683

  • Loading branch information...
timheuer committed May 10, 2019
commit c5cadf7b004ab4c380dabfe52c3458935df7383e
@@ -329,6 +329,7 @@ namespace winrt::TerminalApp::implementation
bindings.ScrollDown([this]() { _DoScroll(1); });
bindings.NextTab([this]() { _SelectNextTab(true); });
bindings.PrevTab([this]() { _SelectNextTab(false); });
bindings.OpenSettings([this]() { _OpenSettings(); });
}

// Method Description:
@@ -657,6 +658,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()
@@ -72,6 +72,8 @@ namespace winrt::TerminalApp::implementation
void _CreateNewTabFlyout();

void _LoadSettings();
void _OpenSettings();

void _HookupKeyBindings(TerminalApp::AppKeyBindings bindings) noexcept;

void _RegisterSettingsChange();
@@ -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);
@@ -112,6 +115,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);


}
@@ -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;
@@ -27,7 +27,8 @@ namespace TerminalApp
IncreaseFontSize,
DecreaseFontSize,
ScrollUp,
ScrollDown
ScrollDown,
OpenSettings
};

delegate void CopyTextEventArgs();
@@ -44,6 +45,7 @@ namespace TerminalApp
delegate void DecreaseFontSizeEventArgs();
delegate void ScrollUpEventArgs();
delegate void ScrollDownEventArgs();
delegate void OpenSettingsEventArgs();

[default_interface]
runtimeclass AppKeyBindings : Microsoft.Terminal.Settings.IKeyBindings
@@ -66,5 +68,6 @@ namespace TerminalApp
event DecreaseFontSizeEventArgs DecreaseFontSize;
event ScrollUpEventArgs ScrollUp;
event ScrollDownEventArgs ScrollDown;
event OpenSettingsEventArgs OpenSettings;
}
}
@@ -173,6 +173,9 @@ void CascadiaSettings::_CreateDefaultKeybindings()
keyBindings.SetKeyBinding(ShortcutAction::CloseTab,
KeyChord{ KeyModifiers::Ctrl,
static_cast<int>('W') });
keyBindings.SetKeyBinding(ShortcutAction::OpenSettings,
KeyChord{ KeyModifiers::Ctrl,
static_cast<int>('S') });

keyBindings.SetKeyBinding(ShortcutAction::NextTab,
KeyChord{ KeyModifiers::Ctrl,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.