use fret_core::{Point, Rect};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Utf16Range {
pub start: u32,
pub end: u32,
}
impl Utf16Range {
pub fn new(start: u32, end: u32) -> Self {
Self { start, end }
}
pub fn normalized(self) -> Self {
Self {
start: self.start.min(self.end),
end: self.start.max(self.end),
}
}
pub fn is_empty(self) -> bool {
self.start == self.end
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum PlatformTextInputQuery {
SelectedTextRange,
MarkedTextRange,
TextForRange { range: Utf16Range },
BoundsForRange { range: Utf16Range },
CharacterIndexForPoint { point: Point },
}
#[derive(Debug, Clone, PartialEq)]
pub enum PlatformTextInputQueryResult {
Range(Option<Utf16Range>),
Text(Option<String>),
Bounds(Option<Rect>),
Index(Option<u32>),
}