pub struct ImeSurroundingText { /* private fields */ }Expand description
Defines the text surrounding the caret
Implementations§
Source§impl ImeSurroundingText
impl ImeSurroundingText
Sourcepub const MAX_TEXT_BYTES: usize = 4000
pub const MAX_TEXT_BYTES: usize = 4000
The maximum size of the text excerpt.
Sourcepub fn new(
text: String,
cursor: usize,
anchor: usize,
) -> Result<ImeSurroundingText, ImeSurroundingTextError>
pub fn new( text: String, cursor: usize, anchor: usize, ) -> Result<ImeSurroundingText, ImeSurroundingTextError>
Defines the text surrounding the cursor and the selection within it.
text: An excerpt of the text present in the text input field, excluding preedit.
It must be limited to 4000 bytes due to backend constraints.
cursor: The position of the caret, in bytes from the beginning of the string.
`anchor: The position of the other end of selection, in bytes.
With no selection, it should be the same as the cursor.
This may fail if the byte indices don’t fall on code point boundaries, or if the text is too long.
§Examples:
A text field containing foo|bar where | denotes the caret would correspond to a value
obtained by:
let s = ImeSurroundingText::new("foobar".into(), 3, 3).unwrap();Because preedit is excluded from the text string, a text field containing foo[baz|]bar
where | denotes the caret and [baz|] is the preedit would be created in exactly the same
way.
Sourcepub fn into_text(self) -> String
pub fn into_text(self) -> String
Consumes the object, releasing the text string only. Use this call in the backend to avoid an extra clone when submitting the surrounding text.
pub fn text(&self) -> &str
pub fn cursor(&self) -> usize
pub fn anchor(&self) -> usize
Trait Implementations§
Source§impl Clone for ImeSurroundingText
impl Clone for ImeSurroundingText
Source§fn clone(&self) -> ImeSurroundingText
fn clone(&self) -> ImeSurroundingText
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImeSurroundingText
impl Debug for ImeSurroundingText
Source§impl<'de> Deserialize<'de> for ImeSurroundingText
impl<'de> Deserialize<'de> for ImeSurroundingText
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ImeSurroundingText, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ImeSurroundingText, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Hash for ImeSurroundingText
impl Hash for ImeSurroundingText
Source§impl PartialEq for ImeSurroundingText
impl PartialEq for ImeSurroundingText
Source§impl Serialize for ImeSurroundingText
impl Serialize for ImeSurroundingText
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for ImeSurroundingText
impl StructuralPartialEq for ImeSurroundingText
Auto Trait Implementations§
impl Freeze for ImeSurroundingText
impl RefUnwindSafe for ImeSurroundingText
impl Send for ImeSurroundingText
impl Sync for ImeSurroundingText
impl Unpin for ImeSurroundingText
impl UnwindSafe for ImeSurroundingText
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.