[][src]Struct meli::terminal::cells::CellBuffer

pub struct CellBuffer {
    cols: usize,
    rows: usize,
    buf: Vec<Cell>,
    pub default_cell: Cell,
    pub ascii_drawing: bool,
    growable: bool,
    tag_table: HashMap<u64, FormatTag>,
    tag_associations: SmallVec<[(u64, (usize, usize)); 128]>,
}

An array of Cells that represents a terminal display.

A CellBuffer is a two-dimensional array of Cells, each pair of indices correspond to a single point on the underlying terminal.

The first index, Cellbuffer[y], corresponds to a row, and thus the y-axis. The second index, Cellbuffer[y][x], corresponds to a column within a row and thus the x-axis.

Fields

cols: usizerows: usizebuf: Vec<Cell>default_cell: Cellascii_drawing: bool

ASCII-only flag.

growable: bool

If printing to this buffer and we run out of space, expand it.

tag_table: HashMap<u64, FormatTag>tag_associations: SmallVec<[(u64, (usize, usize)); 128]>

Implementations

impl CellBuffer[src]

pub fn area(&self) -> Area[src]

pub fn set_cols(&mut self, new_cols: usize)[src]

pub fn new(cols: usize, rows: usize, default_cell: Cell) -> CellBuffer[src]

Constructs a new CellBuffer with the given number of columns and rows, using the given cell as a blank.

pub fn new_with_context(
    cols: usize,
    rows: usize,
    default_cell: Option<Cell>,
    context: &Context
) -> CellBuffer
[src]

pub fn set_ascii_drawing(&mut self, new_val: bool)[src]

pub fn set_growable(&mut self, new_val: bool)[src]

pub fn resize(&mut self, newcols: usize, newrows: usize, blank: Cell)[src]

Resizes CellBuffer to the given number of rows and columns, using the given Cell as a blank.

pub fn is_empty(&self) -> bool[src]

pub fn empty(&mut self)[src]

pub fn clear(&mut self, blank: Cell)[src]

Clears self, using the given Cell as a blank.

pub fn pos_to_index(&self, x: usize, y: usize) -> Option<usize>[src]

pub fn get(&self, x: usize, y: usize) -> Option<&Cell>[src]

Returns a reference to the Cell at the given coordinates, or None if the index is out of bounds.

Examples


let mut term = Terminal::new().unwrap();

let a_cell = term.get(5, 5);

pub fn get_mut(&mut self, x: usize, y: usize) -> Option<&mut Cell>[src]

Returns a mutable reference to the Cell at the given coordinates, or None if the index is out of bounds.

Examples


let mut term = Terminal::new().unwrap();

let a_mut_cell = term.get_mut(5, 5);

pub fn size(&self) -> (usize, usize)[src]

pub fn cellvec(&self) -> &Vec<Cell>[src]

pub fn cellvec_mut(&mut self) -> &mut Vec<Cell>[src]

pub fn cols(&self) -> usize[src]

pub fn rows(&self) -> usize[src]

pub fn scroll_up(
    &mut self,
    scroll_region: &ScrollRegion,
    top: usize,
    offset: usize
)
[src]

Performs the normal scroll up motion:

First clear offset number of lines:

For offset = 1, top = 1:

| 111111111111 |            |              |
| 222222222222 |            | 222222222222 |
| 333333333333 |            | 333333333333 |
| 444444444444 |    -->     | 444444444444 |
| 555555555555 |            | 555555555555 |
| 666666666666 |            | 666666666666 |

In each step, swap the current line with the next by offset:

|              |            | 222222222222 |
| 222222222222 |            |              |
| 333333333333 |            | 333333333333 |
| 444444444444 |    -->     | 444444444444 |
| 555555555555 |            | 555555555555 |
| 666666666666 |            | 666666666666 |

Result:

  Before                      After
| 111111111111 |            | 222222222222 |
| 222222222222 |            | 333333333333 |
| 333333333333 |            | 444444444444 |
| 444444444444 |            | 555555555555 |
| 555555555555 |            | 666666666666 |
| 666666666666 |            |              |

pub fn scroll_down(
    &mut self,
    scroll_region: &ScrollRegion,
    top: usize,
    offset: usize
)
[src]

Performs the normal scroll down motion:

First clear offset number of lines:

For offset = 1, top = 1:

| 111111111111 |            | 111111111111 |
| 222222222222 |            | 222222222222 |
| 333333333333 |            | 333333333333 |
| 444444444444 |    -->     | 444444444444 |
| 555555555555 |            | 555555555555 |
| 666666666666 |            |              |

In each step, swap the current line with the prev by offset:

| 111111111111 |            | 111111111111 |
| 222222222222 |            | 222222222222 |
| 333333333333 |            | 333333333333 |
| 444444444444 |    -->     | 444444444444 |
| 555555555555 |            |              |
|              |            | 555555555555 |

Result:

  Before                      After
| 111111111111 |            |              |
| 222222222222 |            | 111111111111 |
| 333333333333 |            | 222222222222 |
| 444444444444 |            | 333333333333 |
| 555555555555 |            | 444444444444 |
| 666666666666 |            | 555555555555 |

pub fn bounds_iter(&self, area: Area) -> BoundsIterator

Notable traits for BoundsIterator

impl Iterator for BoundsIterator type Item = RowIterator;
[src]

See BoundsIterator documentation.

pub fn row_iter(&self, bounds: Range<usize>, row: usize) -> RowIterator

Notable traits for RowIterator

impl Iterator for RowIterator type Item = (usize, usize);
[src]

See RowIterator documentation.

pub fn tag_associations(&self) -> SmallVec<[(usize, u64, bool); 128]>[src]

pub fn tag_table(&self) -> &HashMap<u64, FormatTag>[src]

pub fn tag_table_mut(&mut self) -> &mut HashMap<u64, FormatTag>[src]

pub fn insert_tag(&mut self, tag: FormatTag) -> u64[src]

pub fn set_tag(&mut self, tag: u64, start: (usize, usize), end: (usize, usize))[src]

Trait Implementations

impl Clone for CellBuffer[src]

impl Debug for CellBuffer[src]

impl Default for CellBuffer[src]

fn default() -> CellBuffer[src]

Constructs a new CellBuffer with a size of (0, 0), using the default Cell as a blank.

impl Deref for CellBuffer[src]

type Target = [Cell]

The resulting type after dereferencing.

impl DerefMut for CellBuffer[src]

impl Display for CellBuffer[src]

impl Eq for CellBuffer[src]

impl Index<(usize, usize)> for CellBuffer[src]

type Output = Cell

The returned type after indexing.

impl IndexMut<(usize, usize)> for CellBuffer[src]

impl KMP for CellBuffer[src]

impl PartialEq<CellBuffer> for CellBuffer[src]

impl StructuralEq for CellBuffer[src]

impl StructuralPartialEq for CellBuffer[src]

Auto Trait Implementations

impl RefUnwindSafe for CellBuffer

impl Send for CellBuffer

impl Sync for CellBuffer

impl Unpin for CellBuffer

impl UnwindSafe for CellBuffer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]