WIP
This commit is contained in:
@@ -42,7 +42,7 @@ use gpui::{
|
||||
action, actions, div, point, px, relative, rems, size, uniform_list, AnyElement, AppContext,
|
||||
AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Component, Context,
|
||||
EventEmitter, FocusHandle, FontFeatures, FontStyle, FontWeight, HighlightStyle, Hsla,
|
||||
InputHandler, KeyBindingContext, Model, MouseButton, ParentElement, Pixels, Render,
|
||||
InputHandler, KeyContext, Model, MouseButton, ParentElement, Pixels, Render,
|
||||
StatelessInteractive, Styled, Subscription, Task, TextStyle, UniformListScrollHandle, View,
|
||||
ViewContext, VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
@@ -646,7 +646,7 @@ pub struct Editor {
|
||||
collapse_matches: bool,
|
||||
autoindent_mode: Option<AutoindentMode>,
|
||||
workspace: Option<(WeakView<Workspace>, i64)>,
|
||||
keymap_context_layers: BTreeMap<TypeId, KeyBindingContext>,
|
||||
keymap_context_layers: BTreeMap<TypeId, KeyContext>,
|
||||
input_enabled: bool,
|
||||
read_only: bool,
|
||||
leader_peer_id: Option<PeerId>,
|
||||
@@ -1980,8 +1980,8 @@ impl Editor {
|
||||
this
|
||||
}
|
||||
|
||||
fn dispatch_context(&self, cx: &AppContext) -> KeyBindingContext {
|
||||
let mut dispatch_context = KeyBindingContext::default();
|
||||
fn dispatch_context(&self, cx: &AppContext) -> KeyContext {
|
||||
let mut dispatch_context = KeyContext::default();
|
||||
dispatch_context.add("Editor");
|
||||
let mode = match self.mode {
|
||||
EditorMode::SingleLine => "single_line",
|
||||
|
||||
@@ -18,10 +18,9 @@ use gpui::{
|
||||
black, hsla, point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace,
|
||||
BorrowAppContext, BorrowWindow, Bounds, ContentMask, Corners, DispatchPhase, Edges, Element,
|
||||
ElementId, ElementInputHandler, Entity, FocusHandle, GlobalElementId, Hsla, InputHandler,
|
||||
KeyBindingContext, KeyDownEvent, KeyListener, KeyMatch, Line, LineLayout, Modifiers,
|
||||
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, ScrollWheelEvent,
|
||||
ShapedGlyph, Size, Style, TextRun, TextStyle, TextSystem, ViewContext, WindowContext,
|
||||
WrappedLineLayout,
|
||||
KeyContext, KeyDownEvent, KeyListener, KeyMatch, Line, LineLayout, Modifiers, MouseButton,
|
||||
MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, ScrollWheelEvent, ShapedGlyph, Size,
|
||||
Style, TextRun, TextStyle, TextSystem, ViewContext, WindowContext, WrappedLineLayout,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::language_settings::ShowWhitespaceSetting;
|
||||
@@ -2457,11 +2456,11 @@ impl Element<Editor> for EditorElement {
|
||||
|
||||
let dispatch_context = editor.dispatch_context(cx);
|
||||
cx.with_element_id(cx.view().entity_id(), |global_id, cx| {
|
||||
cx.with_key_dispatch_context(dispatch_context, |cx| {
|
||||
cx.with_key_listeners(build_key_listeners(global_id), |cx| {
|
||||
cx.with_focus(editor.focus_handle.clone(), |_| {})
|
||||
});
|
||||
})
|
||||
cx.with_key_dispatch(
|
||||
dispatch_context,
|
||||
Some(editor.focus_handle.clone()),
|
||||
|_, _| {},
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4165,7 +4164,7 @@ fn build_key_listener<T: 'static>(
|
||||
listener: impl Fn(
|
||||
&mut Editor,
|
||||
&T,
|
||||
&[&KeyBindingContext],
|
||||
&[&KeyContext],
|
||||
DispatchPhase,
|
||||
&mut ViewContext<Editor>,
|
||||
) -> Option<Box<dyn Action>>
|
||||
|
||||
Reference in New Issue
Block a user