1#[derive(Clone, Copy, Debug, Default)]
7#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
8pub struct CCursor {
9 pub index: usize,
11
12 pub prefer_next_row: bool,
17}
18
19impl CCursor {
20 #[inline]
21 pub fn new(index: usize) -> Self {
22 Self {
23 index,
24 prefer_next_row: false,
25 }
26 }
27}
28
29impl PartialEq for CCursor {
32 #[inline]
33 fn eq(&self, other: &Self) -> bool {
34 self.index == other.index
35 }
36}
37
38impl std::ops::Add<usize> for CCursor {
39 type Output = Self;
40
41 fn add(self, rhs: usize) -> Self::Output {
42 Self {
43 index: self.index.saturating_add(rhs),
44 prefer_next_row: self.prefer_next_row,
45 }
46 }
47}
48
49impl std::ops::Sub<usize> for CCursor {
50 type Output = Self;
51
52 fn sub(self, rhs: usize) -> Self::Output {
53 Self {
54 index: self.index.saturating_sub(rhs),
55 prefer_next_row: self.prefer_next_row,
56 }
57 }
58}
59
60impl std::ops::AddAssign<usize> for CCursor {
61 fn add_assign(&mut self, rhs: usize) {
62 self.index = self.index.saturating_add(rhs);
63 }
64}
65
66impl std::ops::SubAssign<usize> for CCursor {
67 fn sub_assign(&mut self, rhs: usize) {
68 self.index = self.index.saturating_sub(rhs);
69 }
70}
71
72#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
76#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
77pub struct LayoutCursor {
78 pub row: usize,
82
83 pub column: usize,
87}