Files
addr2line
adler
aho_corasick
backtrace
bitflags
cfg_if
ctrlc
dirs
dirs_next
dirs_sys
dirs_sys_next
docopt
endian_type
failure
failure_derive
fd_lock
gimli
lalrpop_util
lazy_static
libc
log
memchr
memoffset
miniz_oxide
nibble_vec
nix
numtoa
object
oursh
proc_macro2
pwd
quote
radix_trie
regex
regex_syntax
retain_mut
rustc_demangle
rustyline
serde
serde_derive
smallvec
strsim
syn
synstructure
termion
unicode_segmentation
unicode_width
unicode_xid
utf8parse
 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, // The leftmost column is number 0.
    pub row: usize, // The highest row is number 0.
}

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 {
    /// Prompt Unicode/visible width and height
    pub prompt_size: Position,
    pub default_prompt: bool,
    /// Cursor position (relative to the start of the prompt)
    pub cursor: Position,
    /// Number of rows used so far (from start of prompt to end of input)
    pub end: Position,
}