pub struct Preedit {
pub text: String,
pub cursor_range: Option<(usize, usize)>,
}Expand description
IME composition (preedit) state.
Represents the intermediate text that has been entered but not yet committed by the input method.
Fields§
§text: StringThe composition string currently being typed.
cursor_range: Option<(usize, usize)>Byte offset range of the cursor within the preedit text, if any. The first element is the start, the second is the end (exclusive).
Implementations§
Source§impl Preedit
impl Preedit
Sourcepub fn new(
text: impl Into<String>,
cursor_range: Option<(usize, usize)>,
) -> Self
pub fn new( text: impl Into<String>, cursor_range: Option<(usize, usize)>, ) -> Self
Create a new Preedit with the given text and optional cursor range.
Sourcepub fn underline_segments(
&self,
x_start: f32,
y_baseline: f32,
char_width: f32,
) -> Vec<DecorationSegment>
pub fn underline_segments( &self, x_start: f32, y_baseline: f32, char_width: f32, ) -> Vec<DecorationSegment>
Generate underline DecorationSegments for the preedit text.
x_start is the x-coordinate (in logical pixels) where the preedit
text begins. y_baseline is the y-coordinate of the text baseline.
char_width is used as an approximate advance width per character.
Returns an empty Vec when the preedit text is empty.
Sourcepub fn composition_window_rect(
&self,
caret_x: f32,
caret_y: f32,
char_width: f32,
line_height: f32,
) -> (f32, f32, f32, f32)
pub fn composition_window_rect( &self, caret_x: f32, caret_y: f32, char_width: f32, line_height: f32, ) -> (f32, f32, f32, f32)
Compute the composition window rectangle relative to the insertion caret.
Returns (x, y, width, height) in logical pixels. The width is the
approximate pixel width of the preedit text; the height equals
line_height.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Preedit
impl RefUnwindSafe for Preedit
impl Send for Preedit
impl Sync for Preedit
impl Unpin for Preedit
impl UnsafeUnpin for Preedit
impl UnwindSafe for Preedit
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,
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>
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>
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