aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-14 02:19:06 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-14 02:25:04 -0500
commit7e7041f7fc1d9ff3577d44c9178181a70ee94463 (patch)
tree3ae104c00a5843ba0d24581014af41b4f0cf231b
parentc53651e934f65150069d600622186a2fad1f3d0e (diff)
downloadvt100-rust-7e7041f7fc1d9ff3577d44c9178181a70ee94463.tar.gz
vt100-rust-7e7041f7fc1d9ff3577d44c9178181a70ee94463.zip
just pass in the row on its own
-rw-r--r--src/grid.rs23
-rw-r--r--src/screen.rs59
2 files changed, 31 insertions, 51 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 7f83b1a..2f6a25c 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -135,39 +135,40 @@ impl Grid {
self.rows.iter_mut()
}
- pub fn visible_row(&self, pos: Pos) -> Option<&crate::row::Row> {
- self.visible_rows().nth(pos.row as usize)
+ pub fn visible_row(&self, row: u16) -> Option<&crate::row::Row> {
+ self.visible_rows().nth(row as usize)
}
- pub fn drawing_row(&self, pos: Pos) -> Option<&crate::row::Row> {
- self.drawing_rows().nth(pos.row as usize)
+ pub fn drawing_row(&self, row: u16) -> Option<&crate::row::Row> {
+ self.drawing_rows().nth(row as usize)
}
pub fn drawing_row_mut(
&mut self,
- pos: Pos,
+ row: u16,
) -> Option<&mut crate::row::Row> {
- self.drawing_rows_mut().nth(pos.row as usize)
+ self.drawing_rows_mut().nth(row as usize)
}
pub fn current_row_mut(&mut self) -> &mut crate::row::Row {
- self.drawing_row_mut(self.pos)
+ self.drawing_row_mut(self.pos.row)
.expect("cursor not pointing to a cell")
}
pub fn visible_cell(&self, pos: Pos) -> Option<&crate::cell::Cell> {
- self.visible_row(pos).and_then(|r| r.get(pos.col))
+ self.visible_row(pos.row).and_then(|r| r.get(pos.col))
}
pub fn drawing_cell(&self, pos: Pos) -> Option<&crate::cell::Cell> {
- self.drawing_row(pos).and_then(|r| r.get(pos.col))
+ self.drawing_row(pos.row).and_then(|r| r.get(pos.col))
}
pub fn drawing_cell_mut(
&mut self,
pos: Pos,
) -> Option<&mut crate::cell::Cell> {
- self.drawing_row_mut(pos).and_then(|r| r.get_mut(pos.col))
+ self.drawing_row_mut(pos.row)
+ .and_then(|r| r.get_mut(pos.col))
}
pub fn current_cell(&self) -> &crate::cell::Cell {
@@ -630,7 +631,7 @@ impl Grid {
let scrolled = self.row_inc_scroll(1);
prev_pos.row -= scrolled;
let new_pos = self.pos;
- self.drawing_row_mut(prev_pos)
+ self.drawing_row_mut(prev_pos.row)
.unwrap()
.wrap(wrap && prev_pos.row + 1 == new_pos.row);
}
diff --git a/src/screen.rs b/src/screen.rs
index 24f461c..08e0161 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -597,7 +597,7 @@ impl Screen {
#[must_use]
pub fn row_wrapped(&self, row: u16) -> bool {
self.grid()
- .visible_row(crate::grid::Pos { row, col: 0 })
+ .visible_row(row)
.map_or(false, crate::row::Row::wrapped)
}
@@ -747,32 +747,6 @@ impl Screen {
}
}
- fn drawing_row(&self, pos: crate::grid::Pos) -> Option<&crate::row::Row> {
- self.grid().drawing_row(pos)
- }
-
- fn drawing_cell(
- &self,
- pos: crate::grid::Pos,
- ) -> Option<&crate::cell::Cell> {
- self.grid().drawing_cell(pos)
- }
-
- fn drawing_cell_mut(
- &mut self,
- pos: crate::grid::Pos,
- ) -> Option<&mut crate::cell::Cell> {
- self.grid_mut().drawing_cell_mut(pos)
- }
-
- fn current_cell(&self) -> &crate::cell::Cell {
- self.grid().current_cell()
- }
-
- fn current_cell_mut(&mut self) -> &mut crate::cell::Cell {
- self.grid_mut().current_cell_mut()
- }
-
fn enter_alternate_grid(&mut self) {
self.grid_mut().set_scrollback(0);
self.set_mode(MODE_ALTERNATE_SCREEN);
@@ -850,6 +824,7 @@ impl Screen {
let mut wrap = false;
if pos.col > size.cols - width {
let last_cell = self
+ .grid()
.drawing_cell(crate::grid::Pos {
row: pos.row,
col: size.cols - 1,
@@ -865,6 +840,7 @@ impl Screen {
if width == 0 {
if pos.col > 0 {
let mut prev_cell = self
+ .grid_mut()
.drawing_cell_mut(crate::grid::Pos {
row: pos.row,
col: pos.col - 1,
@@ -872,6 +848,7 @@ impl Screen {
.unwrap();
if prev_cell.is_wide_continuation() {
prev_cell = self
+ .grid_mut()
.drawing_cell_mut(crate::grid::Pos {
row: pos.row,
col: pos.col - 2,
@@ -880,14 +857,10 @@ impl Screen {
}
prev_cell.append(c);
} else if pos.row > 0 {
- let prev_row = self
- .drawing_row(crate::grid::Pos {
- row: pos.row - 1,
- col: 0,
- })
- .unwrap();
+ let prev_row = self.grid().drawing_row(pos.row - 1).unwrap();
if prev_row.wrapped() {
let mut prev_cell = self
+ .grid_mut()
.drawing_cell_mut(crate::grid::Pos {
row: pos.row - 1,
col: size.cols - 1,
@@ -895,6 +868,7 @@ impl Screen {
.unwrap();
if prev_cell.is_wide_continuation() {
prev_cell = self
+ .grid_mut()
.drawing_cell_mut(crate::grid::Pos {
row: pos.row - 1,
col: size.cols - 2,
@@ -915,11 +889,13 @@ impl Screen {
};
if self
+ .grid()
.drawing_cell(drawing_pos)
.unwrap()
.is_wide_continuation()
{
let prev_cell = self
+ .grid_mut()
.drawing_cell_mut(crate::grid::Pos {
row: drawing_pos.row,
col: drawing_pos.col - 1,
@@ -928,8 +904,9 @@ impl Screen {
prev_cell.clear(attrs);
}
- if self.drawing_cell(drawing_pos).unwrap().is_wide() {
+ if self.grid().drawing_cell(drawing_pos).unwrap().is_wide() {
let next_cell = self
+ .grid_mut()
.drawing_cell_mut(crate::grid::Pos {
row: drawing_pos.row,
col: drawing_pos.col + 1,
@@ -938,27 +915,29 @@ impl Screen {
next_cell.set(' ', attrs);
}
- let cell = self.current_cell_mut();
+ let cell = self.grid_mut().current_cell_mut();
cell.set(c, attrs);
self.grid_mut().col_inc(1);
if width > 1 {
let pos = self.grid().pos();
- if self.current_cell().is_wide() {
+ if self.grid().current_cell().is_wide() {
let next_next_pos = crate::grid::Pos {
row: pos.row,
col: pos.col + 1,
};
- let next_next_cell =
- self.drawing_cell_mut(next_next_pos).unwrap();
+ let next_next_cell = self
+ .grid_mut()
+ .drawing_cell_mut(next_next_pos)
+ .unwrap();
next_next_cell.clear(attrs);
if next_next_pos.col == size.cols - 1 {
self.grid_mut()
- .drawing_row_mut(next_next_pos)
+ .drawing_row_mut(pos.row)
.unwrap()
.wrap(false);
}
}
- let next_cell = self.current_cell_mut();
+ let next_cell = self.grid_mut().current_cell_mut();
next_cell.clear(crate::attrs::Attrs::default());
next_cell.set_wide_continuation(true);
self.grid_mut().col_inc(1);