aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-09 01:45:05 -0500
committerJesse Luehrs <doy@tozt.net>2023-03-09 01:45:05 -0500
commitb615e03beb20cb836fe643b57291657b9c2845d8 (patch)
tree9880823cbc1235ea84f1d5e60c9b4dbddd88b678 /src
parente11519d403f5ac0cdff70f1029791c0aa9dbe8d5 (diff)
downloadvt100-rust-b615e03beb20cb836fe643b57291657b9c2845d8.tar.gz
vt100-rust-b615e03beb20cb836fe643b57291657b9c2845d8.zip
stop implementing Default for Cell
Diffstat (limited to 'src')
-rw-r--r--src/cell.rs10
-rw-r--r--src/grid.rs6
-rw-r--r--src/row.rs4
3 files changed, 14 insertions, 6 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 240ddf9..b7ddd26 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -3,7 +3,7 @@ use unicode_width::UnicodeWidthChar as _;
const CODEPOINTS_IN_CELL: usize = 6;
/// Represents a single terminal cell.
-#[derive(Clone, Debug, Default, Eq)]
+#[derive(Clone, Debug, Eq)]
pub struct Cell {
contents: [char; CODEPOINTS_IN_CELL],
len: u8,
@@ -25,6 +25,14 @@ impl PartialEq<Self> for Cell {
}
impl Cell {
+ pub(crate) fn new() -> Self {
+ Self {
+ contents: Default::default(),
+ len: 0,
+ attrs: crate::attrs::Attrs::default(),
+ }
+ }
+
#[inline]
fn len(&self) -> usize {
usize::from(self.len & 0x0f)
diff --git a/src/grid.rs b/src/grid.rs
index dee4e10..a9ecfff 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -76,7 +76,7 @@ impl Grid {
self.size = size;
for row in &mut self.rows {
- row.resize(size.cols, crate::Cell::default());
+ row.resize(size.cols, crate::Cell::new());
}
self.rows.resize(usize::from(size.rows), self.new_row());
@@ -496,7 +496,7 @@ impl Grid {
if wide {
row.get_mut(pos.col).unwrap().set_wide_continuation(false);
}
- row.insert(pos.col, crate::Cell::default());
+ row.insert(pos.col, crate::Cell::new());
if wide {
row.get_mut(pos.col).unwrap().set_wide_continuation(true);
}
@@ -511,7 +511,7 @@ impl Grid {
for _ in 0..(count.min(size.cols - pos.col)) {
row.remove(pos.col);
}
- row.resize(size.cols, crate::Cell::default());
+ row.resize(size.cols, crate::Cell::new());
}
pub fn erase_cells(&mut self, count: u16, attrs: crate::attrs::Attrs) {
diff --git a/src/row.rs b/src/row.rs
index def12f6..b52146c 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -9,7 +9,7 @@ pub struct Row {
impl Row {
pub fn new(cols: u16) -> Self {
Self {
- cells: vec![crate::Cell::default(); usize::from(cols)],
+ cells: vec![crate::Cell::new(); usize::from(cols)],
wrapped: false,
}
}
@@ -145,7 +145,7 @@ impl Row {
prev_attrs: Option<crate::attrs::Attrs>,
) -> (crate::grid::Pos, crate::attrs::Attrs) {
let mut prev_was_wide = false;
- let default_cell = crate::Cell::default();
+ let default_cell = crate::Cell::new();
let mut prev_pos = prev_pos.unwrap_or_else(|| {
if wrapping {