1use std::cmp::Ordering;
23#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
4pub struct Position {
5pub col: usize, // The leftmost column is number 0.
6pub row: usize, // The highest row is number 0.
7}
89impl PartialOrd for Position {
10fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
11Some(self.cmp(other))
12 }
13}
1415impl Ord for Position {
16fn cmp(&self, other: &Self) -> Ordering {
17match self.row.cmp(&other.row) {
18 Ordering::Equal => self.col.cmp(&other.col),
19 o => o,
20 }
21 }
22}
2324#[derive(Debug, Default)]
25pub struct Layout {
26/// Prompt Unicode/visible width and height
27pub prompt_size: Position,
28pub default_prompt: bool,
29/// Cursor position (relative to the start of the prompt)
30pub cursor: Position,
31/// Number of rows used so far (from start of prompt to end of input)
32pub end: Position,
33}