1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::cmp::{Ord, Ordering, PartialOrd};
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct Position {
pub col: usize,
pub row: usize,
}
impl PartialOrd for Position {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Position {
fn cmp(&self, other: &Self) -> Ordering {
match self.row.cmp(&other.row) {
Ordering::Equal => self.col.cmp(&other.col),
o => o,
}
}
}
#[derive(Debug, Default)]
pub struct Layout {
pub prompt_size: Position,
pub default_prompt: bool,
pub cursor: Position,
pub end: Position,
}