#[derive(Clone, Copy, Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct CCursor {
pub index: usize,
pub prefer_next_row: bool,
}
impl CCursor {
#[inline]
pub fn new(index: usize) -> Self {
Self {
index,
prefer_next_row: false,
}
}
}
impl PartialEq for CCursor {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.index == other.index
}
}
impl std::ops::Add<usize> for CCursor {
type Output = Self;
fn add(self, rhs: usize) -> Self::Output {
Self {
index: self.index.saturating_add(rhs),
prefer_next_row: self.prefer_next_row,
}
}
}
impl std::ops::Sub<usize> for CCursor {
type Output = Self;
fn sub(self, rhs: usize) -> Self::Output {
Self {
index: self.index.saturating_sub(rhs),
prefer_next_row: self.prefer_next_row,
}
}
}
impl std::ops::AddAssign<usize> for CCursor {
fn add_assign(&mut self, rhs: usize) {
self.index = self.index.saturating_add(rhs);
}
}
impl std::ops::SubAssign<usize> for CCursor {
fn sub_assign(&mut self, rhs: usize) {
self.index = self.index.saturating_sub(rhs);
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct LayoutCursor {
pub row: usize,
pub column: usize,
}