pub struct TestInput { /* private fields */ }Expand description
Bridges an explicit GPUI InputHandler to a test window so tests can
exercise UTF-16 composition (replace_and_mark_text_in_range), preedit
cancellation, and text commits without relying on an OS IME.
Implementations§
Source§impl TestInput
impl TestInput
Sourcepub fn new(
handler: impl InputHandler + 'static,
window: impl Into<AnyWindowHandle>,
) -> TestInput
pub fn new( handler: impl InputHandler + 'static, window: impl Into<AnyWindowHandle>, ) -> TestInput
Creates a composition bridge bound to handler and window.
Sourcepub fn commit_text(&mut self, text: &str, cx: &mut TestAppContext)
pub fn commit_text(&mut self, text: &str, cx: &mut TestAppContext)
Commits text through InputHandler::replace_text_in_range and completes a frame.
Sourcepub fn compose_text(
&mut self,
replacement: Option<Range<usize>>,
text: &str,
selection: Option<Range<usize>>,
cx: &mut TestAppContext,
)
pub fn compose_text( &mut self, replacement: Option<Range<usize>>, text: &str, selection: Option<Range<usize>>, cx: &mut TestAppContext, )
Updates marked/preedit text through InputHandler::replace_and_mark_text_in_range
using UTF-16 code-unit ranges and completes a frame.
Sourcepub fn marked_text_range(
&mut self,
cx: &mut TestAppContext,
) -> Option<Range<usize>>
pub fn marked_text_range( &mut self, cx: &mut TestAppContext, ) -> Option<Range<usize>>
Returns the document-relative UTF-16 marked range, if any.
Sourcepub fn selected_text_range(
&mut self,
cx: &mut TestAppContext,
) -> Option<UTF16Selection>
pub fn selected_text_range( &mut self, cx: &mut TestAppContext, ) -> Option<UTF16Selection>
Returns the current UTF-16 selection range and direction, if any.
Sourcepub fn unmark_text(&mut self, cx: &mut TestAppContext)
pub fn unmark_text(&mut self, cx: &mut TestAppContext)
Clears active preedit marking while keeping its text and completes a frame.
Auto Trait Implementations§
impl !RefUnwindSafe for TestInput
impl !Send for TestInput
impl !Sync for TestInput
impl !UnwindSafe for TestInput
impl Forget for TestInput
impl Freeze for TestInputwhere
*const dyn InputHandler is !null: Freeze,
PhantomData<dyn InputHandler>: Freeze,
NonZero<u32>: Freeze,
*const (): Freeze,
&'static str: Freeze,
impl Move for TestInput
impl Unpin for TestInput
impl UnsafeUnpin for TestInputwhere
*const dyn InputHandler is !null: UnsafeUnpin,
PhantomData<dyn InputHandler>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
&'static str: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more