codemp/src/cursor/mod.rs

38 lines
794 B
Rust
Raw Normal View History

2023-08-20 00:46:55 +02:00
//! ### cursor
//!
//! each user holds a cursor, which consists of multiple highlighted region
//! on a specific buffer
pub(crate) mod worker;
2023-08-20 00:46:55 +02:00
/// cursor controller implementation
pub mod controller;
pub use controller::CursorController as Controller;
use crate::proto::{RowCol, CursorPosition};
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 CursorPosition {
2023-08-20 00:46:55 +02:00
/// extract start position, defaulting to (0,0)
pub fn start(&self) -> RowCol {
self.start.clone().unwrap_or((0, 0).into())
}
2023-08-20 00:46:55 +02:00
/// extract end position, defaulting to (0,0)
pub fn end(&self) -> RowCol {
self.end.clone().unwrap_or((0, 0).into())
}
}