makepad_draw/text/
selection.rs

1#[derive(Clone, Copy, Debug, Default)]
2pub struct Selection {
3    pub cursor: Cursor,
4    pub anchor: Cursor,
5}
6
7impl Selection {
8    pub fn start(self) -> Cursor {
9        self.cursor.min(self.anchor)
10    }
11
12    pub fn end(self) -> Cursor {
13        self.cursor.max(self.anchor)
14    }
15}
16
17#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
18pub struct Cursor {
19    pub index: usize,
20    pub prefer_next_row: bool,
21}
22
23#[derive(Clone, Copy, Debug, Default)]
24pub struct CursorPosition {
25    pub row_index: usize,
26    pub x_in_lpxs: f32,
27}