From b77fab0fae3b5f799f1cfef52da9590a6cdd3031 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 8 Nov 2023 16:24:11 -0800 Subject: [PATCH] :art: --- crates/gpui2/src/window_input_handler.rs | 52 ++++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/gpui2/src/window_input_handler.rs b/crates/gpui2/src/window_input_handler.rs index d09a842a6b..f3ff33f3c0 100644 --- a/crates/gpui2/src/window_input_handler.rs +++ b/crates/gpui2/src/window_input_handler.rs @@ -37,6 +37,32 @@ pub trait InputHandlerView { ) -> Option>; } +pub trait InputHandler: Sized { + fn text_for_range(&self, range: Range, cx: &mut ViewContext) -> Option; + fn selected_text_range(&self, cx: &mut ViewContext) -> Option>; + fn marked_text_range(&self, cx: &mut ViewContext) -> Option>; + fn unmark_text(&mut self, cx: &mut ViewContext); + fn replace_text_in_range( + &mut self, + range: Option>, + text: &str, + cx: &mut ViewContext, + ); + fn replace_and_mark_text_in_range( + &mut self, + range: Option>, + new_text: &str, + new_selected_range: Option>, + cx: &mut ViewContext, + ); + fn bounds_for_range( + &mut self, + range_utf16: std::ops::Range, + element_bounds: crate::Bounds, + cx: &mut ViewContext, + ) -> Option>; +} + impl InputHandlerView for View { fn text_for_range(&self, range: Range, cx: &mut WindowContext) -> Option { self.update(cx, |this, cx| this.text_for_range(range, cx)) @@ -139,29 +165,3 @@ impl WindowInputHandler { .ok() } } - -pub trait InputHandler: Sized { - fn text_for_range(&self, range: Range, cx: &mut ViewContext) -> Option; - fn selected_text_range(&self, cx: &mut ViewContext) -> Option>; - fn marked_text_range(&self, cx: &mut ViewContext) -> Option>; - fn unmark_text(&mut self, cx: &mut ViewContext); - fn replace_text_in_range( - &mut self, - range: Option>, - text: &str, - cx: &mut ViewContext, - ); - fn replace_and_mark_text_in_range( - &mut self, - range: Option>, - new_text: &str, - new_selected_range: Option>, - cx: &mut ViewContext, - ); - fn bounds_for_range( - &mut self, - range_utf16: std::ops::Range, - element_bounds: crate::Bounds, - cx: &mut ViewContext, - ) -> Option>; -}