parent
a91a3f2dce
commit
26ac1df0b1
|
@ -36,6 +36,17 @@ pub struct Cell {
|
||||||
pub flags: Flags,
|
pub flags: Flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Cell {
|
||||||
|
fn default() -> Cell {
|
||||||
|
Cell::new(
|
||||||
|
' ',
|
||||||
|
Color::Named(NamedColor::Foreground),
|
||||||
|
Color::Named(NamedColor::Background)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the length of occupied cells in a line
|
/// Get the length of occupied cells in a line
|
||||||
pub trait LineLength {
|
pub trait LineLength {
|
||||||
/// Calculate the occupied line length
|
/// Calculate the occupied line length
|
||||||
|
@ -100,11 +111,10 @@ mod tests {
|
||||||
|
|
||||||
use grid::Row;
|
use grid::Row;
|
||||||
use index::Column;
|
use index::Column;
|
||||||
use ansi::Color;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn line_length_works() {
|
fn line_length_works() {
|
||||||
let template = Cell::new(' ', Color::Indexed(0), Color::Indexed(0));
|
let template = Cell::default();
|
||||||
let mut row = Row::new(Column(10), &template);
|
let mut row = Row::new(Column(10), &template);
|
||||||
row[Column(5)].c = 'a';
|
row[Column(5)].c = 'a';
|
||||||
|
|
||||||
|
@ -113,7 +123,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn line_length_works_with_wrapline() {
|
fn line_length_works_with_wrapline() {
|
||||||
let template = Cell::new(' ', Color::Indexed(0), Color::Indexed(0));
|
let template = Cell::default();
|
||||||
let mut row = Row::new(Column(10), &template);
|
let mut row = Row::new(Column(10), &template);
|
||||||
row[Column(9)].flags.insert(super::WRAPLINE);
|
row[Column(9)].flags.insert(super::WRAPLINE);
|
||||||
|
|
||||||
|
|
|
@ -277,11 +277,7 @@ impl SizeInfo {
|
||||||
|
|
||||||
impl Term {
|
impl Term {
|
||||||
pub fn new(size: SizeInfo) -> Term {
|
pub fn new(size: SizeInfo) -> Term {
|
||||||
let template = Cell::new(
|
let template = Cell::default();
|
||||||
' ',
|
|
||||||
Color::Named(NamedColor::Foreground),
|
|
||||||
Color::Named(NamedColor::Background)
|
|
||||||
);
|
|
||||||
|
|
||||||
let num_cols = size.cols();
|
let num_cols = size.cols();
|
||||||
let num_lines = size.lines();
|
let num_lines = size.lines();
|
||||||
|
@ -1040,7 +1036,6 @@ mod tests {
|
||||||
|
|
||||||
use super::limit;
|
use super::limit;
|
||||||
|
|
||||||
use ansi::{Color, NamedColor};
|
|
||||||
use grid::Grid;
|
use grid::Grid;
|
||||||
use index::{Line, Column};
|
use index::{Line, Column};
|
||||||
use term::{Cell};
|
use term::{Cell};
|
||||||
|
@ -1051,11 +1046,7 @@ mod tests {
|
||||||
/// test this property with a T=Cell.
|
/// test this property with a T=Cell.
|
||||||
#[test]
|
#[test]
|
||||||
fn grid_serde() {
|
fn grid_serde() {
|
||||||
let template = Cell::new(
|
let template = Cell::default();
|
||||||
' ',
|
|
||||||
Color::Named(NamedColor::Foreground),
|
|
||||||
Color::Named(NamedColor::Background)
|
|
||||||
);
|
|
||||||
|
|
||||||
let grid = Grid::new(Line(24), Column(80), &template);
|
let grid = Grid::new(Line(24), Column(80), &template);
|
||||||
let serialized = serde_json::to_string(&grid).expect("ser");
|
let serialized = serde_json::to_string(&grid).expect("ser");
|
||||||
|
|
Loading…
Reference in New Issue