Struct ImeSurroundingText
pub struct ImeSurroundingText { /* private fields */ }Expand description
Defines the text surrounding the caret
Implementations§
§impl ImeSurroundingText
impl ImeSurroundingText
pub const MAX_TEXT_BYTES: usize = 4_000usize
pub const MAX_TEXT_BYTES: usize = 4_000usize
The maximum size of the text excerpt.
pub 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.
pub 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§
§impl Clone for ImeSurroundingText
impl Clone for ImeSurroundingText
§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 more§impl Debug for ImeSurroundingText
impl Debug for ImeSurroundingText
§impl Hash for ImeSurroundingText
impl Hash for ImeSurroundingText
§impl PartialEq for ImeSurroundingText
impl PartialEq for ImeSurroundingText
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.