fret_runtime/
platform_text_input.rs1use fret_core::{Point, Rect};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub struct Utf16Range {
9 pub start: u32,
10 pub end: u32,
11}
12
13impl Utf16Range {
14 pub fn new(start: u32, end: u32) -> Self {
15 Self { start, end }
16 }
17
18 pub fn normalized(self) -> Self {
19 Self {
20 start: self.start.min(self.end),
21 end: self.start.max(self.end),
22 }
23 }
24
25 pub fn is_empty(self) -> bool {
26 self.start == self.end
27 }
28}
29
30#[derive(Debug, Clone, PartialEq)]
34pub enum PlatformTextInputQuery {
35 SelectedTextRange,
36 MarkedTextRange,
37 TextForRange { range: Utf16Range },
38 BoundsForRange { range: Utf16Range },
39 CharacterIndexForPoint { point: Point },
40}
41
42#[derive(Debug, Clone, PartialEq)]
43pub enum PlatformTextInputQueryResult {
44 Range(Option<Utf16Range>),
45 Text(Option<String>),
46 Bounds(Option<Rect>),
47 Index(Option<u32>),
48}