codemp/src/cursor/mod.rs

37 lines
847 B
Rust

//! ### cursor
//!
//! ![demo gif of early cursor sync in action](https://cdn.alemi.dev/codemp/demo-nvim.gif)
//!
//! each user holds a cursor, which consists of multiple highlighted region
//! on a specific buffer
pub(crate) mod worker;
/// cursor controller implementation
pub mod controller;
pub use controller::CursorController as Controller;
use crate::proto::cursor::RowCol;
impl From::<RowCol> for (i32, i32) {
fn from(pos: RowCol) -> (i32, i32) {
(pos.row, pos.col)
}
}
impl From::<(i32, i32)> for RowCol {
fn from((row, col): (i32, i32)) -> Self {
RowCol { row, col }
}
}
impl PartialOrd for RowCol {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
match self.row.partial_cmp(&other.row) {
Some(core::cmp::Ordering::Equal) => {}
ord => return ord,
}
self.col.partial_cmp(&other.col)
}
}