mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
🎨
This commit is contained in:
parent
7a8f219251
commit
b77fab0fae
1 changed files with 26 additions and 26 deletions
|
@ -37,6 +37,32 @@ pub trait InputHandlerView {
|
||||||
) -> Option<crate::Bounds<Pixels>>;
|
) -> Option<crate::Bounds<Pixels>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait InputHandler: Sized {
|
||||||
|
fn text_for_range(&self, range: Range<usize>, cx: &mut ViewContext<Self>) -> Option<String>;
|
||||||
|
fn selected_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>>;
|
||||||
|
fn marked_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>>;
|
||||||
|
fn unmark_text(&mut self, cx: &mut ViewContext<Self>);
|
||||||
|
fn replace_text_in_range(
|
||||||
|
&mut self,
|
||||||
|
range: Option<Range<usize>>,
|
||||||
|
text: &str,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
);
|
||||||
|
fn replace_and_mark_text_in_range(
|
||||||
|
&mut self,
|
||||||
|
range: Option<Range<usize>>,
|
||||||
|
new_text: &str,
|
||||||
|
new_selected_range: Option<Range<usize>>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
);
|
||||||
|
fn bounds_for_range(
|
||||||
|
&mut self,
|
||||||
|
range_utf16: std::ops::Range<usize>,
|
||||||
|
element_bounds: crate::Bounds<Pixels>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Option<crate::Bounds<Pixels>>;
|
||||||
|
}
|
||||||
|
|
||||||
impl<V: InputHandler + 'static> InputHandlerView for View<V> {
|
impl<V: InputHandler + 'static> InputHandlerView for View<V> {
|
||||||
fn text_for_range(&self, range: Range<usize>, cx: &mut WindowContext) -> Option<String> {
|
fn text_for_range(&self, range: Range<usize>, cx: &mut WindowContext) -> Option<String> {
|
||||||
self.update(cx, |this, cx| this.text_for_range(range, cx))
|
self.update(cx, |this, cx| this.text_for_range(range, cx))
|
||||||
|
@ -139,29 +165,3 @@ impl WindowInputHandler {
|
||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait InputHandler: Sized {
|
|
||||||
fn text_for_range(&self, range: Range<usize>, cx: &mut ViewContext<Self>) -> Option<String>;
|
|
||||||
fn selected_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>>;
|
|
||||||
fn marked_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>>;
|
|
||||||
fn unmark_text(&mut self, cx: &mut ViewContext<Self>);
|
|
||||||
fn replace_text_in_range(
|
|
||||||
&mut self,
|
|
||||||
range: Option<Range<usize>>,
|
|
||||||
text: &str,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
);
|
|
||||||
fn replace_and_mark_text_in_range(
|
|
||||||
&mut self,
|
|
||||||
range: Option<Range<usize>>,
|
|
||||||
new_text: &str,
|
|
||||||
new_selected_range: Option<Range<usize>>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
);
|
|
||||||
fn bounds_for_range(
|
|
||||||
&mut self,
|
|
||||||
range_utf16: std::ops::Range<usize>,
|
|
||||||
element_bounds: crate::Bounds<Pixels>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) -> Option<crate::Bounds<Pixels>>;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue