Load modal key bindings from JSON file

This commit is contained in:
Max Brunsfeld 2022-04-10 11:39:43 -07:00
parent 1e2eeaa22a
commit b4babbeeaa
6 changed files with 34 additions and 50 deletions

View file

@ -1,12 +1,8 @@
use editor::Editor;
use fuzzy::PathMatch;
use gpui::{
actions,
elements::*,
impl_internal_actions,
keymap::{self, Binding},
AppContext, Axis, Entity, ModelHandle, MutableAppContext, RenderContext, Task, View,
ViewContext, ViewHandle, WeakViewHandle,
actions, elements::*, impl_internal_actions, keymap, AppContext, Axis, Entity, ModelHandle,
MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle,
};
use project::{Project, ProjectPath, WorktreeId};
use settings::Settings;
@ -50,11 +46,6 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(FileFinder::select);
cx.add_action(FileFinder::select_prev);
cx.add_action(FileFinder::select_next);
cx.add_bindings(vec![
Binding::new("cmd-p", Toggle, None),
Binding::new("escape", Toggle, Some("FileFinder")),
]);
}
pub enum Event {

View file

@ -1,7 +1,7 @@
use editor::{display_map::ToDisplayPoint, Autoscroll, DisplayPoint, Editor};
use gpui::{
actions, elements::*, geometry::vector::Vector2F, keymap::Binding, Axis, Entity,
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
actions, elements::*, geometry::vector::Vector2F, Axis, Entity, MutableAppContext,
RenderContext, View, ViewContext, ViewHandle,
};
use settings::Settings;
use text::{Bias, Point};
@ -10,11 +10,6 @@ use workspace::Workspace;
actions!(go_to_line, [Toggle, Confirm]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_bindings([
Binding::new("ctrl-g", Toggle, Some("Editor")),
Binding::new("escape", Toggle, Some("GoToLine")),
Binding::new("enter", Confirm, Some("GoToLine")),
]);
cx.add_action(GoToLine::toggle);
cx.add_action(GoToLine::confirm);
}

View file

@ -4,12 +4,8 @@ use editor::{
};
use fuzzy::StringMatch;
use gpui::{
actions,
elements::*,
geometry::vector::Vector2F,
keymap::{self, Binding},
AppContext, Axis, Entity, MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
WeakViewHandle,
actions, elements::*, geometry::vector::Vector2F, keymap, AppContext, Axis, Entity,
MutableAppContext, RenderContext, View, ViewContext, ViewHandle, WeakViewHandle,
};
use language::Outline;
use ordered_float::OrderedFloat;
@ -23,10 +19,6 @@ use workspace::{
actions!(outline, [Toggle]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_bindings([
Binding::new("cmd-shift-O", Toggle, Some("Editor")),
Binding::new("escape", Toggle, Some("OutlineView")),
]);
cx.add_action(OutlineView::toggle);
cx.add_action(OutlineView::confirm);
cx.add_action(OutlineView::select_prev);

View file

@ -3,11 +3,8 @@ use editor::{
};
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
actions,
elements::*,
keymap::{self, Binding},
AppContext, Axis, Entity, ModelHandle, MutableAppContext, RenderContext, Task, View,
ViewContext, ViewHandle, WeakViewHandle,
actions, elements::*, keymap, AppContext, Axis, Entity, ModelHandle, MutableAppContext,
RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle,
};
use ordered_float::OrderedFloat;
use project::{Project, Symbol};
@ -25,10 +22,6 @@ use workspace::{
actions!(project_symbols, [Toggle]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_bindings([
Binding::new("cmd-t", Toggle, None),
Binding::new("escape", Toggle, Some("ProjectSymbolsView")),
]);
cx.add_action(ProjectSymbolsView::toggle);
cx.add_action(ProjectSymbolsView::confirm);
cx.add_action(ProjectSymbolsView::select_prev);

View file

@ -1,11 +1,8 @@
use editor::Editor;
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{
actions,
elements::*,
keymap::{self, Binding},
AppContext, Axis, Element, ElementBox, Entity, MutableAppContext, RenderContext, View,
ViewContext, ViewHandle,
actions, elements::*, keymap, AppContext, Axis, Element, ElementBox, Entity, MutableAppContext,
RenderContext, View, ViewContext, ViewHandle,
};
use settings::Settings;
use std::{cmp, sync::Arc};
@ -33,12 +30,6 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(ThemeSelector::select_next);
cx.add_action(ThemeSelector::toggle);
cx.add_action(ThemeSelector::reload);
cx.add_bindings(vec![
Binding::new("cmd-k cmd-t", Toggle, None),
Binding::new("cmd-k t", Reload, None),
Binding::new("escape", Toggle, Some("ThemeSelector")),
]);
}
pub enum Event {

View file

@ -47,7 +47,11 @@
"cmd-shift-G": "search::SelectPrevMatch"
},
"Workspace": {
"cmd-shift-F": "project_search::Deploy"
"cmd-shift-F": "project_search::Deploy",
"cmd-k cmd-t": "theme_selector::Toggle",
"cmd-k t": "theme_selector::Reload",
"cmd-t": "project_symbols::Toggle",
"cmd-p": "file_finder::Toggle"
},
"ProjectSearchBar": {
"enter": "project_search::Search",
@ -217,12 +221,30 @@
{
"focus": false
}
]
],
"cmd-shift-O": "outline::Toggle",
"ctrl-g": "go_to_line::Toggle"
},
"Editor && mode == auto_height": {
"alt-enter": [
"editor::Input",
"\n"
]
},
"OutlineView": {
"escape": "outline::Toggle"
},
"ProjectSymbolsView": {
"escape": "project_symbols::Toggle"
},
"ThemeSelector": {
"escape": "theme_selector::Toggle"
},
"GoToLine": {
"escape": "go_to_line::Toggle",
"enter": "go_to_line::Confirm"
},
"FileFinder": {
"escape": "file_finder::Toggle"
}
}