@ -1,5 +1,5 @@
/*
* meli - ui crate .
* meli
*
* Copyright 2017 - 2018 Manos Pitsidianakis
*
@ -36,6 +36,9 @@ use termion::color::{AnsiValue, Rgb as TermionRgb};
/// In a scroll region up and down cursor movements shift the region vertically. The new lines are
/// empty.
///
/// See `CellBuffer::scroll_up` and `CellBuffer::scroll_down` for an explanation of how `xterm`
/// scrolling works.
#[ derive(Debug, Clone, PartialEq, Eq, Default) ]
pub struct ScrollRegion {
pub top : usize ,
@ -56,7 +59,9 @@ pub struct CellBuffer {
cols : usize ,
rows : usize ,
buf : Vec < Cell > ,
/// ASCII-only flag.
pub ascii_drawing : bool ,
/// If printing to this buffer and we run out of space, expand it.
growable : bool ,
}
@ -170,7 +175,7 @@ impl CellBuffer {
///
/// # Examples
///
/// ```norun
/// ```no_ run
///
/// let mut term = Terminal::new().unwrap();
///
@ -188,7 +193,7 @@ impl CellBuffer {
///
/// # Examples
///
/// ```norun
/// ```no_ run
///
/// let mut term = Terminal::new().unwrap();
///
@ -427,6 +432,8 @@ impl fmt::Display for CellBuffer {
pub struct Cell {
ch : char ,
/// Set a `Cell` as empty when a previous cell spans multiple columns and it would
/// "overflow" to this cell.
empty : bool ,
fg : Color ,
bg : Color ,
@ -440,8 +447,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let cell = Cell::new('x', Color::Default, Color::Green, Attr::Default);
/// assert_eq!(cell.ch(), 'x');
/// assert_eq!(cell.fg(), Color::Default);
@ -464,8 +470,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::with_char('x');
/// assert_eq!(cell.ch(), 'x');
/// assert_eq!(cell.fg(), Color::Default);
@ -480,8 +485,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::with_style(Color::Default, Color::Red, Attr::Bold);
/// assert_eq!(cell.fg(), Color::Default);
/// assert_eq!(cell.bg(), Color::Red);
@ -496,8 +500,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::with_char('x');
/// assert_eq!(cell.ch(), 'x');
/// ```
@ -509,8 +512,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::with_char('x');
/// assert_eq!(cell.ch(), 'x');
///
@ -528,8 +530,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::with_style(Color::Blue, Color::Default, Attr::Default);
/// assert_eq!(cell.fg(), Color::Blue);
/// ```
@ -541,8 +542,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::default();
/// assert_eq!(cell.fg(), Color::Default);
///
@ -560,7 +560,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
/// ```no_ run
/// let mut cell = Cell::with_style(Color::Default, Color::Green, Attr::Default);
/// assert_eq!(cell.bg(), Color::Green);
/// ```
@ -572,7 +572,7 @@ impl Cell {
///
/// # Examples
///
/// ```norun
/// ```no_ run
/// let mut cell = Cell::default();
/// assert_eq!(cell.bg(), Color::Default);
///
@ -626,8 +626,7 @@ impl Default for Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// let mut cell = Cell::default();
/// assert_eq!(cell.ch(), ' ');
/// assert_eq!(cell.fg(), Color::Default);
@ -650,8 +649,7 @@ impl Default for Cell {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// // The default color.
/// let default = Color::Default;
///
@ -676,6 +674,7 @@ pub enum Color {
White ,
Byte ( u8 ) ,
Rgb ( u8 , u8 , u8 ) ,
/// Terminal default.
Default ,
}
@ -1371,8 +1370,7 @@ impl Serialize for Color {
///
/// # Examples
///
/// ```norun
///
/// ```no_run
/// // Default attribute.
/// let def = Attr::Default;
///
@ -1384,6 +1382,7 @@ impl Serialize for Color {
/// ```
#[ derive(Debug, Copy, Clone, PartialEq, Eq) ]
pub enum Attr {
/// Terminal default.
Default = 0b000 ,
Bold = 0b001 ,
Underline = 0b100 ,
@ -2003,7 +2002,7 @@ pub mod ansi {
/// the iterator will simply return `None` when it reaches the end of the row.
/// `RowIterator` can be created via the `CellBuffer::row_iter` method and can be returned by
/// `BoundsIterator` which iterates each row.
/// ```norun
/// ```no_ run
/// for c in grid.row_iter(
/// x..(x + 11),
/// 0,
@ -2017,7 +2016,7 @@ pub struct RowIterator {
}
/// `BoundsIterator` iterates each row returning a `RowIterator`.
/// ```norun
/// ```no_ run
/// /* Visit each `Cell` in `area`. */
/// for c in grid.bounds_iter(area) {
/// grid[c].set_ch('w');